babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718
  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. readonly 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 readonly 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 LogLevels: 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/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** 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 */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** 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 */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** 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 */
  640. static readonly GEQUAL: number;
  641. /** 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 */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  946. * Test order :
  947. * Is the bounding sphere outside the frustum ?
  948. * If not, are the bounding box vertices outside the frustum ?
  949. * It not, then the cullable object is in the frustum.
  950. */
  951. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  952. /** Culling strategy : Bounding Sphere Only.
  953. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  954. * It's also less accurate than the standard because some not visible objects can still be selected.
  955. * Test : is the bounding sphere outside the frustum ?
  956. * If not, then the cullable object is in the frustum.
  957. */
  958. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  959. /** Culling strategy : Optimistic Inclusion.
  960. * This in an inclusion test first, then the standard exclusion test.
  961. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  962. * 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.
  963. * Anyway, it's as accurate as the standard strategy.
  964. * Test :
  965. * Is the cullable object bounding sphere center in the frustum ?
  966. * If not, apply the default culling strategy.
  967. */
  968. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  969. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  970. * This in an inclusion test first, then the bounding sphere only exclusion test.
  971. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  972. * 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.
  973. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  974. * Test :
  975. * Is the cullable object bounding sphere center in the frustum ?
  976. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  977. */
  978. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  979. /**
  980. * No logging while loading
  981. */
  982. static readonly SCENELOADER_NO_LOGGING: number;
  983. /**
  984. * Minimal logging while loading
  985. */
  986. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  987. /**
  988. * Summary logging while loading
  989. */
  990. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  991. /**
  992. * Detailled logging while loading
  993. */
  994. static readonly SCENELOADER_DETAILED_LOGGING: number;
  995. }
  996. }
  997. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  998. import { Nullable } from "babylonjs/types";
  999. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1000. /**
  1001. * This represents the required contract to create a new type of texture loader.
  1002. */
  1003. export interface IInternalTextureLoader {
  1004. /**
  1005. * Defines wether the loader supports cascade loading the different faces.
  1006. */
  1007. supportCascades: boolean;
  1008. /**
  1009. * This returns if the loader support the current file information.
  1010. * @param extension defines the file extension of the file being loaded
  1011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1012. * @param fallback defines the fallback internal texture if any
  1013. * @param isBase64 defines whether the texture is encoded as a base64
  1014. * @param isBuffer defines whether the texture data are stored as a buffer
  1015. * @returns true if the loader can load the specified file
  1016. */
  1017. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1018. /**
  1019. * Transform the url before loading if required.
  1020. * @param rootUrl the url of the texture
  1021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1022. * @returns the transformed texture
  1023. */
  1024. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1025. /**
  1026. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1027. * @param rootUrl the url of the texture
  1028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1029. * @returns the fallback texture
  1030. */
  1031. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1032. /**
  1033. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1034. * @param data contains the texture data
  1035. * @param texture defines the BabylonJS internal texture
  1036. * @param createPolynomials will be true if polynomials have been requested
  1037. * @param onLoad defines the callback to trigger once the texture is ready
  1038. * @param onError defines the callback to trigger in case of error
  1039. */
  1040. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1041. /**
  1042. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1043. * @param data contains the texture data
  1044. * @param texture defines the BabylonJS internal texture
  1045. * @param callback defines the method to call once ready to upload
  1046. */
  1047. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1048. }
  1049. }
  1050. declare module "babylonjs/Engines/IPipelineContext" {
  1051. /**
  1052. * Class used to store and describe the pipeline context associated with an effect
  1053. */
  1054. export interface IPipelineContext {
  1055. /**
  1056. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1057. */
  1058. isAsync: boolean;
  1059. /**
  1060. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1061. */
  1062. isReady: boolean;
  1063. /** @hidden */
  1064. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1065. }
  1066. }
  1067. declare module "babylonjs/Meshes/dataBuffer" {
  1068. /**
  1069. * Class used to store gfx data (like WebGLBuffer)
  1070. */
  1071. export class DataBuffer {
  1072. /**
  1073. * Gets or sets the number of objects referencing this buffer
  1074. */
  1075. references: number;
  1076. /** Gets or sets the size of the underlying buffer */
  1077. capacity: number;
  1078. /**
  1079. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1080. */
  1081. is32Bits: boolean;
  1082. /**
  1083. * Gets the underlying buffer
  1084. */
  1085. readonly underlyingResource: any;
  1086. }
  1087. }
  1088. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1089. /** @hidden */
  1090. export interface IShaderProcessor {
  1091. attributeProcessor?: (attribute: string) => string;
  1092. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1093. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1094. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1095. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1096. lineProcessor?: (line: string, isFragment: boolean) => string;
  1097. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1098. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1102. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1103. /** @hidden */
  1104. export interface ProcessingOptions {
  1105. defines: string[];
  1106. indexParameters: any;
  1107. isFragment: boolean;
  1108. shouldUseHighPrecisionShader: boolean;
  1109. supportsUniformBuffers: boolean;
  1110. shadersRepository: string;
  1111. includesShadersStore: {
  1112. [key: string]: string;
  1113. };
  1114. processor?: IShaderProcessor;
  1115. version: string;
  1116. platformName: string;
  1117. lookForClosingBracketForUniformBuffer?: boolean;
  1118. }
  1119. }
  1120. declare module "babylonjs/Misc/stringTools" {
  1121. /**
  1122. * Helper to manipulate strings
  1123. */
  1124. export class StringTools {
  1125. /**
  1126. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1127. * @param str Source string
  1128. * @param suffix Suffix to search for in the source string
  1129. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1130. */
  1131. static EndsWith(str: string, suffix: string): boolean;
  1132. /**
  1133. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1134. * @param str Source string
  1135. * @param suffix Suffix to search for in the source string
  1136. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1137. */
  1138. static StartsWith(str: string, suffix: string): boolean;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1142. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1143. /** @hidden */
  1144. export class ShaderCodeNode {
  1145. line: string;
  1146. children: ShaderCodeNode[];
  1147. additionalDefineKey?: string;
  1148. additionalDefineValue?: string;
  1149. isValid(preprocessors: {
  1150. [key: string]: string;
  1151. }): boolean;
  1152. process(preprocessors: {
  1153. [key: string]: string;
  1154. }, options: ProcessingOptions): string;
  1155. }
  1156. }
  1157. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1158. /** @hidden */
  1159. export class ShaderCodeCursor {
  1160. private _lines;
  1161. lineIndex: number;
  1162. readonly currentLine: string;
  1163. readonly canRead: boolean;
  1164. lines: string[];
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1168. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1169. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1170. /** @hidden */
  1171. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1172. process(preprocessors: {
  1173. [key: string]: string;
  1174. }, options: ProcessingOptions): string;
  1175. }
  1176. }
  1177. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1178. /** @hidden */
  1179. export class ShaderDefineExpression {
  1180. isTrue(preprocessors: {
  1181. [key: string]: string;
  1182. }): boolean;
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1188. /** @hidden */
  1189. export class ShaderCodeTestNode extends ShaderCodeNode {
  1190. testExpression: ShaderDefineExpression;
  1191. isValid(preprocessors: {
  1192. [key: string]: string;
  1193. }): boolean;
  1194. }
  1195. }
  1196. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1197. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1212. leftOperand: ShaderDefineExpression;
  1213. rightOperand: ShaderDefineExpression;
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1220. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1221. /** @hidden */
  1222. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1223. leftOperand: ShaderDefineExpression;
  1224. rightOperand: ShaderDefineExpression;
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. operand: string;
  1236. testValue: string;
  1237. constructor(define: string, operand: string, testValue: string);
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Misc/loadFileError" {
  1244. import { WebRequest } from "babylonjs/Misc/webRequest";
  1245. /**
  1246. * @ignore
  1247. * Application error to support additional information when loading a file
  1248. */
  1249. export class LoadFileError extends Error {
  1250. /** defines the optional web request */
  1251. request?: WebRequest | undefined;
  1252. private static _setPrototypeOf;
  1253. /**
  1254. * Creates a new LoadFileError
  1255. * @param message defines the message of the error
  1256. * @param request defines the optional web request
  1257. */
  1258. constructor(message: string,
  1259. /** defines the optional web request */
  1260. request?: WebRequest | undefined);
  1261. }
  1262. }
  1263. declare module "babylonjs/Offline/IOfflineProvider" {
  1264. /**
  1265. * Class used to enable access to offline support
  1266. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1267. */
  1268. export interface IOfflineProvider {
  1269. /**
  1270. * Gets a boolean indicating if scene must be saved in the database
  1271. */
  1272. enableSceneOffline: boolean;
  1273. /**
  1274. * Gets a boolean indicating if textures must be saved in the database
  1275. */
  1276. enableTexturesOffline: boolean;
  1277. /**
  1278. * Open the offline support and make it available
  1279. * @param successCallback defines the callback to call on success
  1280. * @param errorCallback defines the callback to call on error
  1281. */
  1282. open(successCallback: () => void, errorCallback: () => void): void;
  1283. /**
  1284. * Loads an image from the offline support
  1285. * @param url defines the url to load from
  1286. * @param image defines the target DOM image
  1287. */
  1288. loadImage(url: string, image: HTMLImageElement): void;
  1289. /**
  1290. * Loads a file from offline support
  1291. * @param url defines the URL to load from
  1292. * @param sceneLoaded defines a callback to call on success
  1293. * @param progressCallBack defines a callback to call when progress changed
  1294. * @param errorCallback defines a callback to call on error
  1295. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1296. */
  1297. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/filesInputStore" {
  1301. /**
  1302. * Class used to help managing file picking and drag'n'drop
  1303. * File Storage
  1304. */
  1305. export class FilesInputStore {
  1306. /**
  1307. * List of files ready to be loaded
  1308. */
  1309. static FilesToLoad: {
  1310. [key: string]: File;
  1311. };
  1312. }
  1313. }
  1314. declare module "babylonjs/Misc/retryStrategy" {
  1315. import { WebRequest } from "babylonjs/Misc/webRequest";
  1316. /**
  1317. * Class used to define a retry strategy when error happens while loading assets
  1318. */
  1319. export class RetryStrategy {
  1320. /**
  1321. * Function used to defines an exponential back off strategy
  1322. * @param maxRetries defines the maximum number of retries (3 by default)
  1323. * @param baseInterval defines the interval between retries
  1324. * @returns the strategy function to use
  1325. */
  1326. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1327. }
  1328. }
  1329. declare module "babylonjs/Misc/fileTools" {
  1330. import { WebRequest } from "babylonjs/Misc/webRequest";
  1331. import { Nullable } from "babylonjs/types";
  1332. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1333. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1334. /**
  1335. * @hidden
  1336. */
  1337. export class FileTools {
  1338. /**
  1339. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1340. */
  1341. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1342. /**
  1343. * Gets or sets the base URL to use to load assets
  1344. */
  1345. static BaseUrl: string;
  1346. /**
  1347. * Default behaviour for cors in the application.
  1348. * It can be a string if the expected behavior is identical in the entire app.
  1349. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1350. */
  1351. static CorsBehavior: string | ((url: string | string[]) => string);
  1352. /**
  1353. * Gets or sets a function used to pre-process url before using them to load assets
  1354. */
  1355. static PreprocessUrl: (url: string) => string;
  1356. /**
  1357. * Removes unwanted characters from an url
  1358. * @param url defines the url to clean
  1359. * @returns the cleaned url
  1360. */
  1361. private static _CleanUrl;
  1362. /**
  1363. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1364. * @param url define the url we are trying
  1365. * @param element define the dom element where to configure the cors policy
  1366. */
  1367. static SetCorsBehavior(url: string | string[], element: {
  1368. crossOrigin: string | null;
  1369. }): void;
  1370. private static _ArrayBufferToBase64;
  1371. /**
  1372. * Loads an image as an HTMLImageElement.
  1373. * @param input url string, ArrayBuffer, or Blob to load
  1374. * @param onLoad callback called when the image successfully loads
  1375. * @param onError callback called when the image fails to load
  1376. * @param offlineProvider offline provider for caching
  1377. * @param mimeType optional mime type
  1378. * @returns the HTMLImageElement of the loaded image
  1379. */
  1380. 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>;
  1381. /**
  1382. * Loads a file
  1383. * @param fileToLoad defines the file to load
  1384. * @param callback defines the callback to call when data is loaded
  1385. * @param progressCallBack defines the callback to call during loading process
  1386. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1387. * @returns a file request object
  1388. */
  1389. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1390. /**
  1391. * Loads a file
  1392. * @param url url string, ArrayBuffer, or Blob to load
  1393. * @param onSuccess callback called when the file successfully loads
  1394. * @param onProgress callback called while file is loading (if the server supports this mode)
  1395. * @param offlineProvider defines the offline provider for caching
  1396. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1397. * @param onError callback called when the file fails to load
  1398. * @returns a file request object
  1399. */
  1400. 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;
  1401. /**
  1402. * Checks if the loaded document was accessed via `file:`-Protocol.
  1403. * @returns boolean
  1404. */
  1405. static IsFileURL(): boolean;
  1406. }
  1407. }
  1408. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1409. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1410. /** @hidden */
  1411. export class ShaderProcessor {
  1412. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1413. private static _ProcessPrecision;
  1414. private static _ExtractOperation;
  1415. private static _BuildSubExpression;
  1416. private static _BuildExpression;
  1417. private static _MoveCursorWithinIf;
  1418. private static _MoveCursor;
  1419. private static _EvaluatePreProcessors;
  1420. private static _PreparePreProcessors;
  1421. private static _ProcessShaderConversion;
  1422. private static _ProcessIncludes;
  1423. }
  1424. }
  1425. declare module "babylonjs/Maths/math.like" {
  1426. import { float, int, DeepImmutable } from "babylonjs/types";
  1427. /**
  1428. * @hidden
  1429. */
  1430. export interface IColor4Like {
  1431. r: float;
  1432. g: float;
  1433. b: float;
  1434. a: float;
  1435. }
  1436. /**
  1437. * @hidden
  1438. */
  1439. export interface IColor3Like {
  1440. r: float;
  1441. g: float;
  1442. b: float;
  1443. }
  1444. /**
  1445. * @hidden
  1446. */
  1447. export interface IVector4Like {
  1448. x: float;
  1449. y: float;
  1450. z: float;
  1451. w: float;
  1452. }
  1453. /**
  1454. * @hidden
  1455. */
  1456. export interface IVector3Like {
  1457. x: float;
  1458. y: float;
  1459. z: float;
  1460. }
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IVector2Like {
  1465. x: float;
  1466. y: float;
  1467. }
  1468. /**
  1469. * @hidden
  1470. */
  1471. export interface IMatrixLike {
  1472. toArray(): DeepImmutable<Float32Array>;
  1473. updateFlag: int;
  1474. }
  1475. /**
  1476. * @hidden
  1477. */
  1478. export interface IViewportLike {
  1479. x: float;
  1480. y: float;
  1481. width: float;
  1482. height: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IPlaneLike {
  1488. normal: IVector3Like;
  1489. d: float;
  1490. normalize(): void;
  1491. }
  1492. }
  1493. declare module "babylonjs/Materials/iEffectFallbacks" {
  1494. import { Effect } from "babylonjs/Materials/effect";
  1495. /**
  1496. * Interface used to define common properties for effect fallbacks
  1497. */
  1498. export interface IEffectFallbacks {
  1499. /**
  1500. * Removes the defines that should be removed when falling back.
  1501. * @param currentDefines defines the current define statements for the shader.
  1502. * @param effect defines the current effect we try to compile
  1503. * @returns The resulting defines with defines of the current rank removed.
  1504. */
  1505. reduce(currentDefines: string, effect: Effect): string;
  1506. /**
  1507. * Removes the fallback from the bound mesh.
  1508. */
  1509. unBindMesh(): void;
  1510. /**
  1511. * Checks to see if more fallbacks are still availible.
  1512. */
  1513. hasMoreFallbacks: boolean;
  1514. }
  1515. }
  1516. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1517. /**
  1518. * Class used to evalaute queries containing `and` and `or` operators
  1519. */
  1520. export class AndOrNotEvaluator {
  1521. /**
  1522. * Evaluate a query
  1523. * @param query defines the query to evaluate
  1524. * @param evaluateCallback defines the callback used to filter result
  1525. * @returns true if the query matches
  1526. */
  1527. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1528. private static _HandleParenthesisContent;
  1529. private static _SimplifyNegation;
  1530. }
  1531. }
  1532. declare module "babylonjs/Misc/tags" {
  1533. /**
  1534. * Class used to store custom tags
  1535. */
  1536. export class Tags {
  1537. /**
  1538. * Adds support for tags on the given object
  1539. * @param obj defines the object to use
  1540. */
  1541. static EnableFor(obj: any): void;
  1542. /**
  1543. * Removes tags support
  1544. * @param obj defines the object to use
  1545. */
  1546. static DisableFor(obj: any): void;
  1547. /**
  1548. * Gets a boolean indicating if the given object has tags
  1549. * @param obj defines the object to use
  1550. * @returns a boolean
  1551. */
  1552. static HasTags(obj: any): boolean;
  1553. /**
  1554. * Gets the tags available on a given object
  1555. * @param obj defines the object to use
  1556. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1557. * @returns the tags
  1558. */
  1559. static GetTags(obj: any, asString?: boolean): any;
  1560. /**
  1561. * Adds tags to an object
  1562. * @param obj defines the object to use
  1563. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1564. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1565. */
  1566. static AddTagsTo(obj: any, tagsString: string): void;
  1567. /**
  1568. * @hidden
  1569. */
  1570. static _AddTagTo(obj: any, tag: string): void;
  1571. /**
  1572. * Removes specific tags from a specific object
  1573. * @param obj defines the object to use
  1574. * @param tagsString defines the tags to remove
  1575. */
  1576. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1577. /**
  1578. * @hidden
  1579. */
  1580. static _RemoveTagFrom(obj: any, tag: string): void;
  1581. /**
  1582. * Defines if tags hosted on an object match a given query
  1583. * @param obj defines the object to use
  1584. * @param tagsQuery defines the tag query
  1585. * @returns a boolean
  1586. */
  1587. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1588. }
  1589. }
  1590. declare module "babylonjs/Maths/math.scalar" {
  1591. /**
  1592. * Scalar computation library
  1593. */
  1594. export class Scalar {
  1595. /**
  1596. * Two pi constants convenient for computation.
  1597. */
  1598. static TwoPi: number;
  1599. /**
  1600. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1601. * @param a number
  1602. * @param b number
  1603. * @param epsilon (default = 1.401298E-45)
  1604. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1605. */
  1606. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1607. /**
  1608. * Returns a string : the upper case translation of the number i to hexadecimal.
  1609. * @param i number
  1610. * @returns the upper case translation of the number i to hexadecimal.
  1611. */
  1612. static ToHex(i: number): string;
  1613. /**
  1614. * Returns -1 if value is negative and +1 is value is positive.
  1615. * @param value the value
  1616. * @returns the value itself if it's equal to zero.
  1617. */
  1618. static Sign(value: number): number;
  1619. /**
  1620. * Returns the value itself if it's between min and max.
  1621. * Returns min if the value is lower than min.
  1622. * Returns max if the value is greater than max.
  1623. * @param value the value to clmap
  1624. * @param min the min value to clamp to (default: 0)
  1625. * @param max the max value to clamp to (default: 1)
  1626. * @returns the clamped value
  1627. */
  1628. static Clamp(value: number, min?: number, max?: number): number;
  1629. /**
  1630. * the log2 of value.
  1631. * @param value the value to compute log2 of
  1632. * @returns the log2 of value.
  1633. */
  1634. static Log2(value: number): number;
  1635. /**
  1636. * Loops the value, so that it is never larger than length and never smaller than 0.
  1637. *
  1638. * This is similar to the modulo operator but it works with floating point numbers.
  1639. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1640. * With t = 5 and length = 2.5, the result would be 0.0.
  1641. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1642. * @param value the value
  1643. * @param length the length
  1644. * @returns the looped value
  1645. */
  1646. static Repeat(value: number, length: number): number;
  1647. /**
  1648. * Normalize the value between 0.0 and 1.0 using min and max values
  1649. * @param value value to normalize
  1650. * @param min max to normalize between
  1651. * @param max min to normalize between
  1652. * @returns the normalized value
  1653. */
  1654. static Normalize(value: number, min: number, max: number): number;
  1655. /**
  1656. * Denormalize the value from 0.0 and 1.0 using min and max values
  1657. * @param normalized value to denormalize
  1658. * @param min max to denormalize between
  1659. * @param max min to denormalize between
  1660. * @returns the denormalized value
  1661. */
  1662. static Denormalize(normalized: number, min: number, max: number): number;
  1663. /**
  1664. * Calculates the shortest difference between two given angles given in degrees.
  1665. * @param current current angle in degrees
  1666. * @param target target angle in degrees
  1667. * @returns the delta
  1668. */
  1669. static DeltaAngle(current: number, target: number): number;
  1670. /**
  1671. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1672. * @param tx value
  1673. * @param length length
  1674. * @returns The returned value will move back and forth between 0 and length
  1675. */
  1676. static PingPong(tx: number, length: number): number;
  1677. /**
  1678. * Interpolates between min and max with smoothing at the limits.
  1679. *
  1680. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1681. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1682. * @param from from
  1683. * @param to to
  1684. * @param tx value
  1685. * @returns the smooth stepped value
  1686. */
  1687. static SmoothStep(from: number, to: number, tx: number): number;
  1688. /**
  1689. * Moves a value current towards target.
  1690. *
  1691. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1692. * Negative values of maxDelta pushes the value away from target.
  1693. * @param current current value
  1694. * @param target target value
  1695. * @param maxDelta max distance to move
  1696. * @returns resulting value
  1697. */
  1698. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1699. /**
  1700. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1701. *
  1702. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1703. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1704. * @param current current value
  1705. * @param target target value
  1706. * @param maxDelta max distance to move
  1707. * @returns resulting angle
  1708. */
  1709. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1710. /**
  1711. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1712. * @param start start value
  1713. * @param end target value
  1714. * @param amount amount to lerp between
  1715. * @returns the lerped value
  1716. */
  1717. static Lerp(start: number, end: number, amount: number): number;
  1718. /**
  1719. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1720. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1721. * @param start start value
  1722. * @param end target value
  1723. * @param amount amount to lerp between
  1724. * @returns the lerped value
  1725. */
  1726. static LerpAngle(start: number, end: number, amount: number): number;
  1727. /**
  1728. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1729. * @param a start value
  1730. * @param b target value
  1731. * @param value value between a and b
  1732. * @returns the inverseLerp value
  1733. */
  1734. static InverseLerp(a: number, b: number, value: number): number;
  1735. /**
  1736. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1737. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1738. * @param value1 spline value
  1739. * @param tangent1 spline value
  1740. * @param value2 spline value
  1741. * @param tangent2 spline value
  1742. * @param amount input value
  1743. * @returns hermite result
  1744. */
  1745. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1746. /**
  1747. * Returns a random float number between and min and max values
  1748. * @param min min value of random
  1749. * @param max max value of random
  1750. * @returns random value
  1751. */
  1752. static RandomRange(min: number, max: number): number;
  1753. /**
  1754. * This function returns percentage of a number in a given range.
  1755. *
  1756. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1757. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1758. * @param number to convert to percentage
  1759. * @param min min range
  1760. * @param max max range
  1761. * @returns the percentage
  1762. */
  1763. static RangeToPercent(number: number, min: number, max: number): number;
  1764. /**
  1765. * This function returns number that corresponds to the percentage in a given range.
  1766. *
  1767. * PercentToRange(0.34,0,100) will return 34.
  1768. * @param percent to convert to number
  1769. * @param min min range
  1770. * @param max max range
  1771. * @returns the number
  1772. */
  1773. static PercentToRange(percent: number, min: number, max: number): number;
  1774. /**
  1775. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1776. * @param angle The angle to normalize in radian.
  1777. * @return The converted angle.
  1778. */
  1779. static NormalizeRadians(angle: number): number;
  1780. }
  1781. }
  1782. declare module "babylonjs/Maths/math.constants" {
  1783. /**
  1784. * Constant used to convert a value to gamma space
  1785. * @ignorenaming
  1786. */
  1787. export const ToGammaSpace: number;
  1788. /**
  1789. * Constant used to convert a value to linear space
  1790. * @ignorenaming
  1791. */
  1792. export const ToLinearSpace = 2.2;
  1793. /**
  1794. * Constant used to define the minimal number value in Babylon.js
  1795. * @ignorenaming
  1796. */
  1797. let Epsilon: number;
  1798. export { Epsilon };
  1799. }
  1800. declare module "babylonjs/Maths/math.viewport" {
  1801. /**
  1802. * Class used to represent a viewport on screen
  1803. */
  1804. export class Viewport {
  1805. /** viewport left coordinate */
  1806. x: number;
  1807. /** viewport top coordinate */
  1808. y: number;
  1809. /**viewport width */
  1810. width: number;
  1811. /** viewport height */
  1812. height: number;
  1813. /**
  1814. * Creates a Viewport object located at (x, y) and sized (width, height)
  1815. * @param x defines viewport left coordinate
  1816. * @param y defines viewport top coordinate
  1817. * @param width defines the viewport width
  1818. * @param height defines the viewport height
  1819. */
  1820. constructor(
  1821. /** viewport left coordinate */
  1822. x: number,
  1823. /** viewport top coordinate */
  1824. y: number,
  1825. /**viewport width */
  1826. width: number,
  1827. /** viewport height */
  1828. height: number);
  1829. /**
  1830. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1831. * @param renderWidth defines the rendering width
  1832. * @param renderHeight defines the rendering height
  1833. * @returns a new Viewport
  1834. */
  1835. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1836. /**
  1837. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1838. * @param renderWidth defines the rendering width
  1839. * @param renderHeight defines the rendering height
  1840. * @param ref defines the target viewport
  1841. * @returns the current viewport
  1842. */
  1843. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1844. /**
  1845. * Returns a new Viewport copied from the current one
  1846. * @returns a new Viewport
  1847. */
  1848. clone(): Viewport;
  1849. }
  1850. }
  1851. declare module "babylonjs/Misc/arrayTools" {
  1852. /**
  1853. * Class containing a set of static utilities functions for arrays.
  1854. */
  1855. export class ArrayTools {
  1856. /**
  1857. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1858. * @param size the number of element to construct and put in the array
  1859. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1860. * @returns a new array filled with new objects
  1861. */
  1862. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1863. }
  1864. }
  1865. declare module "babylonjs/Maths/math.vector" {
  1866. import { Viewport } from "babylonjs/Maths/math.viewport";
  1867. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1868. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1869. /**
  1870. * Class representing a vector containing 2 coordinates
  1871. */
  1872. export class Vector2 {
  1873. /** defines the first coordinate */
  1874. x: number;
  1875. /** defines the second coordinate */
  1876. y: number;
  1877. /**
  1878. * Creates a new Vector2 from the given x and y coordinates
  1879. * @param x defines the first coordinate
  1880. * @param y defines the second coordinate
  1881. */
  1882. constructor(
  1883. /** defines the first coordinate */
  1884. x?: number,
  1885. /** defines the second coordinate */
  1886. y?: number);
  1887. /**
  1888. * Gets a string with the Vector2 coordinates
  1889. * @returns a string with the Vector2 coordinates
  1890. */
  1891. toString(): string;
  1892. /**
  1893. * Gets class name
  1894. * @returns the string "Vector2"
  1895. */
  1896. getClassName(): string;
  1897. /**
  1898. * Gets current vector hash code
  1899. * @returns the Vector2 hash code as a number
  1900. */
  1901. getHashCode(): number;
  1902. /**
  1903. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1904. * @param array defines the source array
  1905. * @param index defines the offset in source array
  1906. * @returns the current Vector2
  1907. */
  1908. toArray(array: FloatArray, index?: number): Vector2;
  1909. /**
  1910. * Copy the current vector to an array
  1911. * @returns a new array with 2 elements: the Vector2 coordinates.
  1912. */
  1913. asArray(): number[];
  1914. /**
  1915. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1916. * @param source defines the source Vector2
  1917. * @returns the current updated Vector2
  1918. */
  1919. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1920. /**
  1921. * Sets the Vector2 coordinates with the given floats
  1922. * @param x defines the first coordinate
  1923. * @param y defines the second coordinate
  1924. * @returns the current updated Vector2
  1925. */
  1926. copyFromFloats(x: number, y: number): Vector2;
  1927. /**
  1928. * Sets the Vector2 coordinates with the given floats
  1929. * @param x defines the first coordinate
  1930. * @param y defines the second coordinate
  1931. * @returns the current updated Vector2
  1932. */
  1933. set(x: number, y: number): Vector2;
  1934. /**
  1935. * Add another vector with the current one
  1936. * @param otherVector defines the other vector
  1937. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1938. */
  1939. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1940. /**
  1941. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1942. * @param otherVector defines the other vector
  1943. * @param result defines the target vector
  1944. * @returns the unmodified current Vector2
  1945. */
  1946. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1947. /**
  1948. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1949. * @param otherVector defines the other vector
  1950. * @returns the current updated Vector2
  1951. */
  1952. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1955. * @param otherVector defines the other vector
  1956. * @returns a new Vector2
  1957. */
  1958. addVector3(otherVector: Vector3): Vector2;
  1959. /**
  1960. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1961. * @param otherVector defines the other vector
  1962. * @returns a new Vector2
  1963. */
  1964. subtract(otherVector: Vector2): Vector2;
  1965. /**
  1966. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1967. * @param otherVector defines the other vector
  1968. * @param result defines the target vector
  1969. * @returns the unmodified current Vector2
  1970. */
  1971. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1972. /**
  1973. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1974. * @param otherVector defines the other vector
  1975. * @returns the current updated Vector2
  1976. */
  1977. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Multiplies in place the current Vector2 coordinates by the given ones
  1980. * @param otherVector defines the other vector
  1981. * @returns the current updated Vector2
  1982. */
  1983. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1984. /**
  1985. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1986. * @param otherVector defines the other vector
  1987. * @returns a new Vector2
  1988. */
  1989. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1990. /**
  1991. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1992. * @param otherVector defines the other vector
  1993. * @param result defines the target vector
  1994. * @returns the unmodified current Vector2
  1995. */
  1996. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1999. * @param x defines the first coordinate
  2000. * @param y defines the second coordinate
  2001. * @returns a new Vector2
  2002. */
  2003. multiplyByFloats(x: number, y: number): Vector2;
  2004. /**
  2005. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. divide(otherVector: Vector2): Vector2;
  2010. /**
  2011. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @param result defines the target vector
  2014. * @returns the unmodified current Vector2
  2015. */
  2016. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2017. /**
  2018. * Divides the current Vector2 coordinates by the given ones
  2019. * @param otherVector defines the other vector
  2020. * @returns the current updated Vector2
  2021. */
  2022. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Gets a new Vector2 with current Vector2 negated coordinates
  2025. * @returns a new Vector2
  2026. */
  2027. negate(): Vector2;
  2028. /**
  2029. * Multiply the Vector2 coordinates by scale
  2030. * @param scale defines the scaling factor
  2031. * @returns the current updated Vector2
  2032. */
  2033. scaleInPlace(scale: number): Vector2;
  2034. /**
  2035. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2036. * @param scale defines the scaling factor
  2037. * @returns a new Vector2
  2038. */
  2039. scale(scale: number): Vector2;
  2040. /**
  2041. * Scale the current Vector2 values by a factor to a given Vector2
  2042. * @param scale defines the scale factor
  2043. * @param result defines the Vector2 object where to store the result
  2044. * @returns the unmodified current Vector2
  2045. */
  2046. scaleToRef(scale: number, result: Vector2): Vector2;
  2047. /**
  2048. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2049. * @param scale defines the scale factor
  2050. * @param result defines the Vector2 object where to store the result
  2051. * @returns the unmodified current Vector2
  2052. */
  2053. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2054. /**
  2055. * Gets a boolean if two vectors are equals
  2056. * @param otherVector defines the other vector
  2057. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2058. */
  2059. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2060. /**
  2061. * Gets a boolean if two vectors are equals (using an epsilon value)
  2062. * @param otherVector defines the other vector
  2063. * @param epsilon defines the minimal distance to consider equality
  2064. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2065. */
  2066. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2067. /**
  2068. * Gets a new Vector2 from current Vector2 floored values
  2069. * @returns a new Vector2
  2070. */
  2071. floor(): Vector2;
  2072. /**
  2073. * Gets a new Vector2 from current Vector2 floored values
  2074. * @returns a new Vector2
  2075. */
  2076. fract(): Vector2;
  2077. /**
  2078. * Gets the length of the vector
  2079. * @returns the vector length (float)
  2080. */
  2081. length(): number;
  2082. /**
  2083. * Gets the vector squared length
  2084. * @returns the vector squared length (float)
  2085. */
  2086. lengthSquared(): number;
  2087. /**
  2088. * Normalize the vector
  2089. * @returns the current updated Vector2
  2090. */
  2091. normalize(): Vector2;
  2092. /**
  2093. * Gets a new Vector2 copied from the Vector2
  2094. * @returns a new Vector2
  2095. */
  2096. clone(): Vector2;
  2097. /**
  2098. * Gets a new Vector2(0, 0)
  2099. * @returns a new Vector2
  2100. */
  2101. static Zero(): Vector2;
  2102. /**
  2103. * Gets a new Vector2(1, 1)
  2104. * @returns a new Vector2
  2105. */
  2106. static One(): Vector2;
  2107. /**
  2108. * Gets a new Vector2 set from the given index element of the given array
  2109. * @param array defines the data source
  2110. * @param offset defines the offset in the data source
  2111. * @returns a new Vector2
  2112. */
  2113. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2114. /**
  2115. * Sets "result" from the given index element of the given array
  2116. * @param array defines the data source
  2117. * @param offset defines the offset in the data source
  2118. * @param result defines the target vector
  2119. */
  2120. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2121. /**
  2122. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2123. * @param value1 defines 1st point of control
  2124. * @param value2 defines 2nd point of control
  2125. * @param value3 defines 3rd point of control
  2126. * @param value4 defines 4th point of control
  2127. * @param amount defines the interpolation factor
  2128. * @returns a new Vector2
  2129. */
  2130. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2131. /**
  2132. * 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".
  2133. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2134. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2135. * @param value defines the value to clamp
  2136. * @param min defines the lower limit
  2137. * @param max defines the upper limit
  2138. * @returns a new Vector2
  2139. */
  2140. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2141. /**
  2142. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2143. * @param value1 defines the 1st control point
  2144. * @param tangent1 defines the outgoing tangent
  2145. * @param value2 defines the 2nd control point
  2146. * @param tangent2 defines the incoming tangent
  2147. * @param amount defines the interpolation factor
  2148. * @returns a new Vector2
  2149. */
  2150. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2151. /**
  2152. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2153. * @param start defines the start vector
  2154. * @param end defines the end vector
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * Gets the dot product of the vector "left" and the vector "right"
  2161. * @param left defines first vector
  2162. * @param right defines second vector
  2163. * @returns the dot product (float)
  2164. */
  2165. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2166. /**
  2167. * Returns a new Vector2 equal to the normalized given vector
  2168. * @param vector defines the vector to normalize
  2169. * @returns a new Vector2
  2170. */
  2171. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2174. * @param left defines 1st vector
  2175. * @param right defines 2nd vector
  2176. * @returns a new Vector2
  2177. */
  2178. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2179. /**
  2180. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2181. * @param left defines 1st vector
  2182. * @param right defines 2nd vector
  2183. * @returns a new Vector2
  2184. */
  2185. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2186. /**
  2187. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2188. * @param vector defines the vector to transform
  2189. * @param transformation defines the matrix to apply
  2190. * @returns a new Vector2
  2191. */
  2192. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2193. /**
  2194. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2195. * @param vector defines the vector to transform
  2196. * @param transformation defines the matrix to apply
  2197. * @param result defines the target vector
  2198. */
  2199. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2200. /**
  2201. * Determines if a given vector is included in a triangle
  2202. * @param p defines the vector to test
  2203. * @param p0 defines 1st triangle point
  2204. * @param p1 defines 2nd triangle point
  2205. * @param p2 defines 3rd triangle point
  2206. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2207. */
  2208. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2209. /**
  2210. * Gets the distance between the vectors "value1" and "value2"
  2211. * @param value1 defines first vector
  2212. * @param value2 defines second vector
  2213. * @returns the distance between vectors
  2214. */
  2215. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2216. /**
  2217. * Returns the squared distance between the vectors "value1" and "value2"
  2218. * @param value1 defines first vector
  2219. * @param value2 defines second vector
  2220. * @returns the squared distance between vectors
  2221. */
  2222. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2223. /**
  2224. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2225. * @param value1 defines first vector
  2226. * @param value2 defines second vector
  2227. * @returns a new Vector2
  2228. */
  2229. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2232. * @param p defines the middle point
  2233. * @param segA defines one point of the segment
  2234. * @param segB defines the other point of the segment
  2235. * @returns the shortest distance
  2236. */
  2237. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2238. }
  2239. /**
  2240. * Classed used to store (x,y,z) vector representation
  2241. * A Vector3 is the main object used in 3D geometry
  2242. * It can represent etiher the coordinates of a point the space, either a direction
  2243. * Reminder: js uses a left handed forward facing system
  2244. */
  2245. export class Vector3 {
  2246. /**
  2247. * Defines the first coordinates (on X axis)
  2248. */
  2249. x: number;
  2250. /**
  2251. * Defines the second coordinates (on Y axis)
  2252. */
  2253. y: number;
  2254. /**
  2255. * Defines the third coordinates (on Z axis)
  2256. */
  2257. z: number;
  2258. private static _UpReadOnly;
  2259. private static _ZeroReadOnly;
  2260. /**
  2261. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2262. * @param x defines the first coordinates (on X axis)
  2263. * @param y defines the second coordinates (on Y axis)
  2264. * @param z defines the third coordinates (on Z axis)
  2265. */
  2266. constructor(
  2267. /**
  2268. * Defines the first coordinates (on X axis)
  2269. */
  2270. x?: number,
  2271. /**
  2272. * Defines the second coordinates (on Y axis)
  2273. */
  2274. y?: number,
  2275. /**
  2276. * Defines the third coordinates (on Z axis)
  2277. */
  2278. z?: number);
  2279. /**
  2280. * Creates a string representation of the Vector3
  2281. * @returns a string with the Vector3 coordinates.
  2282. */
  2283. toString(): string;
  2284. /**
  2285. * Gets the class name
  2286. * @returns the string "Vector3"
  2287. */
  2288. getClassName(): string;
  2289. /**
  2290. * Creates the Vector3 hash code
  2291. * @returns a number which tends to be unique between Vector3 instances
  2292. */
  2293. getHashCode(): number;
  2294. /**
  2295. * Creates an array containing three elements : the coordinates of the Vector3
  2296. * @returns a new array of numbers
  2297. */
  2298. asArray(): number[];
  2299. /**
  2300. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2301. * @param array defines the destination array
  2302. * @param index defines the offset in the destination array
  2303. * @returns the current Vector3
  2304. */
  2305. toArray(array: FloatArray, index?: number): Vector3;
  2306. /**
  2307. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2308. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2309. */
  2310. toQuaternion(): Quaternion;
  2311. /**
  2312. * Adds the given vector to the current Vector3
  2313. * @param otherVector defines the second operand
  2314. * @returns the current updated Vector3
  2315. */
  2316. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2317. /**
  2318. * Adds the given coordinates to the current Vector3
  2319. * @param x defines the x coordinate of the operand
  2320. * @param y defines the y coordinate of the operand
  2321. * @param z defines the z coordinate of the operand
  2322. * @returns the current updated Vector3
  2323. */
  2324. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2325. /**
  2326. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2327. * @param otherVector defines the second operand
  2328. * @returns the resulting Vector3
  2329. */
  2330. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2331. /**
  2332. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2333. * @param otherVector defines the second operand
  2334. * @param result defines the Vector3 object where to store the result
  2335. * @returns the current Vector3
  2336. */
  2337. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2338. /**
  2339. * Subtract the given vector from the current Vector3
  2340. * @param otherVector defines the second operand
  2341. * @returns the current updated Vector3
  2342. */
  2343. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2344. /**
  2345. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the resulting Vector3
  2348. */
  2349. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2352. * @param otherVector defines the second operand
  2353. * @param result defines the Vector3 object where to store the result
  2354. * @returns the current Vector3
  2355. */
  2356. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2357. /**
  2358. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the resulting Vector3
  2363. */
  2364. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2367. * @param x defines the x coordinate of the operand
  2368. * @param y defines the y coordinate of the operand
  2369. * @param z defines the z coordinate of the operand
  2370. * @param result defines the Vector3 object where to store the result
  2371. * @returns the current Vector3
  2372. */
  2373. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2374. /**
  2375. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2376. * @returns a new Vector3
  2377. */
  2378. negate(): Vector3;
  2379. /**
  2380. * Multiplies the Vector3 coordinates by the float "scale"
  2381. * @param scale defines the multiplier factor
  2382. * @returns the current updated Vector3
  2383. */
  2384. scaleInPlace(scale: number): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2387. * @param scale defines the multiplier factor
  2388. * @returns a new Vector3
  2389. */
  2390. scale(scale: number): Vector3;
  2391. /**
  2392. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2393. * @param scale defines the multiplier factor
  2394. * @param result defines the Vector3 object where to store the result
  2395. * @returns the current Vector3
  2396. */
  2397. scaleToRef(scale: number, result: Vector3): Vector3;
  2398. /**
  2399. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2400. * @param scale defines the scale factor
  2401. * @param result defines the Vector3 object where to store the result
  2402. * @returns the unmodified current Vector3
  2403. */
  2404. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2405. /**
  2406. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2407. * @param otherVector defines the second operand
  2408. * @returns true if both vectors are equals
  2409. */
  2410. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2411. /**
  2412. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2413. * @param otherVector defines the second operand
  2414. * @param epsilon defines the minimal distance to define values as equals
  2415. * @returns true if both vectors are distant less than epsilon
  2416. */
  2417. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2418. /**
  2419. * Returns true if the current Vector3 coordinates equals the given floats
  2420. * @param x defines the x coordinate of the operand
  2421. * @param y defines the y coordinate of the operand
  2422. * @param z defines the z coordinate of the operand
  2423. * @returns true if both vectors are equals
  2424. */
  2425. equalsToFloats(x: number, y: number, z: number): boolean;
  2426. /**
  2427. * Multiplies the current Vector3 coordinates by the given ones
  2428. * @param otherVector defines the second operand
  2429. * @returns the current updated Vector3
  2430. */
  2431. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2434. * @param otherVector defines the second operand
  2435. * @returns the new Vector3
  2436. */
  2437. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2438. /**
  2439. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2440. * @param otherVector defines the second operand
  2441. * @param result defines the Vector3 object where to store the result
  2442. * @returns the current Vector3
  2443. */
  2444. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2447. * @param x defines the x coordinate of the operand
  2448. * @param y defines the y coordinate of the operand
  2449. * @param z defines the z coordinate of the operand
  2450. * @returns the new Vector3
  2451. */
  2452. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2453. /**
  2454. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2455. * @param otherVector defines the second operand
  2456. * @returns the new Vector3
  2457. */
  2458. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2459. /**
  2460. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2461. * @param otherVector defines the second operand
  2462. * @param result defines the Vector3 object where to store the result
  2463. * @returns the current Vector3
  2464. */
  2465. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2466. /**
  2467. * Divides the current Vector3 coordinates by the given ones.
  2468. * @param otherVector defines the second operand
  2469. * @returns the current updated Vector3
  2470. */
  2471. divideInPlace(otherVector: Vector3): Vector3;
  2472. /**
  2473. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2474. * @param other defines the second operand
  2475. * @returns the current updated Vector3
  2476. */
  2477. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2478. /**
  2479. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2480. * @param other defines the second operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2484. /**
  2485. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2486. * @param x defines the x coordinate of the operand
  2487. * @param y defines the y coordinate of the operand
  2488. * @param z defines the z coordinate of the operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2492. /**
  2493. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2494. * @param x defines the x coordinate of the operand
  2495. * @param y defines the y coordinate of the operand
  2496. * @param z defines the z coordinate of the operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2500. /**
  2501. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2502. * Check if is non uniform within a certain amount of decimal places to account for this
  2503. * @param epsilon the amount the values can differ
  2504. * @returns if the the vector is non uniform to a certain number of decimal places
  2505. */
  2506. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2507. /**
  2508. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2509. */
  2510. readonly isNonUniform: boolean;
  2511. /**
  2512. * Gets a new Vector3 from current Vector3 floored values
  2513. * @returns a new Vector3
  2514. */
  2515. floor(): Vector3;
  2516. /**
  2517. * Gets a new Vector3 from current Vector3 floored values
  2518. * @returns a new Vector3
  2519. */
  2520. fract(): Vector3;
  2521. /**
  2522. * Gets the length of the Vector3
  2523. * @returns the length of the Vector3
  2524. */
  2525. length(): number;
  2526. /**
  2527. * Gets the squared length of the Vector3
  2528. * @returns squared length of the Vector3
  2529. */
  2530. lengthSquared(): number;
  2531. /**
  2532. * Normalize the current Vector3.
  2533. * Please note that this is an in place operation.
  2534. * @returns the current updated Vector3
  2535. */
  2536. normalize(): Vector3;
  2537. /**
  2538. * Reorders the x y z properties of the vector in place
  2539. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2540. * @returns the current updated vector
  2541. */
  2542. reorderInPlace(order: string): this;
  2543. /**
  2544. * Rotates the vector around 0,0,0 by a quaternion
  2545. * @param quaternion the rotation quaternion
  2546. * @param result vector to store the result
  2547. * @returns the resulting vector
  2548. */
  2549. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2550. /**
  2551. * Rotates a vector around a given point
  2552. * @param quaternion the rotation quaternion
  2553. * @param point the point to rotate around
  2554. * @param result vector to store the result
  2555. * @returns the resulting vector
  2556. */
  2557. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2560. * The cross product is then orthogonal to both current and "other"
  2561. * @param other defines the right operand
  2562. * @returns the cross product
  2563. */
  2564. cross(other: Vector3): Vector3;
  2565. /**
  2566. * Normalize the current Vector3 with the given input length.
  2567. * Please note that this is an in place operation.
  2568. * @param len the length of the vector
  2569. * @returns the current updated Vector3
  2570. */
  2571. normalizeFromLength(len: number): Vector3;
  2572. /**
  2573. * Normalize the current Vector3 to a new vector
  2574. * @returns the new Vector3
  2575. */
  2576. normalizeToNew(): Vector3;
  2577. /**
  2578. * Normalize the current Vector3 to the reference
  2579. * @param reference define the Vector3 to update
  2580. * @returns the updated Vector3
  2581. */
  2582. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2583. /**
  2584. * Creates a new Vector3 copied from the current Vector3
  2585. * @returns the new Vector3
  2586. */
  2587. clone(): Vector3;
  2588. /**
  2589. * Copies the given vector coordinates to the current Vector3 ones
  2590. * @param source defines the source Vector3
  2591. * @returns the current updated Vector3
  2592. */
  2593. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2594. /**
  2595. * Copies the given floats to the current Vector3 coordinates
  2596. * @param x defines the x coordinate of the operand
  2597. * @param y defines the y coordinate of the operand
  2598. * @param z defines the z coordinate of the operand
  2599. * @returns the current updated Vector3
  2600. */
  2601. copyFromFloats(x: number, y: number, z: number): Vector3;
  2602. /**
  2603. * Copies the given floats to the current Vector3 coordinates
  2604. * @param x defines the x coordinate of the operand
  2605. * @param y defines the y coordinate of the operand
  2606. * @param z defines the z coordinate of the operand
  2607. * @returns the current updated Vector3
  2608. */
  2609. set(x: number, y: number, z: number): Vector3;
  2610. /**
  2611. * Copies the given float to the current Vector3 coordinates
  2612. * @param v defines the x, y and z coordinates of the operand
  2613. * @returns the current updated Vector3
  2614. */
  2615. setAll(v: number): Vector3;
  2616. /**
  2617. * Get the clip factor between two vectors
  2618. * @param vector0 defines the first operand
  2619. * @param vector1 defines the second operand
  2620. * @param axis defines the axis to use
  2621. * @param size defines the size along the axis
  2622. * @returns the clip factor
  2623. */
  2624. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2625. /**
  2626. * Get angle between two vectors
  2627. * @param vector0 angle between vector0 and vector1
  2628. * @param vector1 angle between vector0 and vector1
  2629. * @param normal direction of the normal
  2630. * @return the angle between vector0 and vector1
  2631. */
  2632. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2633. /**
  2634. * Returns a new Vector3 set from the index "offset" of the given array
  2635. * @param array defines the source array
  2636. * @param offset defines the offset in the source array
  2637. * @returns the new Vector3
  2638. */
  2639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2640. /**
  2641. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2642. * This function is deprecated. Use FromArray instead
  2643. * @param array defines the source array
  2644. * @param offset defines the offset in the source array
  2645. * @returns the new Vector3
  2646. */
  2647. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2648. /**
  2649. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2650. * @param array defines the source array
  2651. * @param offset defines the offset in the source array
  2652. * @param result defines the Vector3 where to store the result
  2653. */
  2654. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2655. /**
  2656. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2657. * This function is deprecated. Use FromArrayToRef instead.
  2658. * @param array defines the source array
  2659. * @param offset defines the offset in the source array
  2660. * @param result defines the Vector3 where to store the result
  2661. */
  2662. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2663. /**
  2664. * Sets the given vector "result" with the given floats.
  2665. * @param x defines the x coordinate of the source
  2666. * @param y defines the y coordinate of the source
  2667. * @param z defines the z coordinate of the source
  2668. * @param result defines the Vector3 where to store the result
  2669. */
  2670. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2671. /**
  2672. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2673. * @returns a new empty Vector3
  2674. */
  2675. static Zero(): Vector3;
  2676. /**
  2677. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2678. * @returns a new unit Vector3
  2679. */
  2680. static One(): Vector3;
  2681. /**
  2682. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2683. * @returns a new up Vector3
  2684. */
  2685. static Up(): Vector3;
  2686. /**
  2687. * Gets a up Vector3 that must not be updated
  2688. */
  2689. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2690. /**
  2691. * Gets a zero Vector3 that must not be updated
  2692. */
  2693. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2694. /**
  2695. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2696. * @returns a new down Vector3
  2697. */
  2698. static Down(): Vector3;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2701. * @returns a new forward Vector3
  2702. */
  2703. static Forward(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2706. * @returns a new forward Vector3
  2707. */
  2708. static Backward(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2711. * @returns a new right Vector3
  2712. */
  2713. static Right(): Vector3;
  2714. /**
  2715. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2716. * @returns a new left Vector3
  2717. */
  2718. static Left(): Vector3;
  2719. /**
  2720. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2721. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2722. * @param vector defines the Vector3 to transform
  2723. * @param transformation defines the transformation matrix
  2724. * @returns the transformed Vector3
  2725. */
  2726. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2727. /**
  2728. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2729. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2730. * @param vector defines the Vector3 to transform
  2731. * @param transformation defines the transformation matrix
  2732. * @param result defines the Vector3 where to store the result
  2733. */
  2734. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2735. /**
  2736. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2737. * This method computes tranformed coordinates only, not transformed direction vectors
  2738. * @param x define the x coordinate of the source vector
  2739. * @param y define the y coordinate of the source vector
  2740. * @param z define the z coordinate of the source vector
  2741. * @param transformation defines the transformation matrix
  2742. * @param result defines the Vector3 where to store the result
  2743. */
  2744. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2745. /**
  2746. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2747. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2748. * @param vector defines the Vector3 to transform
  2749. * @param transformation defines the transformation matrix
  2750. * @returns the new Vector3
  2751. */
  2752. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2753. /**
  2754. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2755. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2756. * @param vector defines the Vector3 to transform
  2757. * @param transformation defines the transformation matrix
  2758. * @param result defines the Vector3 where to store the result
  2759. */
  2760. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2761. /**
  2762. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2763. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2764. * @param x define the x coordinate of the source vector
  2765. * @param y define the y coordinate of the source vector
  2766. * @param z define the z coordinate of the source vector
  2767. * @param transformation defines the transformation matrix
  2768. * @param result defines the Vector3 where to store the result
  2769. */
  2770. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2771. /**
  2772. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2773. * @param value1 defines the first control point
  2774. * @param value2 defines the second control point
  2775. * @param value3 defines the third control point
  2776. * @param value4 defines the fourth control point
  2777. * @param amount defines the amount on the spline to use
  2778. * @returns the new Vector3
  2779. */
  2780. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2781. /**
  2782. * 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"
  2783. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2784. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2785. * @param value defines the current value
  2786. * @param min defines the lower range value
  2787. * @param max defines the upper range value
  2788. * @returns the new Vector3
  2789. */
  2790. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2791. /**
  2792. * 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"
  2793. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2794. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2795. * @param value defines the current value
  2796. * @param min defines the lower range value
  2797. * @param max defines the upper range value
  2798. * @param result defines the Vector3 where to store the result
  2799. */
  2800. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2801. /**
  2802. * Checks if a given vector is inside a specific range
  2803. * @param v defines the vector to test
  2804. * @param min defines the minimum range
  2805. * @param max defines the maximum range
  2806. */
  2807. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2808. /**
  2809. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2810. * @param value1 defines the first control point
  2811. * @param tangent1 defines the first tangent vector
  2812. * @param value2 defines the second control point
  2813. * @param tangent2 defines the second tangent vector
  2814. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2815. * @returns the new Vector3
  2816. */
  2817. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2818. /**
  2819. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2820. * @param start defines the start value
  2821. * @param end defines the end value
  2822. * @param amount max defines amount between both (between 0 and 1)
  2823. * @returns the new Vector3
  2824. */
  2825. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2828. * @param start defines the start value
  2829. * @param end defines the end value
  2830. * @param amount max defines amount between both (between 0 and 1)
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2834. /**
  2835. * Returns the dot product (float) between the vectors "left" and "right"
  2836. * @param left defines the left operand
  2837. * @param right defines the right operand
  2838. * @returns the dot product
  2839. */
  2840. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2841. /**
  2842. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2843. * The cross product is then orthogonal to both "left" and "right"
  2844. * @param left defines the left operand
  2845. * @param right defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the cross product of "left" and "right"
  2851. * The cross product is then orthogonal to both "left" and "right"
  2852. * @param left defines the left operand
  2853. * @param right defines the right operand
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 as the normalization of the given vector
  2859. * @param vector defines the Vector3 to normalize
  2860. * @returns the new Vector3
  2861. */
  2862. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2863. /**
  2864. * Sets the given vector "result" with the normalization of the given first vector
  2865. * @param vector defines the Vector3 to normalize
  2866. * @param result defines the Vector3 where to store the result
  2867. */
  2868. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2869. /**
  2870. * Project a Vector3 onto screen space
  2871. * @param vector defines the Vector3 to project
  2872. * @param world defines the world matrix to use
  2873. * @param transform defines the transform (view x projection) matrix to use
  2874. * @param viewport defines the screen viewport to use
  2875. * @returns the new Vector3
  2876. */
  2877. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2878. /** @hidden */
  2879. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2880. /**
  2881. * Unproject from screen space to object space
  2882. * @param source defines the screen space Vector3 to use
  2883. * @param viewportWidth defines the current width of the viewport
  2884. * @param viewportHeight defines the current height of the viewport
  2885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2886. * @param transform defines the transform (view x projection) matrix to use
  2887. * @returns the new Vector3
  2888. */
  2889. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2890. /**
  2891. * Unproject from screen space to object space
  2892. * @param source defines the screen space Vector3 to use
  2893. * @param viewportWidth defines the current width of the viewport
  2894. * @param viewportHeight defines the current height of the viewport
  2895. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2896. * @param view defines the view matrix to use
  2897. * @param projection defines the projection matrix to use
  2898. * @returns the new Vector3
  2899. */
  2900. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2901. /**
  2902. * Unproject from screen space to object space
  2903. * @param source defines the screen space Vector3 to use
  2904. * @param viewportWidth defines the current width of the viewport
  2905. * @param viewportHeight defines the current height of the viewport
  2906. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2907. * @param view defines the view matrix to use
  2908. * @param projection defines the projection matrix to use
  2909. * @param result defines the Vector3 where to store the result
  2910. */
  2911. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2912. /**
  2913. * Unproject from screen space to object space
  2914. * @param sourceX defines the screen space x coordinate to use
  2915. * @param sourceY defines the screen space y coordinate to use
  2916. * @param sourceZ defines the screen space z coordinate to use
  2917. * @param viewportWidth defines the current width of the viewport
  2918. * @param viewportHeight defines the current height of the viewport
  2919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2920. * @param view defines the view matrix to use
  2921. * @param projection defines the projection matrix to use
  2922. * @param result defines the Vector3 where to store the result
  2923. */
  2924. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2925. /**
  2926. * Gets the minimal coordinate values between two Vector3
  2927. * @param left defines the first operand
  2928. * @param right defines the second operand
  2929. * @returns the new Vector3
  2930. */
  2931. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2932. /**
  2933. * Gets the maximal coordinate values between two Vector3
  2934. * @param left defines the first operand
  2935. * @param right defines the second operand
  2936. * @returns the new Vector3
  2937. */
  2938. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2939. /**
  2940. * Returns the distance between the vectors "value1" and "value2"
  2941. * @param value1 defines the first operand
  2942. * @param value2 defines the second operand
  2943. * @returns the distance
  2944. */
  2945. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2946. /**
  2947. * Returns the squared distance between the vectors "value1" and "value2"
  2948. * @param value1 defines the first operand
  2949. * @param value2 defines the second operand
  2950. * @returns the squared distance
  2951. */
  2952. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2953. /**
  2954. * Returns a new Vector3 located at the center between "value1" and "value2"
  2955. * @param value1 defines the first operand
  2956. * @param value2 defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2962. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2963. * to something in order to rotate it from its local system to the given target system
  2964. * Note: axis1, axis2 and axis3 are normalized during this operation
  2965. * @param axis1 defines the first axis
  2966. * @param axis2 defines the second axis
  2967. * @param axis3 defines the third axis
  2968. * @returns a new Vector3
  2969. */
  2970. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2971. /**
  2972. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2973. * @param axis1 defines the first axis
  2974. * @param axis2 defines the second axis
  2975. * @param axis3 defines the third axis
  2976. * @param ref defines the Vector3 where to store the result
  2977. */
  2978. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2979. }
  2980. /**
  2981. * Vector4 class created for EulerAngle class conversion to Quaternion
  2982. */
  2983. export class Vector4 {
  2984. /** x value of the vector */
  2985. x: number;
  2986. /** y value of the vector */
  2987. y: number;
  2988. /** z value of the vector */
  2989. z: number;
  2990. /** w value of the vector */
  2991. w: number;
  2992. /**
  2993. * Creates a Vector4 object from the given floats.
  2994. * @param x x value of the vector
  2995. * @param y y value of the vector
  2996. * @param z z value of the vector
  2997. * @param w w value of the vector
  2998. */
  2999. constructor(
  3000. /** x value of the vector */
  3001. x: number,
  3002. /** y value of the vector */
  3003. y: number,
  3004. /** z value of the vector */
  3005. z: number,
  3006. /** w value of the vector */
  3007. w: number);
  3008. /**
  3009. * Returns the string with the Vector4 coordinates.
  3010. * @returns a string containing all the vector values
  3011. */
  3012. toString(): string;
  3013. /**
  3014. * Returns the string "Vector4".
  3015. * @returns "Vector4"
  3016. */
  3017. getClassName(): string;
  3018. /**
  3019. * Returns the Vector4 hash code.
  3020. * @returns a unique hash code
  3021. */
  3022. getHashCode(): number;
  3023. /**
  3024. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3025. * @returns the resulting array
  3026. */
  3027. asArray(): number[];
  3028. /**
  3029. * Populates the given array from the given index with the Vector4 coordinates.
  3030. * @param array array to populate
  3031. * @param index index of the array to start at (default: 0)
  3032. * @returns the Vector4.
  3033. */
  3034. toArray(array: FloatArray, index?: number): Vector4;
  3035. /**
  3036. * Adds the given vector to the current Vector4.
  3037. * @param otherVector the vector to add
  3038. * @returns the updated Vector4.
  3039. */
  3040. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3041. /**
  3042. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3043. * @param otherVector the vector to add
  3044. * @returns the resulting vector
  3045. */
  3046. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3047. /**
  3048. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3049. * @param otherVector the vector to add
  3050. * @param result the vector to store the result
  3051. * @returns the current Vector4.
  3052. */
  3053. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3054. /**
  3055. * Subtract in place the given vector from the current Vector4.
  3056. * @param otherVector the vector to subtract
  3057. * @returns the updated Vector4.
  3058. */
  3059. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3060. /**
  3061. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3062. * @param otherVector the vector to add
  3063. * @returns the new vector with the result
  3064. */
  3065. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3066. /**
  3067. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3068. * @param otherVector the vector to subtract
  3069. * @param result the vector to store the result
  3070. * @returns the current Vector4.
  3071. */
  3072. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3073. /**
  3074. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3075. */
  3076. /**
  3077. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3078. * @param x value to subtract
  3079. * @param y value to subtract
  3080. * @param z value to subtract
  3081. * @param w value to subtract
  3082. * @returns new vector containing the result
  3083. */
  3084. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3085. /**
  3086. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3087. * @param x value to subtract
  3088. * @param y value to subtract
  3089. * @param z value to subtract
  3090. * @param w value to subtract
  3091. * @param result the vector to store the result in
  3092. * @returns the current Vector4.
  3093. */
  3094. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3095. /**
  3096. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3097. * @returns a new vector with the negated values
  3098. */
  3099. negate(): Vector4;
  3100. /**
  3101. * Multiplies the current Vector4 coordinates by scale (float).
  3102. * @param scale the number to scale with
  3103. * @returns the updated Vector4.
  3104. */
  3105. scaleInPlace(scale: number): Vector4;
  3106. /**
  3107. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3108. * @param scale the number to scale with
  3109. * @returns a new vector with the result
  3110. */
  3111. scale(scale: number): Vector4;
  3112. /**
  3113. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3114. * @param scale the number to scale with
  3115. * @param result a vector to store the result in
  3116. * @returns the current Vector4.
  3117. */
  3118. scaleToRef(scale: number, result: Vector4): Vector4;
  3119. /**
  3120. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3121. * @param scale defines the scale factor
  3122. * @param result defines the Vector4 object where to store the result
  3123. * @returns the unmodified current Vector4
  3124. */
  3125. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3126. /**
  3127. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3128. * @param otherVector the vector to compare against
  3129. * @returns true if they are equal
  3130. */
  3131. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3132. /**
  3133. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3134. * @param otherVector vector to compare against
  3135. * @param epsilon (Default: very small number)
  3136. * @returns true if they are equal
  3137. */
  3138. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3139. /**
  3140. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3141. * @param x x value to compare against
  3142. * @param y y value to compare against
  3143. * @param z z value to compare against
  3144. * @param w w value to compare against
  3145. * @returns true if equal
  3146. */
  3147. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3148. /**
  3149. * Multiplies in place the current Vector4 by the given one.
  3150. * @param otherVector vector to multiple with
  3151. * @returns the updated Vector4.
  3152. */
  3153. multiplyInPlace(otherVector: Vector4): Vector4;
  3154. /**
  3155. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3156. * @param otherVector vector to multiple with
  3157. * @returns resulting new vector
  3158. */
  3159. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3160. /**
  3161. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3162. * @param otherVector vector to multiple with
  3163. * @param result vector to store the result
  3164. * @returns the current Vector4.
  3165. */
  3166. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3167. /**
  3168. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3169. * @param x x value multiply with
  3170. * @param y y value multiply with
  3171. * @param z z value multiply with
  3172. * @param w w value multiply with
  3173. * @returns resulting new vector
  3174. */
  3175. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3176. /**
  3177. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3178. * @param otherVector vector to devide with
  3179. * @returns resulting new vector
  3180. */
  3181. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3182. /**
  3183. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3184. * @param otherVector vector to devide with
  3185. * @param result vector to store the result
  3186. * @returns the current Vector4.
  3187. */
  3188. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3189. /**
  3190. * Divides the current Vector3 coordinates by the given ones.
  3191. * @param otherVector vector to devide with
  3192. * @returns the updated Vector3.
  3193. */
  3194. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3195. /**
  3196. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3197. * @param other defines the second operand
  3198. * @returns the current updated Vector4
  3199. */
  3200. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3201. /**
  3202. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3203. * @param other defines the second operand
  3204. * @returns the current updated Vector4
  3205. */
  3206. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3207. /**
  3208. * Gets a new Vector4 from current Vector4 floored values
  3209. * @returns a new Vector4
  3210. */
  3211. floor(): Vector4;
  3212. /**
  3213. * Gets a new Vector4 from current Vector3 floored values
  3214. * @returns a new Vector4
  3215. */
  3216. fract(): Vector4;
  3217. /**
  3218. * Returns the Vector4 length (float).
  3219. * @returns the length
  3220. */
  3221. length(): number;
  3222. /**
  3223. * Returns the Vector4 squared length (float).
  3224. * @returns the length squared
  3225. */
  3226. lengthSquared(): number;
  3227. /**
  3228. * Normalizes in place the Vector4.
  3229. * @returns the updated Vector4.
  3230. */
  3231. normalize(): Vector4;
  3232. /**
  3233. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3234. * @returns this converted to a new vector3
  3235. */
  3236. toVector3(): Vector3;
  3237. /**
  3238. * Returns a new Vector4 copied from the current one.
  3239. * @returns the new cloned vector
  3240. */
  3241. clone(): Vector4;
  3242. /**
  3243. * Updates the current Vector4 with the given one coordinates.
  3244. * @param source the source vector to copy from
  3245. * @returns the updated Vector4.
  3246. */
  3247. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the current Vector4 coordinates with the given floats.
  3250. * @param x float to copy from
  3251. * @param y float to copy from
  3252. * @param z float to copy from
  3253. * @param w float to copy from
  3254. * @returns the updated Vector4.
  3255. */
  3256. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3257. /**
  3258. * Updates the current Vector4 coordinates with the given floats.
  3259. * @param x float to set from
  3260. * @param y float to set from
  3261. * @param z float to set from
  3262. * @param w float to set from
  3263. * @returns the updated Vector4.
  3264. */
  3265. set(x: number, y: number, z: number, w: number): Vector4;
  3266. /**
  3267. * Copies the given float to the current Vector3 coordinates
  3268. * @param v defines the x, y, z and w coordinates of the operand
  3269. * @returns the current updated Vector3
  3270. */
  3271. setAll(v: number): Vector4;
  3272. /**
  3273. * Returns a new Vector4 set from the starting index of the given array.
  3274. * @param array the array to pull values from
  3275. * @param offset the offset into the array to start at
  3276. * @returns the new vector
  3277. */
  3278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3279. /**
  3280. * Updates the given vector "result" from the starting index of the given array.
  3281. * @param array the array to pull values from
  3282. * @param offset the offset into the array to start at
  3283. * @param result the vector to store the result in
  3284. */
  3285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3286. /**
  3287. * Updates the given vector "result" from the starting index of the given Float32Array.
  3288. * @param array the array to pull values from
  3289. * @param offset the offset into the array to start at
  3290. * @param result the vector to store the result in
  3291. */
  3292. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3293. /**
  3294. * Updates the given vector "result" coordinates from the given floats.
  3295. * @param x float to set from
  3296. * @param y float to set from
  3297. * @param z float to set from
  3298. * @param w float to set from
  3299. * @param result the vector to the floats in
  3300. */
  3301. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3302. /**
  3303. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3304. * @returns the new vector
  3305. */
  3306. static Zero(): Vector4;
  3307. /**
  3308. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3309. * @returns the new vector
  3310. */
  3311. static One(): Vector4;
  3312. /**
  3313. * Returns a new normalized Vector4 from the given one.
  3314. * @param vector the vector to normalize
  3315. * @returns the vector
  3316. */
  3317. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3318. /**
  3319. * Updates the given vector "result" from the normalization of the given one.
  3320. * @param vector the vector to normalize
  3321. * @param result the vector to store the result in
  3322. */
  3323. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3324. /**
  3325. * Returns a vector with the minimum values from the left and right vectors
  3326. * @param left left vector to minimize
  3327. * @param right right vector to minimize
  3328. * @returns a new vector with the minimum of the left and right vector values
  3329. */
  3330. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3331. /**
  3332. * Returns a vector with the maximum values from the left and right vectors
  3333. * @param left left vector to maximize
  3334. * @param right right vector to maximize
  3335. * @returns a new vector with the maximum of the left and right vector values
  3336. */
  3337. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3338. /**
  3339. * Returns the distance (float) between the vectors "value1" and "value2".
  3340. * @param value1 value to calulate the distance between
  3341. * @param value2 value to calulate the distance between
  3342. * @return the distance between the two vectors
  3343. */
  3344. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3345. /**
  3346. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3347. * @param value1 value to calulate the distance between
  3348. * @param value2 value to calulate the distance between
  3349. * @return the distance between the two vectors squared
  3350. */
  3351. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3352. /**
  3353. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3354. * @param value1 value to calulate the center between
  3355. * @param value2 value to calulate the center between
  3356. * @return the center between the two vectors
  3357. */
  3358. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3361. * This methods computes transformed normalized direction vectors only.
  3362. * @param vector the vector to transform
  3363. * @param transformation the transformation matrix to apply
  3364. * @returns the new vector
  3365. */
  3366. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3367. /**
  3368. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3369. * This methods computes transformed normalized direction vectors only.
  3370. * @param vector the vector to transform
  3371. * @param transformation the transformation matrix to apply
  3372. * @param result the vector to store the result in
  3373. */
  3374. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3375. /**
  3376. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3377. * This methods computes transformed normalized direction vectors only.
  3378. * @param x value to transform
  3379. * @param y value to transform
  3380. * @param z value to transform
  3381. * @param w value to transform
  3382. * @param transformation the transformation matrix to apply
  3383. * @param result the vector to store the results in
  3384. */
  3385. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3386. /**
  3387. * Creates a new Vector4 from a Vector3
  3388. * @param source defines the source data
  3389. * @param w defines the 4th component (default is 0)
  3390. * @returns a new Vector4
  3391. */
  3392. static FromVector3(source: Vector3, w?: number): Vector4;
  3393. }
  3394. /**
  3395. * Class used to store quaternion data
  3396. * @see https://en.wikipedia.org/wiki/Quaternion
  3397. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3398. */
  3399. export class Quaternion {
  3400. /** defines the first component (0 by default) */
  3401. x: number;
  3402. /** defines the second component (0 by default) */
  3403. y: number;
  3404. /** defines the third component (0 by default) */
  3405. z: number;
  3406. /** defines the fourth component (1.0 by default) */
  3407. w: number;
  3408. /**
  3409. * Creates a new Quaternion from the given floats
  3410. * @param x defines the first component (0 by default)
  3411. * @param y defines the second component (0 by default)
  3412. * @param z defines the third component (0 by default)
  3413. * @param w defines the fourth component (1.0 by default)
  3414. */
  3415. constructor(
  3416. /** defines the first component (0 by default) */
  3417. x?: number,
  3418. /** defines the second component (0 by default) */
  3419. y?: number,
  3420. /** defines the third component (0 by default) */
  3421. z?: number,
  3422. /** defines the fourth component (1.0 by default) */
  3423. w?: number);
  3424. /**
  3425. * Gets a string representation for the current quaternion
  3426. * @returns a string with the Quaternion coordinates
  3427. */
  3428. toString(): string;
  3429. /**
  3430. * Gets the class name of the quaternion
  3431. * @returns the string "Quaternion"
  3432. */
  3433. getClassName(): string;
  3434. /**
  3435. * Gets a hash code for this quaternion
  3436. * @returns the quaternion hash code
  3437. */
  3438. getHashCode(): number;
  3439. /**
  3440. * Copy the quaternion to an array
  3441. * @returns a new array populated with 4 elements from the quaternion coordinates
  3442. */
  3443. asArray(): number[];
  3444. /**
  3445. * Check if two quaternions are equals
  3446. * @param otherQuaternion defines the second operand
  3447. * @return true if the current quaternion and the given one coordinates are strictly equals
  3448. */
  3449. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3450. /**
  3451. * Clone the current quaternion
  3452. * @returns a new quaternion copied from the current one
  3453. */
  3454. clone(): Quaternion;
  3455. /**
  3456. * Copy a quaternion to the current one
  3457. * @param other defines the other quaternion
  3458. * @returns the updated current quaternion
  3459. */
  3460. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3461. /**
  3462. * Updates the current quaternion with the given float coordinates
  3463. * @param x defines the x coordinate
  3464. * @param y defines the y coordinate
  3465. * @param z defines the z coordinate
  3466. * @param w defines the w coordinate
  3467. * @returns the updated current quaternion
  3468. */
  3469. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3470. /**
  3471. * Updates the current quaternion from the given float coordinates
  3472. * @param x defines the x coordinate
  3473. * @param y defines the y coordinate
  3474. * @param z defines the z coordinate
  3475. * @param w defines the w coordinate
  3476. * @returns the updated current quaternion
  3477. */
  3478. set(x: number, y: number, z: number, w: number): Quaternion;
  3479. /**
  3480. * Adds two quaternions
  3481. * @param other defines the second operand
  3482. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3483. */
  3484. add(other: DeepImmutable<Quaternion>): Quaternion;
  3485. /**
  3486. * Add a quaternion to the current one
  3487. * @param other defines the quaternion to add
  3488. * @returns the current quaternion
  3489. */
  3490. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3491. /**
  3492. * Subtract two quaternions
  3493. * @param other defines the second operand
  3494. * @returns a new quaternion as the subtraction result of the given one from the current one
  3495. */
  3496. subtract(other: Quaternion): Quaternion;
  3497. /**
  3498. * Multiplies the current quaternion by a scale factor
  3499. * @param value defines the scale factor
  3500. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3501. */
  3502. scale(value: number): Quaternion;
  3503. /**
  3504. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3505. * @param scale defines the scale factor
  3506. * @param result defines the Quaternion object where to store the result
  3507. * @returns the unmodified current quaternion
  3508. */
  3509. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3510. /**
  3511. * Multiplies in place the current quaternion by a scale factor
  3512. * @param value defines the scale factor
  3513. * @returns the current modified quaternion
  3514. */
  3515. scaleInPlace(value: number): Quaternion;
  3516. /**
  3517. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3518. * @param scale defines the scale factor
  3519. * @param result defines the Quaternion object where to store the result
  3520. * @returns the unmodified current quaternion
  3521. */
  3522. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3523. /**
  3524. * Multiplies two quaternions
  3525. * @param q1 defines the second operand
  3526. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3527. */
  3528. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3529. /**
  3530. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3531. * @param q1 defines the second operand
  3532. * @param result defines the target quaternion
  3533. * @returns the current quaternion
  3534. */
  3535. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3536. /**
  3537. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3538. * @param q1 defines the second operand
  3539. * @returns the currentupdated quaternion
  3540. */
  3541. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3542. /**
  3543. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3544. * @param ref defines the target quaternion
  3545. * @returns the current quaternion
  3546. */
  3547. conjugateToRef(ref: Quaternion): Quaternion;
  3548. /**
  3549. * Conjugates in place (1-q) the current quaternion
  3550. * @returns the current updated quaternion
  3551. */
  3552. conjugateInPlace(): Quaternion;
  3553. /**
  3554. * Conjugates in place (1-q) the current quaternion
  3555. * @returns a new quaternion
  3556. */
  3557. conjugate(): Quaternion;
  3558. /**
  3559. * Gets length of current quaternion
  3560. * @returns the quaternion length (float)
  3561. */
  3562. length(): number;
  3563. /**
  3564. * Normalize in place the current quaternion
  3565. * @returns the current updated quaternion
  3566. */
  3567. normalize(): Quaternion;
  3568. /**
  3569. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3570. * @param order is a reserved parameter and is ignore for now
  3571. * @returns a new Vector3 containing the Euler angles
  3572. */
  3573. toEulerAngles(order?: string): Vector3;
  3574. /**
  3575. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3576. * @param result defines the vector which will be filled with the Euler angles
  3577. * @param order is a reserved parameter and is ignore for now
  3578. * @returns the current unchanged quaternion
  3579. */
  3580. toEulerAnglesToRef(result: Vector3): Quaternion;
  3581. /**
  3582. * Updates the given rotation matrix with the current quaternion values
  3583. * @param result defines the target matrix
  3584. * @returns the current unchanged quaternion
  3585. */
  3586. toRotationMatrix(result: Matrix): Quaternion;
  3587. /**
  3588. * Updates the current quaternion from the given rotation matrix values
  3589. * @param matrix defines the source matrix
  3590. * @returns the current updated quaternion
  3591. */
  3592. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3593. /**
  3594. * Creates a new quaternion from a rotation matrix
  3595. * @param matrix defines the source matrix
  3596. * @returns a new quaternion created from the given rotation matrix values
  3597. */
  3598. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3599. /**
  3600. * Updates the given quaternion with the given rotation matrix values
  3601. * @param matrix defines the source matrix
  3602. * @param result defines the target quaternion
  3603. */
  3604. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3605. /**
  3606. * Returns the dot product (float) between the quaternions "left" and "right"
  3607. * @param left defines the left operand
  3608. * @param right defines the right operand
  3609. * @returns the dot product
  3610. */
  3611. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3612. /**
  3613. * Checks if the two quaternions are close to each other
  3614. * @param quat0 defines the first quaternion to check
  3615. * @param quat1 defines the second quaternion to check
  3616. * @returns true if the two quaternions are close to each other
  3617. */
  3618. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3619. /**
  3620. * Creates an empty quaternion
  3621. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3622. */
  3623. static Zero(): Quaternion;
  3624. /**
  3625. * Inverse a given quaternion
  3626. * @param q defines the source quaternion
  3627. * @returns a new quaternion as the inverted current quaternion
  3628. */
  3629. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3630. /**
  3631. * Inverse a given quaternion
  3632. * @param q defines the source quaternion
  3633. * @param result the quaternion the result will be stored in
  3634. * @returns the result quaternion
  3635. */
  3636. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3637. /**
  3638. * Creates an identity quaternion
  3639. * @returns the identity quaternion
  3640. */
  3641. static Identity(): Quaternion;
  3642. /**
  3643. * Gets a boolean indicating if the given quaternion is identity
  3644. * @param quaternion defines the quaternion to check
  3645. * @returns true if the quaternion is identity
  3646. */
  3647. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3648. /**
  3649. * Creates a quaternion from a rotation around an axis
  3650. * @param axis defines the axis to use
  3651. * @param angle defines the angle to use
  3652. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3653. */
  3654. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3655. /**
  3656. * Creates a rotation around an axis and stores it into the given quaternion
  3657. * @param axis defines the axis to use
  3658. * @param angle defines the angle to use
  3659. * @param result defines the target quaternion
  3660. * @returns the target quaternion
  3661. */
  3662. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3663. /**
  3664. * Creates a new quaternion from data stored into an array
  3665. * @param array defines the data source
  3666. * @param offset defines the offset in the source array where the data starts
  3667. * @returns a new quaternion
  3668. */
  3669. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3670. /**
  3671. * Create a quaternion from Euler rotation angles
  3672. * @param x Pitch
  3673. * @param y Yaw
  3674. * @param z Roll
  3675. * @returns the new Quaternion
  3676. */
  3677. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3678. /**
  3679. * Updates a quaternion from Euler rotation angles
  3680. * @param x Pitch
  3681. * @param y Yaw
  3682. * @param z Roll
  3683. * @param result the quaternion to store the result
  3684. * @returns the updated quaternion
  3685. */
  3686. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3687. /**
  3688. * Create a quaternion from Euler rotation vector
  3689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3690. * @returns the new Quaternion
  3691. */
  3692. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3693. /**
  3694. * Updates a quaternion from Euler rotation vector
  3695. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3696. * @param result the quaternion to store the result
  3697. * @returns the updated quaternion
  3698. */
  3699. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3700. /**
  3701. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3702. * @param yaw defines the rotation around Y axis
  3703. * @param pitch defines the rotation around X axis
  3704. * @param roll defines the rotation around Z axis
  3705. * @returns the new quaternion
  3706. */
  3707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3708. /**
  3709. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3710. * @param yaw defines the rotation around Y axis
  3711. * @param pitch defines the rotation around X axis
  3712. * @param roll defines the rotation around Z axis
  3713. * @param result defines the target quaternion
  3714. */
  3715. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3716. /**
  3717. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3718. * @param alpha defines the rotation around first axis
  3719. * @param beta defines the rotation around second axis
  3720. * @param gamma defines the rotation around third axis
  3721. * @returns the new quaternion
  3722. */
  3723. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3724. /**
  3725. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3726. * @param alpha defines the rotation around first axis
  3727. * @param beta defines the rotation around second axis
  3728. * @param gamma defines the rotation around third axis
  3729. * @param result defines the target quaternion
  3730. */
  3731. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3732. /**
  3733. * 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)
  3734. * @param axis1 defines the first axis
  3735. * @param axis2 defines the second axis
  3736. * @param axis3 defines the third axis
  3737. * @returns the new quaternion
  3738. */
  3739. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3740. /**
  3741. * 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
  3742. * @param axis1 defines the first axis
  3743. * @param axis2 defines the second axis
  3744. * @param axis3 defines the third axis
  3745. * @param ref defines the target quaternion
  3746. */
  3747. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3748. /**
  3749. * Interpolates between two quaternions
  3750. * @param left defines first quaternion
  3751. * @param right defines second quaternion
  3752. * @param amount defines the gradient to use
  3753. * @returns the new interpolated quaternion
  3754. */
  3755. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3756. /**
  3757. * Interpolates between two quaternions and stores it into a target quaternion
  3758. * @param left defines first quaternion
  3759. * @param right defines second quaternion
  3760. * @param amount defines the gradient to use
  3761. * @param result defines the target quaternion
  3762. */
  3763. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3764. /**
  3765. * Interpolate between two quaternions using Hermite interpolation
  3766. * @param value1 defines first quaternion
  3767. * @param tangent1 defines the incoming tangent
  3768. * @param value2 defines second quaternion
  3769. * @param tangent2 defines the outgoing tangent
  3770. * @param amount defines the target quaternion
  3771. * @returns the new interpolated quaternion
  3772. */
  3773. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3774. }
  3775. /**
  3776. * Class used to store matrix data (4x4)
  3777. */
  3778. export class Matrix {
  3779. private static _updateFlagSeed;
  3780. private static _identityReadOnly;
  3781. private _isIdentity;
  3782. private _isIdentityDirty;
  3783. private _isIdentity3x2;
  3784. private _isIdentity3x2Dirty;
  3785. /**
  3786. * Gets the update flag of the matrix which is an unique number for the matrix.
  3787. * It will be incremented every time the matrix data change.
  3788. * You can use it to speed the comparison between two versions of the same matrix.
  3789. */
  3790. updateFlag: number;
  3791. private readonly _m;
  3792. /**
  3793. * Gets the internal data of the matrix
  3794. */
  3795. readonly m: DeepImmutable<Float32Array>;
  3796. /** @hidden */
  3797. _markAsUpdated(): void;
  3798. /** @hidden */
  3799. private _updateIdentityStatus;
  3800. /**
  3801. * Creates an empty matrix (filled with zeros)
  3802. */
  3803. constructor();
  3804. /**
  3805. * Check if the current matrix is identity
  3806. * @returns true is the matrix is the identity matrix
  3807. */
  3808. isIdentity(): boolean;
  3809. /**
  3810. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3811. * @returns true is the matrix is the identity matrix
  3812. */
  3813. isIdentityAs3x2(): boolean;
  3814. /**
  3815. * Gets the determinant of the matrix
  3816. * @returns the matrix determinant
  3817. */
  3818. determinant(): number;
  3819. /**
  3820. * Returns the matrix as a Float32Array
  3821. * @returns the matrix underlying array
  3822. */
  3823. toArray(): DeepImmutable<Float32Array>;
  3824. /**
  3825. * Returns the matrix as a Float32Array
  3826. * @returns the matrix underlying array.
  3827. */
  3828. asArray(): DeepImmutable<Float32Array>;
  3829. /**
  3830. * Inverts the current matrix in place
  3831. * @returns the current inverted matrix
  3832. */
  3833. invert(): Matrix;
  3834. /**
  3835. * Sets all the matrix elements to zero
  3836. * @returns the current matrix
  3837. */
  3838. reset(): Matrix;
  3839. /**
  3840. * Adds the current matrix with a second one
  3841. * @param other defines the matrix to add
  3842. * @returns a new matrix as the addition of the current matrix and the given one
  3843. */
  3844. add(other: DeepImmutable<Matrix>): Matrix;
  3845. /**
  3846. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3847. * @param other defines the matrix to add
  3848. * @param result defines the target matrix
  3849. * @returns the current matrix
  3850. */
  3851. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3852. /**
  3853. * Adds in place the given matrix to the current matrix
  3854. * @param other defines the second operand
  3855. * @returns the current updated matrix
  3856. */
  3857. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3858. /**
  3859. * Sets the given matrix to the current inverted Matrix
  3860. * @param other defines the target matrix
  3861. * @returns the unmodified current matrix
  3862. */
  3863. invertToRef(other: Matrix): Matrix;
  3864. /**
  3865. * add a value at the specified position in the current Matrix
  3866. * @param index the index of the value within the matrix. between 0 and 15.
  3867. * @param value the value to be added
  3868. * @returns the current updated matrix
  3869. */
  3870. addAtIndex(index: number, value: number): Matrix;
  3871. /**
  3872. * mutiply the specified position in the current Matrix by a value
  3873. * @param index the index of the value within the matrix. between 0 and 15.
  3874. * @param value the value to be added
  3875. * @returns the current updated matrix
  3876. */
  3877. multiplyAtIndex(index: number, value: number): Matrix;
  3878. /**
  3879. * Inserts the translation vector (using 3 floats) in the current matrix
  3880. * @param x defines the 1st component of the translation
  3881. * @param y defines the 2nd component of the translation
  3882. * @param z defines the 3rd component of the translation
  3883. * @returns the current updated matrix
  3884. */
  3885. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3886. /**
  3887. * Adds the translation vector (using 3 floats) in the current matrix
  3888. * @param x defines the 1st component of the translation
  3889. * @param y defines the 2nd component of the translation
  3890. * @param z defines the 3rd component of the translation
  3891. * @returns the current updated matrix
  3892. */
  3893. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3894. /**
  3895. * Inserts the translation vector in the current matrix
  3896. * @param vector3 defines the translation to insert
  3897. * @returns the current updated matrix
  3898. */
  3899. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3900. /**
  3901. * Gets the translation value of the current matrix
  3902. * @returns a new Vector3 as the extracted translation from the matrix
  3903. */
  3904. getTranslation(): Vector3;
  3905. /**
  3906. * Fill a Vector3 with the extracted translation from the matrix
  3907. * @param result defines the Vector3 where to store the translation
  3908. * @returns the current matrix
  3909. */
  3910. getTranslationToRef(result: Vector3): Matrix;
  3911. /**
  3912. * Remove rotation and scaling part from the matrix
  3913. * @returns the updated matrix
  3914. */
  3915. removeRotationAndScaling(): Matrix;
  3916. /**
  3917. * Multiply two matrices
  3918. * @param other defines the second operand
  3919. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3920. */
  3921. multiply(other: DeepImmutable<Matrix>): Matrix;
  3922. /**
  3923. * Copy the current matrix from the given one
  3924. * @param other defines the source matrix
  3925. * @returns the current updated matrix
  3926. */
  3927. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3928. /**
  3929. * Populates the given array from the starting index with the current matrix values
  3930. * @param array defines the target array
  3931. * @param offset defines the offset in the target array where to start storing values
  3932. * @returns the current matrix
  3933. */
  3934. copyToArray(array: Float32Array, offset?: number): Matrix;
  3935. /**
  3936. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3937. * @param other defines the second operand
  3938. * @param result defines the matrix where to store the multiplication
  3939. * @returns the current matrix
  3940. */
  3941. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3942. /**
  3943. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3944. * @param other defines the second operand
  3945. * @param result defines the array where to store the multiplication
  3946. * @param offset defines the offset in the target array where to start storing values
  3947. * @returns the current matrix
  3948. */
  3949. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3950. /**
  3951. * Check equality between this matrix and a second one
  3952. * @param value defines the second matrix to compare
  3953. * @returns true is the current matrix and the given one values are strictly equal
  3954. */
  3955. equals(value: DeepImmutable<Matrix>): boolean;
  3956. /**
  3957. * Clone the current matrix
  3958. * @returns a new matrix from the current matrix
  3959. */
  3960. clone(): Matrix;
  3961. /**
  3962. * Returns the name of the current matrix class
  3963. * @returns the string "Matrix"
  3964. */
  3965. getClassName(): string;
  3966. /**
  3967. * Gets the hash code of the current matrix
  3968. * @returns the hash code
  3969. */
  3970. getHashCode(): number;
  3971. /**
  3972. * Decomposes the current Matrix into a translation, rotation and scaling components
  3973. * @param scale defines the scale vector3 given as a reference to update
  3974. * @param rotation defines the rotation quaternion given as a reference to update
  3975. * @param translation defines the translation vector3 given as a reference to update
  3976. * @returns true if operation was successful
  3977. */
  3978. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3979. /**
  3980. * Gets specific row of the matrix
  3981. * @param index defines the number of the row to get
  3982. * @returns the index-th row of the current matrix as a new Vector4
  3983. */
  3984. getRow(index: number): Nullable<Vector4>;
  3985. /**
  3986. * Sets the index-th row of the current matrix to the vector4 values
  3987. * @param index defines the number of the row to set
  3988. * @param row defines the target vector4
  3989. * @returns the updated current matrix
  3990. */
  3991. setRow(index: number, row: Vector4): Matrix;
  3992. /**
  3993. * Compute the transpose of the matrix
  3994. * @returns the new transposed matrix
  3995. */
  3996. transpose(): Matrix;
  3997. /**
  3998. * Compute the transpose of the matrix and store it in a given matrix
  3999. * @param result defines the target matrix
  4000. * @returns the current matrix
  4001. */
  4002. transposeToRef(result: Matrix): Matrix;
  4003. /**
  4004. * Sets the index-th row of the current matrix with the given 4 x float values
  4005. * @param index defines the row index
  4006. * @param x defines the x component to set
  4007. * @param y defines the y component to set
  4008. * @param z defines the z component to set
  4009. * @param w defines the w component to set
  4010. * @returns the updated current matrix
  4011. */
  4012. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4013. /**
  4014. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4015. * @param scale defines the scale factor
  4016. * @returns a new matrix
  4017. */
  4018. scale(scale: number): Matrix;
  4019. /**
  4020. * Scale the current matrix values by a factor to a given result matrix
  4021. * @param scale defines the scale factor
  4022. * @param result defines the matrix to store the result
  4023. * @returns the current matrix
  4024. */
  4025. scaleToRef(scale: number, result: Matrix): Matrix;
  4026. /**
  4027. * Scale the current matrix values by a factor and add the result to a given matrix
  4028. * @param scale defines the scale factor
  4029. * @param result defines the Matrix to store the result
  4030. * @returns the current matrix
  4031. */
  4032. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4033. /**
  4034. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4035. * @param ref matrix to store the result
  4036. */
  4037. toNormalMatrix(ref: Matrix): void;
  4038. /**
  4039. * Gets only rotation part of the current matrix
  4040. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4041. */
  4042. getRotationMatrix(): Matrix;
  4043. /**
  4044. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4045. * @param result defines the target matrix to store data to
  4046. * @returns the current matrix
  4047. */
  4048. getRotationMatrixToRef(result: Matrix): Matrix;
  4049. /**
  4050. * Toggles model matrix from being right handed to left handed in place and vice versa
  4051. */
  4052. toggleModelMatrixHandInPlace(): void;
  4053. /**
  4054. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4055. */
  4056. toggleProjectionMatrixHandInPlace(): void;
  4057. /**
  4058. * Creates a matrix from an array
  4059. * @param array defines the source array
  4060. * @param offset defines an offset in the source array
  4061. * @returns a new Matrix set from the starting index of the given array
  4062. */
  4063. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4064. /**
  4065. * Copy the content of an array into a given matrix
  4066. * @param array defines the source array
  4067. * @param offset defines an offset in the source array
  4068. * @param result defines the target matrix
  4069. */
  4070. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4071. /**
  4072. * Stores an array into a matrix after having multiplied each component by a given factor
  4073. * @param array defines the source array
  4074. * @param offset defines the offset in the source array
  4075. * @param scale defines the scaling factor
  4076. * @param result defines the target matrix
  4077. */
  4078. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4079. /**
  4080. * Gets an identity matrix that must not be updated
  4081. */
  4082. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4083. /**
  4084. * Stores a list of values (16) inside a given matrix
  4085. * @param initialM11 defines 1st value of 1st row
  4086. * @param initialM12 defines 2nd value of 1st row
  4087. * @param initialM13 defines 3rd value of 1st row
  4088. * @param initialM14 defines 4th value of 1st row
  4089. * @param initialM21 defines 1st value of 2nd row
  4090. * @param initialM22 defines 2nd value of 2nd row
  4091. * @param initialM23 defines 3rd value of 2nd row
  4092. * @param initialM24 defines 4th value of 2nd row
  4093. * @param initialM31 defines 1st value of 3rd row
  4094. * @param initialM32 defines 2nd value of 3rd row
  4095. * @param initialM33 defines 3rd value of 3rd row
  4096. * @param initialM34 defines 4th value of 3rd row
  4097. * @param initialM41 defines 1st value of 4th row
  4098. * @param initialM42 defines 2nd value of 4th row
  4099. * @param initialM43 defines 3rd value of 4th row
  4100. * @param initialM44 defines 4th value of 4th row
  4101. * @param result defines the target matrix
  4102. */
  4103. 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;
  4104. /**
  4105. * Creates new matrix from a list of values (16)
  4106. * @param initialM11 defines 1st value of 1st row
  4107. * @param initialM12 defines 2nd value of 1st row
  4108. * @param initialM13 defines 3rd value of 1st row
  4109. * @param initialM14 defines 4th value of 1st row
  4110. * @param initialM21 defines 1st value of 2nd row
  4111. * @param initialM22 defines 2nd value of 2nd row
  4112. * @param initialM23 defines 3rd value of 2nd row
  4113. * @param initialM24 defines 4th value of 2nd row
  4114. * @param initialM31 defines 1st value of 3rd row
  4115. * @param initialM32 defines 2nd value of 3rd row
  4116. * @param initialM33 defines 3rd value of 3rd row
  4117. * @param initialM34 defines 4th value of 3rd row
  4118. * @param initialM41 defines 1st value of 4th row
  4119. * @param initialM42 defines 2nd value of 4th row
  4120. * @param initialM43 defines 3rd value of 4th row
  4121. * @param initialM44 defines 4th value of 4th row
  4122. * @returns the new matrix
  4123. */
  4124. 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;
  4125. /**
  4126. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4127. * @param scale defines the scale vector3
  4128. * @param rotation defines the rotation quaternion
  4129. * @param translation defines the translation vector3
  4130. * @returns a new matrix
  4131. */
  4132. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4133. /**
  4134. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4135. * @param scale defines the scale vector3
  4136. * @param rotation defines the rotation quaternion
  4137. * @param translation defines the translation vector3
  4138. * @param result defines the target matrix
  4139. */
  4140. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4141. /**
  4142. * Creates a new identity matrix
  4143. * @returns a new identity matrix
  4144. */
  4145. static Identity(): Matrix;
  4146. /**
  4147. * Creates a new identity matrix and stores the result in a given matrix
  4148. * @param result defines the target matrix
  4149. */
  4150. static IdentityToRef(result: Matrix): void;
  4151. /**
  4152. * Creates a new zero matrix
  4153. * @returns a new zero matrix
  4154. */
  4155. static Zero(): Matrix;
  4156. /**
  4157. * Creates a new rotation matrix for "angle" radians around the X axis
  4158. * @param angle defines the angle (in radians) to use
  4159. * @return the new matrix
  4160. */
  4161. static RotationX(angle: number): Matrix;
  4162. /**
  4163. * Creates a new matrix as the invert of a given matrix
  4164. * @param source defines the source matrix
  4165. * @returns the new matrix
  4166. */
  4167. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4168. /**
  4169. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4170. * @param angle defines the angle (in radians) to use
  4171. * @param result defines the target matrix
  4172. */
  4173. static RotationXToRef(angle: number, result: Matrix): void;
  4174. /**
  4175. * Creates a new rotation matrix for "angle" radians around the Y axis
  4176. * @param angle defines the angle (in radians) to use
  4177. * @return the new matrix
  4178. */
  4179. static RotationY(angle: number): Matrix;
  4180. /**
  4181. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4182. * @param angle defines the angle (in radians) to use
  4183. * @param result defines the target matrix
  4184. */
  4185. static RotationYToRef(angle: number, result: Matrix): void;
  4186. /**
  4187. * Creates a new rotation matrix for "angle" radians around the Z axis
  4188. * @param angle defines the angle (in radians) to use
  4189. * @return the new matrix
  4190. */
  4191. static RotationZ(angle: number): Matrix;
  4192. /**
  4193. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4194. * @param angle defines the angle (in radians) to use
  4195. * @param result defines the target matrix
  4196. */
  4197. static RotationZToRef(angle: number, result: Matrix): void;
  4198. /**
  4199. * Creates a new rotation matrix for "angle" radians around the given axis
  4200. * @param axis defines the axis to use
  4201. * @param angle defines the angle (in radians) to use
  4202. * @return the new matrix
  4203. */
  4204. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4205. /**
  4206. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4207. * @param axis defines the axis to use
  4208. * @param angle defines the angle (in radians) to use
  4209. * @param result defines the target matrix
  4210. */
  4211. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4212. /**
  4213. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4214. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4215. * @param from defines the vector to align
  4216. * @param to defines the vector to align to
  4217. * @param result defines the target matrix
  4218. */
  4219. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4220. /**
  4221. * Creates a rotation matrix
  4222. * @param yaw defines the yaw angle in radians (Y axis)
  4223. * @param pitch defines the pitch angle in radians (X axis)
  4224. * @param roll defines the roll angle in radians (X axis)
  4225. * @returns the new rotation matrix
  4226. */
  4227. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4228. /**
  4229. * Creates a rotation matrix and stores it in a given matrix
  4230. * @param yaw defines the yaw angle in radians (Y axis)
  4231. * @param pitch defines the pitch angle in radians (X axis)
  4232. * @param roll defines the roll angle in radians (X axis)
  4233. * @param result defines the target matrix
  4234. */
  4235. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4236. /**
  4237. * Creates a scaling matrix
  4238. * @param x defines the scale factor on X axis
  4239. * @param y defines the scale factor on Y axis
  4240. * @param z defines the scale factor on Z axis
  4241. * @returns the new matrix
  4242. */
  4243. static Scaling(x: number, y: number, z: number): Matrix;
  4244. /**
  4245. * Creates a scaling matrix and stores it in a given matrix
  4246. * @param x defines the scale factor on X axis
  4247. * @param y defines the scale factor on Y axis
  4248. * @param z defines the scale factor on Z axis
  4249. * @param result defines the target matrix
  4250. */
  4251. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4252. /**
  4253. * Creates a translation matrix
  4254. * @param x defines the translation on X axis
  4255. * @param y defines the translation on Y axis
  4256. * @param z defines the translationon Z axis
  4257. * @returns the new matrix
  4258. */
  4259. static Translation(x: number, y: number, z: number): Matrix;
  4260. /**
  4261. * Creates a translation matrix and stores it in a given matrix
  4262. * @param x defines the translation on X axis
  4263. * @param y defines the translation on Y axis
  4264. * @param z defines the translationon Z axis
  4265. * @param result defines the target matrix
  4266. */
  4267. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4268. /**
  4269. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4270. * @param startValue defines the start value
  4271. * @param endValue defines the end value
  4272. * @param gradient defines the gradient factor
  4273. * @returns the new matrix
  4274. */
  4275. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4276. /**
  4277. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4278. * @param startValue defines the start value
  4279. * @param endValue defines the end value
  4280. * @param gradient defines the gradient factor
  4281. * @param result defines the Matrix object where to store data
  4282. */
  4283. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4284. /**
  4285. * Builds a new matrix whose values are computed by:
  4286. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4287. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4288. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4289. * @param startValue defines the first matrix
  4290. * @param endValue defines the second matrix
  4291. * @param gradient defines the gradient between the two matrices
  4292. * @returns the new matrix
  4293. */
  4294. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4295. /**
  4296. * Update a matrix to values which are computed by:
  4297. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4298. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4299. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4300. * @param startValue defines the first matrix
  4301. * @param endValue defines the second matrix
  4302. * @param gradient defines the gradient between the two matrices
  4303. * @param result defines the target matrix
  4304. */
  4305. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4306. /**
  4307. * 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"
  4308. * This function works in left handed mode
  4309. * @param eye defines the final position of the entity
  4310. * @param target defines where the entity should look at
  4311. * @param up defines the up vector for the entity
  4312. * @returns the new matrix
  4313. */
  4314. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4315. /**
  4316. * 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".
  4317. * This function works in left handed mode
  4318. * @param eye defines the final position of the entity
  4319. * @param target defines where the entity should look at
  4320. * @param up defines the up vector for the entity
  4321. * @param result defines the target matrix
  4322. */
  4323. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4324. /**
  4325. * 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"
  4326. * This function works in right handed mode
  4327. * @param eye defines the final position of the entity
  4328. * @param target defines where the entity should look at
  4329. * @param up defines the up vector for the entity
  4330. * @returns the new matrix
  4331. */
  4332. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4333. /**
  4334. * 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".
  4335. * This function works in right handed mode
  4336. * @param eye defines the final position of the entity
  4337. * @param target defines where the entity should look at
  4338. * @param up defines the up vector for the entity
  4339. * @param result defines the target matrix
  4340. */
  4341. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4342. /**
  4343. * Create a left-handed orthographic projection matrix
  4344. * @param width defines the viewport width
  4345. * @param height defines the viewport height
  4346. * @param znear defines the near clip plane
  4347. * @param zfar defines the far clip plane
  4348. * @returns a new matrix as a left-handed orthographic projection matrix
  4349. */
  4350. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4351. /**
  4352. * Store a left-handed orthographic projection to a given matrix
  4353. * @param width defines the viewport width
  4354. * @param height defines the viewport height
  4355. * @param znear defines the near clip plane
  4356. * @param zfar defines the far clip plane
  4357. * @param result defines the target matrix
  4358. */
  4359. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4360. /**
  4361. * Create a left-handed orthographic projection matrix
  4362. * @param left defines the viewport left coordinate
  4363. * @param right defines the viewport right coordinate
  4364. * @param bottom defines the viewport bottom coordinate
  4365. * @param top defines the viewport top coordinate
  4366. * @param znear defines the near clip plane
  4367. * @param zfar defines the far clip plane
  4368. * @returns a new matrix as a left-handed orthographic projection matrix
  4369. */
  4370. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4371. /**
  4372. * Stores a left-handed orthographic projection into a given matrix
  4373. * @param left defines the viewport left coordinate
  4374. * @param right defines the viewport right coordinate
  4375. * @param bottom defines the viewport bottom coordinate
  4376. * @param top defines the viewport top coordinate
  4377. * @param znear defines the near clip plane
  4378. * @param zfar defines the far clip plane
  4379. * @param result defines the target matrix
  4380. */
  4381. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4382. /**
  4383. * Creates a right-handed orthographic projection matrix
  4384. * @param left defines the viewport left coordinate
  4385. * @param right defines the viewport right coordinate
  4386. * @param bottom defines the viewport bottom coordinate
  4387. * @param top defines the viewport top coordinate
  4388. * @param znear defines the near clip plane
  4389. * @param zfar defines the far clip plane
  4390. * @returns a new matrix as a right-handed orthographic projection matrix
  4391. */
  4392. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4393. /**
  4394. * Stores a right-handed orthographic projection into a given matrix
  4395. * @param left defines the viewport left coordinate
  4396. * @param right defines the viewport right coordinate
  4397. * @param bottom defines the viewport bottom coordinate
  4398. * @param top defines the viewport top coordinate
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @param result defines the target matrix
  4402. */
  4403. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4404. /**
  4405. * Creates a left-handed perspective projection matrix
  4406. * @param width defines the viewport width
  4407. * @param height defines the viewport height
  4408. * @param znear defines the near clip plane
  4409. * @param zfar defines the far clip plane
  4410. * @returns a new matrix as a left-handed perspective projection matrix
  4411. */
  4412. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4413. /**
  4414. * Creates a left-handed perspective projection matrix
  4415. * @param fov defines the horizontal field of view
  4416. * @param aspect defines the aspect ratio
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @returns a new matrix as a left-handed perspective projection matrix
  4420. */
  4421. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4422. /**
  4423. * Stores a left-handed perspective projection into a given matrix
  4424. * @param fov defines the horizontal field of view
  4425. * @param aspect defines the aspect ratio
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @param result defines the target matrix
  4429. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4430. */
  4431. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4432. /**
  4433. * Creates a right-handed perspective projection matrix
  4434. * @param fov defines the horizontal field of view
  4435. * @param aspect defines the aspect ratio
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a right-handed perspective projection matrix
  4439. */
  4440. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Stores a right-handed perspective projection into a given matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @param result defines the target matrix
  4448. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4449. */
  4450. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4451. /**
  4452. * Stores a perspective projection for WebVR info a given matrix
  4453. * @param fov defines the field of view
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4458. */
  4459. static PerspectiveFovWebVRToRef(fov: {
  4460. upDegrees: number;
  4461. downDegrees: number;
  4462. leftDegrees: number;
  4463. rightDegrees: number;
  4464. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4465. /**
  4466. * Computes a complete transformation matrix
  4467. * @param viewport defines the viewport to use
  4468. * @param world defines the world matrix
  4469. * @param view defines the view matrix
  4470. * @param projection defines the projection matrix
  4471. * @param zmin defines the near clip plane
  4472. * @param zmax defines the far clip plane
  4473. * @returns the transformation matrix
  4474. */
  4475. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4476. /**
  4477. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4478. * @param matrix defines the matrix to use
  4479. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4480. */
  4481. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4482. /**
  4483. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4484. * @param matrix defines the matrix to use
  4485. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4486. */
  4487. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4488. /**
  4489. * Compute the transpose of a given matrix
  4490. * @param matrix defines the matrix to transpose
  4491. * @returns the new matrix
  4492. */
  4493. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4494. /**
  4495. * Compute the transpose of a matrix and store it in a target matrix
  4496. * @param matrix defines the matrix to transpose
  4497. * @param result defines the target matrix
  4498. */
  4499. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4500. /**
  4501. * Computes a reflection matrix from a plane
  4502. * @param plane defines the reflection plane
  4503. * @returns a new matrix
  4504. */
  4505. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4506. /**
  4507. * Computes a reflection matrix from a plane
  4508. * @param plane defines the reflection plane
  4509. * @param result defines the target matrix
  4510. */
  4511. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4512. /**
  4513. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4514. * @param xaxis defines the value of the 1st axis
  4515. * @param yaxis defines the value of the 2nd axis
  4516. * @param zaxis defines the value of the 3rd axis
  4517. * @param result defines the target matrix
  4518. */
  4519. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4520. /**
  4521. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4522. * @param quat defines the quaternion to use
  4523. * @param result defines the target matrix
  4524. */
  4525. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4526. }
  4527. /**
  4528. * @hidden
  4529. */
  4530. export class TmpVectors {
  4531. static Vector2: Vector2[];
  4532. static Vector3: Vector3[];
  4533. static Vector4: Vector4[];
  4534. static Quaternion: Quaternion[];
  4535. static Matrix: Matrix[];
  4536. }
  4537. }
  4538. declare module "babylonjs/Maths/math.path" {
  4539. import { DeepImmutable, Nullable } from "babylonjs/types";
  4540. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4541. /**
  4542. * Defines potential orientation for back face culling
  4543. */
  4544. export enum Orientation {
  4545. /**
  4546. * Clockwise
  4547. */
  4548. CW = 0,
  4549. /** Counter clockwise */
  4550. CCW = 1
  4551. }
  4552. /** Class used to represent a Bezier curve */
  4553. export class BezierCurve {
  4554. /**
  4555. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4556. * @param t defines the time
  4557. * @param x1 defines the left coordinate on X axis
  4558. * @param y1 defines the left coordinate on Y axis
  4559. * @param x2 defines the right coordinate on X axis
  4560. * @param y2 defines the right coordinate on Y axis
  4561. * @returns the interpolated value
  4562. */
  4563. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4564. }
  4565. /**
  4566. * Defines angle representation
  4567. */
  4568. export class Angle {
  4569. private _radians;
  4570. /**
  4571. * Creates an Angle object of "radians" radians (float).
  4572. * @param radians the angle in radians
  4573. */
  4574. constructor(radians: number);
  4575. /**
  4576. * Get value in degrees
  4577. * @returns the Angle value in degrees (float)
  4578. */
  4579. degrees(): number;
  4580. /**
  4581. * Get value in radians
  4582. * @returns the Angle value in radians (float)
  4583. */
  4584. radians(): number;
  4585. /**
  4586. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4587. * @param a defines first vector
  4588. * @param b defines second vector
  4589. * @returns a new Angle
  4590. */
  4591. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4592. /**
  4593. * Gets a new Angle object from the given float in radians
  4594. * @param radians defines the angle value in radians
  4595. * @returns a new Angle
  4596. */
  4597. static FromRadians(radians: number): Angle;
  4598. /**
  4599. * Gets a new Angle object from the given float in degrees
  4600. * @param degrees defines the angle value in degrees
  4601. * @returns a new Angle
  4602. */
  4603. static FromDegrees(degrees: number): Angle;
  4604. }
  4605. /**
  4606. * This represents an arc in a 2d space.
  4607. */
  4608. export class Arc2 {
  4609. /** Defines the start point of the arc */
  4610. startPoint: Vector2;
  4611. /** Defines the mid point of the arc */
  4612. midPoint: Vector2;
  4613. /** Defines the end point of the arc */
  4614. endPoint: Vector2;
  4615. /**
  4616. * Defines the center point of the arc.
  4617. */
  4618. centerPoint: Vector2;
  4619. /**
  4620. * Defines the radius of the arc.
  4621. */
  4622. radius: number;
  4623. /**
  4624. * Defines the angle of the arc (from mid point to end point).
  4625. */
  4626. angle: Angle;
  4627. /**
  4628. * Defines the start angle of the arc (from start point to middle point).
  4629. */
  4630. startAngle: Angle;
  4631. /**
  4632. * Defines the orientation of the arc (clock wise/counter clock wise).
  4633. */
  4634. orientation: Orientation;
  4635. /**
  4636. * Creates an Arc object from the three given points : start, middle and end.
  4637. * @param startPoint Defines the start point of the arc
  4638. * @param midPoint Defines the midlle point of the arc
  4639. * @param endPoint Defines the end point of the arc
  4640. */
  4641. constructor(
  4642. /** Defines the start point of the arc */
  4643. startPoint: Vector2,
  4644. /** Defines the mid point of the arc */
  4645. midPoint: Vector2,
  4646. /** Defines the end point of the arc */
  4647. endPoint: Vector2);
  4648. }
  4649. /**
  4650. * Represents a 2D path made up of multiple 2D points
  4651. */
  4652. export class Path2 {
  4653. private _points;
  4654. private _length;
  4655. /**
  4656. * If the path start and end point are the same
  4657. */
  4658. closed: boolean;
  4659. /**
  4660. * Creates a Path2 object from the starting 2D coordinates x and y.
  4661. * @param x the starting points x value
  4662. * @param y the starting points y value
  4663. */
  4664. constructor(x: number, y: number);
  4665. /**
  4666. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4667. * @param x the added points x value
  4668. * @param y the added points y value
  4669. * @returns the updated Path2.
  4670. */
  4671. addLineTo(x: number, y: number): Path2;
  4672. /**
  4673. * 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.
  4674. * @param midX middle point x value
  4675. * @param midY middle point y value
  4676. * @param endX end point x value
  4677. * @param endY end point y value
  4678. * @param numberOfSegments (default: 36)
  4679. * @returns the updated Path2.
  4680. */
  4681. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4682. /**
  4683. * Closes the Path2.
  4684. * @returns the Path2.
  4685. */
  4686. close(): Path2;
  4687. /**
  4688. * Gets the sum of the distance between each sequential point in the path
  4689. * @returns the Path2 total length (float).
  4690. */
  4691. length(): number;
  4692. /**
  4693. * Gets the points which construct the path
  4694. * @returns the Path2 internal array of points.
  4695. */
  4696. getPoints(): Vector2[];
  4697. /**
  4698. * Retreives the point at the distance aways from the starting point
  4699. * @param normalizedLengthPosition the length along the path to retreive the point from
  4700. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4701. */
  4702. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4703. /**
  4704. * Creates a new path starting from an x and y position
  4705. * @param x starting x value
  4706. * @param y starting y value
  4707. * @returns a new Path2 starting at the coordinates (x, y).
  4708. */
  4709. static StartingAt(x: number, y: number): Path2;
  4710. }
  4711. /**
  4712. * Represents a 3D path made up of multiple 3D points
  4713. */
  4714. export class Path3D {
  4715. /**
  4716. * an array of Vector3, the curve axis of the Path3D
  4717. */
  4718. path: Vector3[];
  4719. private _curve;
  4720. private _distances;
  4721. private _tangents;
  4722. private _normals;
  4723. private _binormals;
  4724. private _raw;
  4725. /**
  4726. * new Path3D(path, normal, raw)
  4727. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4728. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4729. * @param path an array of Vector3, the curve axis of the Path3D
  4730. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4731. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4732. */
  4733. constructor(
  4734. /**
  4735. * an array of Vector3, the curve axis of the Path3D
  4736. */
  4737. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4738. /**
  4739. * Returns the Path3D array of successive Vector3 designing its curve.
  4740. * @returns the Path3D array of successive Vector3 designing its curve.
  4741. */
  4742. getCurve(): Vector3[];
  4743. /**
  4744. * Returns an array populated with tangent vectors on each Path3D curve point.
  4745. * @returns an array populated with tangent vectors on each Path3D curve point.
  4746. */
  4747. getTangents(): Vector3[];
  4748. /**
  4749. * Returns an array populated with normal vectors on each Path3D curve point.
  4750. * @returns an array populated with normal vectors on each Path3D curve point.
  4751. */
  4752. getNormals(): Vector3[];
  4753. /**
  4754. * Returns an array populated with binormal vectors on each Path3D curve point.
  4755. * @returns an array populated with binormal vectors on each Path3D curve point.
  4756. */
  4757. getBinormals(): Vector3[];
  4758. /**
  4759. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4760. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4761. */
  4762. getDistances(): number[];
  4763. /**
  4764. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4765. * @param path path which all values are copied into the curves points
  4766. * @param firstNormal which should be projected onto the curve
  4767. * @returns the same object updated.
  4768. */
  4769. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4770. private _compute;
  4771. private _getFirstNonNullVector;
  4772. private _getLastNonNullVector;
  4773. private _normalVector;
  4774. }
  4775. /**
  4776. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4777. * A Curve3 is designed from a series of successive Vector3.
  4778. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4779. */
  4780. export class Curve3 {
  4781. private _points;
  4782. private _length;
  4783. /**
  4784. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4785. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4786. * @param v1 (Vector3) the control point
  4787. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4788. * @param nbPoints (integer) the wanted number of points in the curve
  4789. * @returns the created Curve3
  4790. */
  4791. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4792. /**
  4793. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4794. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4795. * @param v1 (Vector3) the first control point
  4796. * @param v2 (Vector3) the second control point
  4797. * @param v3 (Vector3) the end point of the Cubic Bezier
  4798. * @param nbPoints (integer) the wanted number of points in the curve
  4799. * @returns the created Curve3
  4800. */
  4801. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4802. /**
  4803. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4804. * @param p1 (Vector3) the origin point of the Hermite Spline
  4805. * @param t1 (Vector3) the tangent vector at the origin point
  4806. * @param p2 (Vector3) the end point of the Hermite Spline
  4807. * @param t2 (Vector3) the tangent vector at the end point
  4808. * @param nbPoints (integer) the wanted number of points in the curve
  4809. * @returns the created Curve3
  4810. */
  4811. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4812. /**
  4813. * Returns a Curve3 object along a CatmullRom Spline curve :
  4814. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4815. * @param nbPoints (integer) the wanted number of points between each curve control points
  4816. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4817. * @returns the created Curve3
  4818. */
  4819. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4820. /**
  4821. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4822. * A Curve3 is designed from a series of successive Vector3.
  4823. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4824. * @param points points which make up the curve
  4825. */
  4826. constructor(points: Vector3[]);
  4827. /**
  4828. * @returns the Curve3 stored array of successive Vector3
  4829. */
  4830. getPoints(): Vector3[];
  4831. /**
  4832. * @returns the computed length (float) of the curve.
  4833. */
  4834. length(): number;
  4835. /**
  4836. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4837. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4838. * curveA and curveB keep unchanged.
  4839. * @param curve the curve to continue from this curve
  4840. * @returns the newly constructed curve
  4841. */
  4842. continue(curve: DeepImmutable<Curve3>): Curve3;
  4843. private _computeLength;
  4844. }
  4845. }
  4846. declare module "babylonjs/Animations/easing" {
  4847. /**
  4848. * This represents the main contract an easing function should follow.
  4849. * Easing functions are used throughout the animation system.
  4850. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4851. */
  4852. export interface IEasingFunction {
  4853. /**
  4854. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4855. * of the easing function.
  4856. * The link below provides some of the most common examples of easing functions.
  4857. * @see https://easings.net/
  4858. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4859. * @returns the corresponding value on the curve defined by the easing function
  4860. */
  4861. ease(gradient: number): number;
  4862. }
  4863. /**
  4864. * Base class used for every default easing function.
  4865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4866. */
  4867. export class EasingFunction implements IEasingFunction {
  4868. /**
  4869. * Interpolation follows the mathematical formula associated with the easing function.
  4870. */
  4871. static readonly EASINGMODE_EASEIN: number;
  4872. /**
  4873. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4874. */
  4875. static readonly EASINGMODE_EASEOUT: number;
  4876. /**
  4877. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4878. */
  4879. static readonly EASINGMODE_EASEINOUT: number;
  4880. private _easingMode;
  4881. /**
  4882. * Sets the easing mode of the current function.
  4883. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4884. */
  4885. setEasingMode(easingMode: number): void;
  4886. /**
  4887. * Gets the current easing mode.
  4888. * @returns the easing mode
  4889. */
  4890. getEasingMode(): number;
  4891. /**
  4892. * @hidden
  4893. */
  4894. easeInCore(gradient: number): number;
  4895. /**
  4896. * Given an input gradient between 0 and 1, this returns the corresponding value
  4897. * of the easing function.
  4898. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4899. * @returns the corresponding value on the curve defined by the easing function
  4900. */
  4901. ease(gradient: number): number;
  4902. }
  4903. /**
  4904. * Easing function with a circle shape (see link below).
  4905. * @see https://easings.net/#easeInCirc
  4906. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4907. */
  4908. export class CircleEase extends EasingFunction implements IEasingFunction {
  4909. /** @hidden */
  4910. easeInCore(gradient: number): number;
  4911. }
  4912. /**
  4913. * Easing function with a ease back shape (see link below).
  4914. * @see https://easings.net/#easeInBack
  4915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4916. */
  4917. export class BackEase extends EasingFunction implements IEasingFunction {
  4918. /** Defines the amplitude of the function */
  4919. amplitude: number;
  4920. /**
  4921. * Instantiates a back ease easing
  4922. * @see https://easings.net/#easeInBack
  4923. * @param amplitude Defines the amplitude of the function
  4924. */
  4925. constructor(
  4926. /** Defines the amplitude of the function */
  4927. amplitude?: number);
  4928. /** @hidden */
  4929. easeInCore(gradient: number): number;
  4930. }
  4931. /**
  4932. * Easing function with a bouncing shape (see link below).
  4933. * @see https://easings.net/#easeInBounce
  4934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4935. */
  4936. export class BounceEase extends EasingFunction implements IEasingFunction {
  4937. /** Defines the number of bounces */
  4938. bounces: number;
  4939. /** Defines the amplitude of the bounce */
  4940. bounciness: number;
  4941. /**
  4942. * Instantiates a bounce easing
  4943. * @see https://easings.net/#easeInBounce
  4944. * @param bounces Defines the number of bounces
  4945. * @param bounciness Defines the amplitude of the bounce
  4946. */
  4947. constructor(
  4948. /** Defines the number of bounces */
  4949. bounces?: number,
  4950. /** Defines the amplitude of the bounce */
  4951. bounciness?: number);
  4952. /** @hidden */
  4953. easeInCore(gradient: number): number;
  4954. }
  4955. /**
  4956. * Easing function with a power of 3 shape (see link below).
  4957. * @see https://easings.net/#easeInCubic
  4958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4959. */
  4960. export class CubicEase extends EasingFunction implements IEasingFunction {
  4961. /** @hidden */
  4962. easeInCore(gradient: number): number;
  4963. }
  4964. /**
  4965. * Easing function with an elastic shape (see link below).
  4966. * @see https://easings.net/#easeInElastic
  4967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4968. */
  4969. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4970. /** Defines the number of oscillations*/
  4971. oscillations: number;
  4972. /** Defines the amplitude of the oscillations*/
  4973. springiness: number;
  4974. /**
  4975. * Instantiates an elastic easing function
  4976. * @see https://easings.net/#easeInElastic
  4977. * @param oscillations Defines the number of oscillations
  4978. * @param springiness Defines the amplitude of the oscillations
  4979. */
  4980. constructor(
  4981. /** Defines the number of oscillations*/
  4982. oscillations?: number,
  4983. /** Defines the amplitude of the oscillations*/
  4984. springiness?: number);
  4985. /** @hidden */
  4986. easeInCore(gradient: number): number;
  4987. }
  4988. /**
  4989. * Easing function with an exponential shape (see link below).
  4990. * @see https://easings.net/#easeInExpo
  4991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4992. */
  4993. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4994. /** Defines the exponent of the function */
  4995. exponent: number;
  4996. /**
  4997. * Instantiates an exponential easing function
  4998. * @see https://easings.net/#easeInExpo
  4999. * @param exponent Defines the exponent of the function
  5000. */
  5001. constructor(
  5002. /** Defines the exponent of the function */
  5003. exponent?: number);
  5004. /** @hidden */
  5005. easeInCore(gradient: number): number;
  5006. }
  5007. /**
  5008. * Easing function with a power shape (see link below).
  5009. * @see https://easings.net/#easeInQuad
  5010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5011. */
  5012. export class PowerEase extends EasingFunction implements IEasingFunction {
  5013. /** Defines the power of the function */
  5014. power: number;
  5015. /**
  5016. * Instantiates an power base easing function
  5017. * @see https://easings.net/#easeInQuad
  5018. * @param power Defines the power of the function
  5019. */
  5020. constructor(
  5021. /** Defines the power of the function */
  5022. power?: number);
  5023. /** @hidden */
  5024. easeInCore(gradient: number): number;
  5025. }
  5026. /**
  5027. * Easing function with a power of 2 shape (see link below).
  5028. * @see https://easings.net/#easeInQuad
  5029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5030. */
  5031. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5032. /** @hidden */
  5033. easeInCore(gradient: number): number;
  5034. }
  5035. /**
  5036. * Easing function with a power of 4 shape (see link below).
  5037. * @see https://easings.net/#easeInQuart
  5038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5039. */
  5040. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5041. /** @hidden */
  5042. easeInCore(gradient: number): number;
  5043. }
  5044. /**
  5045. * Easing function with a power of 5 shape (see link below).
  5046. * @see https://easings.net/#easeInQuint
  5047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5048. */
  5049. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5050. /** @hidden */
  5051. easeInCore(gradient: number): number;
  5052. }
  5053. /**
  5054. * Easing function with a sin shape (see link below).
  5055. * @see https://easings.net/#easeInSine
  5056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5057. */
  5058. export class SineEase extends EasingFunction implements IEasingFunction {
  5059. /** @hidden */
  5060. easeInCore(gradient: number): number;
  5061. }
  5062. /**
  5063. * Easing function with a bezier shape (see link below).
  5064. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5068. /** Defines the x component of the start tangent in the bezier curve */
  5069. x1: number;
  5070. /** Defines the y component of the start tangent in the bezier curve */
  5071. y1: number;
  5072. /** Defines the x component of the end tangent in the bezier curve */
  5073. x2: number;
  5074. /** Defines the y component of the end tangent in the bezier curve */
  5075. y2: number;
  5076. /**
  5077. * Instantiates a bezier function
  5078. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5079. * @param x1 Defines the x component of the start tangent in the bezier curve
  5080. * @param y1 Defines the y component of the start tangent in the bezier curve
  5081. * @param x2 Defines the x component of the end tangent in the bezier curve
  5082. * @param y2 Defines the y component of the end tangent in the bezier curve
  5083. */
  5084. constructor(
  5085. /** Defines the x component of the start tangent in the bezier curve */
  5086. x1?: number,
  5087. /** Defines the y component of the start tangent in the bezier curve */
  5088. y1?: number,
  5089. /** Defines the x component of the end tangent in the bezier curve */
  5090. x2?: number,
  5091. /** Defines the y component of the end tangent in the bezier curve */
  5092. y2?: number);
  5093. /** @hidden */
  5094. easeInCore(gradient: number): number;
  5095. }
  5096. }
  5097. declare module "babylonjs/Maths/math.color" {
  5098. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5099. /**
  5100. * Class used to hold a RBG color
  5101. */
  5102. export class Color3 {
  5103. /**
  5104. * Defines the red component (between 0 and 1, default is 0)
  5105. */
  5106. r: number;
  5107. /**
  5108. * Defines the green component (between 0 and 1, default is 0)
  5109. */
  5110. g: number;
  5111. /**
  5112. * Defines the blue component (between 0 and 1, default is 0)
  5113. */
  5114. b: number;
  5115. /**
  5116. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5117. * @param r defines the red component (between 0 and 1, default is 0)
  5118. * @param g defines the green component (between 0 and 1, default is 0)
  5119. * @param b defines the blue component (between 0 and 1, default is 0)
  5120. */
  5121. constructor(
  5122. /**
  5123. * Defines the red component (between 0 and 1, default is 0)
  5124. */
  5125. r?: number,
  5126. /**
  5127. * Defines the green component (between 0 and 1, default is 0)
  5128. */
  5129. g?: number,
  5130. /**
  5131. * Defines the blue component (between 0 and 1, default is 0)
  5132. */
  5133. b?: number);
  5134. /**
  5135. * Creates a string with the Color3 current values
  5136. * @returns the string representation of the Color3 object
  5137. */
  5138. toString(): string;
  5139. /**
  5140. * Returns the string "Color3"
  5141. * @returns "Color3"
  5142. */
  5143. getClassName(): string;
  5144. /**
  5145. * Compute the Color3 hash code
  5146. * @returns an unique number that can be used to hash Color3 objects
  5147. */
  5148. getHashCode(): number;
  5149. /**
  5150. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5151. * @param array defines the array where to store the r,g,b components
  5152. * @param index defines an optional index in the target array to define where to start storing values
  5153. * @returns the current Color3 object
  5154. */
  5155. toArray(array: FloatArray, index?: number): Color3;
  5156. /**
  5157. * Returns a new Color4 object from the current Color3 and the given alpha
  5158. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5159. * @returns a new Color4 object
  5160. */
  5161. toColor4(alpha?: number): Color4;
  5162. /**
  5163. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5164. * @returns the new array
  5165. */
  5166. asArray(): number[];
  5167. /**
  5168. * Returns the luminance value
  5169. * @returns a float value
  5170. */
  5171. toLuminance(): number;
  5172. /**
  5173. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5174. * @param otherColor defines the second operand
  5175. * @returns the new Color3 object
  5176. */
  5177. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5178. /**
  5179. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5180. * @param otherColor defines the second operand
  5181. * @param result defines the Color3 object where to store the result
  5182. * @returns the current Color3
  5183. */
  5184. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5185. /**
  5186. * Determines equality between Color3 objects
  5187. * @param otherColor defines the second operand
  5188. * @returns true if the rgb values are equal to the given ones
  5189. */
  5190. equals(otherColor: DeepImmutable<Color3>): boolean;
  5191. /**
  5192. * Determines equality between the current Color3 object and a set of r,b,g values
  5193. * @param r defines the red component to check
  5194. * @param g defines the green component to check
  5195. * @param b defines the blue component to check
  5196. * @returns true if the rgb values are equal to the given ones
  5197. */
  5198. equalsFloats(r: number, g: number, b: number): boolean;
  5199. /**
  5200. * Multiplies in place each rgb value by scale
  5201. * @param scale defines the scaling factor
  5202. * @returns the updated Color3
  5203. */
  5204. scale(scale: number): Color3;
  5205. /**
  5206. * Multiplies the rgb values by scale and stores the result into "result"
  5207. * @param scale defines the scaling factor
  5208. * @param result defines the Color3 object where to store the result
  5209. * @returns the unmodified current Color3
  5210. */
  5211. scaleToRef(scale: number, result: Color3): Color3;
  5212. /**
  5213. * Scale the current Color3 values by a factor and add the result to a given Color3
  5214. * @param scale defines the scale factor
  5215. * @param result defines color to store the result into
  5216. * @returns the unmodified current Color3
  5217. */
  5218. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5219. /**
  5220. * Clamps the rgb values by the min and max values and stores the result into "result"
  5221. * @param min defines minimum clamping value (default is 0)
  5222. * @param max defines maximum clamping value (default is 1)
  5223. * @param result defines color to store the result into
  5224. * @returns the original Color3
  5225. */
  5226. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5227. /**
  5228. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5229. * @param otherColor defines the second operand
  5230. * @returns the new Color3
  5231. */
  5232. add(otherColor: DeepImmutable<Color3>): Color3;
  5233. /**
  5234. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5235. * @param otherColor defines the second operand
  5236. * @param result defines Color3 object to store the result into
  5237. * @returns the unmodified current Color3
  5238. */
  5239. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5240. /**
  5241. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5242. * @param otherColor defines the second operand
  5243. * @returns the new Color3
  5244. */
  5245. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5246. /**
  5247. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5248. * @param otherColor defines the second operand
  5249. * @param result defines Color3 object to store the result into
  5250. * @returns the unmodified current Color3
  5251. */
  5252. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5253. /**
  5254. * Copy the current object
  5255. * @returns a new Color3 copied the current one
  5256. */
  5257. clone(): Color3;
  5258. /**
  5259. * Copies the rgb values from the source in the current Color3
  5260. * @param source defines the source Color3 object
  5261. * @returns the updated Color3 object
  5262. */
  5263. copyFrom(source: DeepImmutable<Color3>): Color3;
  5264. /**
  5265. * Updates the Color3 rgb values from the given floats
  5266. * @param r defines the red component to read from
  5267. * @param g defines the green component to read from
  5268. * @param b defines the blue component to read from
  5269. * @returns the current Color3 object
  5270. */
  5271. copyFromFloats(r: number, g: number, b: number): Color3;
  5272. /**
  5273. * Updates the Color3 rgb values from the given floats
  5274. * @param r defines the red component to read from
  5275. * @param g defines the green component to read from
  5276. * @param b defines the blue component to read from
  5277. * @returns the current Color3 object
  5278. */
  5279. set(r: number, g: number, b: number): Color3;
  5280. /**
  5281. * Compute the Color3 hexadecimal code as a string
  5282. * @returns a string containing the hexadecimal representation of the Color3 object
  5283. */
  5284. toHexString(): string;
  5285. /**
  5286. * Computes a new Color3 converted from the current one to linear space
  5287. * @returns a new Color3 object
  5288. */
  5289. toLinearSpace(): Color3;
  5290. /**
  5291. * Converts current color in rgb space to HSV values
  5292. * @returns a new color3 representing the HSV values
  5293. */
  5294. toHSV(): Color3;
  5295. /**
  5296. * Converts current color in rgb space to HSV values
  5297. * @param result defines the Color3 where to store the HSV values
  5298. */
  5299. toHSVToRef(result: Color3): void;
  5300. /**
  5301. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5302. * @param convertedColor defines the Color3 object where to store the linear space version
  5303. * @returns the unmodified Color3
  5304. */
  5305. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5306. /**
  5307. * Computes a new Color3 converted from the current one to gamma space
  5308. * @returns a new Color3 object
  5309. */
  5310. toGammaSpace(): Color3;
  5311. /**
  5312. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5313. * @param convertedColor defines the Color3 object where to store the gamma space version
  5314. * @returns the unmodified Color3
  5315. */
  5316. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5317. private static _BlackReadOnly;
  5318. /**
  5319. * Convert Hue, saturation and value to a Color3 (RGB)
  5320. * @param hue defines the hue
  5321. * @param saturation defines the saturation
  5322. * @param value defines the value
  5323. * @param result defines the Color3 where to store the RGB values
  5324. */
  5325. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5326. /**
  5327. * Creates a new Color3 from the string containing valid hexadecimal values
  5328. * @param hex defines a string containing valid hexadecimal values
  5329. * @returns a new Color3 object
  5330. */
  5331. static FromHexString(hex: string): Color3;
  5332. /**
  5333. * Creates a new Color3 from the starting index of the given array
  5334. * @param array defines the source array
  5335. * @param offset defines an offset in the source array
  5336. * @returns a new Color3 object
  5337. */
  5338. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5339. /**
  5340. * Creates a new Color3 from integer values (< 256)
  5341. * @param r defines the red component to read from (value between 0 and 255)
  5342. * @param g defines the green component to read from (value between 0 and 255)
  5343. * @param b defines the blue component to read from (value between 0 and 255)
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromInts(r: number, g: number, b: number): Color3;
  5347. /**
  5348. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5349. * @param start defines the start Color3 value
  5350. * @param end defines the end Color3 value
  5351. * @param amount defines the gradient value between start and end
  5352. * @returns a new Color3 object
  5353. */
  5354. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5355. /**
  5356. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5357. * @param left defines the start value
  5358. * @param right defines the end value
  5359. * @param amount defines the gradient factor
  5360. * @param result defines the Color3 object where to store the result
  5361. */
  5362. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5363. /**
  5364. * Returns a Color3 value containing a red color
  5365. * @returns a new Color3 object
  5366. */
  5367. static Red(): Color3;
  5368. /**
  5369. * Returns a Color3 value containing a green color
  5370. * @returns a new Color3 object
  5371. */
  5372. static Green(): Color3;
  5373. /**
  5374. * Returns a Color3 value containing a blue color
  5375. * @returns a new Color3 object
  5376. */
  5377. static Blue(): Color3;
  5378. /**
  5379. * Returns a Color3 value containing a black color
  5380. * @returns a new Color3 object
  5381. */
  5382. static Black(): Color3;
  5383. /**
  5384. * Gets a Color3 value containing a black color that must not be updated
  5385. */
  5386. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5387. /**
  5388. * Returns a Color3 value containing a white color
  5389. * @returns a new Color3 object
  5390. */
  5391. static White(): Color3;
  5392. /**
  5393. * Returns a Color3 value containing a purple color
  5394. * @returns a new Color3 object
  5395. */
  5396. static Purple(): Color3;
  5397. /**
  5398. * Returns a Color3 value containing a magenta color
  5399. * @returns a new Color3 object
  5400. */
  5401. static Magenta(): Color3;
  5402. /**
  5403. * Returns a Color3 value containing a yellow color
  5404. * @returns a new Color3 object
  5405. */
  5406. static Yellow(): Color3;
  5407. /**
  5408. * Returns a Color3 value containing a gray color
  5409. * @returns a new Color3 object
  5410. */
  5411. static Gray(): Color3;
  5412. /**
  5413. * Returns a Color3 value containing a teal color
  5414. * @returns a new Color3 object
  5415. */
  5416. static Teal(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a random color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Random(): Color3;
  5422. }
  5423. /**
  5424. * Class used to hold a RBGA color
  5425. */
  5426. export class Color4 {
  5427. /**
  5428. * Defines the red component (between 0 and 1, default is 0)
  5429. */
  5430. r: number;
  5431. /**
  5432. * Defines the green component (between 0 and 1, default is 0)
  5433. */
  5434. g: number;
  5435. /**
  5436. * Defines the blue component (between 0 and 1, default is 0)
  5437. */
  5438. b: number;
  5439. /**
  5440. * Defines the alpha component (between 0 and 1, default is 1)
  5441. */
  5442. a: number;
  5443. /**
  5444. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5445. * @param r defines the red component (between 0 and 1, default is 0)
  5446. * @param g defines the green component (between 0 and 1, default is 0)
  5447. * @param b defines the blue component (between 0 and 1, default is 0)
  5448. * @param a defines the alpha component (between 0 and 1, default is 1)
  5449. */
  5450. constructor(
  5451. /**
  5452. * Defines the red component (between 0 and 1, default is 0)
  5453. */
  5454. r?: number,
  5455. /**
  5456. * Defines the green component (between 0 and 1, default is 0)
  5457. */
  5458. g?: number,
  5459. /**
  5460. * Defines the blue component (between 0 and 1, default is 0)
  5461. */
  5462. b?: number,
  5463. /**
  5464. * Defines the alpha component (between 0 and 1, default is 1)
  5465. */
  5466. a?: number);
  5467. /**
  5468. * Adds in place the given Color4 values to the current Color4 object
  5469. * @param right defines the second operand
  5470. * @returns the current updated Color4 object
  5471. */
  5472. addInPlace(right: DeepImmutable<Color4>): Color4;
  5473. /**
  5474. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5475. * @returns the new array
  5476. */
  5477. asArray(): number[];
  5478. /**
  5479. * Stores from the starting index in the given array the Color4 successive values
  5480. * @param array defines the array where to store the r,g,b components
  5481. * @param index defines an optional index in the target array to define where to start storing values
  5482. * @returns the current Color4 object
  5483. */
  5484. toArray(array: number[], index?: number): Color4;
  5485. /**
  5486. * Determines equality between Color4 objects
  5487. * @param otherColor defines the second operand
  5488. * @returns true if the rgba values are equal to the given ones
  5489. */
  5490. equals(otherColor: DeepImmutable<Color4>): boolean;
  5491. /**
  5492. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5493. * @param right defines the second operand
  5494. * @returns a new Color4 object
  5495. */
  5496. add(right: DeepImmutable<Color4>): Color4;
  5497. /**
  5498. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5499. * @param right defines the second operand
  5500. * @returns a new Color4 object
  5501. */
  5502. subtract(right: DeepImmutable<Color4>): Color4;
  5503. /**
  5504. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5505. * @param right defines the second operand
  5506. * @param result defines the Color4 object where to store the result
  5507. * @returns the current Color4 object
  5508. */
  5509. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5510. /**
  5511. * Creates a new Color4 with the current Color4 values multiplied by scale
  5512. * @param scale defines the scaling factor to apply
  5513. * @returns a new Color4 object
  5514. */
  5515. scale(scale: number): Color4;
  5516. /**
  5517. * Multiplies the current Color4 values by scale and stores the result in "result"
  5518. * @param scale defines the scaling factor to apply
  5519. * @param result defines the Color4 object where to store the result
  5520. * @returns the current unmodified Color4
  5521. */
  5522. scaleToRef(scale: number, result: Color4): Color4;
  5523. /**
  5524. * Scale the current Color4 values by a factor and add the result to a given Color4
  5525. * @param scale defines the scale factor
  5526. * @param result defines the Color4 object where to store the result
  5527. * @returns the unmodified current Color4
  5528. */
  5529. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5530. /**
  5531. * Clamps the rgb values by the min and max values and stores the result into "result"
  5532. * @param min defines minimum clamping value (default is 0)
  5533. * @param max defines maximum clamping value (default is 1)
  5534. * @param result defines color to store the result into.
  5535. * @returns the cuurent Color4
  5536. */
  5537. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5538. /**
  5539. * Multipy an Color4 value by another and return a new Color4 object
  5540. * @param color defines the Color4 value to multiply by
  5541. * @returns a new Color4 object
  5542. */
  5543. multiply(color: Color4): Color4;
  5544. /**
  5545. * Multipy a Color4 value by another and push the result in a reference value
  5546. * @param color defines the Color4 value to multiply by
  5547. * @param result defines the Color4 to fill the result in
  5548. * @returns the result Color4
  5549. */
  5550. multiplyToRef(color: Color4, result: Color4): Color4;
  5551. /**
  5552. * Creates a string with the Color4 current values
  5553. * @returns the string representation of the Color4 object
  5554. */
  5555. toString(): string;
  5556. /**
  5557. * Returns the string "Color4"
  5558. * @returns "Color4"
  5559. */
  5560. getClassName(): string;
  5561. /**
  5562. * Compute the Color4 hash code
  5563. * @returns an unique number that can be used to hash Color4 objects
  5564. */
  5565. getHashCode(): number;
  5566. /**
  5567. * Creates a new Color4 copied from the current one
  5568. * @returns a new Color4 object
  5569. */
  5570. clone(): Color4;
  5571. /**
  5572. * Copies the given Color4 values into the current one
  5573. * @param source defines the source Color4 object
  5574. * @returns the current updated Color4 object
  5575. */
  5576. copyFrom(source: Color4): Color4;
  5577. /**
  5578. * Copies the given float values into the current one
  5579. * @param r defines the red component to read from
  5580. * @param g defines the green component to read from
  5581. * @param b defines the blue component to read from
  5582. * @param a defines the alpha component to read from
  5583. * @returns the current updated Color4 object
  5584. */
  5585. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5586. /**
  5587. * Copies the given float values into the current one
  5588. * @param r defines the red component to read from
  5589. * @param g defines the green component to read from
  5590. * @param b defines the blue component to read from
  5591. * @param a defines the alpha component to read from
  5592. * @returns the current updated Color4 object
  5593. */
  5594. set(r: number, g: number, b: number, a: number): Color4;
  5595. /**
  5596. * Compute the Color4 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color4 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color4 converted from the current one to linear space
  5602. * @returns a new Color4 object
  5603. */
  5604. toLinearSpace(): Color4;
  5605. /**
  5606. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5607. * @param convertedColor defines the Color4 object where to store the linear space version
  5608. * @returns the unmodified Color4
  5609. */
  5610. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5611. /**
  5612. * Computes a new Color4 converted from the current one to gamma space
  5613. * @returns a new Color4 object
  5614. */
  5615. toGammaSpace(): Color4;
  5616. /**
  5617. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5618. * @param convertedColor defines the Color4 object where to store the gamma space version
  5619. * @returns the unmodified Color4
  5620. */
  5621. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5622. /**
  5623. * Creates a new Color4 from the string containing valid hexadecimal values
  5624. * @param hex defines a string containing valid hexadecimal values
  5625. * @returns a new Color4 object
  5626. */
  5627. static FromHexString(hex: string): Color4;
  5628. /**
  5629. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5630. * @param left defines the start value
  5631. * @param right defines the end value
  5632. * @param amount defines the gradient factor
  5633. * @returns a new Color4 object
  5634. */
  5635. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5636. /**
  5637. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5638. * @param left defines the start value
  5639. * @param right defines the end value
  5640. * @param amount defines the gradient factor
  5641. * @param result defines the Color4 object where to store data
  5642. */
  5643. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5644. /**
  5645. * Creates a new Color4 from a Color3 and an alpha value
  5646. * @param color3 defines the source Color3 to read from
  5647. * @param alpha defines the alpha component (1.0 by default)
  5648. * @returns a new Color4 object
  5649. */
  5650. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5651. /**
  5652. * Creates a new Color4 from the starting index element of the given array
  5653. * @param array defines the source array to read from
  5654. * @param offset defines the offset in the source array
  5655. * @returns a new Color4 object
  5656. */
  5657. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5658. /**
  5659. * Creates a new Color3 from integer values (< 256)
  5660. * @param r defines the red component to read from (value between 0 and 255)
  5661. * @param g defines the green component to read from (value between 0 and 255)
  5662. * @param b defines the blue component to read from (value between 0 and 255)
  5663. * @param a defines the alpha component to read from (value between 0 and 255)
  5664. * @returns a new Color3 object
  5665. */
  5666. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5667. /**
  5668. * Check the content of a given array and convert it to an array containing RGBA data
  5669. * If the original array was already containing count * 4 values then it is returned directly
  5670. * @param colors defines the array to check
  5671. * @param count defines the number of RGBA data to expect
  5672. * @returns an array containing count * 4 values (RGBA)
  5673. */
  5674. static CheckColors4(colors: number[], count: number): number[];
  5675. }
  5676. /**
  5677. * @hidden
  5678. */
  5679. export class TmpColors {
  5680. static Color3: Color3[];
  5681. static Color4: Color4[];
  5682. }
  5683. }
  5684. declare module "babylonjs/Animations/animationKey" {
  5685. /**
  5686. * Defines an interface which represents an animation key frame
  5687. */
  5688. export interface IAnimationKey {
  5689. /**
  5690. * Frame of the key frame
  5691. */
  5692. frame: number;
  5693. /**
  5694. * Value at the specifies key frame
  5695. */
  5696. value: any;
  5697. /**
  5698. * The input tangent for the cubic hermite spline
  5699. */
  5700. inTangent?: any;
  5701. /**
  5702. * The output tangent for the cubic hermite spline
  5703. */
  5704. outTangent?: any;
  5705. /**
  5706. * The animation interpolation type
  5707. */
  5708. interpolation?: AnimationKeyInterpolation;
  5709. }
  5710. /**
  5711. * Enum for the animation key frame interpolation type
  5712. */
  5713. export enum AnimationKeyInterpolation {
  5714. /**
  5715. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5716. */
  5717. STEP = 1
  5718. }
  5719. }
  5720. declare module "babylonjs/Animations/animationRange" {
  5721. /**
  5722. * Represents the range of an animation
  5723. */
  5724. export class AnimationRange {
  5725. /**The name of the animation range**/
  5726. name: string;
  5727. /**The starting frame of the animation */
  5728. from: number;
  5729. /**The ending frame of the animation*/
  5730. to: number;
  5731. /**
  5732. * Initializes the range of an animation
  5733. * @param name The name of the animation range
  5734. * @param from The starting frame of the animation
  5735. * @param to The ending frame of the animation
  5736. */
  5737. constructor(
  5738. /**The name of the animation range**/
  5739. name: string,
  5740. /**The starting frame of the animation */
  5741. from: number,
  5742. /**The ending frame of the animation*/
  5743. to: number);
  5744. /**
  5745. * Makes a copy of the animation range
  5746. * @returns A copy of the animation range
  5747. */
  5748. clone(): AnimationRange;
  5749. }
  5750. }
  5751. declare module "babylonjs/Animations/animationEvent" {
  5752. /**
  5753. * Composed of a frame, and an action function
  5754. */
  5755. export class AnimationEvent {
  5756. /** The frame for which the event is triggered **/
  5757. frame: number;
  5758. /** The event to perform when triggered **/
  5759. action: (currentFrame: number) => void;
  5760. /** Specifies if the event should be triggered only once**/
  5761. onlyOnce?: boolean | undefined;
  5762. /**
  5763. * Specifies if the animation event is done
  5764. */
  5765. isDone: boolean;
  5766. /**
  5767. * Initializes the animation event
  5768. * @param frame The frame for which the event is triggered
  5769. * @param action The event to perform when triggered
  5770. * @param onlyOnce Specifies if the event should be triggered only once
  5771. */
  5772. constructor(
  5773. /** The frame for which the event is triggered **/
  5774. frame: number,
  5775. /** The event to perform when triggered **/
  5776. action: (currentFrame: number) => void,
  5777. /** Specifies if the event should be triggered only once**/
  5778. onlyOnce?: boolean | undefined);
  5779. /** @hidden */
  5780. _clone(): AnimationEvent;
  5781. }
  5782. }
  5783. declare module "babylonjs/Behaviors/behavior" {
  5784. import { Nullable } from "babylonjs/types";
  5785. /**
  5786. * Interface used to define a behavior
  5787. */
  5788. export interface Behavior<T> {
  5789. /** gets or sets behavior's name */
  5790. name: string;
  5791. /**
  5792. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5793. */
  5794. init(): void;
  5795. /**
  5796. * Called when the behavior is attached to a target
  5797. * @param target defines the target where the behavior is attached to
  5798. */
  5799. attach(target: T): void;
  5800. /**
  5801. * Called when the behavior is detached from its target
  5802. */
  5803. detach(): void;
  5804. }
  5805. /**
  5806. * Interface implemented by classes supporting behaviors
  5807. */
  5808. export interface IBehaviorAware<T> {
  5809. /**
  5810. * Attach a behavior
  5811. * @param behavior defines the behavior to attach
  5812. * @returns the current host
  5813. */
  5814. addBehavior(behavior: Behavior<T>): T;
  5815. /**
  5816. * Remove a behavior from the current object
  5817. * @param behavior defines the behavior to detach
  5818. * @returns the current host
  5819. */
  5820. removeBehavior(behavior: Behavior<T>): T;
  5821. /**
  5822. * Gets a behavior using its name to search
  5823. * @param name defines the name to search
  5824. * @returns the behavior or null if not found
  5825. */
  5826. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5827. }
  5828. }
  5829. declare module "babylonjs/Misc/smartArray" {
  5830. /**
  5831. * Defines an array and its length.
  5832. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5833. */
  5834. export interface ISmartArrayLike<T> {
  5835. /**
  5836. * The data of the array.
  5837. */
  5838. data: Array<T>;
  5839. /**
  5840. * The active length of the array.
  5841. */
  5842. length: number;
  5843. }
  5844. /**
  5845. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5846. */
  5847. export class SmartArray<T> implements ISmartArrayLike<T> {
  5848. /**
  5849. * The full set of data from the array.
  5850. */
  5851. data: Array<T>;
  5852. /**
  5853. * The active length of the array.
  5854. */
  5855. length: number;
  5856. protected _id: number;
  5857. /**
  5858. * Instantiates a Smart Array.
  5859. * @param capacity defines the default capacity of the array.
  5860. */
  5861. constructor(capacity: number);
  5862. /**
  5863. * Pushes a value at the end of the active data.
  5864. * @param value defines the object to push in the array.
  5865. */
  5866. push(value: T): void;
  5867. /**
  5868. * Iterates over the active data and apply the lambda to them.
  5869. * @param func defines the action to apply on each value.
  5870. */
  5871. forEach(func: (content: T) => void): void;
  5872. /**
  5873. * Sorts the full sets of data.
  5874. * @param compareFn defines the comparison function to apply.
  5875. */
  5876. sort(compareFn: (a: T, b: T) => number): void;
  5877. /**
  5878. * Resets the active data to an empty array.
  5879. */
  5880. reset(): void;
  5881. /**
  5882. * Releases all the data from the array as well as the array.
  5883. */
  5884. dispose(): void;
  5885. /**
  5886. * Concats the active data with a given array.
  5887. * @param array defines the data to concatenate with.
  5888. */
  5889. concat(array: any): void;
  5890. /**
  5891. * Returns the position of a value in the active data.
  5892. * @param value defines the value to find the index for
  5893. * @returns the index if found in the active data otherwise -1
  5894. */
  5895. indexOf(value: T): number;
  5896. /**
  5897. * Returns whether an element is part of the active data.
  5898. * @param value defines the value to look for
  5899. * @returns true if found in the active data otherwise false
  5900. */
  5901. contains(value: T): boolean;
  5902. private static _GlobalId;
  5903. }
  5904. /**
  5905. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5906. * The data in this array can only be present once
  5907. */
  5908. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5909. private _duplicateId;
  5910. /**
  5911. * Pushes a value at the end of the active data.
  5912. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5913. * @param value defines the object to push in the array.
  5914. */
  5915. push(value: T): void;
  5916. /**
  5917. * Pushes a value at the end of the active data.
  5918. * If the data is already present, it won t be added again
  5919. * @param value defines the object to push in the array.
  5920. * @returns true if added false if it was already present
  5921. */
  5922. pushNoDuplicate(value: T): boolean;
  5923. /**
  5924. * Resets the active data to an empty array.
  5925. */
  5926. reset(): void;
  5927. /**
  5928. * Concats the active data with a given array.
  5929. * This ensures no dupplicate will be present in the result.
  5930. * @param array defines the data to concatenate with.
  5931. */
  5932. concatWithNoDuplicate(array: any): void;
  5933. }
  5934. }
  5935. declare module "babylonjs/Cameras/cameraInputsManager" {
  5936. import { Nullable } from "babylonjs/types";
  5937. import { Camera } from "babylonjs/Cameras/camera";
  5938. /**
  5939. * @ignore
  5940. * This is a list of all the different input types that are available in the application.
  5941. * Fo instance: ArcRotateCameraGamepadInput...
  5942. */
  5943. export var CameraInputTypes: {};
  5944. /**
  5945. * This is the contract to implement in order to create a new input class.
  5946. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5947. */
  5948. export interface ICameraInput<TCamera extends Camera> {
  5949. /**
  5950. * Defines the camera the input is attached to.
  5951. */
  5952. camera: Nullable<TCamera>;
  5953. /**
  5954. * Gets the class name of the current intput.
  5955. * @returns the class name
  5956. */
  5957. getClassName(): string;
  5958. /**
  5959. * Get the friendly name associated with the input class.
  5960. * @returns the input friendly name
  5961. */
  5962. getSimpleName(): string;
  5963. /**
  5964. * Attach the input controls to a specific dom element to get the input from.
  5965. * @param element Defines the element the controls should be listened from
  5966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5967. */
  5968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5969. /**
  5970. * Detach the current controls from the specified dom element.
  5971. * @param element Defines the element to stop listening the inputs from
  5972. */
  5973. detachControl(element: Nullable<HTMLElement>): void;
  5974. /**
  5975. * Update the current camera state depending on the inputs that have been used this frame.
  5976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5977. */
  5978. checkInputs?: () => void;
  5979. }
  5980. /**
  5981. * Represents a map of input types to input instance or input index to input instance.
  5982. */
  5983. export interface CameraInputsMap<TCamera extends Camera> {
  5984. /**
  5985. * Accessor to the input by input type.
  5986. */
  5987. [name: string]: ICameraInput<TCamera>;
  5988. /**
  5989. * Accessor to the input by input index.
  5990. */
  5991. [idx: number]: ICameraInput<TCamera>;
  5992. }
  5993. /**
  5994. * This represents the input manager used within a camera.
  5995. * It helps dealing with all the different kind of input attached to a camera.
  5996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5997. */
  5998. export class CameraInputsManager<TCamera extends Camera> {
  5999. /**
  6000. * Defines the list of inputs attahed to the camera.
  6001. */
  6002. attached: CameraInputsMap<TCamera>;
  6003. /**
  6004. * Defines the dom element the camera is collecting inputs from.
  6005. * This is null if the controls have not been attached.
  6006. */
  6007. attachedElement: Nullable<HTMLElement>;
  6008. /**
  6009. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6010. */
  6011. noPreventDefault: boolean;
  6012. /**
  6013. * Defined the camera the input manager belongs to.
  6014. */
  6015. camera: TCamera;
  6016. /**
  6017. * Update the current camera state depending on the inputs that have been used this frame.
  6018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6019. */
  6020. checkInputs: () => void;
  6021. /**
  6022. * Instantiate a new Camera Input Manager.
  6023. * @param camera Defines the camera the input manager blongs to
  6024. */
  6025. constructor(camera: TCamera);
  6026. /**
  6027. * Add an input method to a camera
  6028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6029. * @param input camera input method
  6030. */
  6031. add(input: ICameraInput<TCamera>): void;
  6032. /**
  6033. * Remove a specific input method from a camera
  6034. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6035. * @param inputToRemove camera input method
  6036. */
  6037. remove(inputToRemove: ICameraInput<TCamera>): void;
  6038. /**
  6039. * Remove a specific input type from a camera
  6040. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6041. * @param inputType the type of the input to remove
  6042. */
  6043. removeByType(inputType: string): void;
  6044. private _addCheckInputs;
  6045. /**
  6046. * Attach the input controls to the currently attached dom element to listen the events from.
  6047. * @param input Defines the input to attach
  6048. */
  6049. attachInput(input: ICameraInput<TCamera>): void;
  6050. /**
  6051. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6052. * @param element Defines the dom element to collect the events from
  6053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6054. */
  6055. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6056. /**
  6057. * Detach the current manager inputs controls from a specific dom element.
  6058. * @param element Defines the dom element to collect the events from
  6059. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6060. */
  6061. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6062. /**
  6063. * Rebuild the dynamic inputCheck function from the current list of
  6064. * defined inputs in the manager.
  6065. */
  6066. rebuildInputCheck(): void;
  6067. /**
  6068. * Remove all attached input methods from a camera
  6069. */
  6070. clear(): void;
  6071. /**
  6072. * Serialize the current input manager attached to a camera.
  6073. * This ensures than once parsed,
  6074. * the input associated to the camera will be identical to the current ones
  6075. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6076. */
  6077. serialize(serializedCamera: any): void;
  6078. /**
  6079. * Parses an input manager serialized JSON to restore the previous list of inputs
  6080. * and states associated to a camera.
  6081. * @param parsedCamera Defines the JSON to parse
  6082. */
  6083. parse(parsedCamera: any): void;
  6084. }
  6085. }
  6086. declare module "babylonjs/Meshes/buffer" {
  6087. import { Nullable, DataArray } from "babylonjs/types";
  6088. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6089. /**
  6090. * Class used to store data that will be store in GPU memory
  6091. */
  6092. export class Buffer {
  6093. private _engine;
  6094. private _buffer;
  6095. /** @hidden */
  6096. _data: Nullable<DataArray>;
  6097. private _updatable;
  6098. private _instanced;
  6099. private _divisor;
  6100. /**
  6101. * Gets the byte stride.
  6102. */
  6103. readonly byteStride: number;
  6104. /**
  6105. * Constructor
  6106. * @param engine the engine
  6107. * @param data the data to use for this buffer
  6108. * @param updatable whether the data is updatable
  6109. * @param stride the stride (optional)
  6110. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6111. * @param instanced whether the buffer is instanced (optional)
  6112. * @param useBytes set to true if the stride in in bytes (optional)
  6113. * @param divisor sets an optional divisor for instances (1 by default)
  6114. */
  6115. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6116. /**
  6117. * Create a new VertexBuffer based on the current buffer
  6118. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6119. * @param offset defines offset in the buffer (0 by default)
  6120. * @param size defines the size in floats of attributes (position is 3 for instance)
  6121. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6122. * @param instanced defines if the vertex buffer contains indexed data
  6123. * @param useBytes defines if the offset and stride are in bytes *
  6124. * @param divisor sets an optional divisor for instances (1 by default)
  6125. * @returns the new vertex buffer
  6126. */
  6127. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6128. /**
  6129. * Gets a boolean indicating if the Buffer is updatable?
  6130. * @returns true if the buffer is updatable
  6131. */
  6132. isUpdatable(): boolean;
  6133. /**
  6134. * Gets current buffer's data
  6135. * @returns a DataArray or null
  6136. */
  6137. getData(): Nullable<DataArray>;
  6138. /**
  6139. * Gets underlying native buffer
  6140. * @returns underlying native buffer
  6141. */
  6142. getBuffer(): Nullable<DataBuffer>;
  6143. /**
  6144. * Gets the stride in float32 units (i.e. byte stride / 4).
  6145. * May not be an integer if the byte stride is not divisible by 4.
  6146. * DEPRECATED. Use byteStride instead.
  6147. * @returns the stride in float32 units
  6148. */
  6149. getStrideSize(): number;
  6150. /**
  6151. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6152. * @param data defines the data to store
  6153. */
  6154. create(data?: Nullable<DataArray>): void;
  6155. /** @hidden */
  6156. _rebuild(): void;
  6157. /**
  6158. * Update current buffer data
  6159. * @param data defines the data to store
  6160. */
  6161. update(data: DataArray): void;
  6162. /**
  6163. * Updates the data directly.
  6164. * @param data the new data
  6165. * @param offset the new offset
  6166. * @param vertexCount the vertex count (optional)
  6167. * @param useBytes set to true if the offset is in bytes
  6168. */
  6169. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6170. /**
  6171. * Release all resources
  6172. */
  6173. dispose(): void;
  6174. }
  6175. /**
  6176. * Specialized buffer used to store vertex data
  6177. */
  6178. export class VertexBuffer {
  6179. /** @hidden */
  6180. _buffer: Buffer;
  6181. private _kind;
  6182. private _size;
  6183. private _ownsBuffer;
  6184. private _instanced;
  6185. private _instanceDivisor;
  6186. /**
  6187. * The byte type.
  6188. */
  6189. static readonly BYTE: number;
  6190. /**
  6191. * The unsigned byte type.
  6192. */
  6193. static readonly UNSIGNED_BYTE: number;
  6194. /**
  6195. * The short type.
  6196. */
  6197. static readonly SHORT: number;
  6198. /**
  6199. * The unsigned short type.
  6200. */
  6201. static readonly UNSIGNED_SHORT: number;
  6202. /**
  6203. * The integer type.
  6204. */
  6205. static readonly INT: number;
  6206. /**
  6207. * The unsigned integer type.
  6208. */
  6209. static readonly UNSIGNED_INT: number;
  6210. /**
  6211. * The float type.
  6212. */
  6213. static readonly FLOAT: number;
  6214. /**
  6215. * Gets or sets the instance divisor when in instanced mode
  6216. */
  6217. instanceDivisor: number;
  6218. /**
  6219. * Gets the byte stride.
  6220. */
  6221. readonly byteStride: number;
  6222. /**
  6223. * Gets the byte offset.
  6224. */
  6225. readonly byteOffset: number;
  6226. /**
  6227. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6228. */
  6229. readonly normalized: boolean;
  6230. /**
  6231. * Gets the data type of each component in the array.
  6232. */
  6233. readonly type: number;
  6234. /**
  6235. * Constructor
  6236. * @param engine the engine
  6237. * @param data the data to use for this vertex buffer
  6238. * @param kind the vertex buffer kind
  6239. * @param updatable whether the data is updatable
  6240. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6241. * @param stride the stride (optional)
  6242. * @param instanced whether the buffer is instanced (optional)
  6243. * @param offset the offset of the data (optional)
  6244. * @param size the number of components (optional)
  6245. * @param type the type of the component (optional)
  6246. * @param normalized whether the data contains normalized data (optional)
  6247. * @param useBytes set to true if stride and offset are in bytes (optional)
  6248. * @param divisor defines the instance divisor to use (1 by default)
  6249. */
  6250. 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);
  6251. /** @hidden */
  6252. _rebuild(): void;
  6253. /**
  6254. * Returns the kind of the VertexBuffer (string)
  6255. * @returns a string
  6256. */
  6257. getKind(): string;
  6258. /**
  6259. * Gets a boolean indicating if the VertexBuffer is updatable?
  6260. * @returns true if the buffer is updatable
  6261. */
  6262. isUpdatable(): boolean;
  6263. /**
  6264. * Gets current buffer's data
  6265. * @returns a DataArray or null
  6266. */
  6267. getData(): Nullable<DataArray>;
  6268. /**
  6269. * Gets underlying native buffer
  6270. * @returns underlying native buffer
  6271. */
  6272. getBuffer(): Nullable<DataBuffer>;
  6273. /**
  6274. * Gets the stride in float32 units (i.e. byte stride / 4).
  6275. * May not be an integer if the byte stride is not divisible by 4.
  6276. * DEPRECATED. Use byteStride instead.
  6277. * @returns the stride in float32 units
  6278. */
  6279. getStrideSize(): number;
  6280. /**
  6281. * Returns the offset as a multiple of the type byte length.
  6282. * DEPRECATED. Use byteOffset instead.
  6283. * @returns the offset in bytes
  6284. */
  6285. getOffset(): number;
  6286. /**
  6287. * Returns the number of components per vertex attribute (integer)
  6288. * @returns the size in float
  6289. */
  6290. getSize(): number;
  6291. /**
  6292. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6293. * @returns true if this buffer is instanced
  6294. */
  6295. getIsInstanced(): boolean;
  6296. /**
  6297. * Returns the instancing divisor, zero for non-instanced (integer).
  6298. * @returns a number
  6299. */
  6300. getInstanceDivisor(): number;
  6301. /**
  6302. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6303. * @param data defines the data to store
  6304. */
  6305. create(data?: DataArray): void;
  6306. /**
  6307. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6308. * This function will create a new buffer if the current one is not updatable
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6314. * Returns the directly updated WebGLBuffer.
  6315. * @param data the new data
  6316. * @param offset the new offset
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6320. /**
  6321. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6322. */
  6323. dispose(): void;
  6324. /**
  6325. * Enumerates each value of this vertex buffer as numbers.
  6326. * @param count the number of values to enumerate
  6327. * @param callback the callback function called for each value
  6328. */
  6329. forEach(count: number, callback: (value: number, index: number) => void): void;
  6330. /**
  6331. * Positions
  6332. */
  6333. static readonly PositionKind: string;
  6334. /**
  6335. * Normals
  6336. */
  6337. static readonly NormalKind: string;
  6338. /**
  6339. * Tangents
  6340. */
  6341. static readonly TangentKind: string;
  6342. /**
  6343. * Texture coordinates
  6344. */
  6345. static readonly UVKind: string;
  6346. /**
  6347. * Texture coordinates 2
  6348. */
  6349. static readonly UV2Kind: string;
  6350. /**
  6351. * Texture coordinates 3
  6352. */
  6353. static readonly UV3Kind: string;
  6354. /**
  6355. * Texture coordinates 4
  6356. */
  6357. static readonly UV4Kind: string;
  6358. /**
  6359. * Texture coordinates 5
  6360. */
  6361. static readonly UV5Kind: string;
  6362. /**
  6363. * Texture coordinates 6
  6364. */
  6365. static readonly UV6Kind: string;
  6366. /**
  6367. * Colors
  6368. */
  6369. static readonly ColorKind: string;
  6370. /**
  6371. * Matrix indices (for bones)
  6372. */
  6373. static readonly MatricesIndicesKind: string;
  6374. /**
  6375. * Matrix weights (for bones)
  6376. */
  6377. static readonly MatricesWeightsKind: string;
  6378. /**
  6379. * Additional matrix indices (for bones)
  6380. */
  6381. static readonly MatricesIndicesExtraKind: string;
  6382. /**
  6383. * Additional matrix weights (for bones)
  6384. */
  6385. static readonly MatricesWeightsExtraKind: string;
  6386. /**
  6387. * Deduces the stride given a kind.
  6388. * @param kind The kind string to deduce
  6389. * @returns The deduced stride
  6390. */
  6391. static DeduceStride(kind: string): number;
  6392. /**
  6393. * Gets the byte length of the given type.
  6394. * @param type the type
  6395. * @returns the number of bytes
  6396. */
  6397. static GetTypeByteLength(type: number): number;
  6398. /**
  6399. * Enumerates each value of the given parameters as numbers.
  6400. * @param data the data to enumerate
  6401. * @param byteOffset the byte offset of the data
  6402. * @param byteStride the byte stride of the data
  6403. * @param componentCount the number of components per element
  6404. * @param componentType the type of the component
  6405. * @param count the number of values to enumerate
  6406. * @param normalized whether the data is normalized
  6407. * @param callback the callback function called for each value
  6408. */
  6409. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6410. private static _GetFloatValue;
  6411. }
  6412. }
  6413. declare module "babylonjs/Collisions/intersectionInfo" {
  6414. import { Nullable } from "babylonjs/types";
  6415. /**
  6416. * @hidden
  6417. */
  6418. export class IntersectionInfo {
  6419. bu: Nullable<number>;
  6420. bv: Nullable<number>;
  6421. distance: number;
  6422. faceId: number;
  6423. subMeshId: number;
  6424. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6425. }
  6426. }
  6427. declare module "babylonjs/Maths/math.plane" {
  6428. import { DeepImmutable } from "babylonjs/types";
  6429. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6430. /**
  6431. * Represens a plane by the equation ax + by + cz + d = 0
  6432. */
  6433. export class Plane {
  6434. private static _TmpMatrix;
  6435. /**
  6436. * Normal of the plane (a,b,c)
  6437. */
  6438. normal: Vector3;
  6439. /**
  6440. * d component of the plane
  6441. */
  6442. d: number;
  6443. /**
  6444. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6445. * @param a a component of the plane
  6446. * @param b b component of the plane
  6447. * @param c c component of the plane
  6448. * @param d d component of the plane
  6449. */
  6450. constructor(a: number, b: number, c: number, d: number);
  6451. /**
  6452. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6453. */
  6454. asArray(): number[];
  6455. /**
  6456. * @returns a new plane copied from the current Plane.
  6457. */
  6458. clone(): Plane;
  6459. /**
  6460. * @returns the string "Plane".
  6461. */
  6462. getClassName(): string;
  6463. /**
  6464. * @returns the Plane hash code.
  6465. */
  6466. getHashCode(): number;
  6467. /**
  6468. * Normalize the current Plane in place.
  6469. * @returns the updated Plane.
  6470. */
  6471. normalize(): Plane;
  6472. /**
  6473. * Applies a transformation the plane and returns the result
  6474. * @param transformation the transformation matrix to be applied to the plane
  6475. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6476. */
  6477. transform(transformation: DeepImmutable<Matrix>): Plane;
  6478. /**
  6479. * Calcualtte the dot product between the point and the plane normal
  6480. * @param point point to calculate the dot product with
  6481. * @returns the dot product (float) of the point coordinates and the plane normal.
  6482. */
  6483. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6484. /**
  6485. * Updates the current Plane from the plane defined by the three given points.
  6486. * @param point1 one of the points used to contruct the plane
  6487. * @param point2 one of the points used to contruct the plane
  6488. * @param point3 one of the points used to contruct the plane
  6489. * @returns the updated Plane.
  6490. */
  6491. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6492. /**
  6493. * Checks if the plane is facing a given direction
  6494. * @param direction the direction to check if the plane is facing
  6495. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6496. * @returns True is the vector "direction" is the same side than the plane normal.
  6497. */
  6498. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6499. /**
  6500. * Calculates the distance to a point
  6501. * @param point point to calculate distance to
  6502. * @returns the signed distance (float) from the given point to the Plane.
  6503. */
  6504. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6505. /**
  6506. * Creates a plane from an array
  6507. * @param array the array to create a plane from
  6508. * @returns a new Plane from the given array.
  6509. */
  6510. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6511. /**
  6512. * Creates a plane from three points
  6513. * @param point1 point used to create the plane
  6514. * @param point2 point used to create the plane
  6515. * @param point3 point used to create the plane
  6516. * @returns a new Plane defined by the three given points.
  6517. */
  6518. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6519. /**
  6520. * Creates a plane from an origin point and a normal
  6521. * @param origin origin of the plane to be constructed
  6522. * @param normal normal of the plane to be constructed
  6523. * @returns a new Plane the normal vector to this plane at the given origin point.
  6524. * Note : the vector "normal" is updated because normalized.
  6525. */
  6526. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6527. /**
  6528. * Calculates the distance from a plane and a point
  6529. * @param origin origin of the plane to be constructed
  6530. * @param normal normal of the plane to be constructed
  6531. * @param point point to calculate distance to
  6532. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6533. */
  6534. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6535. }
  6536. }
  6537. declare module "babylonjs/Culling/boundingSphere" {
  6538. import { DeepImmutable } from "babylonjs/types";
  6539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6540. import { Plane } from "babylonjs/Maths/math.plane";
  6541. /**
  6542. * Class used to store bounding sphere information
  6543. */
  6544. export class BoundingSphere {
  6545. /**
  6546. * Gets the center of the bounding sphere in local space
  6547. */
  6548. readonly center: Vector3;
  6549. /**
  6550. * Radius of the bounding sphere in local space
  6551. */
  6552. radius: number;
  6553. /**
  6554. * Gets the center of the bounding sphere in world space
  6555. */
  6556. readonly centerWorld: Vector3;
  6557. /**
  6558. * Radius of the bounding sphere in world space
  6559. */
  6560. radiusWorld: number;
  6561. /**
  6562. * Gets the minimum vector in local space
  6563. */
  6564. readonly minimum: Vector3;
  6565. /**
  6566. * Gets the maximum vector in local space
  6567. */
  6568. readonly maximum: Vector3;
  6569. private _worldMatrix;
  6570. private static readonly TmpVector3;
  6571. /**
  6572. * Creates a new bounding sphere
  6573. * @param min defines the minimum vector (in local space)
  6574. * @param max defines the maximum vector (in local space)
  6575. * @param worldMatrix defines the new world matrix
  6576. */
  6577. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6578. /**
  6579. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6580. * @param min defines the new minimum vector (in local space)
  6581. * @param max defines the new maximum vector (in local space)
  6582. * @param worldMatrix defines the new world matrix
  6583. */
  6584. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6585. /**
  6586. * Scale the current bounding sphere by applying a scale factor
  6587. * @param factor defines the scale factor to apply
  6588. * @returns the current bounding box
  6589. */
  6590. scale(factor: number): BoundingSphere;
  6591. /**
  6592. * Gets the world matrix of the bounding box
  6593. * @returns a matrix
  6594. */
  6595. getWorldMatrix(): DeepImmutable<Matrix>;
  6596. /** @hidden */
  6597. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6598. /**
  6599. * Tests if the bounding sphere is intersecting the frustum planes
  6600. * @param frustumPlanes defines the frustum planes to test
  6601. * @returns true if there is an intersection
  6602. */
  6603. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6604. /**
  6605. * Tests if the bounding sphere center is in between the frustum planes.
  6606. * Used for optimistic fast inclusion.
  6607. * @param frustumPlanes defines the frustum planes to test
  6608. * @returns true if the sphere center is in between the frustum planes
  6609. */
  6610. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6611. /**
  6612. * Tests if a point is inside the bounding sphere
  6613. * @param point defines the point to test
  6614. * @returns true if the point is inside the bounding sphere
  6615. */
  6616. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6617. /**
  6618. * Checks if two sphere intersct
  6619. * @param sphere0 sphere 0
  6620. * @param sphere1 sphere 1
  6621. * @returns true if the speres intersect
  6622. */
  6623. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6624. }
  6625. }
  6626. declare module "babylonjs/Culling/boundingBox" {
  6627. import { DeepImmutable } from "babylonjs/types";
  6628. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6629. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6630. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6631. import { Plane } from "babylonjs/Maths/math.plane";
  6632. /**
  6633. * Class used to store bounding box information
  6634. */
  6635. export class BoundingBox implements ICullable {
  6636. /**
  6637. * Gets the 8 vectors representing the bounding box in local space
  6638. */
  6639. readonly vectors: Vector3[];
  6640. /**
  6641. * Gets the center of the bounding box in local space
  6642. */
  6643. readonly center: Vector3;
  6644. /**
  6645. * Gets the center of the bounding box in world space
  6646. */
  6647. readonly centerWorld: Vector3;
  6648. /**
  6649. * Gets the extend size in local space
  6650. */
  6651. readonly extendSize: Vector3;
  6652. /**
  6653. * Gets the extend size in world space
  6654. */
  6655. readonly extendSizeWorld: Vector3;
  6656. /**
  6657. * Gets the OBB (object bounding box) directions
  6658. */
  6659. readonly directions: Vector3[];
  6660. /**
  6661. * Gets the 8 vectors representing the bounding box in world space
  6662. */
  6663. readonly vectorsWorld: Vector3[];
  6664. /**
  6665. * Gets the minimum vector in world space
  6666. */
  6667. readonly minimumWorld: Vector3;
  6668. /**
  6669. * Gets the maximum vector in world space
  6670. */
  6671. readonly maximumWorld: Vector3;
  6672. /**
  6673. * Gets the minimum vector in local space
  6674. */
  6675. readonly minimum: Vector3;
  6676. /**
  6677. * Gets the maximum vector in local space
  6678. */
  6679. readonly maximum: Vector3;
  6680. private _worldMatrix;
  6681. private static readonly TmpVector3;
  6682. /**
  6683. * @hidden
  6684. */
  6685. _tag: number;
  6686. /**
  6687. * Creates a new bounding box
  6688. * @param min defines the minimum vector (in local space)
  6689. * @param max defines the maximum vector (in local space)
  6690. * @param worldMatrix defines the new world matrix
  6691. */
  6692. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6693. /**
  6694. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6695. * @param min defines the new minimum vector (in local space)
  6696. * @param max defines the new maximum vector (in local space)
  6697. * @param worldMatrix defines the new world matrix
  6698. */
  6699. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6700. /**
  6701. * Scale the current bounding box by applying a scale factor
  6702. * @param factor defines the scale factor to apply
  6703. * @returns the current bounding box
  6704. */
  6705. scale(factor: number): BoundingBox;
  6706. /**
  6707. * Gets the world matrix of the bounding box
  6708. * @returns a matrix
  6709. */
  6710. getWorldMatrix(): DeepImmutable<Matrix>;
  6711. /** @hidden */
  6712. _update(world: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Tests if the bounding box is intersecting the frustum planes
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @returns true if there is an intersection
  6717. */
  6718. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if the bounding box is entirely inside the frustum planes
  6721. * @param frustumPlanes defines the frustum planes to test
  6722. * @returns true if there is an inclusion
  6723. */
  6724. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6725. /**
  6726. * Tests if a point is inside the bounding box
  6727. * @param point defines the point to test
  6728. * @returns true if the point is inside the bounding box
  6729. */
  6730. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6731. /**
  6732. * Tests if the bounding box intersects with a bounding sphere
  6733. * @param sphere defines the sphere to test
  6734. * @returns true if there is an intersection
  6735. */
  6736. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6737. /**
  6738. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6739. * @param min defines the min vector to use
  6740. * @param max defines the max vector to use
  6741. * @returns true if there is an intersection
  6742. */
  6743. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6744. /**
  6745. * Tests if two bounding boxes are intersections
  6746. * @param box0 defines the first box to test
  6747. * @param box1 defines the second box to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6751. /**
  6752. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6753. * @param minPoint defines the minimum vector of the bounding box
  6754. * @param maxPoint defines the maximum vector of the bounding box
  6755. * @param sphereCenter defines the sphere center
  6756. * @param sphereRadius defines the sphere radius
  6757. * @returns true if there is an intersection
  6758. */
  6759. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6760. /**
  6761. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6762. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6763. * @param frustumPlanes defines the frustum planes to test
  6764. * @return true if there is an inclusion
  6765. */
  6766. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6767. /**
  6768. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6769. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6770. * @param frustumPlanes defines the frustum planes to test
  6771. * @return true if there is an intersection
  6772. */
  6773. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/collider" {
  6777. import { Nullable, IndicesArray } from "babylonjs/types";
  6778. import { Vector3 } from "babylonjs/Maths/math.vector";
  6779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /** @hidden */
  6782. export class Collider {
  6783. /** Define if a collision was found */
  6784. collisionFound: boolean;
  6785. /**
  6786. * Define last intersection point in local space
  6787. */
  6788. intersectionPoint: Vector3;
  6789. /**
  6790. * Define last collided mesh
  6791. */
  6792. collidedMesh: Nullable<AbstractMesh>;
  6793. private _collisionPoint;
  6794. private _planeIntersectionPoint;
  6795. private _tempVector;
  6796. private _tempVector2;
  6797. private _tempVector3;
  6798. private _tempVector4;
  6799. private _edge;
  6800. private _baseToVertex;
  6801. private _destinationPoint;
  6802. private _slidePlaneNormal;
  6803. private _displacementVector;
  6804. /** @hidden */
  6805. _radius: Vector3;
  6806. /** @hidden */
  6807. _retry: number;
  6808. private _velocity;
  6809. private _basePoint;
  6810. private _epsilon;
  6811. /** @hidden */
  6812. _velocityWorldLength: number;
  6813. /** @hidden */
  6814. _basePointWorld: Vector3;
  6815. private _velocityWorld;
  6816. private _normalizedVelocity;
  6817. /** @hidden */
  6818. _initialVelocity: Vector3;
  6819. /** @hidden */
  6820. _initialPosition: Vector3;
  6821. private _nearestDistance;
  6822. private _collisionMask;
  6823. collisionMask: number;
  6824. /**
  6825. * Gets the plane normal used to compute the sliding response (in local space)
  6826. */
  6827. readonly slidePlaneNormal: Vector3;
  6828. /** @hidden */
  6829. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6830. /** @hidden */
  6831. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6832. /** @hidden */
  6833. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6834. /** @hidden */
  6835. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6838. /** @hidden */
  6839. _getResponse(pos: Vector3, vel: Vector3): void;
  6840. }
  6841. }
  6842. declare module "babylonjs/Culling/boundingInfo" {
  6843. import { DeepImmutable } from "babylonjs/types";
  6844. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6845. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6846. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6847. import { Plane } from "babylonjs/Maths/math.plane";
  6848. import { Collider } from "babylonjs/Collisions/collider";
  6849. /**
  6850. * Interface for cullable objects
  6851. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6852. */
  6853. export interface ICullable {
  6854. /**
  6855. * Checks if the object or part of the object is in the frustum
  6856. * @param frustumPlanes Camera near/planes
  6857. * @returns true if the object is in frustum otherwise false
  6858. */
  6859. isInFrustum(frustumPlanes: Plane[]): boolean;
  6860. /**
  6861. * Checks if a cullable object (mesh...) is in the camera frustum
  6862. * Unlike isInFrustum this cheks the full bounding box
  6863. * @param frustumPlanes Camera near/planes
  6864. * @returns true if the object is in frustum otherwise false
  6865. */
  6866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6867. }
  6868. /**
  6869. * Info for a bounding data of a mesh
  6870. */
  6871. export class BoundingInfo implements ICullable {
  6872. /**
  6873. * Bounding box for the mesh
  6874. */
  6875. readonly boundingBox: BoundingBox;
  6876. /**
  6877. * Bounding sphere for the mesh
  6878. */
  6879. readonly boundingSphere: BoundingSphere;
  6880. private _isLocked;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Constructs bounding info
  6884. * @param minimum min vector of the bounding box/sphere
  6885. * @param maximum max vector of the bounding box/sphere
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * min vector of the bounding box/sphere
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * max vector of the bounding box/sphere
  6902. */
  6903. readonly maximum: Vector3;
  6904. /**
  6905. * If the info is locked and won't be updated to avoid perf overhead
  6906. */
  6907. isLocked: boolean;
  6908. /**
  6909. * Updates the bounding sphere and box
  6910. * @param world world matrix to be used to update
  6911. */
  6912. update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6915. * @param center New center of the bounding info
  6916. * @param extend New extend of the bounding info
  6917. * @returns the current bounding info
  6918. */
  6919. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6920. /**
  6921. * Scale the current bounding info by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding info
  6924. */
  6925. scale(factor: number): BoundingInfo;
  6926. /**
  6927. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6928. * @param frustumPlanes defines the frustum to test
  6929. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6930. * @returns true if the bounding info is in the frustum planes
  6931. */
  6932. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6933. /**
  6934. * Gets the world distance between the min and max points of the bounding box
  6935. */
  6936. readonly diagonalLength: number;
  6937. /**
  6938. * Checks if a cullable object (mesh...) is in the camera frustum
  6939. * Unlike isInFrustum this cheks the full bounding box
  6940. * @param frustumPlanes Camera near/planes
  6941. * @returns true if the object is in frustum otherwise false
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /** @hidden */
  6945. _checkCollision(collider: Collider): boolean;
  6946. /**
  6947. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6948. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6949. * @param point the point to check intersection with
  6950. * @returns if the point intersects
  6951. */
  6952. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6953. /**
  6954. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6955. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6956. * @param boundingInfo the bounding info to check intersection with
  6957. * @param precise if the intersection should be done using OBB
  6958. * @returns if the bounding info intersects
  6959. */
  6960. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6961. }
  6962. }
  6963. declare module "babylonjs/Maths/math.functions" {
  6964. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6965. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6966. /**
  6967. * Extracts minimum and maximum values from a list of indexed positions
  6968. * @param positions defines the positions to use
  6969. * @param indices defines the indices to the positions
  6970. * @param indexStart defines the start index
  6971. * @param indexCount defines the end index
  6972. * @param bias defines bias value to add to the result
  6973. * @return minimum and maximum values
  6974. */
  6975. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6976. minimum: Vector3;
  6977. maximum: Vector3;
  6978. };
  6979. /**
  6980. * Extracts minimum and maximum values from a list of positions
  6981. * @param positions defines the positions to use
  6982. * @param start defines the start index in the positions array
  6983. * @param count defines the number of positions to handle
  6984. * @param bias defines bias value to add to the result
  6985. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6986. * @return minimum and maximum values
  6987. */
  6988. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6989. minimum: Vector3;
  6990. maximum: Vector3;
  6991. };
  6992. }
  6993. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6994. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6995. /** @hidden */
  6996. export class WebGLDataBuffer extends DataBuffer {
  6997. private _buffer;
  6998. constructor(resource: WebGLBuffer);
  6999. readonly underlyingResource: any;
  7000. }
  7001. }
  7002. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7003. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7004. import { Nullable } from "babylonjs/types";
  7005. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7006. /** @hidden */
  7007. export class WebGLPipelineContext implements IPipelineContext {
  7008. engine: ThinEngine;
  7009. program: Nullable<WebGLProgram>;
  7010. context?: WebGLRenderingContext;
  7011. vertexShader?: WebGLShader;
  7012. fragmentShader?: WebGLShader;
  7013. isParallelCompiled: boolean;
  7014. onCompiled?: () => void;
  7015. transformFeedback?: WebGLTransformFeedback | null;
  7016. readonly isAsync: boolean;
  7017. readonly isReady: boolean;
  7018. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7019. }
  7020. }
  7021. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7022. import { FloatArray, Nullable } from "babylonjs/types";
  7023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7025. module "babylonjs/Engines/thinEngine" {
  7026. interface ThinEngine {
  7027. /**
  7028. * Create an uniform buffer
  7029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7030. * @param elements defines the content of the uniform buffer
  7031. * @returns the webGL uniform buffer
  7032. */
  7033. createUniformBuffer(elements: FloatArray): DataBuffer;
  7034. /**
  7035. * Create a dynamic uniform buffer
  7036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7037. * @param elements defines the content of the uniform buffer
  7038. * @returns the webGL uniform buffer
  7039. */
  7040. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7041. /**
  7042. * Update an existing uniform buffer
  7043. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7044. * @param uniformBuffer defines the target uniform buffer
  7045. * @param elements defines the content to update
  7046. * @param offset defines the offset in the uniform buffer where update should start
  7047. * @param count defines the size of the data to update
  7048. */
  7049. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7050. /**
  7051. * Bind an uniform buffer to the current webGL context
  7052. * @param buffer defines the buffer to bind
  7053. */
  7054. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7055. /**
  7056. * Bind a buffer to the current webGL context at a given location
  7057. * @param buffer defines the buffer to bind
  7058. * @param location defines the index where to bind the buffer
  7059. */
  7060. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7061. /**
  7062. * Bind a specific block at a given index in a specific shader program
  7063. * @param pipelineContext defines the pipeline context to use
  7064. * @param blockName defines the block name
  7065. * @param index defines the index where to bind the block
  7066. */
  7067. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7068. }
  7069. }
  7070. }
  7071. declare module "babylonjs/Materials/uniformBuffer" {
  7072. import { Nullable, FloatArray } from "babylonjs/types";
  7073. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7074. import { Engine } from "babylonjs/Engines/engine";
  7075. import { Effect } from "babylonjs/Materials/effect";
  7076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7078. import { Color3 } from "babylonjs/Maths/math.color";
  7079. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7080. /**
  7081. * Uniform buffer objects.
  7082. *
  7083. * Handles blocks of uniform on the GPU.
  7084. *
  7085. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7086. *
  7087. * For more information, please refer to :
  7088. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7089. */
  7090. export class UniformBuffer {
  7091. private _engine;
  7092. private _buffer;
  7093. private _data;
  7094. private _bufferData;
  7095. private _dynamic?;
  7096. private _uniformLocations;
  7097. private _uniformSizes;
  7098. private _uniformLocationPointer;
  7099. private _needSync;
  7100. private _noUBO;
  7101. private _currentEffect;
  7102. /** @hidden */
  7103. _alreadyBound: boolean;
  7104. private static _MAX_UNIFORM_SIZE;
  7105. private static _tempBuffer;
  7106. /**
  7107. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7108. * This is dynamic to allow compat with webgl 1 and 2.
  7109. * You will need to pass the name of the uniform as well as the value.
  7110. */
  7111. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7112. /**
  7113. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7114. * This is dynamic to allow compat with webgl 1 and 2.
  7115. * You will need to pass the name of the uniform as well as the value.
  7116. */
  7117. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7118. /**
  7119. * Lambda to Update a single float in a uniform buffer.
  7120. * This is dynamic to allow compat with webgl 1 and 2.
  7121. * You will need to pass the name of the uniform as well as the value.
  7122. */
  7123. updateFloat: (name: string, x: number) => void;
  7124. /**
  7125. * Lambda to Update a vec2 of float in a uniform buffer.
  7126. * This is dynamic to allow compat with webgl 1 and 2.
  7127. * You will need to pass the name of the uniform as well as the value.
  7128. */
  7129. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7130. /**
  7131. * Lambda to Update a vec3 of float in a uniform buffer.
  7132. * This is dynamic to allow compat with webgl 1 and 2.
  7133. * You will need to pass the name of the uniform as well as the value.
  7134. */
  7135. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7136. /**
  7137. * Lambda to Update a vec4 of float in a uniform buffer.
  7138. * This is dynamic to allow compat with webgl 1 and 2.
  7139. * You will need to pass the name of the uniform as well as the value.
  7140. */
  7141. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7142. /**
  7143. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7144. * This is dynamic to allow compat with webgl 1 and 2.
  7145. * You will need to pass the name of the uniform as well as the value.
  7146. */
  7147. updateMatrix: (name: string, mat: Matrix) => void;
  7148. /**
  7149. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7150. * This is dynamic to allow compat with webgl 1 and 2.
  7151. * You will need to pass the name of the uniform as well as the value.
  7152. */
  7153. updateVector3: (name: string, vector: Vector3) => void;
  7154. /**
  7155. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7156. * This is dynamic to allow compat with webgl 1 and 2.
  7157. * You will need to pass the name of the uniform as well as the value.
  7158. */
  7159. updateVector4: (name: string, vector: Vector4) => void;
  7160. /**
  7161. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7162. * This is dynamic to allow compat with webgl 1 and 2.
  7163. * You will need to pass the name of the uniform as well as the value.
  7164. */
  7165. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7166. /**
  7167. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7168. * This is dynamic to allow compat with webgl 1 and 2.
  7169. * You will need to pass the name of the uniform as well as the value.
  7170. */
  7171. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7172. /**
  7173. * Instantiates a new Uniform buffer objects.
  7174. *
  7175. * Handles blocks of uniform on the GPU.
  7176. *
  7177. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7178. *
  7179. * For more information, please refer to :
  7180. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7181. * @param engine Define the engine the buffer is associated with
  7182. * @param data Define the data contained in the buffer
  7183. * @param dynamic Define if the buffer is updatable
  7184. */
  7185. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7186. /**
  7187. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7188. * or just falling back on setUniformXXX calls.
  7189. */
  7190. readonly useUbo: boolean;
  7191. /**
  7192. * Indicates if the WebGL underlying uniform buffer is in sync
  7193. * with the javascript cache data.
  7194. */
  7195. readonly isSync: boolean;
  7196. /**
  7197. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7198. * Also, a dynamic UniformBuffer will disable cache verification and always
  7199. * update the underlying WebGL uniform buffer to the GPU.
  7200. * @returns if Dynamic, otherwise false
  7201. */
  7202. isDynamic(): boolean;
  7203. /**
  7204. * The data cache on JS side.
  7205. * @returns the underlying data as a float array
  7206. */
  7207. getData(): Float32Array;
  7208. /**
  7209. * The underlying WebGL Uniform buffer.
  7210. * @returns the webgl buffer
  7211. */
  7212. getBuffer(): Nullable<DataBuffer>;
  7213. /**
  7214. * std140 layout specifies how to align data within an UBO structure.
  7215. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7216. * for specs.
  7217. */
  7218. private _fillAlignment;
  7219. /**
  7220. * Adds an uniform in the buffer.
  7221. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7222. * for the layout to be correct !
  7223. * @param name Name of the uniform, as used in the uniform block in the shader.
  7224. * @param size Data size, or data directly.
  7225. */
  7226. addUniform(name: string, size: number | number[]): void;
  7227. /**
  7228. * Adds a Matrix 4x4 to the uniform buffer.
  7229. * @param name Name of the uniform, as used in the uniform block in the shader.
  7230. * @param mat A 4x4 matrix.
  7231. */
  7232. addMatrix(name: string, mat: Matrix): void;
  7233. /**
  7234. * Adds a vec2 to the uniform buffer.
  7235. * @param name Name of the uniform, as used in the uniform block in the shader.
  7236. * @param x Define the x component value of the vec2
  7237. * @param y Define the y component value of the vec2
  7238. */
  7239. addFloat2(name: string, x: number, y: number): void;
  7240. /**
  7241. * Adds a vec3 to the uniform buffer.
  7242. * @param name Name of the uniform, as used in the uniform block in the shader.
  7243. * @param x Define the x component value of the vec3
  7244. * @param y Define the y component value of the vec3
  7245. * @param z Define the z component value of the vec3
  7246. */
  7247. addFloat3(name: string, x: number, y: number, z: number): void;
  7248. /**
  7249. * Adds a vec3 to the uniform buffer.
  7250. * @param name Name of the uniform, as used in the uniform block in the shader.
  7251. * @param color Define the vec3 from a Color
  7252. */
  7253. addColor3(name: string, color: Color3): void;
  7254. /**
  7255. * Adds a vec4 to the uniform buffer.
  7256. * @param name Name of the uniform, as used in the uniform block in the shader.
  7257. * @param color Define the rgb components from a Color
  7258. * @param alpha Define the a component of the vec4
  7259. */
  7260. addColor4(name: string, color: Color3, alpha: number): void;
  7261. /**
  7262. * Adds a vec3 to the uniform buffer.
  7263. * @param name Name of the uniform, as used in the uniform block in the shader.
  7264. * @param vector Define the vec3 components from a Vector
  7265. */
  7266. addVector3(name: string, vector: Vector3): void;
  7267. /**
  7268. * Adds a Matrix 3x3 to the uniform buffer.
  7269. * @param name Name of the uniform, as used in the uniform block in the shader.
  7270. */
  7271. addMatrix3x3(name: string): void;
  7272. /**
  7273. * Adds a Matrix 2x2 to the uniform buffer.
  7274. * @param name Name of the uniform, as used in the uniform block in the shader.
  7275. */
  7276. addMatrix2x2(name: string): void;
  7277. /**
  7278. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7279. */
  7280. create(): void;
  7281. /** @hidden */
  7282. _rebuild(): void;
  7283. /**
  7284. * Updates the WebGL Uniform Buffer on the GPU.
  7285. * If the `dynamic` flag is set to true, no cache comparison is done.
  7286. * Otherwise, the buffer will be updated only if the cache differs.
  7287. */
  7288. update(): void;
  7289. /**
  7290. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7291. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7292. * @param data Define the flattened data
  7293. * @param size Define the size of the data.
  7294. */
  7295. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7296. private _valueCache;
  7297. private _cacheMatrix;
  7298. private _updateMatrix3x3ForUniform;
  7299. private _updateMatrix3x3ForEffect;
  7300. private _updateMatrix2x2ForEffect;
  7301. private _updateMatrix2x2ForUniform;
  7302. private _updateFloatForEffect;
  7303. private _updateFloatForUniform;
  7304. private _updateFloat2ForEffect;
  7305. private _updateFloat2ForUniform;
  7306. private _updateFloat3ForEffect;
  7307. private _updateFloat3ForUniform;
  7308. private _updateFloat4ForEffect;
  7309. private _updateFloat4ForUniform;
  7310. private _updateMatrixForEffect;
  7311. private _updateMatrixForUniform;
  7312. private _updateVector3ForEffect;
  7313. private _updateVector3ForUniform;
  7314. private _updateVector4ForEffect;
  7315. private _updateVector4ForUniform;
  7316. private _updateColor3ForEffect;
  7317. private _updateColor3ForUniform;
  7318. private _updateColor4ForEffect;
  7319. private _updateColor4ForUniform;
  7320. /**
  7321. * Sets a sampler uniform on the effect.
  7322. * @param name Define the name of the sampler.
  7323. * @param texture Define the texture to set in the sampler
  7324. */
  7325. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7326. /**
  7327. * Directly updates the value of the uniform in the cache AND on the GPU.
  7328. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7329. * @param data Define the flattened data
  7330. */
  7331. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7332. /**
  7333. * Binds this uniform buffer to an effect.
  7334. * @param effect Define the effect to bind the buffer to
  7335. * @param name Name of the uniform block in the shader.
  7336. */
  7337. bindToEffect(effect: Effect, name: string): void;
  7338. /**
  7339. * Disposes the uniform buffer.
  7340. */
  7341. dispose(): void;
  7342. }
  7343. }
  7344. declare module "babylonjs/Misc/iInspectable" {
  7345. /**
  7346. * Enum that determines the text-wrapping mode to use.
  7347. */
  7348. export enum InspectableType {
  7349. /**
  7350. * Checkbox for booleans
  7351. */
  7352. Checkbox = 0,
  7353. /**
  7354. * Sliders for numbers
  7355. */
  7356. Slider = 1,
  7357. /**
  7358. * Vector3
  7359. */
  7360. Vector3 = 2,
  7361. /**
  7362. * Quaternions
  7363. */
  7364. Quaternion = 3,
  7365. /**
  7366. * Color3
  7367. */
  7368. Color3 = 4,
  7369. /**
  7370. * String
  7371. */
  7372. String = 5
  7373. }
  7374. /**
  7375. * Interface used to define custom inspectable properties.
  7376. * This interface is used by the inspector to display custom property grids
  7377. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7378. */
  7379. export interface IInspectable {
  7380. /**
  7381. * Gets the label to display
  7382. */
  7383. label: string;
  7384. /**
  7385. * Gets the name of the property to edit
  7386. */
  7387. propertyName: string;
  7388. /**
  7389. * Gets the type of the editor to use
  7390. */
  7391. type: InspectableType;
  7392. /**
  7393. * Gets the minimum value of the property when using in "slider" mode
  7394. */
  7395. min?: number;
  7396. /**
  7397. * Gets the maximum value of the property when using in "slider" mode
  7398. */
  7399. max?: number;
  7400. /**
  7401. * Gets the setp to use when using in "slider" mode
  7402. */
  7403. step?: number;
  7404. }
  7405. }
  7406. declare module "babylonjs/Misc/timingTools" {
  7407. /**
  7408. * Class used to provide helper for timing
  7409. */
  7410. export class TimingTools {
  7411. /**
  7412. * Polyfill for setImmediate
  7413. * @param action defines the action to execute after the current execution block
  7414. */
  7415. static SetImmediate(action: () => void): void;
  7416. }
  7417. }
  7418. declare module "babylonjs/Misc/instantiationTools" {
  7419. /**
  7420. * Class used to enable instatition of objects by class name
  7421. */
  7422. export class InstantiationTools {
  7423. /**
  7424. * Use this object to register external classes like custom textures or material
  7425. * to allow the laoders to instantiate them
  7426. */
  7427. static RegisteredExternalClasses: {
  7428. [key: string]: Object;
  7429. };
  7430. /**
  7431. * Tries to instantiate a new object from a given class name
  7432. * @param className defines the class name to instantiate
  7433. * @returns the new object or null if the system was not able to do the instantiation
  7434. */
  7435. static Instantiate(className: string): any;
  7436. }
  7437. }
  7438. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7439. /**
  7440. * Define options used to create a depth texture
  7441. */
  7442. export class DepthTextureCreationOptions {
  7443. /** Specifies whether or not a stencil should be allocated in the texture */
  7444. generateStencil?: boolean;
  7445. /** Specifies whether or not bilinear filtering is enable on the texture */
  7446. bilinearFiltering?: boolean;
  7447. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7448. comparisonFunction?: number;
  7449. /** Specifies if the created texture is a cube texture */
  7450. isCube?: boolean;
  7451. }
  7452. }
  7453. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7455. import { Nullable } from "babylonjs/types";
  7456. import { Scene } from "babylonjs/scene";
  7457. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7458. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7459. module "babylonjs/Engines/thinEngine" {
  7460. interface ThinEngine {
  7461. /**
  7462. * Creates a depth stencil cube texture.
  7463. * This is only available in WebGL 2.
  7464. * @param size The size of face edge in the cube texture.
  7465. * @param options The options defining the cube texture.
  7466. * @returns The cube texture
  7467. */
  7468. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7469. /**
  7470. * Creates a cube texture
  7471. * @param rootUrl defines the url where the files to load is located
  7472. * @param scene defines the current scene
  7473. * @param files defines the list of files to load (1 per face)
  7474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7475. * @param onLoad defines an optional callback raised when the texture is loaded
  7476. * @param onError defines an optional callback raised if there is an issue to load the texture
  7477. * @param format defines the format of the data
  7478. * @param forcedExtension defines the extension to use to pick the right loader
  7479. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7482. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7483. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7484. * @returns the cube texture as an InternalTexture
  7485. */
  7486. 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;
  7487. /**
  7488. * Creates a cube texture
  7489. * @param rootUrl defines the url where the files to load is located
  7490. * @param scene defines the current scene
  7491. * @param files defines the list of files to load (1 per face)
  7492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7493. * @param onLoad defines an optional callback raised when the texture is loaded
  7494. * @param onError defines an optional callback raised if there is an issue to load the texture
  7495. * @param format defines the format of the data
  7496. * @param forcedExtension defines the extension to use to pick the right loader
  7497. * @returns the cube texture as an InternalTexture
  7498. */
  7499. 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;
  7500. /**
  7501. * Creates a cube texture
  7502. * @param rootUrl defines the url where the files to load is located
  7503. * @param scene defines the current scene
  7504. * @param files defines the list of files to load (1 per face)
  7505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7506. * @param onLoad defines an optional callback raised when the texture is loaded
  7507. * @param onError defines an optional callback raised if there is an issue to load the texture
  7508. * @param format defines the format of the data
  7509. * @param forcedExtension defines the extension to use to pick the right loader
  7510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /** @hidden */
  7517. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7520. /** @hidden */
  7521. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7522. /** @hidden */
  7523. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7524. }
  7525. }
  7526. }
  7527. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7528. import { Nullable } from "babylonjs/types";
  7529. import { Scene } from "babylonjs/scene";
  7530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7532. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7533. /**
  7534. * Class for creating a cube texture
  7535. */
  7536. export class CubeTexture extends BaseTexture {
  7537. private _delayedOnLoad;
  7538. /**
  7539. * The url of the texture
  7540. */
  7541. url: string;
  7542. /**
  7543. * Gets or sets the center of the bounding box associated with the cube texture.
  7544. * It must define where the camera used to render the texture was set
  7545. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7546. */
  7547. boundingBoxPosition: Vector3;
  7548. private _boundingBoxSize;
  7549. /**
  7550. * Gets or sets the size of the bounding box associated with the cube texture
  7551. * When defined, the cubemap will switch to local mode
  7552. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7553. * @example https://www.babylonjs-playground.com/#RNASML
  7554. */
  7555. /**
  7556. * Returns the bounding box size
  7557. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7558. */
  7559. boundingBoxSize: Vector3;
  7560. protected _rotationY: number;
  7561. /**
  7562. * Sets texture matrix rotation angle around Y axis in radians.
  7563. */
  7564. /**
  7565. * Gets texture matrix rotation angle around Y axis radians.
  7566. */
  7567. rotationY: number;
  7568. /**
  7569. * Are mip maps generated for this texture or not.
  7570. */
  7571. readonly noMipmap: boolean;
  7572. private _noMipmap;
  7573. private _files;
  7574. protected _forcedExtension: Nullable<string>;
  7575. private _extensions;
  7576. private _textureMatrix;
  7577. private _format;
  7578. private _createPolynomials;
  7579. /** @hidden */
  7580. _prefiltered: boolean;
  7581. /**
  7582. * Creates a cube texture from an array of image urls
  7583. * @param files defines an array of image urls
  7584. * @param scene defines the hosting scene
  7585. * @param noMipmap specifies if mip maps are not used
  7586. * @returns a cube texture
  7587. */
  7588. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7589. /**
  7590. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7591. * @param url defines the url of the prefiltered texture
  7592. * @param scene defines the scene the texture is attached to
  7593. * @param forcedExtension defines the extension of the file if different from the url
  7594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7595. * @return the prefiltered texture
  7596. */
  7597. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7598. /**
  7599. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7600. * as prefiltered data.
  7601. * @param rootUrl defines the url of the texture or the root name of the six images
  7602. * @param scene defines the scene the texture is attached to
  7603. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7604. * @param noMipmap defines if mipmaps should be created or not
  7605. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7606. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7607. * @param onError defines a callback triggered in case of error during load
  7608. * @param format defines the internal format to use for the texture once loaded
  7609. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7610. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7611. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7614. * @return the cube texture
  7615. */
  7616. 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);
  7617. /**
  7618. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7619. */
  7620. readonly isPrefiltered: boolean;
  7621. /**
  7622. * Get the current class name of the texture useful for serialization or dynamic coding.
  7623. * @returns "CubeTexture"
  7624. */
  7625. getClassName(): string;
  7626. /**
  7627. * Update the url (and optional buffer) of this texture if url was null during construction.
  7628. * @param url the url of the texture
  7629. * @param forcedExtension defines the extension to use
  7630. * @param onLoad callback called when the texture is loaded (defaults to null)
  7631. */
  7632. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7633. /**
  7634. * Delays loading of the cube texture
  7635. * @param forcedExtension defines the extension to use
  7636. */
  7637. delayLoad(forcedExtension?: string): void;
  7638. /**
  7639. * Returns the reflection texture matrix
  7640. * @returns the reflection texture matrix
  7641. */
  7642. getReflectionTextureMatrix(): Matrix;
  7643. /**
  7644. * Sets the reflection texture matrix
  7645. * @param value Reflection texture matrix
  7646. */
  7647. setReflectionTextureMatrix(value: Matrix): void;
  7648. /**
  7649. * Parses text to create a cube texture
  7650. * @param parsedTexture define the serialized text to read from
  7651. * @param scene defines the hosting scene
  7652. * @param rootUrl defines the root url of the cube texture
  7653. * @returns a cube texture
  7654. */
  7655. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7656. /**
  7657. * Makes a clone, or deep copy, of the cube texture
  7658. * @returns a new cube texture
  7659. */
  7660. clone(): CubeTexture;
  7661. }
  7662. }
  7663. declare module "babylonjs/Materials/materialDefines" {
  7664. /**
  7665. * Manages the defines for the Material
  7666. */
  7667. export class MaterialDefines {
  7668. /** @hidden */
  7669. protected _keys: string[];
  7670. private _isDirty;
  7671. /** @hidden */
  7672. _renderId: number;
  7673. /** @hidden */
  7674. _areLightsDirty: boolean;
  7675. /** @hidden */
  7676. _areLightsDisposed: boolean;
  7677. /** @hidden */
  7678. _areAttributesDirty: boolean;
  7679. /** @hidden */
  7680. _areTexturesDirty: boolean;
  7681. /** @hidden */
  7682. _areFresnelDirty: boolean;
  7683. /** @hidden */
  7684. _areMiscDirty: boolean;
  7685. /** @hidden */
  7686. _areImageProcessingDirty: boolean;
  7687. /** @hidden */
  7688. _normals: boolean;
  7689. /** @hidden */
  7690. _uvs: boolean;
  7691. /** @hidden */
  7692. _needNormals: boolean;
  7693. /** @hidden */
  7694. _needUVs: boolean;
  7695. [id: string]: any;
  7696. /**
  7697. * Specifies if the material needs to be re-calculated
  7698. */
  7699. readonly isDirty: boolean;
  7700. /**
  7701. * Marks the material to indicate that it has been re-calculated
  7702. */
  7703. markAsProcessed(): void;
  7704. /**
  7705. * Marks the material to indicate that it needs to be re-calculated
  7706. */
  7707. markAsUnprocessed(): void;
  7708. /**
  7709. * Marks the material to indicate all of its defines need to be re-calculated
  7710. */
  7711. markAllAsDirty(): void;
  7712. /**
  7713. * Marks the material to indicate that image processing needs to be re-calculated
  7714. */
  7715. markAsImageProcessingDirty(): void;
  7716. /**
  7717. * Marks the material to indicate the lights need to be re-calculated
  7718. * @param disposed Defines whether the light is dirty due to dispose or not
  7719. */
  7720. markAsLightDirty(disposed?: boolean): void;
  7721. /**
  7722. * Marks the attribute state as changed
  7723. */
  7724. markAsAttributesDirty(): void;
  7725. /**
  7726. * Marks the texture state as changed
  7727. */
  7728. markAsTexturesDirty(): void;
  7729. /**
  7730. * Marks the fresnel state as changed
  7731. */
  7732. markAsFresnelDirty(): void;
  7733. /**
  7734. * Marks the misc state as changed
  7735. */
  7736. markAsMiscDirty(): void;
  7737. /**
  7738. * Rebuilds the material defines
  7739. */
  7740. rebuild(): void;
  7741. /**
  7742. * Specifies if two material defines are equal
  7743. * @param other - A material define instance to compare to
  7744. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7745. */
  7746. isEqual(other: MaterialDefines): boolean;
  7747. /**
  7748. * Clones this instance's defines to another instance
  7749. * @param other - material defines to clone values to
  7750. */
  7751. cloneTo(other: MaterialDefines): void;
  7752. /**
  7753. * Resets the material define values
  7754. */
  7755. reset(): void;
  7756. /**
  7757. * Converts the material define values to a string
  7758. * @returns - String of material define information
  7759. */
  7760. toString(): string;
  7761. }
  7762. }
  7763. declare module "babylonjs/Materials/colorCurves" {
  7764. import { Effect } from "babylonjs/Materials/effect";
  7765. /**
  7766. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7767. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7768. * 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;
  7769. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7770. */
  7771. export class ColorCurves {
  7772. private _dirty;
  7773. private _tempColor;
  7774. private _globalCurve;
  7775. private _highlightsCurve;
  7776. private _midtonesCurve;
  7777. private _shadowsCurve;
  7778. private _positiveCurve;
  7779. private _negativeCurve;
  7780. private _globalHue;
  7781. private _globalDensity;
  7782. private _globalSaturation;
  7783. private _globalExposure;
  7784. /**
  7785. * Gets the global Hue value.
  7786. * 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).
  7787. */
  7788. /**
  7789. * Sets the global Hue value.
  7790. * 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).
  7791. */
  7792. globalHue: number;
  7793. /**
  7794. * Gets the global Density value.
  7795. * 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.
  7796. * Values less than zero provide a filter of opposite hue.
  7797. */
  7798. /**
  7799. * Sets the global Density value.
  7800. * 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.
  7801. * Values less than zero provide a filter of opposite hue.
  7802. */
  7803. globalDensity: number;
  7804. /**
  7805. * Gets the global Saturation value.
  7806. * 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.
  7807. */
  7808. /**
  7809. * Sets the global Saturation value.
  7810. * 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.
  7811. */
  7812. globalSaturation: number;
  7813. /**
  7814. * Gets the global Exposure value.
  7815. * 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.
  7816. */
  7817. /**
  7818. * Sets the global Exposure value.
  7819. * 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.
  7820. */
  7821. globalExposure: number;
  7822. private _highlightsHue;
  7823. private _highlightsDensity;
  7824. private _highlightsSaturation;
  7825. private _highlightsExposure;
  7826. /**
  7827. * Gets the highlights Hue value.
  7828. * 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).
  7829. */
  7830. /**
  7831. * Sets the highlights Hue value.
  7832. * 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).
  7833. */
  7834. highlightsHue: number;
  7835. /**
  7836. * Gets the highlights Density value.
  7837. * 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.
  7838. * Values less than zero provide a filter of opposite hue.
  7839. */
  7840. /**
  7841. * Sets the highlights Density value.
  7842. * 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.
  7843. * Values less than zero provide a filter of opposite hue.
  7844. */
  7845. highlightsDensity: number;
  7846. /**
  7847. * Gets the highlights Saturation value.
  7848. * 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.
  7849. */
  7850. /**
  7851. * Sets the highlights Saturation value.
  7852. * 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.
  7853. */
  7854. highlightsSaturation: number;
  7855. /**
  7856. * Gets the highlights Exposure value.
  7857. * 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.
  7858. */
  7859. /**
  7860. * Sets the highlights Exposure value.
  7861. * 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.
  7862. */
  7863. highlightsExposure: number;
  7864. private _midtonesHue;
  7865. private _midtonesDensity;
  7866. private _midtonesSaturation;
  7867. private _midtonesExposure;
  7868. /**
  7869. * Gets the midtones Hue value.
  7870. * 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).
  7871. */
  7872. /**
  7873. * Sets the midtones Hue value.
  7874. * 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).
  7875. */
  7876. midtonesHue: number;
  7877. /**
  7878. * Gets the midtones Density value.
  7879. * 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.
  7880. * Values less than zero provide a filter of opposite hue.
  7881. */
  7882. /**
  7883. * Sets the midtones Density value.
  7884. * 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.
  7885. * Values less than zero provide a filter of opposite hue.
  7886. */
  7887. midtonesDensity: number;
  7888. /**
  7889. * Gets the midtones Saturation value.
  7890. * 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.
  7891. */
  7892. /**
  7893. * Sets the midtones Saturation value.
  7894. * 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.
  7895. */
  7896. midtonesSaturation: number;
  7897. /**
  7898. * Gets the midtones Exposure value.
  7899. * 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.
  7900. */
  7901. /**
  7902. * Sets the midtones Exposure value.
  7903. * 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.
  7904. */
  7905. midtonesExposure: number;
  7906. private _shadowsHue;
  7907. private _shadowsDensity;
  7908. private _shadowsSaturation;
  7909. private _shadowsExposure;
  7910. /**
  7911. * Gets the shadows Hue value.
  7912. * 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).
  7913. */
  7914. /**
  7915. * Sets the shadows Hue value.
  7916. * 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).
  7917. */
  7918. shadowsHue: number;
  7919. /**
  7920. * Gets the shadows Density value.
  7921. * 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.
  7922. * Values less than zero provide a filter of opposite hue.
  7923. */
  7924. /**
  7925. * Sets the shadows Density value.
  7926. * 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.
  7927. * Values less than zero provide a filter of opposite hue.
  7928. */
  7929. shadowsDensity: number;
  7930. /**
  7931. * Gets the shadows Saturation value.
  7932. * 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.
  7933. */
  7934. /**
  7935. * Sets the shadows Saturation value.
  7936. * 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.
  7937. */
  7938. shadowsSaturation: number;
  7939. /**
  7940. * Gets the shadows Exposure value.
  7941. * 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.
  7942. */
  7943. /**
  7944. * Sets the shadows Exposure value.
  7945. * 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.
  7946. */
  7947. shadowsExposure: number;
  7948. /**
  7949. * Returns the class name
  7950. * @returns The class name
  7951. */
  7952. getClassName(): string;
  7953. /**
  7954. * Binds the color curves to the shader.
  7955. * @param colorCurves The color curve to bind
  7956. * @param effect The effect to bind to
  7957. * @param positiveUniform The positive uniform shader parameter
  7958. * @param neutralUniform The neutral uniform shader parameter
  7959. * @param negativeUniform The negative uniform shader parameter
  7960. */
  7961. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7962. /**
  7963. * Prepare the list of uniforms associated with the ColorCurves effects.
  7964. * @param uniformsList The list of uniforms used in the effect
  7965. */
  7966. static PrepareUniforms(uniformsList: string[]): void;
  7967. /**
  7968. * Returns color grading data based on a hue, density, saturation and exposure value.
  7969. * @param filterHue The hue of the color filter.
  7970. * @param filterDensity The density of the color filter.
  7971. * @param saturation The saturation.
  7972. * @param exposure The exposure.
  7973. * @param result The result data container.
  7974. */
  7975. private getColorGradingDataToRef;
  7976. /**
  7977. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7978. * @param value The input slider value in range [-100,100].
  7979. * @returns Adjusted value.
  7980. */
  7981. private static applyColorGradingSliderNonlinear;
  7982. /**
  7983. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7984. * @param hue The hue (H) input.
  7985. * @param saturation The saturation (S) input.
  7986. * @param brightness The brightness (B) input.
  7987. * @result An RGBA color represented as Vector4.
  7988. */
  7989. private static fromHSBToRef;
  7990. /**
  7991. * Returns a value clamped between min and max
  7992. * @param value The value to clamp
  7993. * @param min The minimum of value
  7994. * @param max The maximum of value
  7995. * @returns The clamped value.
  7996. */
  7997. private static clamp;
  7998. /**
  7999. * Clones the current color curve instance.
  8000. * @return The cloned curves
  8001. */
  8002. clone(): ColorCurves;
  8003. /**
  8004. * Serializes the current color curve instance to a json representation.
  8005. * @return a JSON representation
  8006. */
  8007. serialize(): any;
  8008. /**
  8009. * Parses the color curve from a json representation.
  8010. * @param source the JSON source to parse
  8011. * @return The parsed curves
  8012. */
  8013. static Parse(source: any): ColorCurves;
  8014. }
  8015. }
  8016. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8017. import { Observable } from "babylonjs/Misc/observable";
  8018. import { Nullable } from "babylonjs/types";
  8019. import { Color4 } from "babylonjs/Maths/math.color";
  8020. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8021. import { Effect } from "babylonjs/Materials/effect";
  8022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8023. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8024. /**
  8025. * Interface to follow in your material defines to integrate easily the
  8026. * Image proccessing functions.
  8027. * @hidden
  8028. */
  8029. export interface IImageProcessingConfigurationDefines {
  8030. IMAGEPROCESSING: boolean;
  8031. VIGNETTE: boolean;
  8032. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8033. VIGNETTEBLENDMODEOPAQUE: boolean;
  8034. TONEMAPPING: boolean;
  8035. TONEMAPPING_ACES: boolean;
  8036. CONTRAST: boolean;
  8037. EXPOSURE: boolean;
  8038. COLORCURVES: boolean;
  8039. COLORGRADING: boolean;
  8040. COLORGRADING3D: boolean;
  8041. SAMPLER3DGREENDEPTH: boolean;
  8042. SAMPLER3DBGRMAP: boolean;
  8043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8044. }
  8045. /**
  8046. * @hidden
  8047. */
  8048. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8049. IMAGEPROCESSING: boolean;
  8050. VIGNETTE: boolean;
  8051. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8052. VIGNETTEBLENDMODEOPAQUE: boolean;
  8053. TONEMAPPING: boolean;
  8054. TONEMAPPING_ACES: boolean;
  8055. CONTRAST: boolean;
  8056. COLORCURVES: boolean;
  8057. COLORGRADING: boolean;
  8058. COLORGRADING3D: boolean;
  8059. SAMPLER3DGREENDEPTH: boolean;
  8060. SAMPLER3DBGRMAP: boolean;
  8061. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8062. EXPOSURE: boolean;
  8063. constructor();
  8064. }
  8065. /**
  8066. * This groups together the common properties used for image processing either in direct forward pass
  8067. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8068. * or not.
  8069. */
  8070. export class ImageProcessingConfiguration {
  8071. /**
  8072. * Default tone mapping applied in BabylonJS.
  8073. */
  8074. static readonly TONEMAPPING_STANDARD: number;
  8075. /**
  8076. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8077. * to other engines rendering to increase portability.
  8078. */
  8079. static readonly TONEMAPPING_ACES: number;
  8080. /**
  8081. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8082. */
  8083. colorCurves: Nullable<ColorCurves>;
  8084. private _colorCurvesEnabled;
  8085. /**
  8086. * Gets wether the color curves effect is enabled.
  8087. */
  8088. /**
  8089. * Sets wether the color curves effect is enabled.
  8090. */
  8091. colorCurvesEnabled: boolean;
  8092. private _colorGradingTexture;
  8093. /**
  8094. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8095. */
  8096. /**
  8097. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8098. */
  8099. colorGradingTexture: Nullable<BaseTexture>;
  8100. private _colorGradingEnabled;
  8101. /**
  8102. * Gets wether the color grading effect is enabled.
  8103. */
  8104. /**
  8105. * Sets wether the color grading effect is enabled.
  8106. */
  8107. colorGradingEnabled: boolean;
  8108. private _colorGradingWithGreenDepth;
  8109. /**
  8110. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8111. */
  8112. /**
  8113. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8114. */
  8115. colorGradingWithGreenDepth: boolean;
  8116. private _colorGradingBGR;
  8117. /**
  8118. * Gets wether the color grading texture contains BGR values.
  8119. */
  8120. /**
  8121. * Sets wether the color grading texture contains BGR values.
  8122. */
  8123. colorGradingBGR: boolean;
  8124. /** @hidden */
  8125. _exposure: number;
  8126. /**
  8127. * Gets the Exposure used in the effect.
  8128. */
  8129. /**
  8130. * Sets the Exposure used in the effect.
  8131. */
  8132. exposure: number;
  8133. private _toneMappingEnabled;
  8134. /**
  8135. * Gets wether the tone mapping effect is enabled.
  8136. */
  8137. /**
  8138. * Sets wether the tone mapping effect is enabled.
  8139. */
  8140. toneMappingEnabled: boolean;
  8141. private _toneMappingType;
  8142. /**
  8143. * Gets the type of tone mapping effect.
  8144. */
  8145. /**
  8146. * Sets the type of tone mapping effect used in BabylonJS.
  8147. */
  8148. toneMappingType: number;
  8149. protected _contrast: number;
  8150. /**
  8151. * Gets the contrast used in the effect.
  8152. */
  8153. /**
  8154. * Sets the contrast used in the effect.
  8155. */
  8156. contrast: number;
  8157. /**
  8158. * Vignette stretch size.
  8159. */
  8160. vignetteStretch: number;
  8161. /**
  8162. * Vignette centre X Offset.
  8163. */
  8164. vignetteCentreX: number;
  8165. /**
  8166. * Vignette centre Y Offset.
  8167. */
  8168. vignetteCentreY: number;
  8169. /**
  8170. * Vignette weight or intensity of the vignette effect.
  8171. */
  8172. vignetteWeight: number;
  8173. /**
  8174. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8175. * if vignetteEnabled is set to true.
  8176. */
  8177. vignetteColor: Color4;
  8178. /**
  8179. * Camera field of view used by the Vignette effect.
  8180. */
  8181. vignetteCameraFov: number;
  8182. private _vignetteBlendMode;
  8183. /**
  8184. * Gets the vignette blend mode allowing different kind of effect.
  8185. */
  8186. /**
  8187. * Sets the vignette blend mode allowing different kind of effect.
  8188. */
  8189. vignetteBlendMode: number;
  8190. private _vignetteEnabled;
  8191. /**
  8192. * Gets wether the vignette effect is enabled.
  8193. */
  8194. /**
  8195. * Sets wether the vignette effect is enabled.
  8196. */
  8197. vignetteEnabled: boolean;
  8198. private _applyByPostProcess;
  8199. /**
  8200. * Gets wether the image processing is applied through a post process or not.
  8201. */
  8202. /**
  8203. * Sets wether the image processing is applied through a post process or not.
  8204. */
  8205. applyByPostProcess: boolean;
  8206. private _isEnabled;
  8207. /**
  8208. * Gets wether the image processing is enabled or not.
  8209. */
  8210. /**
  8211. * Sets wether the image processing is enabled or not.
  8212. */
  8213. isEnabled: boolean;
  8214. /**
  8215. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8216. */
  8217. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8218. /**
  8219. * Method called each time the image processing information changes requires to recompile the effect.
  8220. */
  8221. protected _updateParameters(): void;
  8222. /**
  8223. * Gets the current class name.
  8224. * @return "ImageProcessingConfiguration"
  8225. */
  8226. getClassName(): string;
  8227. /**
  8228. * Prepare the list of uniforms associated with the Image Processing effects.
  8229. * @param uniforms The list of uniforms used in the effect
  8230. * @param defines the list of defines currently in use
  8231. */
  8232. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8233. /**
  8234. * Prepare the list of samplers associated with the Image Processing effects.
  8235. * @param samplersList The list of uniforms used in the effect
  8236. * @param defines the list of defines currently in use
  8237. */
  8238. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8239. /**
  8240. * Prepare the list of defines associated to the shader.
  8241. * @param defines the list of defines to complete
  8242. * @param forPostProcess Define if we are currently in post process mode or not
  8243. */
  8244. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8245. /**
  8246. * Returns true if all the image processing information are ready.
  8247. * @returns True if ready, otherwise, false
  8248. */
  8249. isReady(): boolean;
  8250. /**
  8251. * Binds the image processing to the shader.
  8252. * @param effect The effect to bind to
  8253. * @param aspectRatio Define the current aspect ratio of the effect
  8254. */
  8255. bind(effect: Effect, aspectRatio?: number): void;
  8256. /**
  8257. * Clones the current image processing instance.
  8258. * @return The cloned image processing
  8259. */
  8260. clone(): ImageProcessingConfiguration;
  8261. /**
  8262. * Serializes the current image processing instance to a json representation.
  8263. * @return a JSON representation
  8264. */
  8265. serialize(): any;
  8266. /**
  8267. * Parses the image processing from a json representation.
  8268. * @param source the JSON source to parse
  8269. * @return The parsed image processing
  8270. */
  8271. static Parse(source: any): ImageProcessingConfiguration;
  8272. private static _VIGNETTEMODE_MULTIPLY;
  8273. private static _VIGNETTEMODE_OPAQUE;
  8274. /**
  8275. * Used to apply the vignette as a mix with the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_MULTIPLY: number;
  8278. /**
  8279. * Used to apply the vignette as a replacement of the pixel color.
  8280. */
  8281. static readonly VIGNETTEMODE_OPAQUE: number;
  8282. }
  8283. }
  8284. declare module "babylonjs/Shaders/postprocess.vertex" {
  8285. /** @hidden */
  8286. export var postprocessVertexShader: {
  8287. name: string;
  8288. shader: string;
  8289. };
  8290. }
  8291. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8293. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8294. module "babylonjs/Engines/thinEngine" {
  8295. interface ThinEngine {
  8296. /**
  8297. * Creates a new render target texture
  8298. * @param size defines the size of the texture
  8299. * @param options defines the options used to create the texture
  8300. * @returns a new render target texture stored in an InternalTexture
  8301. */
  8302. createRenderTargetTexture(size: number | {
  8303. width: number;
  8304. height: number;
  8305. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8306. }
  8307. }
  8308. }
  8309. declare module "babylonjs/Maths/math.axis" {
  8310. import { Vector3 } from "babylonjs/Maths/math.vector";
  8311. /** Defines supported spaces */
  8312. export enum Space {
  8313. /** Local (object) space */
  8314. LOCAL = 0,
  8315. /** World space */
  8316. WORLD = 1,
  8317. /** Bone space */
  8318. BONE = 2
  8319. }
  8320. /** Defines the 3 main axes */
  8321. export class Axis {
  8322. /** X axis */
  8323. static X: Vector3;
  8324. /** Y axis */
  8325. static Y: Vector3;
  8326. /** Z axis */
  8327. static Z: Vector3;
  8328. }
  8329. }
  8330. declare module "babylonjs/Cameras/targetCamera" {
  8331. import { Nullable } from "babylonjs/types";
  8332. import { Camera } from "babylonjs/Cameras/camera";
  8333. import { Scene } from "babylonjs/scene";
  8334. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8335. /**
  8336. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8337. * This is the base of the follow, arc rotate cameras and Free camera
  8338. * @see http://doc.babylonjs.com/features/cameras
  8339. */
  8340. export class TargetCamera extends Camera {
  8341. private static _RigCamTransformMatrix;
  8342. private static _TargetTransformMatrix;
  8343. private static _TargetFocalPoint;
  8344. /**
  8345. * Define the current direction the camera is moving to
  8346. */
  8347. cameraDirection: Vector3;
  8348. /**
  8349. * Define the current rotation the camera is rotating to
  8350. */
  8351. cameraRotation: Vector2;
  8352. /**
  8353. * When set, the up vector of the camera will be updated by the rotation of the camera
  8354. */
  8355. updateUpVectorFromRotation: boolean;
  8356. private _tmpQuaternion;
  8357. /**
  8358. * Define the current rotation of the camera
  8359. */
  8360. rotation: Vector3;
  8361. /**
  8362. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8363. */
  8364. rotationQuaternion: Quaternion;
  8365. /**
  8366. * Define the current speed of the camera
  8367. */
  8368. speed: number;
  8369. /**
  8370. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8371. * around all axis.
  8372. */
  8373. noRotationConstraint: boolean;
  8374. /**
  8375. * Define the current target of the camera as an object or a position.
  8376. */
  8377. lockedTarget: any;
  8378. /** @hidden */
  8379. _currentTarget: Vector3;
  8380. /** @hidden */
  8381. _initialFocalDistance: number;
  8382. /** @hidden */
  8383. _viewMatrix: Matrix;
  8384. /** @hidden */
  8385. _camMatrix: Matrix;
  8386. /** @hidden */
  8387. _cameraTransformMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraRotationMatrix: Matrix;
  8390. /** @hidden */
  8391. _referencePoint: Vector3;
  8392. /** @hidden */
  8393. _transformedReferencePoint: Vector3;
  8394. protected _globalCurrentTarget: Vector3;
  8395. protected _globalCurrentUpVector: Vector3;
  8396. /** @hidden */
  8397. _reset: () => void;
  8398. private _defaultUp;
  8399. /**
  8400. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8401. * This is the base of the follow, arc rotate cameras and Free camera
  8402. * @see http://doc.babylonjs.com/features/cameras
  8403. * @param name Defines the name of the camera in the scene
  8404. * @param position Defines the start position of the camera in the scene
  8405. * @param scene Defines the scene the camera belongs to
  8406. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8407. */
  8408. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8409. /**
  8410. * Gets the position in front of the camera at a given distance.
  8411. * @param distance The distance from the camera we want the position to be
  8412. * @returns the position
  8413. */
  8414. getFrontPosition(distance: number): Vector3;
  8415. /** @hidden */
  8416. _getLockedTargetPosition(): Nullable<Vector3>;
  8417. private _storedPosition;
  8418. private _storedRotation;
  8419. private _storedRotationQuaternion;
  8420. /**
  8421. * Store current camera state of the camera (fov, position, rotation, etc..)
  8422. * @returns the camera
  8423. */
  8424. storeState(): Camera;
  8425. /**
  8426. * Restored camera state. You must call storeState() first
  8427. * @returns whether it was successful or not
  8428. * @hidden
  8429. */
  8430. _restoreStateValues(): boolean;
  8431. /** @hidden */
  8432. _initCache(): void;
  8433. /** @hidden */
  8434. _updateCache(ignoreParentClass?: boolean): void;
  8435. /** @hidden */
  8436. _isSynchronizedViewMatrix(): boolean;
  8437. /** @hidden */
  8438. _computeLocalCameraSpeed(): number;
  8439. /**
  8440. * Defines the target the camera should look at.
  8441. * @param target Defines the new target as a Vector or a mesh
  8442. */
  8443. setTarget(target: Vector3): void;
  8444. /**
  8445. * Return the current target position of the camera. This value is expressed in local space.
  8446. * @returns the target position
  8447. */
  8448. getTarget(): Vector3;
  8449. /** @hidden */
  8450. _decideIfNeedsToMove(): boolean;
  8451. /** @hidden */
  8452. _updatePosition(): void;
  8453. /** @hidden */
  8454. _checkInputs(): void;
  8455. protected _updateCameraRotationMatrix(): void;
  8456. /**
  8457. * 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)
  8458. * @returns the current camera
  8459. */
  8460. private _rotateUpVectorWithCameraRotationMatrix;
  8461. private _cachedRotationZ;
  8462. private _cachedQuaternionRotationZ;
  8463. /** @hidden */
  8464. _getViewMatrix(): Matrix;
  8465. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8466. /**
  8467. * @hidden
  8468. */
  8469. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8470. /**
  8471. * @hidden
  8472. */
  8473. _updateRigCameras(): void;
  8474. private _getRigCamPositionAndTarget;
  8475. /**
  8476. * Gets the current object class name.
  8477. * @return the class name
  8478. */
  8479. getClassName(): string;
  8480. }
  8481. }
  8482. declare module "babylonjs/Events/keyboardEvents" {
  8483. /**
  8484. * Gather the list of keyboard event types as constants.
  8485. */
  8486. export class KeyboardEventTypes {
  8487. /**
  8488. * The keydown event is fired when a key becomes active (pressed).
  8489. */
  8490. static readonly KEYDOWN: number;
  8491. /**
  8492. * The keyup event is fired when a key has been released.
  8493. */
  8494. static readonly KEYUP: number;
  8495. }
  8496. /**
  8497. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8498. */
  8499. export class KeyboardInfo {
  8500. /**
  8501. * Defines the type of event (KeyboardEventTypes)
  8502. */
  8503. type: number;
  8504. /**
  8505. * Defines the related dom event
  8506. */
  8507. event: KeyboardEvent;
  8508. /**
  8509. * Instantiates a new keyboard info.
  8510. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8511. * @param type Defines the type of event (KeyboardEventTypes)
  8512. * @param event Defines the related dom event
  8513. */
  8514. constructor(
  8515. /**
  8516. * Defines the type of event (KeyboardEventTypes)
  8517. */
  8518. type: number,
  8519. /**
  8520. * Defines the related dom event
  8521. */
  8522. event: KeyboardEvent);
  8523. }
  8524. /**
  8525. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8526. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8527. */
  8528. export class KeyboardInfoPre extends KeyboardInfo {
  8529. /**
  8530. * Defines the type of event (KeyboardEventTypes)
  8531. */
  8532. type: number;
  8533. /**
  8534. * Defines the related dom event
  8535. */
  8536. event: KeyboardEvent;
  8537. /**
  8538. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8539. */
  8540. skipOnPointerObservable: boolean;
  8541. /**
  8542. * Instantiates a new keyboard pre info.
  8543. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8544. * @param type Defines the type of event (KeyboardEventTypes)
  8545. * @param event Defines the related dom event
  8546. */
  8547. constructor(
  8548. /**
  8549. * Defines the type of event (KeyboardEventTypes)
  8550. */
  8551. type: number,
  8552. /**
  8553. * Defines the related dom event
  8554. */
  8555. event: KeyboardEvent);
  8556. }
  8557. }
  8558. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8559. import { Nullable } from "babylonjs/types";
  8560. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8561. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8562. /**
  8563. * Manage the keyboard inputs to control the movement of a free camera.
  8564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8565. */
  8566. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8567. /**
  8568. * Defines the camera the input is attached to.
  8569. */
  8570. camera: FreeCamera;
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8573. */
  8574. keysUp: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8577. */
  8578. keysDown: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8581. */
  8582. keysLeft: number[];
  8583. /**
  8584. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8585. */
  8586. keysRight: number[];
  8587. private _keys;
  8588. private _onCanvasBlurObserver;
  8589. private _onKeyboardObserver;
  8590. private _engine;
  8591. private _scene;
  8592. /**
  8593. * Attach the input controls to a specific dom element to get the input from.
  8594. * @param element Defines the element the controls should be listened from
  8595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8596. */
  8597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8598. /**
  8599. * Detach the current controls from the specified dom element.
  8600. * @param element Defines the element to stop listening the inputs from
  8601. */
  8602. detachControl(element: Nullable<HTMLElement>): void;
  8603. /**
  8604. * Update the current camera state depending on the inputs that have been used this frame.
  8605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8606. */
  8607. checkInputs(): void;
  8608. /**
  8609. * Gets the class name of the current intput.
  8610. * @returns the class name
  8611. */
  8612. getClassName(): string;
  8613. /** @hidden */
  8614. _onLostFocus(): void;
  8615. /**
  8616. * Get the friendly name associated with the input class.
  8617. * @returns the input friendly name
  8618. */
  8619. getSimpleName(): string;
  8620. }
  8621. }
  8622. declare module "babylonjs/Lights/shadowLight" {
  8623. import { Camera } from "babylonjs/Cameras/camera";
  8624. import { Scene } from "babylonjs/scene";
  8625. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8627. import { Light } from "babylonjs/Lights/light";
  8628. /**
  8629. * Interface describing all the common properties and methods a shadow light needs to implement.
  8630. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8631. * as well as binding the different shadow properties to the effects.
  8632. */
  8633. export interface IShadowLight extends Light {
  8634. /**
  8635. * The light id in the scene (used in scene.findLighById for instance)
  8636. */
  8637. id: string;
  8638. /**
  8639. * The position the shdow will be casted from.
  8640. */
  8641. position: Vector3;
  8642. /**
  8643. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8644. */
  8645. direction: Vector3;
  8646. /**
  8647. * The transformed position. Position of the light in world space taking parenting in account.
  8648. */
  8649. transformedPosition: Vector3;
  8650. /**
  8651. * The transformed direction. Direction of the light in world space taking parenting in account.
  8652. */
  8653. transformedDirection: Vector3;
  8654. /**
  8655. * The friendly name of the light in the scene.
  8656. */
  8657. name: string;
  8658. /**
  8659. * Defines the shadow projection clipping minimum z value.
  8660. */
  8661. shadowMinZ: number;
  8662. /**
  8663. * Defines the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8668. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8669. */
  8670. computeTransformedInformation(): boolean;
  8671. /**
  8672. * Gets the scene the light belongs to.
  8673. * @returns The scene
  8674. */
  8675. getScene(): Scene;
  8676. /**
  8677. * Callback defining a custom Projection Matrix Builder.
  8678. * This can be used to override the default projection matrix computation.
  8679. */
  8680. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8681. /**
  8682. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8683. * @param matrix The materix to updated with the projection information
  8684. * @param viewMatrix The transform matrix of the light
  8685. * @param renderList The list of mesh to render in the map
  8686. * @returns The current light
  8687. */
  8688. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8689. /**
  8690. * Gets the current depth scale used in ESM.
  8691. * @returns The scale
  8692. */
  8693. getDepthScale(): number;
  8694. /**
  8695. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8696. * @returns true if a cube texture needs to be use
  8697. */
  8698. needCube(): boolean;
  8699. /**
  8700. * Detects if the projection matrix requires to be recomputed this frame.
  8701. * @returns true if it requires to be recomputed otherwise, false.
  8702. */
  8703. needProjectionMatrixCompute(): boolean;
  8704. /**
  8705. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8706. */
  8707. forceProjectionMatrixCompute(): void;
  8708. /**
  8709. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8710. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8711. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8712. */
  8713. getShadowDirection(faceIndex?: number): Vector3;
  8714. /**
  8715. * Gets the minZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the min for
  8717. * @returns the depth min z
  8718. */
  8719. getDepthMinZ(activeCamera: Camera): number;
  8720. /**
  8721. * Gets the maxZ used for shadow according to both the scene and the light.
  8722. * @param activeCamera The camera we are returning the max for
  8723. * @returns the depth max z
  8724. */
  8725. getDepthMaxZ(activeCamera: Camera): number;
  8726. }
  8727. /**
  8728. * Base implementation IShadowLight
  8729. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8730. */
  8731. export abstract class ShadowLight extends Light implements IShadowLight {
  8732. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8733. protected _position: Vector3;
  8734. protected _setPosition(value: Vector3): void;
  8735. /**
  8736. * Sets the position the shadow will be casted from. Also use as the light position for both
  8737. * point and spot lights.
  8738. */
  8739. /**
  8740. * Sets the position the shadow will be casted from. Also use as the light position for both
  8741. * point and spot lights.
  8742. */
  8743. position: Vector3;
  8744. protected _direction: Vector3;
  8745. protected _setDirection(value: Vector3): void;
  8746. /**
  8747. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8748. * Also use as the light direction on spot and directional lights.
  8749. */
  8750. /**
  8751. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8752. * Also use as the light direction on spot and directional lights.
  8753. */
  8754. direction: Vector3;
  8755. private _shadowMinZ;
  8756. /**
  8757. * Gets the shadow projection clipping minimum z value.
  8758. */
  8759. /**
  8760. * Sets the shadow projection clipping minimum z value.
  8761. */
  8762. shadowMinZ: number;
  8763. private _shadowMaxZ;
  8764. /**
  8765. * Sets the shadow projection clipping maximum z value.
  8766. */
  8767. /**
  8768. * Gets the shadow projection clipping maximum z value.
  8769. */
  8770. shadowMaxZ: number;
  8771. /**
  8772. * Callback defining a custom Projection Matrix Builder.
  8773. * This can be used to override the default projection matrix computation.
  8774. */
  8775. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8776. /**
  8777. * The transformed position. Position of the light in world space taking parenting in account.
  8778. */
  8779. transformedPosition: Vector3;
  8780. /**
  8781. * The transformed direction. Direction of the light in world space taking parenting in account.
  8782. */
  8783. transformedDirection: Vector3;
  8784. private _needProjectionMatrixCompute;
  8785. /**
  8786. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8787. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8788. */
  8789. computeTransformedInformation(): boolean;
  8790. /**
  8791. * Return the depth scale used for the shadow map.
  8792. * @returns the depth scale.
  8793. */
  8794. getDepthScale(): number;
  8795. /**
  8796. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8797. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8798. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8799. */
  8800. getShadowDirection(faceIndex?: number): Vector3;
  8801. /**
  8802. * Returns the ShadowLight absolute position in the World.
  8803. * @returns the position vector in world space
  8804. */
  8805. getAbsolutePosition(): Vector3;
  8806. /**
  8807. * Sets the ShadowLight direction toward the passed target.
  8808. * @param target The point to target in local space
  8809. * @returns the updated ShadowLight direction
  8810. */
  8811. setDirectionToTarget(target: Vector3): Vector3;
  8812. /**
  8813. * Returns the light rotation in euler definition.
  8814. * @returns the x y z rotation in local space.
  8815. */
  8816. getRotation(): Vector3;
  8817. /**
  8818. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8819. * @returns true if a cube texture needs to be use
  8820. */
  8821. needCube(): boolean;
  8822. /**
  8823. * Detects if the projection matrix requires to be recomputed this frame.
  8824. * @returns true if it requires to be recomputed otherwise, false.
  8825. */
  8826. needProjectionMatrixCompute(): boolean;
  8827. /**
  8828. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8829. */
  8830. forceProjectionMatrixCompute(): void;
  8831. /** @hidden */
  8832. _initCache(): void;
  8833. /** @hidden */
  8834. _isSynchronized(): boolean;
  8835. /**
  8836. * Computes the world matrix of the node
  8837. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8838. * @returns the world matrix
  8839. */
  8840. computeWorldMatrix(force?: boolean): Matrix;
  8841. /**
  8842. * Gets the minZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the min for
  8844. * @returns the depth min z
  8845. */
  8846. getDepthMinZ(activeCamera: Camera): number;
  8847. /**
  8848. * Gets the maxZ used for shadow according to both the scene and the light.
  8849. * @param activeCamera The camera we are returning the max for
  8850. * @returns the depth max z
  8851. */
  8852. getDepthMaxZ(activeCamera: Camera): number;
  8853. /**
  8854. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8855. * @param matrix The materix to updated with the projection information
  8856. * @param viewMatrix The transform matrix of the light
  8857. * @param renderList The list of mesh to render in the map
  8858. * @returns The current light
  8859. */
  8860. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8861. }
  8862. }
  8863. declare module "babylonjs/Materials/effectFallbacks" {
  8864. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8865. import { Effect } from "babylonjs/Materials/effect";
  8866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8867. /**
  8868. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8869. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8870. */
  8871. export class EffectFallbacks implements IEffectFallbacks {
  8872. private _defines;
  8873. private _currentRank;
  8874. private _maxRank;
  8875. private _mesh;
  8876. /**
  8877. * Removes the fallback from the bound mesh.
  8878. */
  8879. unBindMesh(): void;
  8880. /**
  8881. * Adds a fallback on the specified property.
  8882. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8883. * @param define The name of the define in the shader
  8884. */
  8885. addFallback(rank: number, define: string): void;
  8886. /**
  8887. * Sets the mesh to use CPU skinning when needing to fallback.
  8888. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8889. * @param mesh The mesh to use the fallbacks.
  8890. */
  8891. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8892. /**
  8893. * Checks to see if more fallbacks are still availible.
  8894. */
  8895. readonly hasMoreFallbacks: boolean;
  8896. /**
  8897. * Removes the defines that should be removed when falling back.
  8898. * @param currentDefines defines the current define statements for the shader.
  8899. * @param effect defines the current effect we try to compile
  8900. * @returns The resulting defines with defines of the current rank removed.
  8901. */
  8902. reduce(currentDefines: string, effect: Effect): string;
  8903. }
  8904. }
  8905. declare module "babylonjs/Materials/materialHelper" {
  8906. import { Nullable } from "babylonjs/types";
  8907. import { Scene } from "babylonjs/scene";
  8908. import { Engine } from "babylonjs/Engines/engine";
  8909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8910. import { Light } from "babylonjs/Lights/light";
  8911. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8912. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8914. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8915. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8916. /**
  8917. * "Static Class" containing the most commonly used helper while dealing with material for
  8918. * rendering purpose.
  8919. *
  8920. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8921. *
  8922. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8923. */
  8924. export class MaterialHelper {
  8925. /**
  8926. * Bind the current view position to an effect.
  8927. * @param effect The effect to be bound
  8928. * @param scene The scene the eyes position is used from
  8929. */
  8930. static BindEyePosition(effect: Effect, scene: Scene): void;
  8931. /**
  8932. * Helps preparing the defines values about the UVs in used in the effect.
  8933. * UVs are shared as much as we can accross channels in the shaders.
  8934. * @param texture The texture we are preparing the UVs for
  8935. * @param defines The defines to update
  8936. * @param key The channel key "diffuse", "specular"... used in the shader
  8937. */
  8938. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8939. /**
  8940. * Binds a texture matrix value to its corrsponding uniform
  8941. * @param texture The texture to bind the matrix for
  8942. * @param uniformBuffer The uniform buffer receivin the data
  8943. * @param key The channel key "diffuse", "specular"... used in the shader
  8944. */
  8945. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8946. /**
  8947. * Gets the current status of the fog (should it be enabled?)
  8948. * @param mesh defines the mesh to evaluate for fog support
  8949. * @param scene defines the hosting scene
  8950. * @returns true if fog must be enabled
  8951. */
  8952. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8953. /**
  8954. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8955. * @param mesh defines the current mesh
  8956. * @param scene defines the current scene
  8957. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8958. * @param pointsCloud defines if point cloud rendering has to be turned on
  8959. * @param fogEnabled defines if fog has to be turned on
  8960. * @param alphaTest defines if alpha testing has to be turned on
  8961. * @param defines defines the current list of defines
  8962. */
  8963. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8964. /**
  8965. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8966. * @param scene defines the current scene
  8967. * @param engine defines the current engine
  8968. * @param defines specifies the list of active defines
  8969. * @param useInstances defines if instances have to be turned on
  8970. * @param useClipPlane defines if clip plane have to be turned on
  8971. */
  8972. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8973. /**
  8974. * Prepares the defines for bones
  8975. * @param mesh The mesh containing the geometry data we will draw
  8976. * @param defines The defines to update
  8977. */
  8978. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8979. /**
  8980. * Prepares the defines for morph targets
  8981. * @param mesh The mesh containing the geometry data we will draw
  8982. * @param defines The defines to update
  8983. */
  8984. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8985. /**
  8986. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8987. * @param mesh The mesh containing the geometry data we will draw
  8988. * @param defines The defines to update
  8989. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8990. * @param useBones Precise whether bones should be used or not (override mesh info)
  8991. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8992. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8993. * @returns false if defines are considered not dirty and have not been checked
  8994. */
  8995. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8996. /**
  8997. * Prepares the defines related to multiview
  8998. * @param scene The scene we are intending to draw
  8999. * @param defines The defines to update
  9000. */
  9001. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9002. /**
  9003. * Prepares the defines related to the light information passed in parameter
  9004. * @param scene The scene we are intending to draw
  9005. * @param mesh The mesh the effect is compiling for
  9006. * @param light The light the effect is compiling for
  9007. * @param lightIndex The index of the light
  9008. * @param defines The defines to update
  9009. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9010. * @param state Defines the current state regarding what is needed (normals, etc...)
  9011. */
  9012. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9013. needNormals: boolean;
  9014. needRebuild: boolean;
  9015. shadowEnabled: boolean;
  9016. specularEnabled: boolean;
  9017. lightmapMode: boolean;
  9018. }): void;
  9019. /**
  9020. * Prepares the defines related to the light information passed in parameter
  9021. * @param scene The scene we are intending to draw
  9022. * @param mesh The mesh the effect is compiling for
  9023. * @param defines The defines to update
  9024. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9025. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9026. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9027. * @returns true if normals will be required for the rest of the effect
  9028. */
  9029. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9030. /**
  9031. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9032. * @param lightIndex defines the light index
  9033. * @param uniformsList The uniform list
  9034. * @param samplersList The sampler list
  9035. * @param projectedLightTexture defines if projected texture must be used
  9036. * @param uniformBuffersList defines an optional list of uniform buffers
  9037. */
  9038. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9039. /**
  9040. * Prepares the uniforms and samplers list to be used in the effect
  9041. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9042. * @param samplersList The sampler list
  9043. * @param defines The defines helping in the list generation
  9044. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9045. */
  9046. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9047. /**
  9048. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9049. * @param defines The defines to update while falling back
  9050. * @param fallbacks The authorized effect fallbacks
  9051. * @param maxSimultaneousLights The maximum number of lights allowed
  9052. * @param rank the current rank of the Effect
  9053. * @returns The newly affected rank
  9054. */
  9055. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9056. private static _TmpMorphInfluencers;
  9057. /**
  9058. * Prepares the list of attributes required for morph targets according to the effect defines.
  9059. * @param attribs The current list of supported attribs
  9060. * @param mesh The mesh to prepare the morph targets attributes for
  9061. * @param influencers The number of influencers
  9062. */
  9063. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9064. /**
  9065. * Prepares the list of attributes required for morph targets according to the effect defines.
  9066. * @param attribs The current list of supported attribs
  9067. * @param mesh The mesh to prepare the morph targets attributes for
  9068. * @param defines The current Defines of the effect
  9069. */
  9070. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9071. /**
  9072. * Prepares the list of attributes required for bones according to the effect defines.
  9073. * @param attribs The current list of supported attribs
  9074. * @param mesh The mesh to prepare the bones attributes for
  9075. * @param defines The current Defines of the effect
  9076. * @param fallbacks The current efffect fallback strategy
  9077. */
  9078. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9079. /**
  9080. * Check and prepare the list of attributes required for instances according to the effect defines.
  9081. * @param attribs The current list of supported attribs
  9082. * @param defines The current MaterialDefines of the effect
  9083. */
  9084. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9085. /**
  9086. * Add the list of attributes required for instances to the attribs array.
  9087. * @param attribs The current list of supported attribs
  9088. */
  9089. static PushAttributesForInstances(attribs: string[]): void;
  9090. /**
  9091. * Binds the light information to the effect.
  9092. * @param light The light containing the generator
  9093. * @param effect The effect we are binding the data to
  9094. * @param lightIndex The light index in the effect used to render
  9095. */
  9096. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9097. /**
  9098. * Binds the lights information from the scene to the effect for the given mesh.
  9099. * @param light Light to bind
  9100. * @param lightIndex Light index
  9101. * @param scene The scene where the light belongs to
  9102. * @param effect The effect we are binding the data to
  9103. * @param useSpecular Defines if specular is supported
  9104. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9105. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9106. */
  9107. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9108. /**
  9109. * Binds the lights information from the scene to the effect for the given mesh.
  9110. * @param scene The scene the lights belongs to
  9111. * @param mesh The mesh we are binding the information to render
  9112. * @param effect The effect we are binding the data to
  9113. * @param defines The generated defines for the effect
  9114. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9115. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9116. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9117. */
  9118. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9119. private static _tempFogColor;
  9120. /**
  9121. * Binds the fog information from the scene to the effect for the given mesh.
  9122. * @param scene The scene the lights belongs to
  9123. * @param mesh The mesh we are binding the information to render
  9124. * @param effect The effect we are binding the data to
  9125. * @param linearSpace Defines if the fog effect is applied in linear space
  9126. */
  9127. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9128. /**
  9129. * Binds the bones information from the mesh to the effect.
  9130. * @param mesh The mesh we are binding the information to render
  9131. * @param effect The effect we are binding the data to
  9132. */
  9133. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9134. /**
  9135. * Binds the morph targets information from the mesh to the effect.
  9136. * @param abstractMesh The mesh we are binding the information to render
  9137. * @param effect The effect we are binding the data to
  9138. */
  9139. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9140. /**
  9141. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9142. * @param defines The generated defines used in the effect
  9143. * @param effect The effect we are binding the data to
  9144. * @param scene The scene we are willing to render with logarithmic scale for
  9145. */
  9146. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9147. /**
  9148. * Binds the clip plane information from the scene to the effect.
  9149. * @param scene The scene the clip plane information are extracted from
  9150. * @param effect The effect we are binding the data to
  9151. */
  9152. static BindClipPlane(effect: Effect, scene: Scene): void;
  9153. }
  9154. }
  9155. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9156. /** @hidden */
  9157. export var packingFunctions: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9163. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9164. /** @hidden */
  9165. export var shadowMapPixelShader: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9171. /** @hidden */
  9172. export var bonesDeclaration: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9178. /** @hidden */
  9179. export var morphTargetsVertexGlobalDeclaration: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9185. /** @hidden */
  9186. export var morphTargetsVertexDeclaration: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9192. /** @hidden */
  9193. export var instancesDeclaration: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9199. /** @hidden */
  9200. export var helperFunctions: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9206. /** @hidden */
  9207. export var morphTargetsVertex: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9213. /** @hidden */
  9214. export var instancesVertex: {
  9215. name: string;
  9216. shader: string;
  9217. };
  9218. }
  9219. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9220. /** @hidden */
  9221. export var bonesVertex: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9227. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9230. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9232. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9233. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9234. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9235. /** @hidden */
  9236. export var shadowMapVertexShader: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9242. /** @hidden */
  9243. export var depthBoxBlurPixelShader: {
  9244. name: string;
  9245. shader: string;
  9246. };
  9247. }
  9248. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9249. import { Nullable } from "babylonjs/types";
  9250. import { Scene } from "babylonjs/scene";
  9251. import { Matrix } from "babylonjs/Maths/math.vector";
  9252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9254. import { Mesh } from "babylonjs/Meshes/mesh";
  9255. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9256. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9257. import { Effect } from "babylonjs/Materials/effect";
  9258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9259. import "babylonjs/Shaders/shadowMap.fragment";
  9260. import "babylonjs/Shaders/shadowMap.vertex";
  9261. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9262. import { Observable } from "babylonjs/Misc/observable";
  9263. /**
  9264. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9265. */
  9266. export interface ICustomShaderOptions {
  9267. /**
  9268. * Gets or sets the custom shader name to use
  9269. */
  9270. shaderName: string;
  9271. /**
  9272. * The list of attribute names used in the shader
  9273. */
  9274. attributes?: string[];
  9275. /**
  9276. * The list of unifrom names used in the shader
  9277. */
  9278. uniforms?: string[];
  9279. /**
  9280. * The list of sampler names used in the shader
  9281. */
  9282. samplers?: string[];
  9283. /**
  9284. * The list of defines used in the shader
  9285. */
  9286. defines?: string[];
  9287. }
  9288. /**
  9289. * Interface to implement to create a shadow generator compatible with BJS.
  9290. */
  9291. export interface IShadowGenerator {
  9292. /**
  9293. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9294. * @returns The render target texture if present otherwise, null
  9295. */
  9296. getShadowMap(): Nullable<RenderTargetTexture>;
  9297. /**
  9298. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9299. * @returns The render target texture if the shadow map is present otherwise, null
  9300. */
  9301. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9302. /**
  9303. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9304. * @param subMesh The submesh we want to render in the shadow map
  9305. * @param useInstances Defines wether will draw in the map using instances
  9306. * @returns true if ready otherwise, false
  9307. */
  9308. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9309. /**
  9310. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9311. * @param defines Defines of the material we want to update
  9312. * @param lightIndex Index of the light in the enabled light list of the material
  9313. */
  9314. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9315. /**
  9316. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9317. * defined in the generator but impacting the effect).
  9318. * It implies the unifroms available on the materials are the standard BJS ones.
  9319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9320. * @param effect The effect we are binfing the information for
  9321. */
  9322. bindShadowLight(lightIndex: string, effect: Effect): void;
  9323. /**
  9324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9325. * (eq to shadow prjection matrix * light transform matrix)
  9326. * @returns The transform matrix used to create the shadow map
  9327. */
  9328. getTransformMatrix(): Matrix;
  9329. /**
  9330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9331. * Cube and 2D textures for instance.
  9332. */
  9333. recreateShadowMap(): void;
  9334. /**
  9335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9336. * @param onCompiled Callback triggered at the and of the effects compilation
  9337. * @param options Sets of optional options forcing the compilation with different modes
  9338. */
  9339. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9340. useInstances: boolean;
  9341. }>): void;
  9342. /**
  9343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9344. * @param options Sets of optional options forcing the compilation with different modes
  9345. * @returns A promise that resolves when the compilation completes
  9346. */
  9347. forceCompilationAsync(options?: Partial<{
  9348. useInstances: boolean;
  9349. }>): Promise<void>;
  9350. /**
  9351. * Serializes the shadow generator setup to a json object.
  9352. * @returns The serialized JSON object
  9353. */
  9354. serialize(): any;
  9355. /**
  9356. * Disposes the Shadow map and related Textures and effects.
  9357. */
  9358. dispose(): void;
  9359. }
  9360. /**
  9361. * Default implementation IShadowGenerator.
  9362. * This is the main object responsible of generating shadows in the framework.
  9363. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9364. */
  9365. export class ShadowGenerator implements IShadowGenerator {
  9366. /**
  9367. * Shadow generator mode None: no filtering applied.
  9368. */
  9369. static readonly FILTER_NONE: number;
  9370. /**
  9371. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9372. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9373. */
  9374. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9375. /**
  9376. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9377. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9378. */
  9379. static readonly FILTER_POISSONSAMPLING: number;
  9380. /**
  9381. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9382. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9383. */
  9384. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9385. /**
  9386. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9387. * edge artifacts on steep falloff.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9393. * edge artifacts on steep falloff.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode PCF: Percentage Closer Filtering
  9399. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9400. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9401. */
  9402. static readonly FILTER_PCF: number;
  9403. /**
  9404. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9406. * Contact Hardening
  9407. */
  9408. static readonly FILTER_PCSS: number;
  9409. /**
  9410. * Reserved for PCF and PCSS
  9411. * Highest Quality.
  9412. *
  9413. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9414. *
  9415. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9416. */
  9417. static readonly QUALITY_HIGH: number;
  9418. /**
  9419. * Reserved for PCF and PCSS
  9420. * Good tradeoff for quality/perf cross devices
  9421. *
  9422. * Execute PCF on a 3*3 kernel.
  9423. *
  9424. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9425. */
  9426. static readonly QUALITY_MEDIUM: number;
  9427. /**
  9428. * Reserved for PCF and PCSS
  9429. * The lowest quality but the fastest.
  9430. *
  9431. * Execute PCF on a 1*1 kernel.
  9432. *
  9433. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9434. */
  9435. static readonly QUALITY_LOW: number;
  9436. /** Gets or sets the custom shader name to use */
  9437. customShaderOptions: ICustomShaderOptions;
  9438. /**
  9439. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9440. */
  9441. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9442. /**
  9443. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9444. */
  9445. onAfterShadowMapRenderObservable: Observable<Effect>;
  9446. /**
  9447. * Observable triggered before a mesh is rendered in the shadow map.
  9448. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9449. */
  9450. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9451. /**
  9452. * Observable triggered after a mesh is rendered in the shadow map.
  9453. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9454. */
  9455. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9456. private _bias;
  9457. /**
  9458. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9459. */
  9460. /**
  9461. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9462. */
  9463. bias: number;
  9464. private _normalBias;
  9465. /**
  9466. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9467. */
  9468. /**
  9469. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9470. */
  9471. normalBias: number;
  9472. private _blurBoxOffset;
  9473. /**
  9474. * Gets the blur box offset: offset applied during the blur pass.
  9475. * Only useful if useKernelBlur = false
  9476. */
  9477. /**
  9478. * Sets the blur box offset: offset applied during the blur pass.
  9479. * Only useful if useKernelBlur = false
  9480. */
  9481. blurBoxOffset: number;
  9482. private _blurScale;
  9483. /**
  9484. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9485. * 2 means half of the size.
  9486. */
  9487. /**
  9488. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9489. * 2 means half of the size.
  9490. */
  9491. blurScale: number;
  9492. private _blurKernel;
  9493. /**
  9494. * Gets the blur kernel: kernel size of the blur pass.
  9495. * Only useful if useKernelBlur = true
  9496. */
  9497. /**
  9498. * Sets the blur kernel: kernel size of the blur pass.
  9499. * Only useful if useKernelBlur = true
  9500. */
  9501. blurKernel: number;
  9502. private _useKernelBlur;
  9503. /**
  9504. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9505. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9506. */
  9507. /**
  9508. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9509. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9510. */
  9511. useKernelBlur: boolean;
  9512. private _depthScale;
  9513. /**
  9514. * Gets the depth scale used in ESM mode.
  9515. */
  9516. /**
  9517. * Sets the depth scale used in ESM mode.
  9518. * This can override the scale stored on the light.
  9519. */
  9520. depthScale: number;
  9521. private _filter;
  9522. /**
  9523. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9524. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9525. */
  9526. /**
  9527. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9529. */
  9530. filter: number;
  9531. /**
  9532. * Gets if the current filter is set to Poisson Sampling.
  9533. */
  9534. /**
  9535. * Sets the current filter to Poisson Sampling.
  9536. */
  9537. usePoissonSampling: boolean;
  9538. /**
  9539. * Gets if the current filter is set to ESM.
  9540. */
  9541. /**
  9542. * Sets the current filter is to ESM.
  9543. */
  9544. useExponentialShadowMap: boolean;
  9545. /**
  9546. * Gets if the current filter is set to filtered ESM.
  9547. */
  9548. /**
  9549. * Gets if the current filter is set to filtered ESM.
  9550. */
  9551. useBlurExponentialShadowMap: boolean;
  9552. /**
  9553. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9554. * exponential to prevent steep falloff artifacts).
  9555. */
  9556. /**
  9557. * Sets the current filter to "close ESM" (using the inverse of the
  9558. * exponential to prevent steep falloff artifacts).
  9559. */
  9560. useCloseExponentialShadowMap: boolean;
  9561. /**
  9562. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9563. * exponential to prevent steep falloff artifacts).
  9564. */
  9565. /**
  9566. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9567. * exponential to prevent steep falloff artifacts).
  9568. */
  9569. useBlurCloseExponentialShadowMap: boolean;
  9570. /**
  9571. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9572. */
  9573. /**
  9574. * Sets the current filter to "PCF" (percentage closer filtering).
  9575. */
  9576. usePercentageCloserFiltering: boolean;
  9577. private _filteringQuality;
  9578. /**
  9579. * Gets the PCF or PCSS Quality.
  9580. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9581. */
  9582. /**
  9583. * Sets the PCF or PCSS Quality.
  9584. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9585. */
  9586. filteringQuality: number;
  9587. /**
  9588. * Gets if the current filter is set to "PCSS" (contact hardening).
  9589. */
  9590. /**
  9591. * Sets the current filter to "PCSS" (contact hardening).
  9592. */
  9593. useContactHardeningShadow: boolean;
  9594. private _contactHardeningLightSizeUVRatio;
  9595. /**
  9596. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9597. * Using a ratio helps keeping shape stability independently of the map size.
  9598. *
  9599. * It does not account for the light projection as it was having too much
  9600. * instability during the light setup or during light position changes.
  9601. *
  9602. * Only valid if useContactHardeningShadow is true.
  9603. */
  9604. /**
  9605. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9606. * Using a ratio helps keeping shape stability independently of the map size.
  9607. *
  9608. * It does not account for the light projection as it was having too much
  9609. * instability during the light setup or during light position changes.
  9610. *
  9611. * Only valid if useContactHardeningShadow is true.
  9612. */
  9613. contactHardeningLightSizeUVRatio: number;
  9614. private _darkness;
  9615. /** Gets or sets the actual darkness of a shadow */
  9616. darkness: number;
  9617. /**
  9618. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9619. * 0 means strongest and 1 would means no shadow.
  9620. * @returns the darkness.
  9621. */
  9622. getDarkness(): number;
  9623. /**
  9624. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9625. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9626. * @returns the shadow generator allowing fluent coding.
  9627. */
  9628. setDarkness(darkness: number): ShadowGenerator;
  9629. private _transparencyShadow;
  9630. /** Gets or sets the ability to have transparent shadow */
  9631. transparencyShadow: boolean;
  9632. /**
  9633. * Sets the ability to have transparent shadow (boolean).
  9634. * @param transparent True if transparent else False
  9635. * @returns the shadow generator allowing fluent coding
  9636. */
  9637. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9638. private _shadowMap;
  9639. private _shadowMap2;
  9640. /**
  9641. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9642. * @returns The render target texture if present otherwise, null
  9643. */
  9644. getShadowMap(): Nullable<RenderTargetTexture>;
  9645. /**
  9646. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9647. * @returns The render target texture if the shadow map is present otherwise, null
  9648. */
  9649. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9650. /**
  9651. * Gets the class name of that object
  9652. * @returns "ShadowGenerator"
  9653. */
  9654. getClassName(): string;
  9655. /**
  9656. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9657. * @param mesh Mesh to add
  9658. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9659. * @returns the Shadow Generator itself
  9660. */
  9661. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9662. /**
  9663. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9664. * @param mesh Mesh to remove
  9665. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9666. * @returns the Shadow Generator itself
  9667. */
  9668. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9669. /**
  9670. * Controls the extent to which the shadows fade out at the edge of the frustum
  9671. * Used only by directionals and spots
  9672. */
  9673. frustumEdgeFalloff: number;
  9674. private _light;
  9675. /**
  9676. * Returns the associated light object.
  9677. * @returns the light generating the shadow
  9678. */
  9679. getLight(): IShadowLight;
  9680. /**
  9681. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9682. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9683. * It might on the other hand introduce peter panning.
  9684. */
  9685. forceBackFacesOnly: boolean;
  9686. private _scene;
  9687. private _lightDirection;
  9688. private _effect;
  9689. private _viewMatrix;
  9690. private _projectionMatrix;
  9691. private _transformMatrix;
  9692. private _cachedPosition;
  9693. private _cachedDirection;
  9694. private _cachedDefines;
  9695. private _currentRenderID;
  9696. private _boxBlurPostprocess;
  9697. private _kernelBlurXPostprocess;
  9698. private _kernelBlurYPostprocess;
  9699. private _blurPostProcesses;
  9700. private _mapSize;
  9701. private _currentFaceIndex;
  9702. private _currentFaceIndexCache;
  9703. private _textureType;
  9704. private _defaultTextureMatrix;
  9705. private _storedUniqueId;
  9706. /** @hidden */
  9707. static _SceneComponentInitialization: (scene: Scene) => void;
  9708. /**
  9709. * Creates a ShadowGenerator object.
  9710. * A ShadowGenerator is the required tool to use the shadows.
  9711. * Each light casting shadows needs to use its own ShadowGenerator.
  9712. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9713. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9714. * @param light The light object generating the shadows.
  9715. * @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.
  9716. */
  9717. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9718. private _initializeGenerator;
  9719. private _initializeShadowMap;
  9720. private _initializeBlurRTTAndPostProcesses;
  9721. private _renderForShadowMap;
  9722. private _renderSubMeshForShadowMap;
  9723. private _applyFilterValues;
  9724. /**
  9725. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9726. * @param onCompiled Callback triggered at the and of the effects compilation
  9727. * @param options Sets of optional options forcing the compilation with different modes
  9728. */
  9729. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9730. useInstances: boolean;
  9731. }>): void;
  9732. /**
  9733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9734. * @param options Sets of optional options forcing the compilation with different modes
  9735. * @returns A promise that resolves when the compilation completes
  9736. */
  9737. forceCompilationAsync(options?: Partial<{
  9738. useInstances: boolean;
  9739. }>): Promise<void>;
  9740. /**
  9741. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9742. * @param subMesh The submesh we want to render in the shadow map
  9743. * @param useInstances Defines wether will draw in the map using instances
  9744. * @returns true if ready otherwise, false
  9745. */
  9746. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9747. /**
  9748. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9749. * @param defines Defines of the material we want to update
  9750. * @param lightIndex Index of the light in the enabled light list of the material
  9751. */
  9752. prepareDefines(defines: any, lightIndex: number): void;
  9753. /**
  9754. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9755. * defined in the generator but impacting the effect).
  9756. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9757. * @param effect The effect we are binfing the information for
  9758. */
  9759. bindShadowLight(lightIndex: string, effect: Effect): void;
  9760. /**
  9761. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9762. * (eq to shadow prjection matrix * light transform matrix)
  9763. * @returns The transform matrix used to create the shadow map
  9764. */
  9765. getTransformMatrix(): Matrix;
  9766. /**
  9767. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9768. * Cube and 2D textures for instance.
  9769. */
  9770. recreateShadowMap(): void;
  9771. private _disposeBlurPostProcesses;
  9772. private _disposeRTTandPostProcesses;
  9773. /**
  9774. * Disposes the ShadowGenerator.
  9775. * Returns nothing.
  9776. */
  9777. dispose(): void;
  9778. /**
  9779. * Serializes the shadow generator setup to a json object.
  9780. * @returns The serialized JSON object
  9781. */
  9782. serialize(): any;
  9783. /**
  9784. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9785. * @param parsedShadowGenerator The JSON object to parse
  9786. * @param scene The scene to create the shadow map for
  9787. * @returns The parsed shadow generator
  9788. */
  9789. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9790. }
  9791. }
  9792. declare module "babylonjs/Lights/light" {
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Scene } from "babylonjs/scene";
  9795. import { Vector3 } from "babylonjs/Maths/math.vector";
  9796. import { Color3 } from "babylonjs/Maths/math.color";
  9797. import { Node } from "babylonjs/node";
  9798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9799. import { Effect } from "babylonjs/Materials/effect";
  9800. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9801. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9802. /**
  9803. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9804. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9805. * 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.
  9806. */
  9807. export abstract class Light extends Node {
  9808. /**
  9809. * Falloff Default: light is falling off following the material specification:
  9810. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9811. */
  9812. static readonly FALLOFF_DEFAULT: number;
  9813. /**
  9814. * Falloff Physical: light is falling off following the inverse squared distance law.
  9815. */
  9816. static readonly FALLOFF_PHYSICAL: number;
  9817. /**
  9818. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9819. * to enhance interoperability with other engines.
  9820. */
  9821. static readonly FALLOFF_GLTF: number;
  9822. /**
  9823. * Falloff Standard: light is falling off like in the standard material
  9824. * to enhance interoperability with other materials.
  9825. */
  9826. static readonly FALLOFF_STANDARD: number;
  9827. /**
  9828. * If every light affecting the material is in this lightmapMode,
  9829. * material.lightmapTexture adds or multiplies
  9830. * (depends on material.useLightmapAsShadowmap)
  9831. * after every other light calculations.
  9832. */
  9833. static readonly LIGHTMAP_DEFAULT: number;
  9834. /**
  9835. * material.lightmapTexture as only diffuse lighting from this light
  9836. * adds only specular lighting from this light
  9837. * adds dynamic shadows
  9838. */
  9839. static readonly LIGHTMAP_SPECULAR: number;
  9840. /**
  9841. * material.lightmapTexture as only lighting
  9842. * no light calculation from this light
  9843. * only adds dynamic shadows from this light
  9844. */
  9845. static readonly LIGHTMAP_SHADOWSONLY: number;
  9846. /**
  9847. * Each light type uses the default quantity according to its type:
  9848. * point/spot lights use luminous intensity
  9849. * directional lights use illuminance
  9850. */
  9851. static readonly INTENSITYMODE_AUTOMATIC: number;
  9852. /**
  9853. * lumen (lm)
  9854. */
  9855. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9856. /**
  9857. * candela (lm/sr)
  9858. */
  9859. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9860. /**
  9861. * lux (lm/m^2)
  9862. */
  9863. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9864. /**
  9865. * nit (cd/m^2)
  9866. */
  9867. static readonly INTENSITYMODE_LUMINANCE: number;
  9868. /**
  9869. * Light type const id of the point light.
  9870. */
  9871. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9872. /**
  9873. * Light type const id of the directional light.
  9874. */
  9875. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9876. /**
  9877. * Light type const id of the spot light.
  9878. */
  9879. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9880. /**
  9881. * Light type const id of the hemispheric light.
  9882. */
  9883. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9884. /**
  9885. * Diffuse gives the basic color to an object.
  9886. */
  9887. diffuse: Color3;
  9888. /**
  9889. * Specular produces a highlight color on an object.
  9890. * Note: This is note affecting PBR materials.
  9891. */
  9892. specular: Color3;
  9893. /**
  9894. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9895. * falling off base on range or angle.
  9896. * This can be set to any values in Light.FALLOFF_x.
  9897. *
  9898. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9899. * other types of materials.
  9900. */
  9901. falloffType: number;
  9902. /**
  9903. * Strength of the light.
  9904. * Note: By default it is define in the framework own unit.
  9905. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9906. */
  9907. intensity: number;
  9908. private _range;
  9909. protected _inverseSquaredRange: number;
  9910. /**
  9911. * Defines how far from the source the light is impacting in scene units.
  9912. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9913. */
  9914. /**
  9915. * Defines how far from the source the light is impacting in scene units.
  9916. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9917. */
  9918. range: number;
  9919. /**
  9920. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9921. * of light.
  9922. */
  9923. private _photometricScale;
  9924. private _intensityMode;
  9925. /**
  9926. * Gets the photometric scale used to interpret the intensity.
  9927. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9928. */
  9929. /**
  9930. * Sets the photometric scale used to interpret the intensity.
  9931. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9932. */
  9933. intensityMode: number;
  9934. private _radius;
  9935. /**
  9936. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9937. */
  9938. /**
  9939. * sets the light radius used by PBR Materials to simulate soft area lights.
  9940. */
  9941. radius: number;
  9942. private _renderPriority;
  9943. /**
  9944. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9945. * exceeding the number allowed of the materials.
  9946. */
  9947. renderPriority: number;
  9948. private _shadowEnabled;
  9949. /**
  9950. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9951. * the current shadow generator.
  9952. */
  9953. /**
  9954. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9955. * the current shadow generator.
  9956. */
  9957. shadowEnabled: boolean;
  9958. private _includedOnlyMeshes;
  9959. /**
  9960. * Gets the only meshes impacted by this light.
  9961. */
  9962. /**
  9963. * Sets the only meshes impacted by this light.
  9964. */
  9965. includedOnlyMeshes: AbstractMesh[];
  9966. private _excludedMeshes;
  9967. /**
  9968. * Gets the meshes not impacted by this light.
  9969. */
  9970. /**
  9971. * Sets the meshes not impacted by this light.
  9972. */
  9973. excludedMeshes: AbstractMesh[];
  9974. private _excludeWithLayerMask;
  9975. /**
  9976. * Gets the layer id use to find what meshes are not impacted by the light.
  9977. * Inactive if 0
  9978. */
  9979. /**
  9980. * Sets the layer id use to find what meshes are not impacted by the light.
  9981. * Inactive if 0
  9982. */
  9983. excludeWithLayerMask: number;
  9984. private _includeOnlyWithLayerMask;
  9985. /**
  9986. * Gets the layer id use to find what meshes are impacted by the light.
  9987. * Inactive if 0
  9988. */
  9989. /**
  9990. * Sets the layer id use to find what meshes are impacted by the light.
  9991. * Inactive if 0
  9992. */
  9993. includeOnlyWithLayerMask: number;
  9994. private _lightmapMode;
  9995. /**
  9996. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9997. */
  9998. /**
  9999. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10000. */
  10001. lightmapMode: number;
  10002. /**
  10003. * Shadow generator associted to the light.
  10004. * @hidden Internal use only.
  10005. */
  10006. _shadowGenerator: Nullable<IShadowGenerator>;
  10007. /**
  10008. * @hidden Internal use only.
  10009. */
  10010. _excludedMeshesIds: string[];
  10011. /**
  10012. * @hidden Internal use only.
  10013. */
  10014. _includedOnlyMeshesIds: string[];
  10015. /**
  10016. * The current light unifom buffer.
  10017. * @hidden Internal use only.
  10018. */
  10019. _uniformBuffer: UniformBuffer;
  10020. /** @hidden */
  10021. _renderId: number;
  10022. /**
  10023. * Creates a Light object in the scene.
  10024. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10025. * @param name The firendly name of the light
  10026. * @param scene The scene the light belongs too
  10027. */
  10028. constructor(name: string, scene: Scene);
  10029. protected abstract _buildUniformLayout(): void;
  10030. /**
  10031. * Sets the passed Effect "effect" with the Light information.
  10032. * @param effect The effect to update
  10033. * @param lightIndex The index of the light in the effect to update
  10034. * @returns The light
  10035. */
  10036. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10037. /**
  10038. * Sets the passed Effect "effect" with the Light information.
  10039. * @param effect The effect to update
  10040. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10041. * @returns The light
  10042. */
  10043. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10044. /**
  10045. * Returns the string "Light".
  10046. * @returns the class name
  10047. */
  10048. getClassName(): string;
  10049. /** @hidden */
  10050. readonly _isLight: boolean;
  10051. /**
  10052. * Converts the light information to a readable string for debug purpose.
  10053. * @param fullDetails Supports for multiple levels of logging within scene loading
  10054. * @returns the human readable light info
  10055. */
  10056. toString(fullDetails?: boolean): string;
  10057. /** @hidden */
  10058. protected _syncParentEnabledState(): void;
  10059. /**
  10060. * Set the enabled state of this node.
  10061. * @param value - the new enabled state
  10062. */
  10063. setEnabled(value: boolean): void;
  10064. /**
  10065. * Returns the Light associated shadow generator if any.
  10066. * @return the associated shadow generator.
  10067. */
  10068. getShadowGenerator(): Nullable<IShadowGenerator>;
  10069. /**
  10070. * Returns a Vector3, the absolute light position in the World.
  10071. * @returns the world space position of the light
  10072. */
  10073. getAbsolutePosition(): Vector3;
  10074. /**
  10075. * Specifies if the light will affect the passed mesh.
  10076. * @param mesh The mesh to test against the light
  10077. * @return true the mesh is affected otherwise, false.
  10078. */
  10079. canAffectMesh(mesh: AbstractMesh): boolean;
  10080. /**
  10081. * Sort function to order lights for rendering.
  10082. * @param a First Light object to compare to second.
  10083. * @param b Second Light object to compare first.
  10084. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10085. */
  10086. static CompareLightsPriority(a: Light, b: Light): number;
  10087. /**
  10088. * Releases resources associated with this node.
  10089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10091. */
  10092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10093. /**
  10094. * Returns the light type ID (integer).
  10095. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10096. */
  10097. getTypeID(): number;
  10098. /**
  10099. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10100. * @returns the scaled intensity in intensity mode unit
  10101. */
  10102. getScaledIntensity(): number;
  10103. /**
  10104. * Returns a new Light object, named "name", from the current one.
  10105. * @param name The name of the cloned light
  10106. * @returns the new created light
  10107. */
  10108. clone(name: string): Nullable<Light>;
  10109. /**
  10110. * Serializes the current light into a Serialization object.
  10111. * @returns the serialized object.
  10112. */
  10113. serialize(): any;
  10114. /**
  10115. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10116. * This new light is named "name" and added to the passed scene.
  10117. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10118. * @param name The friendly name of the light
  10119. * @param scene The scene the new light will belong to
  10120. * @returns the constructor function
  10121. */
  10122. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10123. /**
  10124. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10125. * @param parsedLight The JSON representation of the light
  10126. * @param scene The scene to create the parsed light in
  10127. * @returns the created light after parsing
  10128. */
  10129. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10130. private _hookArrayForExcluded;
  10131. private _hookArrayForIncludedOnly;
  10132. private _resyncMeshes;
  10133. /**
  10134. * Forces the meshes to update their light related information in their rendering used effects
  10135. * @hidden Internal Use Only
  10136. */
  10137. _markMeshesAsLightDirty(): void;
  10138. /**
  10139. * Recomputes the cached photometric scale if needed.
  10140. */
  10141. private _computePhotometricScale;
  10142. /**
  10143. * Returns the Photometric Scale according to the light type and intensity mode.
  10144. */
  10145. private _getPhotometricScale;
  10146. /**
  10147. * Reorder the light in the scene according to their defined priority.
  10148. * @hidden Internal Use Only
  10149. */
  10150. _reorderLightsInScene(): void;
  10151. /**
  10152. * Prepares the list of defines specific to the light type.
  10153. * @param defines the list of defines
  10154. * @param lightIndex defines the index of the light for the effect
  10155. */
  10156. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10157. }
  10158. }
  10159. declare module "babylonjs/Actions/action" {
  10160. import { Observable } from "babylonjs/Misc/observable";
  10161. import { Condition } from "babylonjs/Actions/condition";
  10162. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10163. import { ActionManager } from "babylonjs/Actions/actionManager";
  10164. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10165. /**
  10166. * Interface used to define Action
  10167. */
  10168. export interface IAction {
  10169. /**
  10170. * Trigger for the action
  10171. */
  10172. trigger: number;
  10173. /** Options of the trigger */
  10174. triggerOptions: any;
  10175. /**
  10176. * Gets the trigger parameters
  10177. * @returns the trigger parameters
  10178. */
  10179. getTriggerParameter(): any;
  10180. /**
  10181. * Internal only - executes current action event
  10182. * @hidden
  10183. */
  10184. _executeCurrent(evt?: ActionEvent): void;
  10185. /**
  10186. * Serialize placeholder for child classes
  10187. * @param parent of child
  10188. * @returns the serialized object
  10189. */
  10190. serialize(parent: any): any;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. _prepare(): void;
  10196. /**
  10197. * Internal only - manager for action
  10198. * @hidden
  10199. */
  10200. _actionManager: AbstractActionManager;
  10201. /**
  10202. * Adds action to chain of actions, may be a DoNothingAction
  10203. * @param action defines the next action to execute
  10204. * @returns The action passed in
  10205. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10206. */
  10207. then(action: IAction): IAction;
  10208. }
  10209. /**
  10210. * The action to be carried out following a trigger
  10211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10212. */
  10213. export class Action implements IAction {
  10214. /** the trigger, with or without parameters, for the action */
  10215. triggerOptions: any;
  10216. /**
  10217. * Trigger for the action
  10218. */
  10219. trigger: number;
  10220. /**
  10221. * Internal only - manager for action
  10222. * @hidden
  10223. */
  10224. _actionManager: ActionManager;
  10225. private _nextActiveAction;
  10226. private _child;
  10227. private _condition?;
  10228. private _triggerParameter;
  10229. /**
  10230. * An event triggered prior to action being executed.
  10231. */
  10232. onBeforeExecuteObservable: Observable<Action>;
  10233. /**
  10234. * Creates a new Action
  10235. * @param triggerOptions the trigger, with or without parameters, for the action
  10236. * @param condition an optional determinant of action
  10237. */
  10238. constructor(
  10239. /** the trigger, with or without parameters, for the action */
  10240. triggerOptions: any, condition?: Condition);
  10241. /**
  10242. * Internal only
  10243. * @hidden
  10244. */
  10245. _prepare(): void;
  10246. /**
  10247. * Gets the trigger parameters
  10248. * @returns the trigger parameters
  10249. */
  10250. getTriggerParameter(): any;
  10251. /**
  10252. * Internal only - executes current action event
  10253. * @hidden
  10254. */
  10255. _executeCurrent(evt?: ActionEvent): void;
  10256. /**
  10257. * Execute placeholder for child classes
  10258. * @param evt optional action event
  10259. */
  10260. execute(evt?: ActionEvent): void;
  10261. /**
  10262. * Skips to next active action
  10263. */
  10264. skipToNextActiveAction(): void;
  10265. /**
  10266. * Adds action to chain of actions, may be a DoNothingAction
  10267. * @param action defines the next action to execute
  10268. * @returns The action passed in
  10269. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10270. */
  10271. then(action: Action): Action;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. _getProperty(propertyPath: string): string;
  10277. /**
  10278. * Internal only
  10279. * @hidden
  10280. */
  10281. _getEffectiveTarget(target: any, propertyPath: string): any;
  10282. /**
  10283. * Serialize placeholder for child classes
  10284. * @param parent of child
  10285. * @returns the serialized object
  10286. */
  10287. serialize(parent: any): any;
  10288. /**
  10289. * Internal only called by serialize
  10290. * @hidden
  10291. */
  10292. protected _serialize(serializedAction: any, parent?: any): any;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. static _SerializeValueAsString: (value: any) => string;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10303. name: string;
  10304. targetType: string;
  10305. value: string;
  10306. };
  10307. }
  10308. }
  10309. declare module "babylonjs/Actions/condition" {
  10310. import { ActionManager } from "babylonjs/Actions/actionManager";
  10311. /**
  10312. * A Condition applied to an Action
  10313. */
  10314. export class Condition {
  10315. /**
  10316. * Internal only - manager for action
  10317. * @hidden
  10318. */
  10319. _actionManager: ActionManager;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _evaluationId: number;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. _currentResult: boolean;
  10330. /**
  10331. * Creates a new Condition
  10332. * @param actionManager the manager of the action the condition is applied to
  10333. */
  10334. constructor(actionManager: ActionManager);
  10335. /**
  10336. * Check if the current condition is valid
  10337. * @returns a boolean
  10338. */
  10339. isValid(): boolean;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. _getProperty(propertyPath: string): string;
  10345. /**
  10346. * Internal only
  10347. * @hidden
  10348. */
  10349. _getEffectiveTarget(target: any, propertyPath: string): any;
  10350. /**
  10351. * Serialize placeholder for child classes
  10352. * @returns the serialized object
  10353. */
  10354. serialize(): any;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */
  10359. protected _serialize(serializedCondition: any): any;
  10360. }
  10361. /**
  10362. * Defines specific conditional operators as extensions of Condition
  10363. */
  10364. export class ValueCondition extends Condition {
  10365. /** path to specify the property of the target the conditional operator uses */
  10366. propertyPath: string;
  10367. /** the value compared by the conditional operator against the current value of the property */
  10368. value: any;
  10369. /** the conditional operator, default ValueCondition.IsEqual */
  10370. operator: number;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private static _IsEqual;
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. private static _IsDifferent;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. private static _IsGreater;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. private static _IsLesser;
  10391. /**
  10392. * returns the number for IsEqual
  10393. */
  10394. static readonly IsEqual: number;
  10395. /**
  10396. * Returns the number for IsDifferent
  10397. */
  10398. static readonly IsDifferent: number;
  10399. /**
  10400. * Returns the number for IsGreater
  10401. */
  10402. static readonly IsGreater: number;
  10403. /**
  10404. * Returns the number for IsLesser
  10405. */
  10406. static readonly IsLesser: number;
  10407. /**
  10408. * Internal only The action manager for the condition
  10409. * @hidden
  10410. */
  10411. _actionManager: ActionManager;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. private _target;
  10417. /**
  10418. * Internal only
  10419. * @hidden
  10420. */
  10421. private _effectiveTarget;
  10422. /**
  10423. * Internal only
  10424. * @hidden
  10425. */
  10426. private _property;
  10427. /**
  10428. * Creates a new ValueCondition
  10429. * @param actionManager manager for the action the condition applies to
  10430. * @param target for the action
  10431. * @param propertyPath path to specify the property of the target the conditional operator uses
  10432. * @param value the value compared by the conditional operator against the current value of the property
  10433. * @param operator the conditional operator, default ValueCondition.IsEqual
  10434. */
  10435. constructor(actionManager: ActionManager, target: any,
  10436. /** path to specify the property of the target the conditional operator uses */
  10437. propertyPath: string,
  10438. /** the value compared by the conditional operator against the current value of the property */
  10439. value: any,
  10440. /** the conditional operator, default ValueCondition.IsEqual */
  10441. operator?: number);
  10442. /**
  10443. * Compares the given value with the property value for the specified conditional operator
  10444. * @returns the result of the comparison
  10445. */
  10446. isValid(): boolean;
  10447. /**
  10448. * Serialize the ValueCondition into a JSON compatible object
  10449. * @returns serialization object
  10450. */
  10451. serialize(): any;
  10452. /**
  10453. * Gets the name of the conditional operator for the ValueCondition
  10454. * @param operator the conditional operator
  10455. * @returns the name
  10456. */
  10457. static GetOperatorName(operator: number): string;
  10458. }
  10459. /**
  10460. * Defines a predicate condition as an extension of Condition
  10461. */
  10462. export class PredicateCondition extends Condition {
  10463. /** defines the predicate function used to validate the condition */
  10464. predicate: () => boolean;
  10465. /**
  10466. * Internal only - manager for action
  10467. * @hidden
  10468. */
  10469. _actionManager: ActionManager;
  10470. /**
  10471. * Creates a new PredicateCondition
  10472. * @param actionManager manager for the action the condition applies to
  10473. * @param predicate defines the predicate function used to validate the condition
  10474. */
  10475. constructor(actionManager: ActionManager,
  10476. /** defines the predicate function used to validate the condition */
  10477. predicate: () => boolean);
  10478. /**
  10479. * @returns the validity of the predicate condition
  10480. */
  10481. isValid(): boolean;
  10482. }
  10483. /**
  10484. * Defines a state condition as an extension of Condition
  10485. */
  10486. export class StateCondition extends Condition {
  10487. /** Value to compare with target state */
  10488. value: string;
  10489. /**
  10490. * Internal only - manager for action
  10491. * @hidden
  10492. */
  10493. _actionManager: ActionManager;
  10494. /**
  10495. * Internal only
  10496. * @hidden
  10497. */
  10498. private _target;
  10499. /**
  10500. * Creates a new StateCondition
  10501. * @param actionManager manager for the action the condition applies to
  10502. * @param target of the condition
  10503. * @param value to compare with target state
  10504. */
  10505. constructor(actionManager: ActionManager, target: any,
  10506. /** Value to compare with target state */
  10507. value: string);
  10508. /**
  10509. * Gets a boolean indicating if the current condition is met
  10510. * @returns the validity of the state
  10511. */
  10512. isValid(): boolean;
  10513. /**
  10514. * Serialize the StateCondition into a JSON compatible object
  10515. * @returns serialization object
  10516. */
  10517. serialize(): any;
  10518. }
  10519. }
  10520. declare module "babylonjs/Actions/directActions" {
  10521. import { Action } from "babylonjs/Actions/action";
  10522. import { Condition } from "babylonjs/Actions/condition";
  10523. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10524. /**
  10525. * This defines an action responsible to toggle a boolean once triggered.
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10527. */
  10528. export class SwitchBooleanAction extends Action {
  10529. /**
  10530. * The path to the boolean property in the target object
  10531. */
  10532. propertyPath: string;
  10533. private _target;
  10534. private _effectiveTarget;
  10535. private _property;
  10536. /**
  10537. * Instantiate the action
  10538. * @param triggerOptions defines the trigger options
  10539. * @param target defines the object containing the boolean
  10540. * @param propertyPath defines the path to the boolean property in the target object
  10541. * @param condition defines the trigger related conditions
  10542. */
  10543. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10544. /** @hidden */
  10545. _prepare(): void;
  10546. /**
  10547. * Execute the action toggle the boolean value.
  10548. */
  10549. execute(): void;
  10550. /**
  10551. * Serializes the actions and its related information.
  10552. * @param parent defines the object to serialize in
  10553. * @returns the serialized object
  10554. */
  10555. serialize(parent: any): any;
  10556. }
  10557. /**
  10558. * This defines an action responsible to set a the state field of the target
  10559. * to a desired value once triggered.
  10560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10561. */
  10562. export class SetStateAction extends Action {
  10563. /**
  10564. * The value to store in the state field.
  10565. */
  10566. value: string;
  10567. private _target;
  10568. /**
  10569. * Instantiate the action
  10570. * @param triggerOptions defines the trigger options
  10571. * @param target defines the object containing the state property
  10572. * @param value defines the value to store in the state field
  10573. * @param condition defines the trigger related conditions
  10574. */
  10575. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10576. /**
  10577. * Execute the action and store the value on the target state property.
  10578. */
  10579. execute(): void;
  10580. /**
  10581. * Serializes the actions and its related information.
  10582. * @param parent defines the object to serialize in
  10583. * @returns the serialized object
  10584. */
  10585. serialize(parent: any): any;
  10586. }
  10587. /**
  10588. * This defines an action responsible to set a property of the target
  10589. * to a desired value once triggered.
  10590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10591. */
  10592. export class SetValueAction extends Action {
  10593. /**
  10594. * The path of the property to set in the target.
  10595. */
  10596. propertyPath: string;
  10597. /**
  10598. * The value to set in the property
  10599. */
  10600. value: any;
  10601. private _target;
  10602. private _effectiveTarget;
  10603. private _property;
  10604. /**
  10605. * Instantiate the action
  10606. * @param triggerOptions defines the trigger options
  10607. * @param target defines the object containing the property
  10608. * @param propertyPath defines the path of the property to set in the target
  10609. * @param value defines the value to set in the property
  10610. * @param condition defines the trigger related conditions
  10611. */
  10612. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10613. /** @hidden */
  10614. _prepare(): void;
  10615. /**
  10616. * Execute the action and set the targetted property to the desired value.
  10617. */
  10618. execute(): void;
  10619. /**
  10620. * Serializes the actions and its related information.
  10621. * @param parent defines the object to serialize in
  10622. * @returns the serialized object
  10623. */
  10624. serialize(parent: any): any;
  10625. }
  10626. /**
  10627. * This defines an action responsible to increment the target value
  10628. * to a desired value once triggered.
  10629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10630. */
  10631. export class IncrementValueAction extends Action {
  10632. /**
  10633. * The path of the property to increment in the target.
  10634. */
  10635. propertyPath: string;
  10636. /**
  10637. * The value we should increment the property by.
  10638. */
  10639. value: any;
  10640. private _target;
  10641. private _effectiveTarget;
  10642. private _property;
  10643. /**
  10644. * Instantiate the action
  10645. * @param triggerOptions defines the trigger options
  10646. * @param target defines the object containing the property
  10647. * @param propertyPath defines the path of the property to increment in the target
  10648. * @param value defines the value value we should increment the property by
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10652. /** @hidden */
  10653. _prepare(): void;
  10654. /**
  10655. * Execute the action and increment the target of the value amount.
  10656. */
  10657. execute(): void;
  10658. /**
  10659. * Serializes the actions and its related information.
  10660. * @param parent defines the object to serialize in
  10661. * @returns the serialized object
  10662. */
  10663. serialize(parent: any): any;
  10664. }
  10665. /**
  10666. * This defines an action responsible to start an animation once triggered.
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10668. */
  10669. export class PlayAnimationAction extends Action {
  10670. /**
  10671. * Where the animation should start (animation frame)
  10672. */
  10673. from: number;
  10674. /**
  10675. * Where the animation should stop (animation frame)
  10676. */
  10677. to: number;
  10678. /**
  10679. * Define if the animation should loop or stop after the first play.
  10680. */
  10681. loop?: boolean;
  10682. private _target;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the target animation or animation name
  10687. * @param from defines from where the animation should start (animation frame)
  10688. * @param end defines where the animation should stop (animation frame)
  10689. * @param loop defines if the animation should loop or stop after the first play
  10690. * @param condition defines the trigger related conditions
  10691. */
  10692. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10693. /** @hidden */
  10694. _prepare(): void;
  10695. /**
  10696. * Execute the action and play the animation.
  10697. */
  10698. execute(): void;
  10699. /**
  10700. * Serializes the actions and its related information.
  10701. * @param parent defines the object to serialize in
  10702. * @returns the serialized object
  10703. */
  10704. serialize(parent: any): any;
  10705. }
  10706. /**
  10707. * This defines an action responsible to stop an animation once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class StopAnimationAction extends Action {
  10711. private _target;
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param target defines the target animation or animation name
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, target: any, condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and stop the animation.
  10723. */
  10724. execute(): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible that does nothing once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class DoNothingAction extends Action {
  10737. /**
  10738. * Instantiate the action
  10739. * @param triggerOptions defines the trigger options
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions?: any, condition?: Condition);
  10743. /**
  10744. * Execute the action and do nothing.
  10745. */
  10746. execute(): void;
  10747. /**
  10748. * Serializes the actions and its related information.
  10749. * @param parent defines the object to serialize in
  10750. * @returns the serialized object
  10751. */
  10752. serialize(parent: any): any;
  10753. }
  10754. /**
  10755. * This defines an action responsible to trigger several actions once triggered.
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10757. */
  10758. export class CombineAction extends Action {
  10759. /**
  10760. * The list of aggregated animations to run.
  10761. */
  10762. children: Action[];
  10763. /**
  10764. * Instantiate the action
  10765. * @param triggerOptions defines the trigger options
  10766. * @param children defines the list of aggregated animations to run
  10767. * @param condition defines the trigger related conditions
  10768. */
  10769. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10770. /** @hidden */
  10771. _prepare(): void;
  10772. /**
  10773. * Execute the action and executes all the aggregated actions.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. /**
  10777. * Serializes the actions and its related information.
  10778. * @param parent defines the object to serialize in
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. }
  10783. /**
  10784. * This defines an action responsible to run code (external event) once triggered.
  10785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10786. */
  10787. export class ExecuteCodeAction extends Action {
  10788. /**
  10789. * The callback function to run.
  10790. */
  10791. func: (evt: ActionEvent) => void;
  10792. /**
  10793. * Instantiate the action
  10794. * @param triggerOptions defines the trigger options
  10795. * @param func defines the callback function to run
  10796. * @param condition defines the trigger related conditions
  10797. */
  10798. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10799. /**
  10800. * Execute the action and run the attached code.
  10801. */
  10802. execute(evt: ActionEvent): void;
  10803. }
  10804. /**
  10805. * This defines an action responsible to set the parent property of the target once triggered.
  10806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10807. */
  10808. export class SetParentAction extends Action {
  10809. private _parent;
  10810. private _target;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the target containing the parent property
  10815. * @param parent defines from where the animation should start (animation frame)
  10816. * @param condition defines the trigger related conditions
  10817. */
  10818. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10819. /** @hidden */
  10820. _prepare(): void;
  10821. /**
  10822. * Execute the action and set the parent property.
  10823. */
  10824. execute(): void;
  10825. /**
  10826. * Serializes the actions and its related information.
  10827. * @param parent defines the object to serialize in
  10828. * @returns the serialized object
  10829. */
  10830. serialize(parent: any): any;
  10831. }
  10832. }
  10833. declare module "babylonjs/Actions/actionManager" {
  10834. import { Nullable } from "babylonjs/types";
  10835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10836. import { Scene } from "babylonjs/scene";
  10837. import { IAction } from "babylonjs/Actions/action";
  10838. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10839. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10840. /**
  10841. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10842. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class ActionManager extends AbstractActionManager {
  10846. /**
  10847. * Nothing
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly NothingTrigger: number;
  10851. /**
  10852. * On pick
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPickTrigger: number;
  10856. /**
  10857. * On left pick
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnLeftPickTrigger: number;
  10861. /**
  10862. * On right pick
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnRightPickTrigger: number;
  10866. /**
  10867. * On center pick
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnCenterPickTrigger: number;
  10871. /**
  10872. * On pick down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnPickDownTrigger: number;
  10876. /**
  10877. * On double pick
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnDoublePickTrigger: number;
  10881. /**
  10882. * On pick up
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnPickUpTrigger: number;
  10886. /**
  10887. * On pick out.
  10888. * This trigger will only be raised if you also declared a OnPickDown
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickOutTrigger: number;
  10892. /**
  10893. * On long press
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnLongPressTrigger: number;
  10897. /**
  10898. * On pointer over
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnPointerOverTrigger: number;
  10902. /**
  10903. * On pointer out
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnPointerOutTrigger: number;
  10907. /**
  10908. * On every frame
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnEveryFrameTrigger: number;
  10912. /**
  10913. * On intersection enter
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnIntersectionEnterTrigger: number;
  10917. /**
  10918. * On intersection exit
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10920. */
  10921. static readonly OnIntersectionExitTrigger: number;
  10922. /**
  10923. * On key down
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnKeyDownTrigger: number;
  10927. /**
  10928. * On key up
  10929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10930. */
  10931. static readonly OnKeyUpTrigger: number;
  10932. private _scene;
  10933. /**
  10934. * Creates a new action manager
  10935. * @param scene defines the hosting scene
  10936. */
  10937. constructor(scene: Scene);
  10938. /**
  10939. * Releases all associated resources
  10940. */
  10941. dispose(): void;
  10942. /**
  10943. * Gets hosting scene
  10944. * @returns the hosting scene
  10945. */
  10946. getScene(): Scene;
  10947. /**
  10948. * Does this action manager handles actions of any of the given triggers
  10949. * @param triggers defines the triggers to be tested
  10950. * @return a boolean indicating whether one (or more) of the triggers is handled
  10951. */
  10952. hasSpecificTriggers(triggers: number[]): boolean;
  10953. /**
  10954. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10955. * speed.
  10956. * @param triggerA defines the trigger to be tested
  10957. * @param triggerB defines the trigger to be tested
  10958. * @return a boolean indicating whether one (or more) of the triggers is handled
  10959. */
  10960. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10961. /**
  10962. * Does this action manager handles actions of a given trigger
  10963. * @param trigger defines the trigger to be tested
  10964. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10965. * @return whether the trigger is handled
  10966. */
  10967. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10968. /**
  10969. * Does this action manager has pointer triggers
  10970. */
  10971. readonly hasPointerTriggers: boolean;
  10972. /**
  10973. * Does this action manager has pick triggers
  10974. */
  10975. readonly hasPickTriggers: boolean;
  10976. /**
  10977. * Registers an action to this action manager
  10978. * @param action defines the action to be registered
  10979. * @return the action amended (prepared) after registration
  10980. */
  10981. registerAction(action: IAction): Nullable<IAction>;
  10982. /**
  10983. * Unregisters an action to this action manager
  10984. * @param action defines the action to be unregistered
  10985. * @return a boolean indicating whether the action has been unregistered
  10986. */
  10987. unregisterAction(action: IAction): Boolean;
  10988. /**
  10989. * Process a specific trigger
  10990. * @param trigger defines the trigger to process
  10991. * @param evt defines the event details to be processed
  10992. */
  10993. processTrigger(trigger: number, evt?: IActionEvent): void;
  10994. /** @hidden */
  10995. _getEffectiveTarget(target: any, propertyPath: string): any;
  10996. /** @hidden */
  10997. _getProperty(propertyPath: string): string;
  10998. /**
  10999. * Serialize this manager to a JSON object
  11000. * @param name defines the property name to store this manager
  11001. * @returns a JSON representation of this manager
  11002. */
  11003. serialize(name: string): any;
  11004. /**
  11005. * Creates a new ActionManager from a JSON data
  11006. * @param parsedActions defines the JSON data to read from
  11007. * @param object defines the hosting mesh
  11008. * @param scene defines the hosting scene
  11009. */
  11010. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11011. /**
  11012. * Get a trigger name by index
  11013. * @param trigger defines the trigger index
  11014. * @returns a trigger name
  11015. */
  11016. static GetTriggerName(trigger: number): string;
  11017. }
  11018. }
  11019. declare module "babylonjs/Culling/ray" {
  11020. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11021. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11023. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11024. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11025. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11026. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11027. import { Plane } from "babylonjs/Maths/math.plane";
  11028. /**
  11029. * Class representing a ray with position and direction
  11030. */
  11031. export class Ray {
  11032. /** origin point */
  11033. origin: Vector3;
  11034. /** direction */
  11035. direction: Vector3;
  11036. /** length of the ray */
  11037. length: number;
  11038. private static readonly TmpVector3;
  11039. private _tmpRay;
  11040. /**
  11041. * Creates a new ray
  11042. * @param origin origin point
  11043. * @param direction direction
  11044. * @param length length of the ray
  11045. */
  11046. constructor(
  11047. /** origin point */
  11048. origin: Vector3,
  11049. /** direction */
  11050. direction: Vector3,
  11051. /** length of the ray */
  11052. length?: number);
  11053. /**
  11054. * Checks if the ray intersects a box
  11055. * @param minimum bound of the box
  11056. * @param maximum bound of the box
  11057. * @param intersectionTreshold extra extend to be added to the box in all direction
  11058. * @returns if the box was hit
  11059. */
  11060. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11061. /**
  11062. * Checks if the ray intersects a box
  11063. * @param box the bounding box to check
  11064. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11065. * @returns if the box was hit
  11066. */
  11067. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11068. /**
  11069. * If the ray hits a sphere
  11070. * @param sphere the bounding sphere to check
  11071. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11072. * @returns true if it hits the sphere
  11073. */
  11074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11075. /**
  11076. * If the ray hits a triange
  11077. * @param vertex0 triangle vertex
  11078. * @param vertex1 triangle vertex
  11079. * @param vertex2 triangle vertex
  11080. * @returns intersection information if hit
  11081. */
  11082. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11083. /**
  11084. * Checks if ray intersects a plane
  11085. * @param plane the plane to check
  11086. * @returns the distance away it was hit
  11087. */
  11088. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11089. /**
  11090. * Calculate the intercept of a ray on a given axis
  11091. * @param axis to check 'x' | 'y' | 'z'
  11092. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11093. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11094. */
  11095. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11096. /**
  11097. * Checks if ray intersects a mesh
  11098. * @param mesh the mesh to check
  11099. * @param fastCheck if only the bounding box should checked
  11100. * @returns picking info of the intersecton
  11101. */
  11102. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11103. /**
  11104. * Checks if ray intersects a mesh
  11105. * @param meshes the meshes to check
  11106. * @param fastCheck if only the bounding box should checked
  11107. * @param results array to store result in
  11108. * @returns Array of picking infos
  11109. */
  11110. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11111. private _comparePickingInfo;
  11112. private static smallnum;
  11113. private static rayl;
  11114. /**
  11115. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11116. * @param sega the first point of the segment to test the intersection against
  11117. * @param segb the second point of the segment to test the intersection against
  11118. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11119. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11120. */
  11121. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11122. /**
  11123. * Update the ray from viewport position
  11124. * @param x position
  11125. * @param y y position
  11126. * @param viewportWidth viewport width
  11127. * @param viewportHeight viewport height
  11128. * @param world world matrix
  11129. * @param view view matrix
  11130. * @param projection projection matrix
  11131. * @returns this ray updated
  11132. */
  11133. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11134. /**
  11135. * Creates a ray with origin and direction of 0,0,0
  11136. * @returns the new ray
  11137. */
  11138. static Zero(): Ray;
  11139. /**
  11140. * Creates a new ray from screen space and viewport
  11141. * @param x position
  11142. * @param y y position
  11143. * @param viewportWidth viewport width
  11144. * @param viewportHeight viewport height
  11145. * @param world world matrix
  11146. * @param view view matrix
  11147. * @param projection projection matrix
  11148. * @returns new ray
  11149. */
  11150. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11151. /**
  11152. * 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
  11153. * transformed to the given world matrix.
  11154. * @param origin The origin point
  11155. * @param end The end point
  11156. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11157. * @returns the new ray
  11158. */
  11159. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11160. /**
  11161. * Transforms a ray by a matrix
  11162. * @param ray ray to transform
  11163. * @param matrix matrix to apply
  11164. * @returns the resulting new ray
  11165. */
  11166. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11167. /**
  11168. * Transforms a ray by a matrix
  11169. * @param ray ray to transform
  11170. * @param matrix matrix to apply
  11171. * @param result ray to store result in
  11172. */
  11173. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11174. /**
  11175. * Unproject a ray from screen space to object space
  11176. * @param sourceX defines the screen space x coordinate to use
  11177. * @param sourceY defines the screen space y coordinate to use
  11178. * @param viewportWidth defines the current width of the viewport
  11179. * @param viewportHeight defines the current height of the viewport
  11180. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11181. * @param view defines the view matrix to use
  11182. * @param projection defines the projection matrix to use
  11183. */
  11184. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11185. }
  11186. /**
  11187. * Type used to define predicate used to select faces when a mesh intersection is detected
  11188. */
  11189. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11190. module "babylonjs/scene" {
  11191. interface Scene {
  11192. /** @hidden */
  11193. _tempPickingRay: Nullable<Ray>;
  11194. /** @hidden */
  11195. _cachedRayForTransform: Ray;
  11196. /** @hidden */
  11197. _pickWithRayInverseMatrix: Matrix;
  11198. /** @hidden */
  11199. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11200. /** @hidden */
  11201. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11202. }
  11203. }
  11204. }
  11205. declare module "babylonjs/sceneComponent" {
  11206. import { Scene } from "babylonjs/scene";
  11207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11209. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11210. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11211. import { Nullable } from "babylonjs/types";
  11212. import { Camera } from "babylonjs/Cameras/camera";
  11213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11215. import { AbstractScene } from "babylonjs/abstractScene";
  11216. /**
  11217. * Groups all the scene component constants in one place to ease maintenance.
  11218. * @hidden
  11219. */
  11220. export class SceneComponentConstants {
  11221. static readonly NAME_EFFECTLAYER: string;
  11222. static readonly NAME_LAYER: string;
  11223. static readonly NAME_LENSFLARESYSTEM: string;
  11224. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11225. static readonly NAME_PARTICLESYSTEM: string;
  11226. static readonly NAME_GAMEPAD: string;
  11227. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11228. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11229. static readonly NAME_DEPTHRENDERER: string;
  11230. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11231. static readonly NAME_SPRITE: string;
  11232. static readonly NAME_OUTLINERENDERER: string;
  11233. static readonly NAME_PROCEDURALTEXTURE: string;
  11234. static readonly NAME_SHADOWGENERATOR: string;
  11235. static readonly NAME_OCTREE: string;
  11236. static readonly NAME_PHYSICSENGINE: string;
  11237. static readonly NAME_AUDIO: string;
  11238. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11239. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11240. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11241. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11242. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11243. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11244. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11245. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11246. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11247. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11248. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11249. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11250. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11251. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11252. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11253. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11254. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11255. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11256. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11257. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11258. static readonly STEP_AFTERRENDER_AUDIO: number;
  11259. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11260. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11261. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11262. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11263. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11264. static readonly STEP_POINTERMOVE_SPRITE: number;
  11265. static readonly STEP_POINTERDOWN_SPRITE: number;
  11266. static readonly STEP_POINTERUP_SPRITE: number;
  11267. }
  11268. /**
  11269. * This represents a scene component.
  11270. *
  11271. * This is used to decouple the dependency the scene is having on the different workloads like
  11272. * layers, post processes...
  11273. */
  11274. export interface ISceneComponent {
  11275. /**
  11276. * The name of the component. Each component must have a unique name.
  11277. */
  11278. name: string;
  11279. /**
  11280. * The scene the component belongs to.
  11281. */
  11282. scene: Scene;
  11283. /**
  11284. * Register the component to one instance of a scene.
  11285. */
  11286. register(): void;
  11287. /**
  11288. * Rebuilds the elements related to this component in case of
  11289. * context lost for instance.
  11290. */
  11291. rebuild(): void;
  11292. /**
  11293. * Disposes the component and the associated ressources.
  11294. */
  11295. dispose(): void;
  11296. }
  11297. /**
  11298. * This represents a SERIALIZABLE scene component.
  11299. *
  11300. * This extends Scene Component to add Serialization methods on top.
  11301. */
  11302. export interface ISceneSerializableComponent extends ISceneComponent {
  11303. /**
  11304. * Adds all the elements from the container to the scene
  11305. * @param container the container holding the elements
  11306. */
  11307. addFromContainer(container: AbstractScene): void;
  11308. /**
  11309. * Removes all the elements in the container from the scene
  11310. * @param container contains the elements to remove
  11311. * @param dispose if the removed element should be disposed (default: false)
  11312. */
  11313. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11314. /**
  11315. * Serializes the component data to the specified json object
  11316. * @param serializationObject The object to serialize to
  11317. */
  11318. serialize(serializationObject: any): void;
  11319. }
  11320. /**
  11321. * Strong typing of a Mesh related stage step action
  11322. */
  11323. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11324. /**
  11325. * Strong typing of a Evaluate Sub Mesh related stage step action
  11326. */
  11327. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11328. /**
  11329. * Strong typing of a Active Mesh related stage step action
  11330. */
  11331. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11332. /**
  11333. * Strong typing of a Camera related stage step action
  11334. */
  11335. export type CameraStageAction = (camera: Camera) => void;
  11336. /**
  11337. * Strong typing of a Camera Frame buffer related stage step action
  11338. */
  11339. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11340. /**
  11341. * Strong typing of a Render Target related stage step action
  11342. */
  11343. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11344. /**
  11345. * Strong typing of a RenderingGroup related stage step action
  11346. */
  11347. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11348. /**
  11349. * Strong typing of a Mesh Render related stage step action
  11350. */
  11351. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11352. /**
  11353. * Strong typing of a simple stage step action
  11354. */
  11355. export type SimpleStageAction = () => void;
  11356. /**
  11357. * Strong typing of a render target action.
  11358. */
  11359. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11360. /**
  11361. * Strong typing of a pointer move action.
  11362. */
  11363. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11364. /**
  11365. * Strong typing of a pointer up/down action.
  11366. */
  11367. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11368. /**
  11369. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11370. * @hidden
  11371. */
  11372. export class Stage<T extends Function> extends Array<{
  11373. index: number;
  11374. component: ISceneComponent;
  11375. action: T;
  11376. }> {
  11377. /**
  11378. * Hide ctor from the rest of the world.
  11379. * @param items The items to add.
  11380. */
  11381. private constructor();
  11382. /**
  11383. * Creates a new Stage.
  11384. * @returns A new instance of a Stage
  11385. */
  11386. static Create<T extends Function>(): Stage<T>;
  11387. /**
  11388. * Registers a step in an ordered way in the targeted stage.
  11389. * @param index Defines the position to register the step in
  11390. * @param component Defines the component attached to the step
  11391. * @param action Defines the action to launch during the step
  11392. */
  11393. registerStep(index: number, component: ISceneComponent, action: T): void;
  11394. /**
  11395. * Clears all the steps from the stage.
  11396. */
  11397. clear(): void;
  11398. }
  11399. }
  11400. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11401. import { Nullable } from "babylonjs/types";
  11402. import { Observable } from "babylonjs/Misc/observable";
  11403. import { Scene } from "babylonjs/scene";
  11404. import { Sprite } from "babylonjs/Sprites/sprite";
  11405. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11406. import { Ray } from "babylonjs/Culling/ray";
  11407. import { Camera } from "babylonjs/Cameras/camera";
  11408. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11409. import { ISceneComponent } from "babylonjs/sceneComponent";
  11410. module "babylonjs/scene" {
  11411. interface Scene {
  11412. /** @hidden */
  11413. _pointerOverSprite: Nullable<Sprite>;
  11414. /** @hidden */
  11415. _pickedDownSprite: Nullable<Sprite>;
  11416. /** @hidden */
  11417. _tempSpritePickingRay: Nullable<Ray>;
  11418. /**
  11419. * All of the sprite managers added to this scene
  11420. * @see http://doc.babylonjs.com/babylon101/sprites
  11421. */
  11422. spriteManagers: Array<ISpriteManager>;
  11423. /**
  11424. * An event triggered when sprites rendering is about to start
  11425. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11426. */
  11427. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11428. /**
  11429. * An event triggered when sprites rendering is done
  11430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11431. */
  11432. onAfterSpritesRenderingObservable: Observable<Scene>;
  11433. /** @hidden */
  11434. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11435. /** Launch a ray to try to pick a sprite in the scene
  11436. * @param x position on screen
  11437. * @param y position on screen
  11438. * @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
  11439. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11440. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11441. * @returns a PickingInfo
  11442. */
  11443. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11444. /** Use the given ray to pick a sprite in the scene
  11445. * @param ray The ray (in world space) to use to pick meshes
  11446. * @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
  11447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11448. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11449. * @returns a PickingInfo
  11450. */
  11451. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11452. /** @hidden */
  11453. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11454. /** Launch a ray to try to pick sprites in the scene
  11455. * @param x position on screen
  11456. * @param y position on screen
  11457. * @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
  11458. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11459. * @returns a PickingInfo array
  11460. */
  11461. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11462. /** Use the given ray to pick sprites in the scene
  11463. * @param ray The ray (in world space) to use to pick meshes
  11464. * @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
  11465. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11466. * @returns a PickingInfo array
  11467. */
  11468. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11469. /**
  11470. * Force the sprite under the pointer
  11471. * @param sprite defines the sprite to use
  11472. */
  11473. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11474. /**
  11475. * Gets the sprite under the pointer
  11476. * @returns a Sprite or null if no sprite is under the pointer
  11477. */
  11478. getPointerOverSprite(): Nullable<Sprite>;
  11479. }
  11480. }
  11481. /**
  11482. * Defines the sprite scene component responsible to manage sprites
  11483. * in a given scene.
  11484. */
  11485. export class SpriteSceneComponent implements ISceneComponent {
  11486. /**
  11487. * The component name helpfull to identify the component in the list of scene components.
  11488. */
  11489. readonly name: string;
  11490. /**
  11491. * The scene the component belongs to.
  11492. */
  11493. scene: Scene;
  11494. /** @hidden */
  11495. private _spritePredicate;
  11496. /**
  11497. * Creates a new instance of the component for the given scene
  11498. * @param scene Defines the scene to register the component in
  11499. */
  11500. constructor(scene: Scene);
  11501. /**
  11502. * Registers the component in a given scene
  11503. */
  11504. register(): void;
  11505. /**
  11506. * Rebuilds the elements related to this component in case of
  11507. * context lost for instance.
  11508. */
  11509. rebuild(): void;
  11510. /**
  11511. * Disposes the component and the associated ressources.
  11512. */
  11513. dispose(): void;
  11514. private _pickSpriteButKeepRay;
  11515. private _pointerMove;
  11516. private _pointerDown;
  11517. private _pointerUp;
  11518. }
  11519. }
  11520. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11521. /** @hidden */
  11522. export var fogFragmentDeclaration: {
  11523. name: string;
  11524. shader: string;
  11525. };
  11526. }
  11527. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11528. /** @hidden */
  11529. export var fogFragment: {
  11530. name: string;
  11531. shader: string;
  11532. };
  11533. }
  11534. declare module "babylonjs/Shaders/sprites.fragment" {
  11535. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11536. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11537. /** @hidden */
  11538. export var spritesPixelShader: {
  11539. name: string;
  11540. shader: string;
  11541. };
  11542. }
  11543. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11544. /** @hidden */
  11545. export var fogVertexDeclaration: {
  11546. name: string;
  11547. shader: string;
  11548. };
  11549. }
  11550. declare module "babylonjs/Shaders/sprites.vertex" {
  11551. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11552. /** @hidden */
  11553. export var spritesVertexShader: {
  11554. name: string;
  11555. shader: string;
  11556. };
  11557. }
  11558. declare module "babylonjs/Sprites/spriteManager" {
  11559. import { IDisposable, Scene } from "babylonjs/scene";
  11560. import { Nullable } from "babylonjs/types";
  11561. import { Observable } from "babylonjs/Misc/observable";
  11562. import { Sprite } from "babylonjs/Sprites/sprite";
  11563. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11564. import { Camera } from "babylonjs/Cameras/camera";
  11565. import { Texture } from "babylonjs/Materials/Textures/texture";
  11566. import "babylonjs/Shaders/sprites.fragment";
  11567. import "babylonjs/Shaders/sprites.vertex";
  11568. import { Ray } from "babylonjs/Culling/ray";
  11569. /**
  11570. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11571. */
  11572. export interface ISpriteManager extends IDisposable {
  11573. /**
  11574. * Restricts the camera to viewing objects with the same layerMask.
  11575. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11576. */
  11577. layerMask: number;
  11578. /**
  11579. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11580. */
  11581. isPickable: boolean;
  11582. /**
  11583. * Specifies the rendering group id for this mesh (0 by default)
  11584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11585. */
  11586. renderingGroupId: number;
  11587. /**
  11588. * Defines the list of sprites managed by the manager.
  11589. */
  11590. sprites: Array<Sprite>;
  11591. /**
  11592. * Tests the intersection of a sprite with a specific ray.
  11593. * @param ray The ray we are sending to test the collision
  11594. * @param camera The camera space we are sending rays in
  11595. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11596. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11597. * @returns picking info or null.
  11598. */
  11599. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11600. /**
  11601. * Intersects the sprites with a ray
  11602. * @param ray defines the ray to intersect with
  11603. * @param camera defines the current active camera
  11604. * @param predicate defines a predicate used to select candidate sprites
  11605. * @returns null if no hit or a PickingInfo array
  11606. */
  11607. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11608. /**
  11609. * Renders the list of sprites on screen.
  11610. */
  11611. render(): void;
  11612. }
  11613. /**
  11614. * Class used to manage multiple sprites on the same spritesheet
  11615. * @see http://doc.babylonjs.com/babylon101/sprites
  11616. */
  11617. export class SpriteManager implements ISpriteManager {
  11618. /** defines the manager's name */
  11619. name: string;
  11620. /** Gets the list of sprites */
  11621. sprites: Sprite[];
  11622. /** Gets or sets the rendering group id (0 by default) */
  11623. renderingGroupId: number;
  11624. /** Gets or sets camera layer mask */
  11625. layerMask: number;
  11626. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11627. fogEnabled: boolean;
  11628. /** Gets or sets a boolean indicating if the sprites are pickable */
  11629. isPickable: boolean;
  11630. /** Defines the default width of a cell in the spritesheet */
  11631. cellWidth: number;
  11632. /** Defines the default height of a cell in the spritesheet */
  11633. cellHeight: number;
  11634. /** Associative array from JSON sprite data file */
  11635. private _cellData;
  11636. /** Array of sprite names from JSON sprite data file */
  11637. private _spriteMap;
  11638. /** True when packed cell data from JSON file is ready*/
  11639. private _packedAndReady;
  11640. /**
  11641. * An event triggered when the manager is disposed.
  11642. */
  11643. onDisposeObservable: Observable<SpriteManager>;
  11644. private _onDisposeObserver;
  11645. /**
  11646. * Callback called when the manager is disposed
  11647. */
  11648. onDispose: () => void;
  11649. private _capacity;
  11650. private _fromPacked;
  11651. private _spriteTexture;
  11652. private _epsilon;
  11653. private _scene;
  11654. private _vertexData;
  11655. private _buffer;
  11656. private _vertexBuffers;
  11657. private _indexBuffer;
  11658. private _effectBase;
  11659. private _effectFog;
  11660. /**
  11661. * Gets or sets the spritesheet texture
  11662. */
  11663. texture: Texture;
  11664. /**
  11665. * Creates a new sprite manager
  11666. * @param name defines the manager's name
  11667. * @param imgUrl defines the sprite sheet url
  11668. * @param capacity defines the maximum allowed number of sprites
  11669. * @param cellSize defines the size of a sprite cell
  11670. * @param scene defines the hosting scene
  11671. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11672. * @param samplingMode defines the smapling mode to use with spritesheet
  11673. * @param fromPacked set to false; do not alter
  11674. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11675. */
  11676. constructor(
  11677. /** defines the manager's name */
  11678. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11679. private _makePacked;
  11680. private _appendSpriteVertex;
  11681. /**
  11682. * Intersects the sprites with a ray
  11683. * @param ray defines the ray to intersect with
  11684. * @param camera defines the current active camera
  11685. * @param predicate defines a predicate used to select candidate sprites
  11686. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11687. * @returns null if no hit or a PickingInfo
  11688. */
  11689. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11690. /**
  11691. * Intersects the sprites with a ray
  11692. * @param ray defines the ray to intersect with
  11693. * @param camera defines the current active camera
  11694. * @param predicate defines a predicate used to select candidate sprites
  11695. * @returns null if no hit or a PickingInfo array
  11696. */
  11697. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11698. /**
  11699. * Render all child sprites
  11700. */
  11701. render(): void;
  11702. /**
  11703. * Release associated resources
  11704. */
  11705. dispose(): void;
  11706. }
  11707. }
  11708. declare module "babylonjs/Sprites/sprite" {
  11709. import { Vector3 } from "babylonjs/Maths/math.vector";
  11710. import { Nullable } from "babylonjs/types";
  11711. import { ActionManager } from "babylonjs/Actions/actionManager";
  11712. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11713. import { Color4 } from "babylonjs/Maths/math.color";
  11714. /**
  11715. * Class used to represent a sprite
  11716. * @see http://doc.babylonjs.com/babylon101/sprites
  11717. */
  11718. export class Sprite {
  11719. /** defines the name */
  11720. name: string;
  11721. /** Gets or sets the current world position */
  11722. position: Vector3;
  11723. /** Gets or sets the main color */
  11724. color: Color4;
  11725. /** Gets or sets the width */
  11726. width: number;
  11727. /** Gets or sets the height */
  11728. height: number;
  11729. /** Gets or sets rotation angle */
  11730. angle: number;
  11731. /** Gets or sets the cell index in the sprite sheet */
  11732. cellIndex: number;
  11733. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11734. cellRef: string;
  11735. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11736. invertU: number;
  11737. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11738. invertV: number;
  11739. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11740. disposeWhenFinishedAnimating: boolean;
  11741. /** Gets the list of attached animations */
  11742. animations: Animation[];
  11743. /** Gets or sets a boolean indicating if the sprite can be picked */
  11744. isPickable: boolean;
  11745. /**
  11746. * Gets or sets the associated action manager
  11747. */
  11748. actionManager: Nullable<ActionManager>;
  11749. private _animationStarted;
  11750. private _loopAnimation;
  11751. private _fromIndex;
  11752. private _toIndex;
  11753. private _delay;
  11754. private _direction;
  11755. private _manager;
  11756. private _time;
  11757. private _onAnimationEnd;
  11758. /**
  11759. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11760. */
  11761. isVisible: boolean;
  11762. /**
  11763. * Gets or sets the sprite size
  11764. */
  11765. size: number;
  11766. /**
  11767. * Creates a new Sprite
  11768. * @param name defines the name
  11769. * @param manager defines the manager
  11770. */
  11771. constructor(
  11772. /** defines the name */
  11773. name: string, manager: ISpriteManager);
  11774. /**
  11775. * Starts an animation
  11776. * @param from defines the initial key
  11777. * @param to defines the end key
  11778. * @param loop defines if the animation must loop
  11779. * @param delay defines the start delay (in ms)
  11780. * @param onAnimationEnd defines a callback to call when animation ends
  11781. */
  11782. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11783. /** Stops current animation (if any) */
  11784. stopAnimation(): void;
  11785. /** @hidden */
  11786. _animate(deltaTime: number): void;
  11787. /** Release associated resources */
  11788. dispose(): void;
  11789. }
  11790. }
  11791. declare module "babylonjs/Collisions/pickingInfo" {
  11792. import { Nullable } from "babylonjs/types";
  11793. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11795. import { Sprite } from "babylonjs/Sprites/sprite";
  11796. import { Ray } from "babylonjs/Culling/ray";
  11797. /**
  11798. * Information about the result of picking within a scene
  11799. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11800. */
  11801. export class PickingInfo {
  11802. /** @hidden */
  11803. _pickingUnavailable: boolean;
  11804. /**
  11805. * If the pick collided with an object
  11806. */
  11807. hit: boolean;
  11808. /**
  11809. * Distance away where the pick collided
  11810. */
  11811. distance: number;
  11812. /**
  11813. * The location of pick collision
  11814. */
  11815. pickedPoint: Nullable<Vector3>;
  11816. /**
  11817. * The mesh corresponding the the pick collision
  11818. */
  11819. pickedMesh: Nullable<AbstractMesh>;
  11820. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11821. bu: number;
  11822. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11823. bv: number;
  11824. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11825. faceId: number;
  11826. /** Id of the the submesh that was picked */
  11827. subMeshId: number;
  11828. /** If a sprite was picked, this will be the sprite the pick collided with */
  11829. pickedSprite: Nullable<Sprite>;
  11830. /**
  11831. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11832. */
  11833. originMesh: Nullable<AbstractMesh>;
  11834. /**
  11835. * The ray that was used to perform the picking.
  11836. */
  11837. ray: Nullable<Ray>;
  11838. /**
  11839. * Gets the normal correspodning to the face the pick collided with
  11840. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11841. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11842. * @returns The normal correspodning to the face the pick collided with
  11843. */
  11844. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11845. /**
  11846. * Gets the texture coordinates of where the pick occured
  11847. * @returns the vector containing the coordnates of the texture
  11848. */
  11849. getTextureCoordinates(): Nullable<Vector2>;
  11850. }
  11851. }
  11852. declare module "babylonjs/Events/pointerEvents" {
  11853. import { Nullable } from "babylonjs/types";
  11854. import { Vector2 } from "babylonjs/Maths/math.vector";
  11855. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11856. import { Ray } from "babylonjs/Culling/ray";
  11857. /**
  11858. * Gather the list of pointer event types as constants.
  11859. */
  11860. export class PointerEventTypes {
  11861. /**
  11862. * 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.
  11863. */
  11864. static readonly POINTERDOWN: number;
  11865. /**
  11866. * The pointerup event is fired when a pointer is no longer active.
  11867. */
  11868. static readonly POINTERUP: number;
  11869. /**
  11870. * The pointermove event is fired when a pointer changes coordinates.
  11871. */
  11872. static readonly POINTERMOVE: number;
  11873. /**
  11874. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11875. */
  11876. static readonly POINTERWHEEL: number;
  11877. /**
  11878. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11879. */
  11880. static readonly POINTERPICK: number;
  11881. /**
  11882. * The pointertap event is fired when a the object has been touched and released without drag.
  11883. */
  11884. static readonly POINTERTAP: number;
  11885. /**
  11886. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11887. */
  11888. static readonly POINTERDOUBLETAP: number;
  11889. }
  11890. /**
  11891. * Base class of pointer info types.
  11892. */
  11893. export class PointerInfoBase {
  11894. /**
  11895. * Defines the type of event (PointerEventTypes)
  11896. */
  11897. type: number;
  11898. /**
  11899. * Defines the related dom event
  11900. */
  11901. event: PointerEvent | MouseWheelEvent;
  11902. /**
  11903. * Instantiates the base class of pointers info.
  11904. * @param type Defines the type of event (PointerEventTypes)
  11905. * @param event Defines the related dom event
  11906. */
  11907. constructor(
  11908. /**
  11909. * Defines the type of event (PointerEventTypes)
  11910. */
  11911. type: number,
  11912. /**
  11913. * Defines the related dom event
  11914. */
  11915. event: PointerEvent | MouseWheelEvent);
  11916. }
  11917. /**
  11918. * This class is used to store pointer related info for the onPrePointerObservable event.
  11919. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11920. */
  11921. export class PointerInfoPre extends PointerInfoBase {
  11922. /**
  11923. * Ray from a pointer if availible (eg. 6dof controller)
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Defines the local position of the pointer on the canvas.
  11928. */
  11929. localPosition: Vector2;
  11930. /**
  11931. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11932. */
  11933. skipOnPointerObservable: boolean;
  11934. /**
  11935. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11936. * @param type Defines the type of event (PointerEventTypes)
  11937. * @param event Defines the related dom event
  11938. * @param localX Defines the local x coordinates of the pointer when the event occured
  11939. * @param localY Defines the local y coordinates of the pointer when the event occured
  11940. */
  11941. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11942. }
  11943. /**
  11944. * This type contains all the data related to a pointer event in Babylon.js.
  11945. * 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.
  11946. */
  11947. export class PointerInfo extends PointerInfoBase {
  11948. /**
  11949. * Defines the picking info associated to the info (if any)\
  11950. */
  11951. pickInfo: Nullable<PickingInfo>;
  11952. /**
  11953. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11954. * @param type Defines the type of event (PointerEventTypes)
  11955. * @param event Defines the related dom event
  11956. * @param pickInfo Defines the picking info associated to the info (if any)\
  11957. */
  11958. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11959. /**
  11960. * Defines the picking info associated to the info (if any)\
  11961. */
  11962. pickInfo: Nullable<PickingInfo>);
  11963. }
  11964. /**
  11965. * Data relating to a touch event on the screen.
  11966. */
  11967. export interface PointerTouch {
  11968. /**
  11969. * X coordinate of touch.
  11970. */
  11971. x: number;
  11972. /**
  11973. * Y coordinate of touch.
  11974. */
  11975. y: number;
  11976. /**
  11977. * Id of touch. Unique for each finger.
  11978. */
  11979. pointerId: number;
  11980. /**
  11981. * Event type passed from DOM.
  11982. */
  11983. type: any;
  11984. }
  11985. }
  11986. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11987. import { Observable } from "babylonjs/Misc/observable";
  11988. import { Nullable } from "babylonjs/types";
  11989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11990. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11991. /**
  11992. * Manage the mouse inputs to control the movement of a free camera.
  11993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11994. */
  11995. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11996. /**
  11997. * Define if touch is enabled in the mouse input
  11998. */
  11999. touchEnabled: boolean;
  12000. /**
  12001. * Defines the camera the input is attached to.
  12002. */
  12003. camera: FreeCamera;
  12004. /**
  12005. * Defines the buttons associated with the input to handle camera move.
  12006. */
  12007. buttons: number[];
  12008. /**
  12009. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12010. */
  12011. angularSensibility: number;
  12012. private _pointerInput;
  12013. private _onMouseMove;
  12014. private _observer;
  12015. private previousPosition;
  12016. /**
  12017. * Observable for when a pointer move event occurs containing the move offset
  12018. */
  12019. onPointerMovedObservable: Observable<{
  12020. offsetX: number;
  12021. offsetY: number;
  12022. }>;
  12023. /**
  12024. * @hidden
  12025. * If the camera should be rotated automatically based on pointer movement
  12026. */
  12027. _allowCameraRotation: boolean;
  12028. /**
  12029. * Manage the mouse inputs to control the movement of a free camera.
  12030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12031. * @param touchEnabled Defines if touch is enabled or not
  12032. */
  12033. constructor(
  12034. /**
  12035. * Define if touch is enabled in the mouse input
  12036. */
  12037. touchEnabled?: boolean);
  12038. /**
  12039. * Attach the input controls to a specific dom element to get the input from.
  12040. * @param element Defines the element the controls should be listened from
  12041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12042. */
  12043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12044. /**
  12045. * Called on JS contextmenu event.
  12046. * Override this method to provide functionality.
  12047. */
  12048. protected onContextMenu(evt: PointerEvent): void;
  12049. /**
  12050. * Detach the current controls from the specified dom element.
  12051. * @param element Defines the element to stop listening the inputs from
  12052. */
  12053. detachControl(element: Nullable<HTMLElement>): void;
  12054. /**
  12055. * Gets the class name of the current intput.
  12056. * @returns the class name
  12057. */
  12058. getClassName(): string;
  12059. /**
  12060. * Get the friendly name associated with the input class.
  12061. * @returns the input friendly name
  12062. */
  12063. getSimpleName(): string;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12067. import { Nullable } from "babylonjs/types";
  12068. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12070. /**
  12071. * Manage the touch inputs to control the movement of a free camera.
  12072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12073. */
  12074. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12075. /**
  12076. * Defines the camera the input is attached to.
  12077. */
  12078. camera: FreeCamera;
  12079. /**
  12080. * Defines the touch sensibility for rotation.
  12081. * The higher the faster.
  12082. */
  12083. touchAngularSensibility: number;
  12084. /**
  12085. * Defines the touch sensibility for move.
  12086. * The higher the faster.
  12087. */
  12088. touchMoveSensibility: number;
  12089. private _offsetX;
  12090. private _offsetY;
  12091. private _pointerPressed;
  12092. private _pointerInput;
  12093. private _observer;
  12094. private _onLostFocus;
  12095. /**
  12096. * Attach the input controls to a specific dom element to get the input from.
  12097. * @param element Defines the element the controls should be listened from
  12098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12099. */
  12100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12101. /**
  12102. * Detach the current controls from the specified dom element.
  12103. * @param element Defines the element to stop listening the inputs from
  12104. */
  12105. detachControl(element: Nullable<HTMLElement>): void;
  12106. /**
  12107. * Update the current camera state depending on the inputs that have been used this frame.
  12108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12109. */
  12110. checkInputs(): void;
  12111. /**
  12112. * Gets the class name of the current intput.
  12113. * @returns the class name
  12114. */
  12115. getClassName(): string;
  12116. /**
  12117. * Get the friendly name associated with the input class.
  12118. * @returns the input friendly name
  12119. */
  12120. getSimpleName(): string;
  12121. }
  12122. }
  12123. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12124. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12125. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12126. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12127. import { Nullable } from "babylonjs/types";
  12128. /**
  12129. * Default Inputs manager for the FreeCamera.
  12130. * It groups all the default supported inputs for ease of use.
  12131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12132. */
  12133. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12134. /**
  12135. * @hidden
  12136. */
  12137. _mouseInput: Nullable<FreeCameraMouseInput>;
  12138. /**
  12139. * Instantiates a new FreeCameraInputsManager.
  12140. * @param camera Defines the camera the inputs belong to
  12141. */
  12142. constructor(camera: FreeCamera);
  12143. /**
  12144. * Add keyboard input support to the input manager.
  12145. * @returns the current input manager
  12146. */
  12147. addKeyboard(): FreeCameraInputsManager;
  12148. /**
  12149. * Add mouse input support to the input manager.
  12150. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12151. * @returns the current input manager
  12152. */
  12153. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12154. /**
  12155. * Removes the mouse input support from the manager
  12156. * @returns the current input manager
  12157. */
  12158. removeMouse(): FreeCameraInputsManager;
  12159. /**
  12160. * Add touch input support to the input manager.
  12161. * @returns the current input manager
  12162. */
  12163. addTouch(): FreeCameraInputsManager;
  12164. /**
  12165. * Remove all attached input methods from a camera
  12166. */
  12167. clear(): void;
  12168. }
  12169. }
  12170. declare module "babylonjs/Cameras/freeCamera" {
  12171. import { Vector3 } from "babylonjs/Maths/math.vector";
  12172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12173. import { Scene } from "babylonjs/scene";
  12174. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12175. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12176. /**
  12177. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12178. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12179. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12180. */
  12181. export class FreeCamera extends TargetCamera {
  12182. /**
  12183. * Define the collision ellipsoid of the camera.
  12184. * This is helpful to simulate a camera body like the player body around the camera
  12185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12186. */
  12187. ellipsoid: Vector3;
  12188. /**
  12189. * Define an offset for the position of the ellipsoid around the camera.
  12190. * This can be helpful to determine the center of the body near the gravity center of the body
  12191. * instead of its head.
  12192. */
  12193. ellipsoidOffset: Vector3;
  12194. /**
  12195. * Enable or disable collisions of the camera with the rest of the scene objects.
  12196. */
  12197. checkCollisions: boolean;
  12198. /**
  12199. * Enable or disable gravity on the camera.
  12200. */
  12201. applyGravity: boolean;
  12202. /**
  12203. * Define the input manager associated to the camera.
  12204. */
  12205. inputs: FreeCameraInputsManager;
  12206. /**
  12207. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12208. * Higher values reduce sensitivity.
  12209. */
  12210. /**
  12211. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12212. * Higher values reduce sensitivity.
  12213. */
  12214. angularSensibility: number;
  12215. /**
  12216. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12217. */
  12218. keysUp: number[];
  12219. /**
  12220. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12221. */
  12222. keysDown: number[];
  12223. /**
  12224. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12225. */
  12226. keysLeft: number[];
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12229. */
  12230. keysRight: number[];
  12231. /**
  12232. * Event raised when the camera collide with a mesh in the scene.
  12233. */
  12234. onCollide: (collidedMesh: AbstractMesh) => void;
  12235. private _collider;
  12236. private _needMoveForGravity;
  12237. private _oldPosition;
  12238. private _diffPosition;
  12239. private _newPosition;
  12240. /** @hidden */
  12241. _localDirection: Vector3;
  12242. /** @hidden */
  12243. _transformedDirection: Vector3;
  12244. /**
  12245. * Instantiates a Free Camera.
  12246. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12247. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12249. * @param name Define the name of the camera in the scene
  12250. * @param position Define the start position of the camera in the scene
  12251. * @param scene Define the scene the camera belongs to
  12252. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12253. */
  12254. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12255. /**
  12256. * Attached controls to the current camera.
  12257. * @param element Defines the element the controls should be listened from
  12258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12259. */
  12260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12261. /**
  12262. * Detach the current controls from the camera.
  12263. * The camera will stop reacting to inputs.
  12264. * @param element Defines the element to stop listening the inputs from
  12265. */
  12266. detachControl(element: HTMLElement): void;
  12267. private _collisionMask;
  12268. /**
  12269. * Define a collision mask to limit the list of object the camera can collide with
  12270. */
  12271. collisionMask: number;
  12272. /** @hidden */
  12273. _collideWithWorld(displacement: Vector3): void;
  12274. private _onCollisionPositionChange;
  12275. /** @hidden */
  12276. _checkInputs(): void;
  12277. /** @hidden */
  12278. _decideIfNeedsToMove(): boolean;
  12279. /** @hidden */
  12280. _updatePosition(): void;
  12281. /**
  12282. * Destroy the camera and release the current resources hold by it.
  12283. */
  12284. dispose(): void;
  12285. /**
  12286. * Gets the current object class name.
  12287. * @return the class name
  12288. */
  12289. getClassName(): string;
  12290. }
  12291. }
  12292. declare module "babylonjs/Gamepads/gamepad" {
  12293. import { Observable } from "babylonjs/Misc/observable";
  12294. /**
  12295. * Represents a gamepad control stick position
  12296. */
  12297. export class StickValues {
  12298. /**
  12299. * The x component of the control stick
  12300. */
  12301. x: number;
  12302. /**
  12303. * The y component of the control stick
  12304. */
  12305. y: number;
  12306. /**
  12307. * Initializes the gamepad x and y control stick values
  12308. * @param x The x component of the gamepad control stick value
  12309. * @param y The y component of the gamepad control stick value
  12310. */
  12311. constructor(
  12312. /**
  12313. * The x component of the control stick
  12314. */
  12315. x: number,
  12316. /**
  12317. * The y component of the control stick
  12318. */
  12319. y: number);
  12320. }
  12321. /**
  12322. * An interface which manages callbacks for gamepad button changes
  12323. */
  12324. export interface GamepadButtonChanges {
  12325. /**
  12326. * Called when a gamepad has been changed
  12327. */
  12328. changed: boolean;
  12329. /**
  12330. * Called when a gamepad press event has been triggered
  12331. */
  12332. pressChanged: boolean;
  12333. /**
  12334. * Called when a touch event has been triggered
  12335. */
  12336. touchChanged: boolean;
  12337. /**
  12338. * Called when a value has changed
  12339. */
  12340. valueChanged: boolean;
  12341. }
  12342. /**
  12343. * Represents a gamepad
  12344. */
  12345. export class Gamepad {
  12346. /**
  12347. * The id of the gamepad
  12348. */
  12349. id: string;
  12350. /**
  12351. * The index of the gamepad
  12352. */
  12353. index: number;
  12354. /**
  12355. * The browser gamepad
  12356. */
  12357. browserGamepad: any;
  12358. /**
  12359. * Specifies what type of gamepad this represents
  12360. */
  12361. type: number;
  12362. private _leftStick;
  12363. private _rightStick;
  12364. /** @hidden */
  12365. _isConnected: boolean;
  12366. private _leftStickAxisX;
  12367. private _leftStickAxisY;
  12368. private _rightStickAxisX;
  12369. private _rightStickAxisY;
  12370. /**
  12371. * Triggered when the left control stick has been changed
  12372. */
  12373. private _onleftstickchanged;
  12374. /**
  12375. * Triggered when the right control stick has been changed
  12376. */
  12377. private _onrightstickchanged;
  12378. /**
  12379. * Represents a gamepad controller
  12380. */
  12381. static GAMEPAD: number;
  12382. /**
  12383. * Represents a generic controller
  12384. */
  12385. static GENERIC: number;
  12386. /**
  12387. * Represents an XBox controller
  12388. */
  12389. static XBOX: number;
  12390. /**
  12391. * Represents a pose-enabled controller
  12392. */
  12393. static POSE_ENABLED: number;
  12394. /**
  12395. * Represents an Dual Shock controller
  12396. */
  12397. static DUALSHOCK: number;
  12398. /**
  12399. * Specifies whether the left control stick should be Y-inverted
  12400. */
  12401. protected _invertLeftStickY: boolean;
  12402. /**
  12403. * Specifies if the gamepad has been connected
  12404. */
  12405. readonly isConnected: boolean;
  12406. /**
  12407. * Initializes the gamepad
  12408. * @param id The id of the gamepad
  12409. * @param index The index of the gamepad
  12410. * @param browserGamepad The browser gamepad
  12411. * @param leftStickX The x component of the left joystick
  12412. * @param leftStickY The y component of the left joystick
  12413. * @param rightStickX The x component of the right joystick
  12414. * @param rightStickY The y component of the right joystick
  12415. */
  12416. constructor(
  12417. /**
  12418. * The id of the gamepad
  12419. */
  12420. id: string,
  12421. /**
  12422. * The index of the gamepad
  12423. */
  12424. index: number,
  12425. /**
  12426. * The browser gamepad
  12427. */
  12428. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12429. /**
  12430. * Callback triggered when the left joystick has changed
  12431. * @param callback
  12432. */
  12433. onleftstickchanged(callback: (values: StickValues) => void): void;
  12434. /**
  12435. * Callback triggered when the right joystick has changed
  12436. * @param callback
  12437. */
  12438. onrightstickchanged(callback: (values: StickValues) => void): void;
  12439. /**
  12440. * Gets the left joystick
  12441. */
  12442. /**
  12443. * Sets the left joystick values
  12444. */
  12445. leftStick: StickValues;
  12446. /**
  12447. * Gets the right joystick
  12448. */
  12449. /**
  12450. * Sets the right joystick value
  12451. */
  12452. rightStick: StickValues;
  12453. /**
  12454. * Updates the gamepad joystick positions
  12455. */
  12456. update(): void;
  12457. /**
  12458. * Disposes the gamepad
  12459. */
  12460. dispose(): void;
  12461. }
  12462. /**
  12463. * Represents a generic gamepad
  12464. */
  12465. export class GenericPad extends Gamepad {
  12466. private _buttons;
  12467. private _onbuttondown;
  12468. private _onbuttonup;
  12469. /**
  12470. * Observable triggered when a button has been pressed
  12471. */
  12472. onButtonDownObservable: Observable<number>;
  12473. /**
  12474. * Observable triggered when a button has been released
  12475. */
  12476. onButtonUpObservable: Observable<number>;
  12477. /**
  12478. * Callback triggered when a button has been pressed
  12479. * @param callback Called when a button has been pressed
  12480. */
  12481. onbuttondown(callback: (buttonPressed: number) => void): void;
  12482. /**
  12483. * Callback triggered when a button has been released
  12484. * @param callback Called when a button has been released
  12485. */
  12486. onbuttonup(callback: (buttonReleased: number) => void): void;
  12487. /**
  12488. * Initializes the generic gamepad
  12489. * @param id The id of the generic gamepad
  12490. * @param index The index of the generic gamepad
  12491. * @param browserGamepad The browser gamepad
  12492. */
  12493. constructor(id: string, index: number, browserGamepad: any);
  12494. private _setButtonValue;
  12495. /**
  12496. * Updates the generic gamepad
  12497. */
  12498. update(): void;
  12499. /**
  12500. * Disposes the generic gamepad
  12501. */
  12502. dispose(): void;
  12503. }
  12504. }
  12505. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12506. import { Nullable } from "babylonjs/types";
  12507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12508. import { Scene } from "babylonjs/scene";
  12509. module "babylonjs/Engines/engine" {
  12510. interface Engine {
  12511. /**
  12512. * Creates a raw texture
  12513. * @param data defines the data to store in the texture
  12514. * @param width defines the width of the texture
  12515. * @param height defines the height of the texture
  12516. * @param format defines the format of the data
  12517. * @param generateMipMaps defines if the engine should generate the mip levels
  12518. * @param invertY defines if data must be stored with Y axis inverted
  12519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12520. * @param compression defines the compression used (null by default)
  12521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12522. * @returns the raw texture inside an InternalTexture
  12523. */
  12524. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12525. /**
  12526. * Update a raw texture
  12527. * @param texture defines the texture to update
  12528. * @param data defines the data to store in the texture
  12529. * @param format defines the format of the data
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. */
  12532. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12533. /**
  12534. * Update a raw texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store in the texture
  12537. * @param format defines the format of the data
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. * @param compression defines the compression used (null by default)
  12540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12541. */
  12542. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12543. /**
  12544. * Creates a new raw cube texture
  12545. * @param data defines the array of data to use to create each face
  12546. * @param size defines the size of the textures
  12547. * @param format defines the format of the data
  12548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12549. * @param generateMipMaps defines if the engine should generate the mip levels
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12552. * @param compression defines the compression used (null by default)
  12553. * @returns the cube texture as an InternalTexture
  12554. */
  12555. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12556. /**
  12557. * Update a raw cube texture
  12558. * @param texture defines the texture to udpdate
  12559. * @param data defines the data to store
  12560. * @param format defines the data format
  12561. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. */
  12564. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12565. /**
  12566. * Update a raw cube texture
  12567. * @param texture defines the texture to udpdate
  12568. * @param data defines the data to store
  12569. * @param format defines the data format
  12570. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12571. * @param invertY defines if data must be stored with Y axis inverted
  12572. * @param compression defines the compression used (null by default)
  12573. */
  12574. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12575. /**
  12576. * Update a raw cube texture
  12577. * @param texture defines the texture to udpdate
  12578. * @param data defines the data to store
  12579. * @param format defines the data format
  12580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12581. * @param invertY defines if data must be stored with Y axis inverted
  12582. * @param compression defines the compression used (null by default)
  12583. * @param level defines which level of the texture to update
  12584. */
  12585. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12586. /**
  12587. * Creates a new raw cube texture from a specified url
  12588. * @param url defines the url where the data is located
  12589. * @param scene defines the current scene
  12590. * @param size defines the size of the textures
  12591. * @param format defines the format of the data
  12592. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12593. * @param noMipmap defines if the engine should avoid generating the mip levels
  12594. * @param callback defines a callback used to extract texture data from loaded data
  12595. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12596. * @param onLoad defines a callback called when texture is loaded
  12597. * @param onError defines a callback called if there is an error
  12598. * @returns the cube texture as an InternalTexture
  12599. */
  12600. 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;
  12601. /**
  12602. * Creates a new raw cube texture from a specified url
  12603. * @param url defines the url where the data is located
  12604. * @param scene defines the current scene
  12605. * @param size defines the size of the textures
  12606. * @param format defines the format of the data
  12607. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12608. * @param noMipmap defines if the engine should avoid generating the mip levels
  12609. * @param callback defines a callback used to extract texture data from loaded data
  12610. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12611. * @param onLoad defines a callback called when texture is loaded
  12612. * @param onError defines a callback called if there is an error
  12613. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12614. * @param invertY defines if data must be stored with Y axis inverted
  12615. * @returns the cube texture as an InternalTexture
  12616. */
  12617. 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;
  12618. /**
  12619. * Creates a new raw 3D texture
  12620. * @param data defines the data used to create the texture
  12621. * @param width defines the width of the texture
  12622. * @param height defines the height of the texture
  12623. * @param depth defines the depth of the texture
  12624. * @param format defines the format of the texture
  12625. * @param generateMipMaps defines if the engine must generate mip levels
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12628. * @param compression defines the compressed used (can be null)
  12629. * @param textureType defines the compressed used (can be null)
  12630. * @returns a new raw 3D texture (stored in an InternalTexture)
  12631. */
  12632. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12633. /**
  12634. * Update a raw 3D texture
  12635. * @param texture defines the texture to update
  12636. * @param data defines the data to store
  12637. * @param format defines the data format
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. */
  12640. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12641. /**
  12642. * Update a raw 3D texture
  12643. * @param texture defines the texture to update
  12644. * @param data defines the data to store
  12645. * @param format defines the data format
  12646. * @param invertY defines if data must be stored with Y axis inverted
  12647. * @param compression defines the used compression (can be null)
  12648. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12649. */
  12650. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12651. }
  12652. }
  12653. }
  12654. declare module "babylonjs/Materials/Textures/rawTexture" {
  12655. import { Scene } from "babylonjs/scene";
  12656. import { Texture } from "babylonjs/Materials/Textures/texture";
  12657. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12658. /**
  12659. * Raw texture can help creating a texture directly from an array of data.
  12660. * This can be super useful if you either get the data from an uncompressed source or
  12661. * if you wish to create your texture pixel by pixel.
  12662. */
  12663. export class RawTexture extends Texture {
  12664. /**
  12665. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12666. */
  12667. format: number;
  12668. private _engine;
  12669. /**
  12670. * Instantiates a new RawTexture.
  12671. * Raw texture can help creating a texture directly from an array of data.
  12672. * This can be super useful if you either get the data from an uncompressed source or
  12673. * if you wish to create your texture pixel by pixel.
  12674. * @param data define the array of data to use to create the texture
  12675. * @param width define the width of the texture
  12676. * @param height define the height of the texture
  12677. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12678. * @param scene define the scene the texture belongs to
  12679. * @param generateMipMaps define whether mip maps should be generated or not
  12680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12682. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12683. */
  12684. constructor(data: ArrayBufferView, width: number, height: number,
  12685. /**
  12686. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12687. */
  12688. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12689. /**
  12690. * Updates the texture underlying data.
  12691. * @param data Define the new data of the texture
  12692. */
  12693. update(data: ArrayBufferView): void;
  12694. /**
  12695. * Creates a luminance texture from some data.
  12696. * @param data Define the texture data
  12697. * @param width Define the width of the texture
  12698. * @param height Define the height of the texture
  12699. * @param scene Define the scene the texture belongs to
  12700. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12701. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12702. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12703. * @returns the luminance texture
  12704. */
  12705. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12706. /**
  12707. * Creates a luminance alpha texture from some data.
  12708. * @param data Define the texture data
  12709. * @param width Define the width of the texture
  12710. * @param height Define the height of the texture
  12711. * @param scene Define the scene the texture belongs to
  12712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12715. * @returns the luminance alpha texture
  12716. */
  12717. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12718. /**
  12719. * Creates an alpha texture from some data.
  12720. * @param data Define the texture data
  12721. * @param width Define the width of the texture
  12722. * @param height Define the height of the texture
  12723. * @param scene Define the scene the texture belongs to
  12724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12727. * @returns the alpha texture
  12728. */
  12729. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12730. /**
  12731. * Creates a RGB texture from some data.
  12732. * @param data Define the texture data
  12733. * @param width Define the width of the texture
  12734. * @param height Define the height of the texture
  12735. * @param scene Define the scene the texture belongs to
  12736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12739. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12740. * @returns the RGB alpha texture
  12741. */
  12742. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12743. /**
  12744. * Creates a RGBA texture from some data.
  12745. * @param data Define the texture data
  12746. * @param width Define the width of the texture
  12747. * @param height Define the height of the texture
  12748. * @param scene Define the scene the texture belongs to
  12749. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12750. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12751. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12752. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12753. * @returns the RGBA texture
  12754. */
  12755. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12756. /**
  12757. * Creates a R texture from some data.
  12758. * @param data Define the texture data
  12759. * @param width Define the width of the texture
  12760. * @param height Define the height of the texture
  12761. * @param scene Define the scene the texture belongs to
  12762. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12763. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12764. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12765. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12766. * @returns the R texture
  12767. */
  12768. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12769. }
  12770. }
  12771. declare module "babylonjs/Maths/math.size" {
  12772. /**
  12773. * Interface for the size containing width and height
  12774. */
  12775. export interface ISize {
  12776. /**
  12777. * Width
  12778. */
  12779. width: number;
  12780. /**
  12781. * Heighht
  12782. */
  12783. height: number;
  12784. }
  12785. /**
  12786. * Size containing widht and height
  12787. */
  12788. export class Size implements ISize {
  12789. /**
  12790. * Width
  12791. */
  12792. width: number;
  12793. /**
  12794. * Height
  12795. */
  12796. height: number;
  12797. /**
  12798. * Creates a Size object from the given width and height (floats).
  12799. * @param width width of the new size
  12800. * @param height height of the new size
  12801. */
  12802. constructor(width: number, height: number);
  12803. /**
  12804. * Returns a string with the Size width and height
  12805. * @returns a string with the Size width and height
  12806. */
  12807. toString(): string;
  12808. /**
  12809. * "Size"
  12810. * @returns the string "Size"
  12811. */
  12812. getClassName(): string;
  12813. /**
  12814. * Returns the Size hash code.
  12815. * @returns a hash code for a unique width and height
  12816. */
  12817. getHashCode(): number;
  12818. /**
  12819. * Updates the current size from the given one.
  12820. * @param src the given size
  12821. */
  12822. copyFrom(src: Size): void;
  12823. /**
  12824. * Updates in place the current Size from the given floats.
  12825. * @param width width of the new size
  12826. * @param height height of the new size
  12827. * @returns the updated Size.
  12828. */
  12829. copyFromFloats(width: number, height: number): Size;
  12830. /**
  12831. * Updates in place the current Size from the given floats.
  12832. * @param width width to set
  12833. * @param height height to set
  12834. * @returns the updated Size.
  12835. */
  12836. set(width: number, height: number): Size;
  12837. /**
  12838. * Multiplies the width and height by numbers
  12839. * @param w factor to multiple the width by
  12840. * @param h factor to multiple the height by
  12841. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12842. */
  12843. multiplyByFloats(w: number, h: number): Size;
  12844. /**
  12845. * Clones the size
  12846. * @returns a new Size copied from the given one.
  12847. */
  12848. clone(): Size;
  12849. /**
  12850. * True if the current Size and the given one width and height are strictly equal.
  12851. * @param other the other size to compare against
  12852. * @returns True if the current Size and the given one width and height are strictly equal.
  12853. */
  12854. equals(other: Size): boolean;
  12855. /**
  12856. * The surface of the Size : width * height (float).
  12857. */
  12858. readonly surface: number;
  12859. /**
  12860. * Create a new size of zero
  12861. * @returns a new Size set to (0.0, 0.0)
  12862. */
  12863. static Zero(): Size;
  12864. /**
  12865. * Sums the width and height of two sizes
  12866. * @param otherSize size to add to this size
  12867. * @returns a new Size set as the addition result of the current Size and the given one.
  12868. */
  12869. add(otherSize: Size): Size;
  12870. /**
  12871. * Subtracts the width and height of two
  12872. * @param otherSize size to subtract to this size
  12873. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12874. */
  12875. subtract(otherSize: Size): Size;
  12876. /**
  12877. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12878. * @param start starting size to lerp between
  12879. * @param end end size to lerp between
  12880. * @param amount amount to lerp between the start and end values
  12881. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12882. */
  12883. static Lerp(start: Size, end: Size, amount: number): Size;
  12884. }
  12885. }
  12886. declare module "babylonjs/Animations/runtimeAnimation" {
  12887. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12888. import { Animatable } from "babylonjs/Animations/animatable";
  12889. import { Scene } from "babylonjs/scene";
  12890. /**
  12891. * Defines a runtime animation
  12892. */
  12893. export class RuntimeAnimation {
  12894. private _events;
  12895. /**
  12896. * The current frame of the runtime animation
  12897. */
  12898. private _currentFrame;
  12899. /**
  12900. * The animation used by the runtime animation
  12901. */
  12902. private _animation;
  12903. /**
  12904. * The target of the runtime animation
  12905. */
  12906. private _target;
  12907. /**
  12908. * The initiating animatable
  12909. */
  12910. private _host;
  12911. /**
  12912. * The original value of the runtime animation
  12913. */
  12914. private _originalValue;
  12915. /**
  12916. * The original blend value of the runtime animation
  12917. */
  12918. private _originalBlendValue;
  12919. /**
  12920. * The offsets cache of the runtime animation
  12921. */
  12922. private _offsetsCache;
  12923. /**
  12924. * The high limits cache of the runtime animation
  12925. */
  12926. private _highLimitsCache;
  12927. /**
  12928. * Specifies if the runtime animation has been stopped
  12929. */
  12930. private _stopped;
  12931. /**
  12932. * The blending factor of the runtime animation
  12933. */
  12934. private _blendingFactor;
  12935. /**
  12936. * The BabylonJS scene
  12937. */
  12938. private _scene;
  12939. /**
  12940. * The current value of the runtime animation
  12941. */
  12942. private _currentValue;
  12943. /** @hidden */
  12944. _animationState: _IAnimationState;
  12945. /**
  12946. * The active target of the runtime animation
  12947. */
  12948. private _activeTargets;
  12949. private _currentActiveTarget;
  12950. private _directTarget;
  12951. /**
  12952. * The target path of the runtime animation
  12953. */
  12954. private _targetPath;
  12955. /**
  12956. * The weight of the runtime animation
  12957. */
  12958. private _weight;
  12959. /**
  12960. * The ratio offset of the runtime animation
  12961. */
  12962. private _ratioOffset;
  12963. /**
  12964. * The previous delay of the runtime animation
  12965. */
  12966. private _previousDelay;
  12967. /**
  12968. * The previous ratio of the runtime animation
  12969. */
  12970. private _previousRatio;
  12971. private _enableBlending;
  12972. private _keys;
  12973. private _minFrame;
  12974. private _maxFrame;
  12975. private _minValue;
  12976. private _maxValue;
  12977. private _targetIsArray;
  12978. /**
  12979. * Gets the current frame of the runtime animation
  12980. */
  12981. readonly currentFrame: number;
  12982. /**
  12983. * Gets the weight of the runtime animation
  12984. */
  12985. readonly weight: number;
  12986. /**
  12987. * Gets the current value of the runtime animation
  12988. */
  12989. readonly currentValue: any;
  12990. /**
  12991. * Gets the target path of the runtime animation
  12992. */
  12993. readonly targetPath: string;
  12994. /**
  12995. * Gets the actual target of the runtime animation
  12996. */
  12997. readonly target: any;
  12998. /** @hidden */
  12999. _onLoop: () => void;
  13000. /**
  13001. * Create a new RuntimeAnimation object
  13002. * @param target defines the target of the animation
  13003. * @param animation defines the source animation object
  13004. * @param scene defines the hosting scene
  13005. * @param host defines the initiating Animatable
  13006. */
  13007. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13008. private _preparePath;
  13009. /**
  13010. * Gets the animation from the runtime animation
  13011. */
  13012. readonly animation: Animation;
  13013. /**
  13014. * Resets the runtime animation to the beginning
  13015. * @param restoreOriginal defines whether to restore the target property to the original value
  13016. */
  13017. reset(restoreOriginal?: boolean): void;
  13018. /**
  13019. * Specifies if the runtime animation is stopped
  13020. * @returns Boolean specifying if the runtime animation is stopped
  13021. */
  13022. isStopped(): boolean;
  13023. /**
  13024. * Disposes of the runtime animation
  13025. */
  13026. dispose(): void;
  13027. /**
  13028. * Apply the interpolated value to the target
  13029. * @param currentValue defines the value computed by the animation
  13030. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13031. */
  13032. setValue(currentValue: any, weight: number): void;
  13033. private _getOriginalValues;
  13034. private _setValue;
  13035. /**
  13036. * Gets the loop pmode of the runtime animation
  13037. * @returns Loop Mode
  13038. */
  13039. private _getCorrectLoopMode;
  13040. /**
  13041. * Move the current animation to a given frame
  13042. * @param frame defines the frame to move to
  13043. */
  13044. goToFrame(frame: number): void;
  13045. /**
  13046. * @hidden Internal use only
  13047. */
  13048. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13049. /**
  13050. * Execute the current animation
  13051. * @param delay defines the delay to add to the current frame
  13052. * @param from defines the lower bound of the animation range
  13053. * @param to defines the upper bound of the animation range
  13054. * @param loop defines if the current animation must loop
  13055. * @param speedRatio defines the current speed ratio
  13056. * @param weight defines the weight of the animation (default is -1 so no weight)
  13057. * @param onLoop optional callback called when animation loops
  13058. * @returns a boolean indicating if the animation is running
  13059. */
  13060. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13061. }
  13062. }
  13063. declare module "babylonjs/Animations/animatable" {
  13064. import { Animation } from "babylonjs/Animations/animation";
  13065. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13066. import { Nullable } from "babylonjs/types";
  13067. import { Observable } from "babylonjs/Misc/observable";
  13068. import { Scene } from "babylonjs/scene";
  13069. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13070. import { Node } from "babylonjs/node";
  13071. /**
  13072. * Class used to store an actual running animation
  13073. */
  13074. export class Animatable {
  13075. /** defines the target object */
  13076. target: any;
  13077. /** defines the starting frame number (default is 0) */
  13078. fromFrame: number;
  13079. /** defines the ending frame number (default is 100) */
  13080. toFrame: number;
  13081. /** defines if the animation must loop (default is false) */
  13082. loopAnimation: boolean;
  13083. /** defines a callback to call when animation ends if it is not looping */
  13084. onAnimationEnd?: (() => void) | null | undefined;
  13085. /** defines a callback to call when animation loops */
  13086. onAnimationLoop?: (() => void) | null | undefined;
  13087. private _localDelayOffset;
  13088. private _pausedDelay;
  13089. private _runtimeAnimations;
  13090. private _paused;
  13091. private _scene;
  13092. private _speedRatio;
  13093. private _weight;
  13094. private _syncRoot;
  13095. /**
  13096. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13097. * This will only apply for non looping animation (default is true)
  13098. */
  13099. disposeOnEnd: boolean;
  13100. /**
  13101. * Gets a boolean indicating if the animation has started
  13102. */
  13103. animationStarted: boolean;
  13104. /**
  13105. * Observer raised when the animation ends
  13106. */
  13107. onAnimationEndObservable: Observable<Animatable>;
  13108. /**
  13109. * Observer raised when the animation loops
  13110. */
  13111. onAnimationLoopObservable: Observable<Animatable>;
  13112. /**
  13113. * Gets the root Animatable used to synchronize and normalize animations
  13114. */
  13115. readonly syncRoot: Nullable<Animatable>;
  13116. /**
  13117. * Gets the current frame of the first RuntimeAnimation
  13118. * Used to synchronize Animatables
  13119. */
  13120. readonly masterFrame: number;
  13121. /**
  13122. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13123. */
  13124. weight: number;
  13125. /**
  13126. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13127. */
  13128. speedRatio: number;
  13129. /**
  13130. * Creates a new Animatable
  13131. * @param scene defines the hosting scene
  13132. * @param target defines the target object
  13133. * @param fromFrame defines the starting frame number (default is 0)
  13134. * @param toFrame defines the ending frame number (default is 100)
  13135. * @param loopAnimation defines if the animation must loop (default is false)
  13136. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13137. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13138. * @param animations defines a group of animation to add to the new Animatable
  13139. * @param onAnimationLoop defines a callback to call when animation loops
  13140. */
  13141. constructor(scene: Scene,
  13142. /** defines the target object */
  13143. target: any,
  13144. /** defines the starting frame number (default is 0) */
  13145. fromFrame?: number,
  13146. /** defines the ending frame number (default is 100) */
  13147. toFrame?: number,
  13148. /** defines if the animation must loop (default is false) */
  13149. loopAnimation?: boolean, speedRatio?: number,
  13150. /** defines a callback to call when animation ends if it is not looping */
  13151. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13152. /** defines a callback to call when animation loops */
  13153. onAnimationLoop?: (() => void) | null | undefined);
  13154. /**
  13155. * Synchronize and normalize current Animatable with a source Animatable
  13156. * This is useful when using animation weights and when animations are not of the same length
  13157. * @param root defines the root Animatable to synchronize with
  13158. * @returns the current Animatable
  13159. */
  13160. syncWith(root: Animatable): Animatable;
  13161. /**
  13162. * Gets the list of runtime animations
  13163. * @returns an array of RuntimeAnimation
  13164. */
  13165. getAnimations(): RuntimeAnimation[];
  13166. /**
  13167. * Adds more animations to the current animatable
  13168. * @param target defines the target of the animations
  13169. * @param animations defines the new animations to add
  13170. */
  13171. appendAnimations(target: any, animations: Animation[]): void;
  13172. /**
  13173. * Gets the source animation for a specific property
  13174. * @param property defines the propertyu to look for
  13175. * @returns null or the source animation for the given property
  13176. */
  13177. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13178. /**
  13179. * Gets the runtime animation for a specific property
  13180. * @param property defines the propertyu to look for
  13181. * @returns null or the runtime animation for the given property
  13182. */
  13183. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13184. /**
  13185. * Resets the animatable to its original state
  13186. */
  13187. reset(): void;
  13188. /**
  13189. * Allows the animatable to blend with current running animations
  13190. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13191. * @param blendingSpeed defines the blending speed to use
  13192. */
  13193. enableBlending(blendingSpeed: number): void;
  13194. /**
  13195. * Disable animation blending
  13196. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13197. */
  13198. disableBlending(): void;
  13199. /**
  13200. * Jump directly to a given frame
  13201. * @param frame defines the frame to jump to
  13202. */
  13203. goToFrame(frame: number): void;
  13204. /**
  13205. * Pause the animation
  13206. */
  13207. pause(): void;
  13208. /**
  13209. * Restart the animation
  13210. */
  13211. restart(): void;
  13212. private _raiseOnAnimationEnd;
  13213. /**
  13214. * Stop and delete the current animation
  13215. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13216. * @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)
  13217. */
  13218. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13219. /**
  13220. * Wait asynchronously for the animation to end
  13221. * @returns a promise which will be fullfilled when the animation ends
  13222. */
  13223. waitAsync(): Promise<Animatable>;
  13224. /** @hidden */
  13225. _animate(delay: number): boolean;
  13226. }
  13227. module "babylonjs/scene" {
  13228. interface Scene {
  13229. /** @hidden */
  13230. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13231. /** @hidden */
  13232. _processLateAnimationBindingsForMatrices(holder: {
  13233. totalWeight: number;
  13234. animations: RuntimeAnimation[];
  13235. originalValue: Matrix;
  13236. }): any;
  13237. /** @hidden */
  13238. _processLateAnimationBindingsForQuaternions(holder: {
  13239. totalWeight: number;
  13240. animations: RuntimeAnimation[];
  13241. originalValue: Quaternion;
  13242. }, refQuaternion: Quaternion): Quaternion;
  13243. /** @hidden */
  13244. _processLateAnimationBindings(): void;
  13245. /**
  13246. * Will start the animation sequence of a given target
  13247. * @param target defines the target
  13248. * @param from defines from which frame should animation start
  13249. * @param to defines until which frame should animation run.
  13250. * @param weight defines the weight to apply to the animation (1.0 by default)
  13251. * @param loop defines if the animation loops
  13252. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13253. * @param onAnimationEnd defines the function to be executed when the animation ends
  13254. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13255. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13256. * @param onAnimationLoop defines the callback to call when an animation loops
  13257. * @returns the animatable object created for this animation
  13258. */
  13259. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13260. /**
  13261. * Will start the animation sequence of a given target
  13262. * @param target defines the target
  13263. * @param from defines from which frame should animation start
  13264. * @param to defines until which frame should animation run.
  13265. * @param loop defines if the animation loops
  13266. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13267. * @param onAnimationEnd defines the function to be executed when the animation ends
  13268. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13269. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13270. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13271. * @param onAnimationLoop defines the callback to call when an animation loops
  13272. * @returns the animatable object created for this animation
  13273. */
  13274. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13275. /**
  13276. * Will start the animation sequence of a given target and its hierarchy
  13277. * @param target defines the target
  13278. * @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.
  13279. * @param from defines from which frame should animation start
  13280. * @param to defines until which frame should animation run.
  13281. * @param loop defines if the animation loops
  13282. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13283. * @param onAnimationEnd defines the function to be executed when the animation ends
  13284. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13285. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13286. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of created animatables
  13289. */
  13290. 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[];
  13291. /**
  13292. * Begin a new animation on a given node
  13293. * @param target defines the target where the animation will take place
  13294. * @param animations defines the list of animations to start
  13295. * @param from defines the initial value
  13296. * @param to defines the final value
  13297. * @param loop defines if you want animation to loop (off by default)
  13298. * @param speedRatio defines the speed ratio to apply to all animations
  13299. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13300. * @param onAnimationLoop defines the callback to call when an animation loops
  13301. * @returns the list of created animatables
  13302. */
  13303. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13304. /**
  13305. * Begin a new animation on a given node and its hierarchy
  13306. * @param target defines the root node where the animation will take place
  13307. * @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.
  13308. * @param animations defines the list of animations to start
  13309. * @param from defines the initial value
  13310. * @param to defines the final value
  13311. * @param loop defines if you want animation to loop (off by default)
  13312. * @param speedRatio defines the speed ratio to apply to all animations
  13313. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13314. * @param onAnimationLoop defines the callback to call when an animation loops
  13315. * @returns the list of animatables created for all nodes
  13316. */
  13317. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13318. /**
  13319. * Gets the animatable associated with a specific target
  13320. * @param target defines the target of the animatable
  13321. * @returns the required animatable if found
  13322. */
  13323. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13324. /**
  13325. * Gets all animatables associated with a given target
  13326. * @param target defines the target to look animatables for
  13327. * @returns an array of Animatables
  13328. */
  13329. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13330. /**
  13331. * Stops and removes all animations that have been applied to the scene
  13332. */
  13333. stopAllAnimations(): void;
  13334. /**
  13335. * Gets the current delta time used by animation engine
  13336. */
  13337. deltaTime: number;
  13338. }
  13339. }
  13340. module "babylonjs/Bones/bone" {
  13341. interface Bone {
  13342. /**
  13343. * Copy an animation range from another bone
  13344. * @param source defines the source bone
  13345. * @param rangeName defines the range name to copy
  13346. * @param frameOffset defines the frame offset
  13347. * @param rescaleAsRequired defines if rescaling must be applied if required
  13348. * @param skelDimensionsRatio defines the scaling ratio
  13349. * @returns true if operation was successful
  13350. */
  13351. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13352. }
  13353. }
  13354. }
  13355. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13356. /**
  13357. * Class used to override all child animations of a given target
  13358. */
  13359. export class AnimationPropertiesOverride {
  13360. /**
  13361. * Gets or sets a value indicating if animation blending must be used
  13362. */
  13363. enableBlending: boolean;
  13364. /**
  13365. * Gets or sets the blending speed to use when enableBlending is true
  13366. */
  13367. blendingSpeed: number;
  13368. /**
  13369. * Gets or sets the default loop mode to use
  13370. */
  13371. loopMode: number;
  13372. }
  13373. }
  13374. declare module "babylonjs/Bones/skeleton" {
  13375. import { Bone } from "babylonjs/Bones/bone";
  13376. import { Observable } from "babylonjs/Misc/observable";
  13377. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13378. import { Scene } from "babylonjs/scene";
  13379. import { Nullable } from "babylonjs/types";
  13380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13381. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13382. import { Animatable } from "babylonjs/Animations/animatable";
  13383. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13384. import { Animation } from "babylonjs/Animations/animation";
  13385. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13386. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13388. /**
  13389. * Class used to handle skinning animations
  13390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13391. */
  13392. export class Skeleton implements IAnimatable {
  13393. /** defines the skeleton name */
  13394. name: string;
  13395. /** defines the skeleton Id */
  13396. id: string;
  13397. /**
  13398. * Defines the list of child bones
  13399. */
  13400. bones: Bone[];
  13401. /**
  13402. * Defines an estimate of the dimension of the skeleton at rest
  13403. */
  13404. dimensionsAtRest: Vector3;
  13405. /**
  13406. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13407. */
  13408. needInitialSkinMatrix: boolean;
  13409. /**
  13410. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13411. */
  13412. overrideMesh: Nullable<AbstractMesh>;
  13413. /**
  13414. * Gets the list of animations attached to this skeleton
  13415. */
  13416. animations: Array<Animation>;
  13417. private _scene;
  13418. private _isDirty;
  13419. private _transformMatrices;
  13420. private _transformMatrixTexture;
  13421. private _meshesWithPoseMatrix;
  13422. private _animatables;
  13423. private _identity;
  13424. private _synchronizedWithMesh;
  13425. private _ranges;
  13426. private _lastAbsoluteTransformsUpdateId;
  13427. private _canUseTextureForBones;
  13428. private _uniqueId;
  13429. /** @hidden */
  13430. _numBonesWithLinkedTransformNode: number;
  13431. /** @hidden */
  13432. _hasWaitingData: Nullable<boolean>;
  13433. /**
  13434. * Specifies if the skeleton should be serialized
  13435. */
  13436. doNotSerialize: boolean;
  13437. private _useTextureToStoreBoneMatrices;
  13438. /**
  13439. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13440. * Please note that this option is not available if the hardware does not support it
  13441. */
  13442. useTextureToStoreBoneMatrices: boolean;
  13443. private _animationPropertiesOverride;
  13444. /**
  13445. * Gets or sets the animation properties override
  13446. */
  13447. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13448. /**
  13449. * List of inspectable custom properties (used by the Inspector)
  13450. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13451. */
  13452. inspectableCustomProperties: IInspectable[];
  13453. /**
  13454. * An observable triggered before computing the skeleton's matrices
  13455. */
  13456. onBeforeComputeObservable: Observable<Skeleton>;
  13457. /**
  13458. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13459. */
  13460. readonly isUsingTextureForMatrices: boolean;
  13461. /**
  13462. * Gets the unique ID of this skeleton
  13463. */
  13464. readonly uniqueId: number;
  13465. /**
  13466. * Creates a new skeleton
  13467. * @param name defines the skeleton name
  13468. * @param id defines the skeleton Id
  13469. * @param scene defines the hosting scene
  13470. */
  13471. constructor(
  13472. /** defines the skeleton name */
  13473. name: string,
  13474. /** defines the skeleton Id */
  13475. id: string, scene: Scene);
  13476. /**
  13477. * Gets the current object class name.
  13478. * @return the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Returns an array containing the root bones
  13483. * @returns an array containing the root bones
  13484. */
  13485. getChildren(): Array<Bone>;
  13486. /**
  13487. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13488. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13489. * @returns a Float32Array containing matrices data
  13490. */
  13491. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13492. /**
  13493. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13494. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13495. * @returns a raw texture containing the data
  13496. */
  13497. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13498. /**
  13499. * Gets the current hosting scene
  13500. * @returns a scene object
  13501. */
  13502. getScene(): Scene;
  13503. /**
  13504. * Gets a string representing the current skeleton data
  13505. * @param fullDetails defines a boolean indicating if we want a verbose version
  13506. * @returns a string representing the current skeleton data
  13507. */
  13508. toString(fullDetails?: boolean): string;
  13509. /**
  13510. * Get bone's index searching by name
  13511. * @param name defines bone's name to search for
  13512. * @return the indice of the bone. Returns -1 if not found
  13513. */
  13514. getBoneIndexByName(name: string): number;
  13515. /**
  13516. * Creater a new animation range
  13517. * @param name defines the name of the range
  13518. * @param from defines the start key
  13519. * @param to defines the end key
  13520. */
  13521. createAnimationRange(name: string, from: number, to: number): void;
  13522. /**
  13523. * Delete a specific animation range
  13524. * @param name defines the name of the range
  13525. * @param deleteFrames defines if frames must be removed as well
  13526. */
  13527. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13528. /**
  13529. * Gets a specific animation range
  13530. * @param name defines the name of the range to look for
  13531. * @returns the requested animation range or null if not found
  13532. */
  13533. getAnimationRange(name: string): Nullable<AnimationRange>;
  13534. /**
  13535. * Gets the list of all animation ranges defined on this skeleton
  13536. * @returns an array
  13537. */
  13538. getAnimationRanges(): Nullable<AnimationRange>[];
  13539. /**
  13540. * Copy animation range from a source skeleton.
  13541. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13542. * @param source defines the source skeleton
  13543. * @param name defines the name of the range to copy
  13544. * @param rescaleAsRequired defines if rescaling must be applied if required
  13545. * @returns true if operation was successful
  13546. */
  13547. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13548. /**
  13549. * Forces the skeleton to go to rest pose
  13550. */
  13551. returnToRest(): void;
  13552. private _getHighestAnimationFrame;
  13553. /**
  13554. * Begin a specific animation range
  13555. * @param name defines the name of the range to start
  13556. * @param loop defines if looping must be turned on (false by default)
  13557. * @param speedRatio defines the speed ratio to apply (1 by default)
  13558. * @param onAnimationEnd defines a callback which will be called when animation will end
  13559. * @returns a new animatable
  13560. */
  13561. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13562. /** @hidden */
  13563. _markAsDirty(): void;
  13564. /** @hidden */
  13565. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13566. /** @hidden */
  13567. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13568. private _computeTransformMatrices;
  13569. /**
  13570. * Build all resources required to render a skeleton
  13571. */
  13572. prepare(): void;
  13573. /**
  13574. * Gets the list of animatables currently running for this skeleton
  13575. * @returns an array of animatables
  13576. */
  13577. getAnimatables(): IAnimatable[];
  13578. /**
  13579. * Clone the current skeleton
  13580. * @param name defines the name of the new skeleton
  13581. * @param id defines the id of the new skeleton
  13582. * @returns the new skeleton
  13583. */
  13584. clone(name: string, id: string): Skeleton;
  13585. /**
  13586. * Enable animation blending for this skeleton
  13587. * @param blendingSpeed defines the blending speed to apply
  13588. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13589. */
  13590. enableBlending(blendingSpeed?: number): void;
  13591. /**
  13592. * Releases all resources associated with the current skeleton
  13593. */
  13594. dispose(): void;
  13595. /**
  13596. * Serialize the skeleton in a JSON object
  13597. * @returns a JSON object
  13598. */
  13599. serialize(): any;
  13600. /**
  13601. * Creates a new skeleton from serialized data
  13602. * @param parsedSkeleton defines the serialized data
  13603. * @param scene defines the hosting scene
  13604. * @returns a new skeleton
  13605. */
  13606. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13607. /**
  13608. * Compute all node absolute transforms
  13609. * @param forceUpdate defines if computation must be done even if cache is up to date
  13610. */
  13611. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13612. /**
  13613. * Gets the root pose matrix
  13614. * @returns a matrix
  13615. */
  13616. getPoseMatrix(): Nullable<Matrix>;
  13617. /**
  13618. * Sorts bones per internal index
  13619. */
  13620. sortBones(): void;
  13621. private _sortBones;
  13622. }
  13623. }
  13624. declare module "babylonjs/Bones/bone" {
  13625. import { Skeleton } from "babylonjs/Bones/skeleton";
  13626. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13627. import { Nullable } from "babylonjs/types";
  13628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13629. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13630. import { Node } from "babylonjs/node";
  13631. import { Space } from "babylonjs/Maths/math.axis";
  13632. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13633. /**
  13634. * Class used to store bone information
  13635. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13636. */
  13637. export class Bone extends Node {
  13638. /**
  13639. * defines the bone name
  13640. */
  13641. name: string;
  13642. private static _tmpVecs;
  13643. private static _tmpQuat;
  13644. private static _tmpMats;
  13645. /**
  13646. * Gets the list of child bones
  13647. */
  13648. children: Bone[];
  13649. /** Gets the animations associated with this bone */
  13650. animations: import("babylonjs/Animations/animation").Animation[];
  13651. /**
  13652. * Gets or sets bone length
  13653. */
  13654. length: number;
  13655. /**
  13656. * @hidden Internal only
  13657. * Set this value to map this bone to a different index in the transform matrices
  13658. * Set this value to -1 to exclude the bone from the transform matrices
  13659. */
  13660. _index: Nullable<number>;
  13661. private _skeleton;
  13662. private _localMatrix;
  13663. private _restPose;
  13664. private _baseMatrix;
  13665. private _absoluteTransform;
  13666. private _invertedAbsoluteTransform;
  13667. private _parent;
  13668. private _scalingDeterminant;
  13669. private _worldTransform;
  13670. private _localScaling;
  13671. private _localRotation;
  13672. private _localPosition;
  13673. private _needToDecompose;
  13674. private _needToCompose;
  13675. /** @hidden */
  13676. _linkedTransformNode: Nullable<TransformNode>;
  13677. /** @hidden */
  13678. _waitingTransformNodeId: Nullable<string>;
  13679. /** @hidden */
  13680. /** @hidden */
  13681. _matrix: Matrix;
  13682. /**
  13683. * Create a new bone
  13684. * @param name defines the bone name
  13685. * @param skeleton defines the parent skeleton
  13686. * @param parentBone defines the parent (can be null if the bone is the root)
  13687. * @param localMatrix defines the local matrix
  13688. * @param restPose defines the rest pose matrix
  13689. * @param baseMatrix defines the base matrix
  13690. * @param index defines index of the bone in the hiearchy
  13691. */
  13692. constructor(
  13693. /**
  13694. * defines the bone name
  13695. */
  13696. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13697. /**
  13698. * Gets the current object class name.
  13699. * @return the class name
  13700. */
  13701. getClassName(): string;
  13702. /**
  13703. * Gets the parent skeleton
  13704. * @returns a skeleton
  13705. */
  13706. getSkeleton(): Skeleton;
  13707. /**
  13708. * Gets parent bone
  13709. * @returns a bone or null if the bone is the root of the bone hierarchy
  13710. */
  13711. getParent(): Nullable<Bone>;
  13712. /**
  13713. * Returns an array containing the root bones
  13714. * @returns an array containing the root bones
  13715. */
  13716. getChildren(): Array<Bone>;
  13717. /**
  13718. * Sets the parent bone
  13719. * @param parent defines the parent (can be null if the bone is the root)
  13720. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13721. */
  13722. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13723. /**
  13724. * Gets the local matrix
  13725. * @returns a matrix
  13726. */
  13727. getLocalMatrix(): Matrix;
  13728. /**
  13729. * Gets the base matrix (initial matrix which remains unchanged)
  13730. * @returns a matrix
  13731. */
  13732. getBaseMatrix(): Matrix;
  13733. /**
  13734. * Gets the rest pose matrix
  13735. * @returns a matrix
  13736. */
  13737. getRestPose(): Matrix;
  13738. /**
  13739. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13740. */
  13741. getWorldMatrix(): Matrix;
  13742. /**
  13743. * Sets the local matrix to rest pose matrix
  13744. */
  13745. returnToRest(): void;
  13746. /**
  13747. * Gets the inverse of the absolute transform matrix.
  13748. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13749. * @returns a matrix
  13750. */
  13751. getInvertedAbsoluteTransform(): Matrix;
  13752. /**
  13753. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13754. * @returns a matrix
  13755. */
  13756. getAbsoluteTransform(): Matrix;
  13757. /**
  13758. * Links with the given transform node.
  13759. * The local matrix of this bone is copied from the transform node every frame.
  13760. * @param transformNode defines the transform node to link to
  13761. */
  13762. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13763. /**
  13764. * Gets the node used to drive the bone's transformation
  13765. * @returns a transform node or null
  13766. */
  13767. getTransformNode(): Nullable<TransformNode>;
  13768. /** Gets or sets current position (in local space) */
  13769. position: Vector3;
  13770. /** Gets or sets current rotation (in local space) */
  13771. rotation: Vector3;
  13772. /** Gets or sets current rotation quaternion (in local space) */
  13773. rotationQuaternion: Quaternion;
  13774. /** Gets or sets current scaling (in local space) */
  13775. scaling: Vector3;
  13776. /**
  13777. * Gets the animation properties override
  13778. */
  13779. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13780. private _decompose;
  13781. private _compose;
  13782. /**
  13783. * Update the base and local matrices
  13784. * @param matrix defines the new base or local matrix
  13785. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13786. * @param updateLocalMatrix defines if the local matrix should be updated
  13787. */
  13788. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13789. /** @hidden */
  13790. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13791. /**
  13792. * Flag the bone as dirty (Forcing it to update everything)
  13793. */
  13794. markAsDirty(): void;
  13795. /** @hidden */
  13796. _markAsDirtyAndCompose(): void;
  13797. private _markAsDirtyAndDecompose;
  13798. /**
  13799. * Translate the bone in local or world space
  13800. * @param vec The amount to translate the bone
  13801. * @param space The space that the translation is in
  13802. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13803. */
  13804. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13805. /**
  13806. * Set the postion of the bone in local or world space
  13807. * @param position The position to set the bone
  13808. * @param space The space that the position is in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Set the absolute position of the bone (world space)
  13814. * @param position The position to set the bone
  13815. * @param mesh The mesh that this bone is attached to
  13816. */
  13817. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13818. /**
  13819. * Scale the bone on the x, y and z axes (in local space)
  13820. * @param x The amount to scale the bone on the x axis
  13821. * @param y The amount to scale the bone on the y axis
  13822. * @param z The amount to scale the bone on the z axis
  13823. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13824. */
  13825. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13826. /**
  13827. * Set the bone scaling in local space
  13828. * @param scale defines the scaling vector
  13829. */
  13830. setScale(scale: Vector3): void;
  13831. /**
  13832. * Gets the current scaling in local space
  13833. * @returns the current scaling vector
  13834. */
  13835. getScale(): Vector3;
  13836. /**
  13837. * Gets the current scaling in local space and stores it in a target vector
  13838. * @param result defines the target vector
  13839. */
  13840. getScaleToRef(result: Vector3): void;
  13841. /**
  13842. * Set the yaw, pitch, and roll of the bone in local or world space
  13843. * @param yaw The rotation of the bone on the y axis
  13844. * @param pitch The rotation of the bone on the x axis
  13845. * @param roll The rotation of the bone on the z axis
  13846. * @param space The space that the axes of rotation are in
  13847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13848. */
  13849. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13850. /**
  13851. * Add a rotation to the bone on an axis in local or world space
  13852. * @param axis The axis to rotate the bone on
  13853. * @param amount The amount to rotate the bone
  13854. * @param space The space that the axis is in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. */
  13857. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13858. /**
  13859. * Set the rotation of the bone to a particular axis angle in local or world space
  13860. * @param axis The axis to rotate the bone on
  13861. * @param angle The angle that the bone should be rotated to
  13862. * @param space The space that the axis is in
  13863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13864. */
  13865. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13866. /**
  13867. * Set the euler rotation of the bone in local of world space
  13868. * @param rotation The euler rotation that the bone should be set to
  13869. * @param space The space that the rotation is in
  13870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13871. */
  13872. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13873. /**
  13874. * Set the quaternion rotation of the bone in local of world space
  13875. * @param quat The quaternion rotation that the bone should be set to
  13876. * @param space The space that the rotation is in
  13877. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13878. */
  13879. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13880. /**
  13881. * Set the rotation matrix of the bone in local of world space
  13882. * @param rotMat The rotation matrix that the bone should be set to
  13883. * @param space The space that the rotation is in
  13884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13885. */
  13886. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13887. private _rotateWithMatrix;
  13888. private _getNegativeRotationToRef;
  13889. /**
  13890. * Get the position of the bone in local or world space
  13891. * @param space The space that the returned position is in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. * @returns The position of the bone
  13894. */
  13895. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13896. /**
  13897. * Copy the position of the bone to a vector3 in local or world space
  13898. * @param space The space that the returned position is in
  13899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13900. * @param result The vector3 to copy the position to
  13901. */
  13902. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13903. /**
  13904. * Get the absolute position of the bone (world space)
  13905. * @param mesh The mesh that this bone is attached to
  13906. * @returns The absolute position of the bone
  13907. */
  13908. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the absolute position of the bone (world space) to the result param
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 to copy the absolute position to
  13913. */
  13914. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13915. /**
  13916. * Compute the absolute transforms of this bone and its children
  13917. */
  13918. computeAbsoluteTransforms(): void;
  13919. /**
  13920. * Get the world direction from an axis that is in the local space of the bone
  13921. * @param localAxis The local direction that is used to compute the world direction
  13922. * @param mesh The mesh that this bone is attached to
  13923. * @returns The world direction
  13924. */
  13925. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13926. /**
  13927. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13928. * @param localAxis The local direction that is used to compute the world direction
  13929. * @param mesh The mesh that this bone is attached to
  13930. * @param result The vector3 that the world direction will be copied to
  13931. */
  13932. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13933. /**
  13934. * Get the euler rotation of the bone in local or world space
  13935. * @param space The space that the rotation should be in
  13936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13937. * @returns The euler rotation
  13938. */
  13939. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13940. /**
  13941. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13942. * @param space The space that the rotation should be in
  13943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13944. * @param result The vector3 that the rotation should be copied to
  13945. */
  13946. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13947. /**
  13948. * Get the quaternion rotation of the bone in either local or world space
  13949. * @param space The space that the rotation should be in
  13950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13951. * @returns The quaternion rotation
  13952. */
  13953. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13954. /**
  13955. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13956. * @param space The space that the rotation should be in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. * @param result The quaternion that the rotation should be copied to
  13959. */
  13960. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13961. /**
  13962. * Get the rotation matrix of the bone in local or world space
  13963. * @param space The space that the rotation should be in
  13964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13965. * @returns The rotation matrix
  13966. */
  13967. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13968. /**
  13969. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13970. * @param space The space that the rotation should be in
  13971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13972. * @param result The quaternion that the rotation should be copied to
  13973. */
  13974. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13975. /**
  13976. * Get the world position of a point that is in the local space of the bone
  13977. * @param position The local position
  13978. * @param mesh The mesh that this bone is attached to
  13979. * @returns The world position
  13980. */
  13981. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13982. /**
  13983. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13984. * @param position The local position
  13985. * @param mesh The mesh that this bone is attached to
  13986. * @param result The vector3 that the world position should be copied to
  13987. */
  13988. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13989. /**
  13990. * Get the local position of a point that is in world space
  13991. * @param position The world position
  13992. * @param mesh The mesh that this bone is attached to
  13993. * @returns The local position
  13994. */
  13995. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13996. /**
  13997. * Get the local position of a point that is in world space and copy it to the result param
  13998. * @param position The world position
  13999. * @param mesh The mesh that this bone is attached to
  14000. * @param result The vector3 that the local position should be copied to
  14001. */
  14002. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14003. }
  14004. }
  14005. declare module "babylonjs/Meshes/transformNode" {
  14006. import { DeepImmutable } from "babylonjs/types";
  14007. import { Observable } from "babylonjs/Misc/observable";
  14008. import { Nullable } from "babylonjs/types";
  14009. import { Camera } from "babylonjs/Cameras/camera";
  14010. import { Scene } from "babylonjs/scene";
  14011. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14012. import { Node } from "babylonjs/node";
  14013. import { Bone } from "babylonjs/Bones/bone";
  14014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14015. import { Space } from "babylonjs/Maths/math.axis";
  14016. /**
  14017. * 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.
  14018. * @see https://doc.babylonjs.com/how_to/transformnode
  14019. */
  14020. export class TransformNode extends Node {
  14021. /**
  14022. * Object will not rotate to face the camera
  14023. */
  14024. static BILLBOARDMODE_NONE: number;
  14025. /**
  14026. * Object will rotate to face the camera but only on the x axis
  14027. */
  14028. static BILLBOARDMODE_X: number;
  14029. /**
  14030. * Object will rotate to face the camera but only on the y axis
  14031. */
  14032. static BILLBOARDMODE_Y: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the z axis
  14035. */
  14036. static BILLBOARDMODE_Z: number;
  14037. /**
  14038. * Object will rotate to face the camera
  14039. */
  14040. static BILLBOARDMODE_ALL: number;
  14041. /**
  14042. * Object will rotate to face the camera's position instead of orientation
  14043. */
  14044. static BILLBOARDMODE_USE_POSITION: number;
  14045. private _forward;
  14046. private _forwardInverted;
  14047. private _up;
  14048. private _right;
  14049. private _rightInverted;
  14050. private _position;
  14051. private _rotation;
  14052. private _rotationQuaternion;
  14053. protected _scaling: Vector3;
  14054. protected _isDirty: boolean;
  14055. private _transformToBoneReferal;
  14056. private _isAbsoluteSynced;
  14057. private _billboardMode;
  14058. /**
  14059. * Gets or sets the billboard mode. Default is 0.
  14060. *
  14061. * | Value | Type | Description |
  14062. * | --- | --- | --- |
  14063. * | 0 | BILLBOARDMODE_NONE | |
  14064. * | 1 | BILLBOARDMODE_X | |
  14065. * | 2 | BILLBOARDMODE_Y | |
  14066. * | 4 | BILLBOARDMODE_Z | |
  14067. * | 7 | BILLBOARDMODE_ALL | |
  14068. *
  14069. */
  14070. billboardMode: number;
  14071. private _preserveParentRotationForBillboard;
  14072. /**
  14073. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14074. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14075. */
  14076. preserveParentRotationForBillboard: boolean;
  14077. /**
  14078. * 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
  14079. */
  14080. scalingDeterminant: number;
  14081. private _infiniteDistance;
  14082. /**
  14083. * Gets or sets the distance of the object to max, often used by skybox
  14084. */
  14085. infiniteDistance: boolean;
  14086. /**
  14087. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14088. * By default the system will update normals to compensate
  14089. */
  14090. ignoreNonUniformScaling: boolean;
  14091. /**
  14092. * 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
  14093. */
  14094. reIntegrateRotationIntoRotationQuaternion: boolean;
  14095. /** @hidden */
  14096. _poseMatrix: Nullable<Matrix>;
  14097. /** @hidden */
  14098. _localMatrix: Matrix;
  14099. private _usePivotMatrix;
  14100. private _absolutePosition;
  14101. private _absoluteScaling;
  14102. private _absoluteRotationQuaternion;
  14103. private _pivotMatrix;
  14104. private _pivotMatrixInverse;
  14105. protected _postMultiplyPivotMatrix: boolean;
  14106. protected _isWorldMatrixFrozen: boolean;
  14107. /** @hidden */
  14108. _indexInSceneTransformNodesArray: number;
  14109. /**
  14110. * An event triggered after the world matrix is updated
  14111. */
  14112. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14113. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14114. /**
  14115. * Gets a string identifying the name of the class
  14116. * @returns "TransformNode" string
  14117. */
  14118. getClassName(): string;
  14119. /**
  14120. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14121. */
  14122. position: Vector3;
  14123. /**
  14124. * 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)).
  14125. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14126. */
  14127. rotation: Vector3;
  14128. /**
  14129. * 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)).
  14130. */
  14131. scaling: Vector3;
  14132. /**
  14133. * 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).
  14134. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14135. */
  14136. rotationQuaternion: Nullable<Quaternion>;
  14137. /**
  14138. * The forward direction of that transform in world space.
  14139. */
  14140. readonly forward: Vector3;
  14141. /**
  14142. * The up direction of that transform in world space.
  14143. */
  14144. readonly up: Vector3;
  14145. /**
  14146. * The right direction of that transform in world space.
  14147. */
  14148. readonly right: Vector3;
  14149. /**
  14150. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14151. * @param matrix the matrix to copy the pose from
  14152. * @returns this TransformNode.
  14153. */
  14154. updatePoseMatrix(matrix: Matrix): TransformNode;
  14155. /**
  14156. * Returns the mesh Pose matrix.
  14157. * @returns the pose matrix
  14158. */
  14159. getPoseMatrix(): Matrix;
  14160. /** @hidden */
  14161. _isSynchronized(): boolean;
  14162. /** @hidden */
  14163. _initCache(): void;
  14164. /**
  14165. * Flag the transform node as dirty (Forcing it to update everything)
  14166. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14167. * @returns this transform node
  14168. */
  14169. markAsDirty(property: string): TransformNode;
  14170. /**
  14171. * Returns the current mesh absolute position.
  14172. * Returns a Vector3.
  14173. */
  14174. readonly absolutePosition: Vector3;
  14175. /**
  14176. * Returns the current mesh absolute scaling.
  14177. * Returns a Vector3.
  14178. */
  14179. readonly absoluteScaling: Vector3;
  14180. /**
  14181. * Returns the current mesh absolute rotation.
  14182. * Returns a Quaternion.
  14183. */
  14184. readonly absoluteRotationQuaternion: Quaternion;
  14185. /**
  14186. * Sets a new matrix to apply before all other transformation
  14187. * @param matrix defines the transform matrix
  14188. * @returns the current TransformNode
  14189. */
  14190. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14191. /**
  14192. * Sets a new pivot matrix to the current node
  14193. * @param matrix defines the new pivot matrix to use
  14194. * @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
  14195. * @returns the current TransformNode
  14196. */
  14197. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14198. /**
  14199. * Returns the mesh pivot matrix.
  14200. * Default : Identity.
  14201. * @returns the matrix
  14202. */
  14203. getPivotMatrix(): Matrix;
  14204. /**
  14205. * Instantiate (when possible) or clone that node with its hierarchy
  14206. * @param newParent defines the new parent to use for the instance (or clone)
  14207. * @returns an instance (or a clone) of the current node with its hiearchy
  14208. */
  14209. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14210. /**
  14211. * Prevents the World matrix to be computed any longer
  14212. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14213. * @returns the TransformNode.
  14214. */
  14215. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14216. /**
  14217. * Allows back the World matrix computation.
  14218. * @returns the TransformNode.
  14219. */
  14220. unfreezeWorldMatrix(): this;
  14221. /**
  14222. * True if the World matrix has been frozen.
  14223. */
  14224. readonly isWorldMatrixFrozen: boolean;
  14225. /**
  14226. * Retuns the mesh absolute position in the World.
  14227. * @returns a Vector3.
  14228. */
  14229. getAbsolutePosition(): Vector3;
  14230. /**
  14231. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14232. * @param absolutePosition the absolute position to set
  14233. * @returns the TransformNode.
  14234. */
  14235. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14236. /**
  14237. * Sets the mesh position in its local space.
  14238. * @param vector3 the position to set in localspace
  14239. * @returns the TransformNode.
  14240. */
  14241. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14242. /**
  14243. * Returns the mesh position in the local space from the current World matrix values.
  14244. * @returns a new Vector3.
  14245. */
  14246. getPositionExpressedInLocalSpace(): Vector3;
  14247. /**
  14248. * Translates the mesh along the passed Vector3 in its local space.
  14249. * @param vector3 the distance to translate in localspace
  14250. * @returns the TransformNode.
  14251. */
  14252. locallyTranslate(vector3: Vector3): TransformNode;
  14253. private static _lookAtVectorCache;
  14254. /**
  14255. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14256. * @param targetPoint the position (must be in same space as current mesh) to look at
  14257. * @param yawCor optional yaw (y-axis) correction in radians
  14258. * @param pitchCor optional pitch (x-axis) correction in radians
  14259. * @param rollCor optional roll (z-axis) correction in radians
  14260. * @param space the choosen space of the target
  14261. * @returns the TransformNode.
  14262. */
  14263. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14264. /**
  14265. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14266. * This Vector3 is expressed in the World space.
  14267. * @param localAxis axis to rotate
  14268. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14269. */
  14270. getDirection(localAxis: Vector3): Vector3;
  14271. /**
  14272. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14273. * localAxis is expressed in the mesh local space.
  14274. * result is computed in the Wordl space from the mesh World matrix.
  14275. * @param localAxis axis to rotate
  14276. * @param result the resulting transformnode
  14277. * @returns this TransformNode.
  14278. */
  14279. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14280. /**
  14281. * Sets this transform node rotation to the given local axis.
  14282. * @param localAxis the axis in local space
  14283. * @param yawCor optional yaw (y-axis) correction in radians
  14284. * @param pitchCor optional pitch (x-axis) correction in radians
  14285. * @param rollCor optional roll (z-axis) correction in radians
  14286. * @returns this TransformNode
  14287. */
  14288. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14289. /**
  14290. * Sets a new pivot point to the current node
  14291. * @param point defines the new pivot point to use
  14292. * @param space defines if the point is in world or local space (local by default)
  14293. * @returns the current TransformNode
  14294. */
  14295. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14296. /**
  14297. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14298. * @returns the pivot point
  14299. */
  14300. getPivotPoint(): Vector3;
  14301. /**
  14302. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14303. * @param result the vector3 to store the result
  14304. * @returns this TransformNode.
  14305. */
  14306. getPivotPointToRef(result: Vector3): TransformNode;
  14307. /**
  14308. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14309. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14310. */
  14311. getAbsolutePivotPoint(): Vector3;
  14312. /**
  14313. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14314. * @param result vector3 to store the result
  14315. * @returns this TransformNode.
  14316. */
  14317. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14318. /**
  14319. * Defines the passed node as the parent of the current node.
  14320. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14321. * @see https://doc.babylonjs.com/how_to/parenting
  14322. * @param node the node ot set as the parent
  14323. * @returns this TransformNode.
  14324. */
  14325. setParent(node: Nullable<Node>): TransformNode;
  14326. private _nonUniformScaling;
  14327. /**
  14328. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14329. */
  14330. readonly nonUniformScaling: boolean;
  14331. /** @hidden */
  14332. _updateNonUniformScalingState(value: boolean): boolean;
  14333. /**
  14334. * Attach the current TransformNode to another TransformNode associated with a bone
  14335. * @param bone Bone affecting the TransformNode
  14336. * @param affectedTransformNode TransformNode associated with the bone
  14337. * @returns this object
  14338. */
  14339. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14340. /**
  14341. * Detach the transform node if its associated with a bone
  14342. * @returns this object
  14343. */
  14344. detachFromBone(): TransformNode;
  14345. private static _rotationAxisCache;
  14346. /**
  14347. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14348. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14349. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14350. * The passed axis is also normalized.
  14351. * @param axis the axis to rotate around
  14352. * @param amount the amount to rotate in radians
  14353. * @param space Space to rotate in (Default: local)
  14354. * @returns the TransformNode.
  14355. */
  14356. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14357. /**
  14358. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14359. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14360. * The passed axis is also normalized. .
  14361. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14362. * @param point the point to rotate around
  14363. * @param axis the axis to rotate around
  14364. * @param amount the amount to rotate in radians
  14365. * @returns the TransformNode
  14366. */
  14367. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14368. /**
  14369. * Translates the mesh along the axis vector for the passed distance in the given space.
  14370. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14371. * @param axis the axis to translate in
  14372. * @param distance the distance to translate
  14373. * @param space Space to rotate in (Default: local)
  14374. * @returns the TransformNode.
  14375. */
  14376. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14377. /**
  14378. * Adds a rotation step to the mesh current rotation.
  14379. * x, y, z are Euler angles expressed in radians.
  14380. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14381. * This means this rotation is made in the mesh local space only.
  14382. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14383. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14384. * ```javascript
  14385. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14386. * ```
  14387. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14388. * 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.
  14389. * @param x Rotation to add
  14390. * @param y Rotation to add
  14391. * @param z Rotation to add
  14392. * @returns the TransformNode.
  14393. */
  14394. addRotation(x: number, y: number, z: number): TransformNode;
  14395. /**
  14396. * @hidden
  14397. */
  14398. protected _getEffectiveParent(): Nullable<Node>;
  14399. /**
  14400. * Computes the world matrix of the node
  14401. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14402. * @returns the world matrix
  14403. */
  14404. computeWorldMatrix(force?: boolean): Matrix;
  14405. protected _afterComputeWorldMatrix(): void;
  14406. /**
  14407. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14408. * @param func callback function to add
  14409. *
  14410. * @returns the TransformNode.
  14411. */
  14412. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14413. /**
  14414. * Removes a registered callback function.
  14415. * @param func callback function to remove
  14416. * @returns the TransformNode.
  14417. */
  14418. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14419. /**
  14420. * Gets the position of the current mesh in camera space
  14421. * @param camera defines the camera to use
  14422. * @returns a position
  14423. */
  14424. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14425. /**
  14426. * Returns the distance from the mesh to the active camera
  14427. * @param camera defines the camera to use
  14428. * @returns the distance
  14429. */
  14430. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14431. /**
  14432. * Clone the current transform node
  14433. * @param name Name of the new clone
  14434. * @param newParent New parent for the clone
  14435. * @param doNotCloneChildren Do not clone children hierarchy
  14436. * @returns the new transform node
  14437. */
  14438. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14439. /**
  14440. * Serializes the objects information.
  14441. * @param currentSerializationObject defines the object to serialize in
  14442. * @returns the serialized object
  14443. */
  14444. serialize(currentSerializationObject?: any): any;
  14445. /**
  14446. * Returns a new TransformNode object parsed from the source provided.
  14447. * @param parsedTransformNode is the source.
  14448. * @param scene the scne the object belongs to
  14449. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14450. * @returns a new TransformNode object parsed from the source provided.
  14451. */
  14452. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14453. /**
  14454. * Get all child-transformNodes of this node
  14455. * @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
  14456. * @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
  14457. * @returns an array of TransformNode
  14458. */
  14459. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14460. /**
  14461. * Releases resources associated with this transform node.
  14462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14464. */
  14465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14466. /**
  14467. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14468. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14469. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14470. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14471. * @returns the current mesh
  14472. */
  14473. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14474. private _syncAbsoluteScalingAndRotation;
  14475. }
  14476. }
  14477. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14478. import { Observable } from "babylonjs/Misc/observable";
  14479. import { Nullable } from "babylonjs/types";
  14480. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14481. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14483. import { Ray } from "babylonjs/Culling/ray";
  14484. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14485. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14486. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14487. /**
  14488. * Defines the types of pose enabled controllers that are supported
  14489. */
  14490. export enum PoseEnabledControllerType {
  14491. /**
  14492. * HTC Vive
  14493. */
  14494. VIVE = 0,
  14495. /**
  14496. * Oculus Rift
  14497. */
  14498. OCULUS = 1,
  14499. /**
  14500. * Windows mixed reality
  14501. */
  14502. WINDOWS = 2,
  14503. /**
  14504. * Samsung gear VR
  14505. */
  14506. GEAR_VR = 3,
  14507. /**
  14508. * Google Daydream
  14509. */
  14510. DAYDREAM = 4,
  14511. /**
  14512. * Generic
  14513. */
  14514. GENERIC = 5
  14515. }
  14516. /**
  14517. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14518. */
  14519. export interface MutableGamepadButton {
  14520. /**
  14521. * Value of the button/trigger
  14522. */
  14523. value: number;
  14524. /**
  14525. * If the button/trigger is currently touched
  14526. */
  14527. touched: boolean;
  14528. /**
  14529. * If the button/trigger is currently pressed
  14530. */
  14531. pressed: boolean;
  14532. }
  14533. /**
  14534. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14535. * @hidden
  14536. */
  14537. export interface ExtendedGamepadButton extends GamepadButton {
  14538. /**
  14539. * If the button/trigger is currently pressed
  14540. */
  14541. readonly pressed: boolean;
  14542. /**
  14543. * If the button/trigger is currently touched
  14544. */
  14545. readonly touched: boolean;
  14546. /**
  14547. * Value of the button/trigger
  14548. */
  14549. readonly value: number;
  14550. }
  14551. /** @hidden */
  14552. export interface _GamePadFactory {
  14553. /**
  14554. * Returns wether or not the current gamepad can be created for this type of controller.
  14555. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14556. * @returns true if it can be created, otherwise false
  14557. */
  14558. canCreate(gamepadInfo: any): boolean;
  14559. /**
  14560. * Creates a new instance of the Gamepad.
  14561. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14562. * @returns the new gamepad instance
  14563. */
  14564. create(gamepadInfo: any): Gamepad;
  14565. }
  14566. /**
  14567. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14568. */
  14569. export class PoseEnabledControllerHelper {
  14570. /** @hidden */
  14571. static _ControllerFactories: _GamePadFactory[];
  14572. /** @hidden */
  14573. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14574. /**
  14575. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14576. * @param vrGamepad the gamepad to initialized
  14577. * @returns a vr controller of the type the gamepad identified as
  14578. */
  14579. static InitiateController(vrGamepad: any): Gamepad;
  14580. }
  14581. /**
  14582. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14583. */
  14584. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14585. /**
  14586. * If the controller is used in a webXR session
  14587. */
  14588. isXR: boolean;
  14589. private _deviceRoomPosition;
  14590. private _deviceRoomRotationQuaternion;
  14591. /**
  14592. * The device position in babylon space
  14593. */
  14594. devicePosition: Vector3;
  14595. /**
  14596. * The device rotation in babylon space
  14597. */
  14598. deviceRotationQuaternion: Quaternion;
  14599. /**
  14600. * The scale factor of the device in babylon space
  14601. */
  14602. deviceScaleFactor: number;
  14603. /**
  14604. * (Likely devicePosition should be used instead) The device position in its room space
  14605. */
  14606. position: Vector3;
  14607. /**
  14608. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14609. */
  14610. rotationQuaternion: Quaternion;
  14611. /**
  14612. * The type of controller (Eg. Windows mixed reality)
  14613. */
  14614. controllerType: PoseEnabledControllerType;
  14615. protected _calculatedPosition: Vector3;
  14616. private _calculatedRotation;
  14617. /**
  14618. * The raw pose from the device
  14619. */
  14620. rawPose: DevicePose;
  14621. private _trackPosition;
  14622. private _maxRotationDistFromHeadset;
  14623. private _draggedRoomRotation;
  14624. /**
  14625. * @hidden
  14626. */
  14627. _disableTrackPosition(fixedPosition: Vector3): void;
  14628. /**
  14629. * Internal, the mesh attached to the controller
  14630. * @hidden
  14631. */
  14632. _mesh: Nullable<AbstractMesh>;
  14633. private _poseControlledCamera;
  14634. private _leftHandSystemQuaternion;
  14635. /**
  14636. * Internal, matrix used to convert room space to babylon space
  14637. * @hidden
  14638. */
  14639. _deviceToWorld: Matrix;
  14640. /**
  14641. * Node to be used when casting a ray from the controller
  14642. * @hidden
  14643. */
  14644. _pointingPoseNode: Nullable<TransformNode>;
  14645. /**
  14646. * Name of the child mesh that can be used to cast a ray from the controller
  14647. */
  14648. static readonly POINTING_POSE: string;
  14649. /**
  14650. * Creates a new PoseEnabledController from a gamepad
  14651. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14652. */
  14653. constructor(browserGamepad: any);
  14654. private _workingMatrix;
  14655. /**
  14656. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14657. */
  14658. update(): void;
  14659. /**
  14660. * Updates only the pose device and mesh without doing any button event checking
  14661. */
  14662. protected _updatePoseAndMesh(): void;
  14663. /**
  14664. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14665. * @param poseData raw pose fromthe device
  14666. */
  14667. updateFromDevice(poseData: DevicePose): void;
  14668. /**
  14669. * @hidden
  14670. */
  14671. _meshAttachedObservable: Observable<AbstractMesh>;
  14672. /**
  14673. * Attaches a mesh to the controller
  14674. * @param mesh the mesh to be attached
  14675. */
  14676. attachToMesh(mesh: AbstractMesh): void;
  14677. /**
  14678. * Attaches the controllers mesh to a camera
  14679. * @param camera the camera the mesh should be attached to
  14680. */
  14681. attachToPoseControlledCamera(camera: TargetCamera): void;
  14682. /**
  14683. * Disposes of the controller
  14684. */
  14685. dispose(): void;
  14686. /**
  14687. * The mesh that is attached to the controller
  14688. */
  14689. readonly mesh: Nullable<AbstractMesh>;
  14690. /**
  14691. * Gets the ray of the controller in the direction the controller is pointing
  14692. * @param length the length the resulting ray should be
  14693. * @returns a ray in the direction the controller is pointing
  14694. */
  14695. getForwardRay(length?: number): Ray;
  14696. }
  14697. }
  14698. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14699. import { Observable } from "babylonjs/Misc/observable";
  14700. import { Scene } from "babylonjs/scene";
  14701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14702. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14703. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14704. import { Nullable } from "babylonjs/types";
  14705. /**
  14706. * Defines the WebVRController object that represents controllers tracked in 3D space
  14707. */
  14708. export abstract class WebVRController extends PoseEnabledController {
  14709. /**
  14710. * Internal, the default controller model for the controller
  14711. */
  14712. protected _defaultModel: Nullable<AbstractMesh>;
  14713. /**
  14714. * Fired when the trigger state has changed
  14715. */
  14716. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14717. /**
  14718. * Fired when the main button state has changed
  14719. */
  14720. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14721. /**
  14722. * Fired when the secondary button state has changed
  14723. */
  14724. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the pad state has changed
  14727. */
  14728. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when controllers stick values have changed
  14731. */
  14732. onPadValuesChangedObservable: Observable<StickValues>;
  14733. /**
  14734. * Array of button availible on the controller
  14735. */
  14736. protected _buttons: Array<MutableGamepadButton>;
  14737. private _onButtonStateChange;
  14738. /**
  14739. * Fired when a controller button's state has changed
  14740. * @param callback the callback containing the button that was modified
  14741. */
  14742. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14743. /**
  14744. * X and Y axis corresponding to the controllers joystick
  14745. */
  14746. pad: StickValues;
  14747. /**
  14748. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14749. */
  14750. hand: string;
  14751. /**
  14752. * The default controller model for the controller
  14753. */
  14754. readonly defaultModel: Nullable<AbstractMesh>;
  14755. /**
  14756. * Creates a new WebVRController from a gamepad
  14757. * @param vrGamepad the gamepad that the WebVRController should be created from
  14758. */
  14759. constructor(vrGamepad: any);
  14760. /**
  14761. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14762. */
  14763. update(): void;
  14764. /**
  14765. * Function to be called when a button is modified
  14766. */
  14767. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14768. /**
  14769. * Loads a mesh and attaches it to the controller
  14770. * @param scene the scene the mesh should be added to
  14771. * @param meshLoaded callback for when the mesh has been loaded
  14772. */
  14773. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14774. private _setButtonValue;
  14775. private _changes;
  14776. private _checkChanges;
  14777. /**
  14778. * Disposes of th webVRCOntroller
  14779. */
  14780. dispose(): void;
  14781. }
  14782. }
  14783. declare module "babylonjs/Lights/hemisphericLight" {
  14784. import { Nullable } from "babylonjs/types";
  14785. import { Scene } from "babylonjs/scene";
  14786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14787. import { Color3 } from "babylonjs/Maths/math.color";
  14788. import { Effect } from "babylonjs/Materials/effect";
  14789. import { Light } from "babylonjs/Lights/light";
  14790. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14791. /**
  14792. * The HemisphericLight simulates the ambient environment light,
  14793. * so the passed direction is the light reflection direction, not the incoming direction.
  14794. */
  14795. export class HemisphericLight extends Light {
  14796. /**
  14797. * The groundColor is the light in the opposite direction to the one specified during creation.
  14798. * 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.
  14799. */
  14800. groundColor: Color3;
  14801. /**
  14802. * The light reflection direction, not the incoming direction.
  14803. */
  14804. direction: Vector3;
  14805. /**
  14806. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14807. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14808. * The HemisphericLight can't cast shadows.
  14809. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14810. * @param name The friendly name of the light
  14811. * @param direction The direction of the light reflection
  14812. * @param scene The scene the light belongs to
  14813. */
  14814. constructor(name: string, direction: Vector3, scene: Scene);
  14815. protected _buildUniformLayout(): void;
  14816. /**
  14817. * Returns the string "HemisphericLight".
  14818. * @return The class name
  14819. */
  14820. getClassName(): string;
  14821. /**
  14822. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14823. * Returns the updated direction.
  14824. * @param target The target the direction should point to
  14825. * @return The computed direction
  14826. */
  14827. setDirectionToTarget(target: Vector3): Vector3;
  14828. /**
  14829. * Returns the shadow generator associated to the light.
  14830. * @returns Always null for hemispheric lights because it does not support shadows.
  14831. */
  14832. getShadowGenerator(): Nullable<IShadowGenerator>;
  14833. /**
  14834. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14835. * @param effect The effect to update
  14836. * @param lightIndex The index of the light in the effect to update
  14837. * @returns The hemispheric light
  14838. */
  14839. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14840. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14841. /**
  14842. * Computes the world matrix of the node
  14843. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14844. * @param useWasUpdatedFlag defines a reserved property
  14845. * @returns the world matrix
  14846. */
  14847. computeWorldMatrix(): Matrix;
  14848. /**
  14849. * Returns the integer 3.
  14850. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14851. */
  14852. getTypeID(): number;
  14853. /**
  14854. * Prepares the list of defines specific to the light type.
  14855. * @param defines the list of defines
  14856. * @param lightIndex defines the index of the light for the effect
  14857. */
  14858. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14859. }
  14860. }
  14861. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14862. /** @hidden */
  14863. export var vrMultiviewToSingleviewPixelShader: {
  14864. name: string;
  14865. shader: string;
  14866. };
  14867. }
  14868. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14870. import { Scene } from "babylonjs/scene";
  14871. /**
  14872. * Renders to multiple views with a single draw call
  14873. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14874. */
  14875. export class MultiviewRenderTarget extends RenderTargetTexture {
  14876. /**
  14877. * Creates a multiview render target
  14878. * @param scene scene used with the render target
  14879. * @param size the size of the render target (used for each view)
  14880. */
  14881. constructor(scene: Scene, size?: number | {
  14882. width: number;
  14883. height: number;
  14884. } | {
  14885. ratio: number;
  14886. });
  14887. /**
  14888. * @hidden
  14889. * @param faceIndex the face index, if its a cube texture
  14890. */
  14891. _bindFrameBuffer(faceIndex?: number): void;
  14892. /**
  14893. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14894. * @returns the view count
  14895. */
  14896. getViewCount(): number;
  14897. }
  14898. }
  14899. declare module "babylonjs/Maths/math.frustum" {
  14900. import { Matrix } from "babylonjs/Maths/math.vector";
  14901. import { DeepImmutable } from "babylonjs/types";
  14902. import { Plane } from "babylonjs/Maths/math.plane";
  14903. /**
  14904. * Represents a camera frustum
  14905. */
  14906. export class Frustum {
  14907. /**
  14908. * Gets the planes representing the frustum
  14909. * @param transform matrix to be applied to the returned planes
  14910. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14911. */
  14912. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14913. /**
  14914. * Gets the near frustum plane transformed by the transform matrix
  14915. * @param transform transformation matrix to be applied to the resulting frustum plane
  14916. * @param frustumPlane the resuling frustum plane
  14917. */
  14918. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14919. /**
  14920. * Gets the far frustum plane transformed by the transform matrix
  14921. * @param transform transformation matrix to be applied to the resulting frustum plane
  14922. * @param frustumPlane the resuling frustum plane
  14923. */
  14924. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14925. /**
  14926. * Gets the left frustum plane transformed by the transform matrix
  14927. * @param transform transformation matrix to be applied to the resulting frustum plane
  14928. * @param frustumPlane the resuling frustum plane
  14929. */
  14930. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14931. /**
  14932. * Gets the right frustum plane transformed by the transform matrix
  14933. * @param transform transformation matrix to be applied to the resulting frustum plane
  14934. * @param frustumPlane the resuling frustum plane
  14935. */
  14936. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14937. /**
  14938. * Gets the top frustum plane transformed by the transform matrix
  14939. * @param transform transformation matrix to be applied to the resulting frustum plane
  14940. * @param frustumPlane the resuling frustum plane
  14941. */
  14942. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14943. /**
  14944. * Gets the bottom frustum plane transformed by the transform matrix
  14945. * @param transform transformation matrix to be applied to the resulting frustum plane
  14946. * @param frustumPlane the resuling frustum plane
  14947. */
  14948. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14949. /**
  14950. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14951. * @param transform transformation matrix to be applied to the resulting frustum planes
  14952. * @param frustumPlanes the resuling frustum planes
  14953. */
  14954. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14955. }
  14956. }
  14957. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14958. import { Camera } from "babylonjs/Cameras/camera";
  14959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14960. import { Nullable } from "babylonjs/types";
  14961. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14962. import { Matrix } from "babylonjs/Maths/math.vector";
  14963. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14964. module "babylonjs/Engines/engine" {
  14965. interface Engine {
  14966. /**
  14967. * Creates a new multiview render target
  14968. * @param width defines the width of the texture
  14969. * @param height defines the height of the texture
  14970. * @returns the created multiview texture
  14971. */
  14972. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14973. /**
  14974. * Binds a multiview framebuffer to be drawn to
  14975. * @param multiviewTexture texture to bind
  14976. */
  14977. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14978. }
  14979. }
  14980. module "babylonjs/Cameras/camera" {
  14981. interface Camera {
  14982. /**
  14983. * @hidden
  14984. * 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)
  14985. */
  14986. _useMultiviewToSingleView: boolean;
  14987. /**
  14988. * @hidden
  14989. * 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)
  14990. */
  14991. _multiviewTexture: Nullable<RenderTargetTexture>;
  14992. /**
  14993. * @hidden
  14994. * ensures the multiview texture of the camera exists and has the specified width/height
  14995. * @param width height to set on the multiview texture
  14996. * @param height width to set on the multiview texture
  14997. */
  14998. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14999. }
  15000. }
  15001. module "babylonjs/scene" {
  15002. interface Scene {
  15003. /** @hidden */
  15004. _transformMatrixR: Matrix;
  15005. /** @hidden */
  15006. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15007. /** @hidden */
  15008. _createMultiviewUbo(): void;
  15009. /** @hidden */
  15010. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15011. /** @hidden */
  15012. _renderMultiviewToSingleView(camera: Camera): void;
  15013. }
  15014. }
  15015. }
  15016. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15017. import { Camera } from "babylonjs/Cameras/camera";
  15018. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15019. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15020. import "babylonjs/Engines/Extensions/engine.multiview";
  15021. /**
  15022. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15023. * This will not be used for webXR as it supports displaying texture arrays directly
  15024. */
  15025. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15026. /**
  15027. * Initializes a VRMultiviewToSingleview
  15028. * @param name name of the post process
  15029. * @param camera camera to be applied to
  15030. * @param scaleFactor scaling factor to the size of the output texture
  15031. */
  15032. constructor(name: string, camera: Camera, scaleFactor: number);
  15033. }
  15034. }
  15035. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15036. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15037. import { Nullable } from "babylonjs/types";
  15038. import { Size } from "babylonjs/Maths/math.size";
  15039. import { Observable } from "babylonjs/Misc/observable";
  15040. module "babylonjs/Engines/engine" {
  15041. interface Engine {
  15042. /** @hidden */
  15043. _vrDisplay: any;
  15044. /** @hidden */
  15045. _vrSupported: boolean;
  15046. /** @hidden */
  15047. _oldSize: Size;
  15048. /** @hidden */
  15049. _oldHardwareScaleFactor: number;
  15050. /** @hidden */
  15051. _vrExclusivePointerMode: boolean;
  15052. /** @hidden */
  15053. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15054. /** @hidden */
  15055. _onVRDisplayPointerRestricted: () => void;
  15056. /** @hidden */
  15057. _onVRDisplayPointerUnrestricted: () => void;
  15058. /** @hidden */
  15059. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15060. /** @hidden */
  15061. _onVrDisplayDisconnect: Nullable<() => void>;
  15062. /** @hidden */
  15063. _onVrDisplayPresentChange: Nullable<() => void>;
  15064. /**
  15065. * Observable signaled when VR display mode changes
  15066. */
  15067. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15068. /**
  15069. * Observable signaled when VR request present is complete
  15070. */
  15071. onVRRequestPresentComplete: Observable<boolean>;
  15072. /**
  15073. * Observable signaled when VR request present starts
  15074. */
  15075. onVRRequestPresentStart: Observable<Engine>;
  15076. /**
  15077. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15078. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15079. */
  15080. isInVRExclusivePointerMode: boolean;
  15081. /**
  15082. * Gets a boolean indicating if a webVR device was detected
  15083. * @returns true if a webVR device was detected
  15084. */
  15085. isVRDevicePresent(): boolean;
  15086. /**
  15087. * Gets the current webVR device
  15088. * @returns the current webVR device (or null)
  15089. */
  15090. getVRDevice(): any;
  15091. /**
  15092. * Initializes a webVR display and starts listening to display change events
  15093. * The onVRDisplayChangedObservable will be notified upon these changes
  15094. * @returns A promise containing a VRDisplay and if vr is supported
  15095. */
  15096. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15097. /** @hidden */
  15098. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15099. /**
  15100. * Call this function to switch to webVR mode
  15101. * Will do nothing if webVR is not supported or if there is no webVR device
  15102. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15103. */
  15104. enableVR(): void;
  15105. /** @hidden */
  15106. _onVRFullScreenTriggered(): void;
  15107. }
  15108. }
  15109. }
  15110. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15111. import { Nullable } from "babylonjs/types";
  15112. import { Observable } from "babylonjs/Misc/observable";
  15113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15114. import { Scene } from "babylonjs/scene";
  15115. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15116. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15117. import { Node } from "babylonjs/node";
  15118. import { Ray } from "babylonjs/Culling/ray";
  15119. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15120. import "babylonjs/Engines/Extensions/engine.webVR";
  15121. /**
  15122. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15123. * IMPORTANT!! The data is right-hand data.
  15124. * @export
  15125. * @interface DevicePose
  15126. */
  15127. export interface DevicePose {
  15128. /**
  15129. * The position of the device, values in array are [x,y,z].
  15130. */
  15131. readonly position: Nullable<Float32Array>;
  15132. /**
  15133. * The linearVelocity of the device, values in array are [x,y,z].
  15134. */
  15135. readonly linearVelocity: Nullable<Float32Array>;
  15136. /**
  15137. * The linearAcceleration of the device, values in array are [x,y,z].
  15138. */
  15139. readonly linearAcceleration: Nullable<Float32Array>;
  15140. /**
  15141. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15142. */
  15143. readonly orientation: Nullable<Float32Array>;
  15144. /**
  15145. * The angularVelocity of the device, values in array are [x,y,z].
  15146. */
  15147. readonly angularVelocity: Nullable<Float32Array>;
  15148. /**
  15149. * The angularAcceleration of the device, values in array are [x,y,z].
  15150. */
  15151. readonly angularAcceleration: Nullable<Float32Array>;
  15152. }
  15153. /**
  15154. * Interface representing a pose controlled object in Babylon.
  15155. * A pose controlled object has both regular pose values as well as pose values
  15156. * from an external device such as a VR head mounted display
  15157. */
  15158. export interface PoseControlled {
  15159. /**
  15160. * The position of the object in babylon space.
  15161. */
  15162. position: Vector3;
  15163. /**
  15164. * The rotation quaternion of the object in babylon space.
  15165. */
  15166. rotationQuaternion: Quaternion;
  15167. /**
  15168. * The position of the device in babylon space.
  15169. */
  15170. devicePosition?: Vector3;
  15171. /**
  15172. * The rotation quaternion of the device in babylon space.
  15173. */
  15174. deviceRotationQuaternion: Quaternion;
  15175. /**
  15176. * The raw pose coming from the device.
  15177. */
  15178. rawPose: Nullable<DevicePose>;
  15179. /**
  15180. * The scale of the device to be used when translating from device space to babylon space.
  15181. */
  15182. deviceScaleFactor: number;
  15183. /**
  15184. * Updates the poseControlled values based on the input device pose.
  15185. * @param poseData the pose data to update the object with
  15186. */
  15187. updateFromDevice(poseData: DevicePose): void;
  15188. }
  15189. /**
  15190. * Set of options to customize the webVRCamera
  15191. */
  15192. export interface WebVROptions {
  15193. /**
  15194. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15195. */
  15196. trackPosition?: boolean;
  15197. /**
  15198. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15199. */
  15200. positionScale?: number;
  15201. /**
  15202. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15203. */
  15204. displayName?: string;
  15205. /**
  15206. * Should the native controller meshes be initialized. (default: true)
  15207. */
  15208. controllerMeshes?: boolean;
  15209. /**
  15210. * Creating a default HemiLight only on controllers. (default: true)
  15211. */
  15212. defaultLightingOnControllers?: boolean;
  15213. /**
  15214. * If you don't want to use the default VR button of the helper. (default: false)
  15215. */
  15216. useCustomVRButton?: boolean;
  15217. /**
  15218. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15219. */
  15220. customVRButton?: HTMLButtonElement;
  15221. /**
  15222. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15223. */
  15224. rayLength?: number;
  15225. /**
  15226. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15227. */
  15228. defaultHeight?: number;
  15229. /**
  15230. * If multiview should be used if availible (default: false)
  15231. */
  15232. useMultiview?: boolean;
  15233. }
  15234. /**
  15235. * This represents a WebVR camera.
  15236. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15237. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15238. */
  15239. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15240. private webVROptions;
  15241. /**
  15242. * @hidden
  15243. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15244. */
  15245. _vrDevice: any;
  15246. /**
  15247. * The rawPose of the vrDevice.
  15248. */
  15249. rawPose: Nullable<DevicePose>;
  15250. private _onVREnabled;
  15251. private _specsVersion;
  15252. private _attached;
  15253. private _frameData;
  15254. protected _descendants: Array<Node>;
  15255. private _deviceRoomPosition;
  15256. /** @hidden */
  15257. _deviceRoomRotationQuaternion: Quaternion;
  15258. private _standingMatrix;
  15259. /**
  15260. * Represents device position in babylon space.
  15261. */
  15262. devicePosition: Vector3;
  15263. /**
  15264. * Represents device rotation in babylon space.
  15265. */
  15266. deviceRotationQuaternion: Quaternion;
  15267. /**
  15268. * The scale of the device to be used when translating from device space to babylon space.
  15269. */
  15270. deviceScaleFactor: number;
  15271. private _deviceToWorld;
  15272. private _worldToDevice;
  15273. /**
  15274. * References to the webVR controllers for the vrDevice.
  15275. */
  15276. controllers: Array<WebVRController>;
  15277. /**
  15278. * Emits an event when a controller is attached.
  15279. */
  15280. onControllersAttachedObservable: Observable<WebVRController[]>;
  15281. /**
  15282. * Emits an event when a controller's mesh has been loaded;
  15283. */
  15284. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15285. /**
  15286. * Emits an event when the HMD's pose has been updated.
  15287. */
  15288. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15289. private _poseSet;
  15290. /**
  15291. * If the rig cameras be used as parent instead of this camera.
  15292. */
  15293. rigParenting: boolean;
  15294. private _lightOnControllers;
  15295. private _defaultHeight?;
  15296. /**
  15297. * Instantiates a WebVRFreeCamera.
  15298. * @param name The name of the WebVRFreeCamera
  15299. * @param position The starting anchor position for the camera
  15300. * @param scene The scene the camera belongs to
  15301. * @param webVROptions a set of customizable options for the webVRCamera
  15302. */
  15303. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15304. /**
  15305. * Gets the device distance from the ground in meters.
  15306. * @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.
  15307. */
  15308. deviceDistanceToRoomGround(): number;
  15309. /**
  15310. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15311. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15312. */
  15313. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15314. /**
  15315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15316. * @returns A promise with a boolean set to if the standing matrix is supported.
  15317. */
  15318. useStandingMatrixAsync(): Promise<boolean>;
  15319. /**
  15320. * Disposes the camera
  15321. */
  15322. dispose(): void;
  15323. /**
  15324. * Gets a vrController by name.
  15325. * @param name The name of the controller to retreive
  15326. * @returns the controller matching the name specified or null if not found
  15327. */
  15328. getControllerByName(name: string): Nullable<WebVRController>;
  15329. private _leftController;
  15330. /**
  15331. * The controller corresponding to the users left hand.
  15332. */
  15333. readonly leftController: Nullable<WebVRController>;
  15334. private _rightController;
  15335. /**
  15336. * The controller corresponding to the users right hand.
  15337. */
  15338. readonly rightController: Nullable<WebVRController>;
  15339. /**
  15340. * Casts a ray forward from the vrCamera's gaze.
  15341. * @param length Length of the ray (default: 100)
  15342. * @returns the ray corresponding to the gaze
  15343. */
  15344. getForwardRay(length?: number): Ray;
  15345. /**
  15346. * @hidden
  15347. * Updates the camera based on device's frame data
  15348. */
  15349. _checkInputs(): void;
  15350. /**
  15351. * Updates the poseControlled values based on the input device pose.
  15352. * @param poseData Pose coming from the device
  15353. */
  15354. updateFromDevice(poseData: DevicePose): void;
  15355. private _htmlElementAttached;
  15356. private _detachIfAttached;
  15357. /**
  15358. * WebVR's attach control will start broadcasting frames to the device.
  15359. * Note that in certain browsers (chrome for example) this function must be called
  15360. * within a user-interaction callback. Example:
  15361. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15362. *
  15363. * @param element html element to attach the vrDevice to
  15364. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15365. */
  15366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15367. /**
  15368. * Detaches the camera from the html element and disables VR
  15369. *
  15370. * @param element html element to detach from
  15371. */
  15372. detachControl(element: HTMLElement): void;
  15373. /**
  15374. * @returns the name of this class
  15375. */
  15376. getClassName(): string;
  15377. /**
  15378. * Calls resetPose on the vrDisplay
  15379. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15380. */
  15381. resetToCurrentRotation(): void;
  15382. /**
  15383. * @hidden
  15384. * Updates the rig cameras (left and right eye)
  15385. */
  15386. _updateRigCameras(): void;
  15387. private _workingVector;
  15388. private _oneVector;
  15389. private _workingMatrix;
  15390. private updateCacheCalled;
  15391. private _correctPositionIfNotTrackPosition;
  15392. /**
  15393. * @hidden
  15394. * Updates the cached values of the camera
  15395. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15396. */
  15397. _updateCache(ignoreParentClass?: boolean): void;
  15398. /**
  15399. * @hidden
  15400. * Get current device position in babylon world
  15401. */
  15402. _computeDevicePosition(): void;
  15403. /**
  15404. * Updates the current device position and rotation in the babylon world
  15405. */
  15406. update(): void;
  15407. /**
  15408. * @hidden
  15409. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15410. * @returns an identity matrix
  15411. */
  15412. _getViewMatrix(): Matrix;
  15413. private _tmpMatrix;
  15414. /**
  15415. * This function is called by the two RIG cameras.
  15416. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15417. * @hidden
  15418. */
  15419. _getWebVRViewMatrix(): Matrix;
  15420. /** @hidden */
  15421. _getWebVRProjectionMatrix(): Matrix;
  15422. private _onGamepadConnectedObserver;
  15423. private _onGamepadDisconnectedObserver;
  15424. private _updateCacheWhenTrackingDisabledObserver;
  15425. /**
  15426. * Initializes the controllers and their meshes
  15427. */
  15428. initControllers(): void;
  15429. }
  15430. }
  15431. declare module "babylonjs/PostProcesses/postProcess" {
  15432. import { Nullable } from "babylonjs/types";
  15433. import { SmartArray } from "babylonjs/Misc/smartArray";
  15434. import { Observable } from "babylonjs/Misc/observable";
  15435. import { Vector2 } from "babylonjs/Maths/math.vector";
  15436. import { Camera } from "babylonjs/Cameras/camera";
  15437. import { Effect } from "babylonjs/Materials/effect";
  15438. import "babylonjs/Shaders/postprocess.vertex";
  15439. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15440. import { Engine } from "babylonjs/Engines/engine";
  15441. import { Color4 } from "babylonjs/Maths/math.color";
  15442. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15444. /**
  15445. * Size options for a post process
  15446. */
  15447. export type PostProcessOptions = {
  15448. width: number;
  15449. height: number;
  15450. };
  15451. /**
  15452. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15453. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15454. */
  15455. export class PostProcess {
  15456. /** Name of the PostProcess. */
  15457. name: string;
  15458. /**
  15459. * Gets or sets the unique id of the post process
  15460. */
  15461. uniqueId: number;
  15462. /**
  15463. * Width of the texture to apply the post process on
  15464. */
  15465. width: number;
  15466. /**
  15467. * Height of the texture to apply the post process on
  15468. */
  15469. height: number;
  15470. /**
  15471. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15472. * @hidden
  15473. */
  15474. _outputTexture: Nullable<InternalTexture>;
  15475. /**
  15476. * Sampling mode used by the shader
  15477. * See https://doc.babylonjs.com/classes/3.1/texture
  15478. */
  15479. renderTargetSamplingMode: number;
  15480. /**
  15481. * Clear color to use when screen clearing
  15482. */
  15483. clearColor: Color4;
  15484. /**
  15485. * If the buffer needs to be cleared before applying the post process. (default: true)
  15486. * Should be set to false if shader will overwrite all previous pixels.
  15487. */
  15488. autoClear: boolean;
  15489. /**
  15490. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15491. */
  15492. alphaMode: number;
  15493. /**
  15494. * Sets the setAlphaBlendConstants of the babylon engine
  15495. */
  15496. alphaConstants: Color4;
  15497. /**
  15498. * Animations to be used for the post processing
  15499. */
  15500. animations: import("babylonjs/Animations/animation").Animation[];
  15501. /**
  15502. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15503. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15504. */
  15505. enablePixelPerfectMode: boolean;
  15506. /**
  15507. * Force the postprocess to be applied without taking in account viewport
  15508. */
  15509. forceFullscreenViewport: boolean;
  15510. /**
  15511. * List of inspectable custom properties (used by the Inspector)
  15512. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15513. */
  15514. inspectableCustomProperties: IInspectable[];
  15515. /**
  15516. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15517. *
  15518. * | Value | Type | Description |
  15519. * | ----- | ----------------------------------- | ----------- |
  15520. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15521. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15522. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15523. *
  15524. */
  15525. scaleMode: number;
  15526. /**
  15527. * Force textures to be a power of two (default: false)
  15528. */
  15529. alwaysForcePOT: boolean;
  15530. private _samples;
  15531. /**
  15532. * Number of sample textures (default: 1)
  15533. */
  15534. samples: number;
  15535. /**
  15536. * Modify the scale of the post process to be the same as the viewport (default: false)
  15537. */
  15538. adaptScaleToCurrentViewport: boolean;
  15539. private _camera;
  15540. private _scene;
  15541. private _engine;
  15542. private _options;
  15543. private _reusable;
  15544. private _textureType;
  15545. /**
  15546. * Smart array of input and output textures for the post process.
  15547. * @hidden
  15548. */
  15549. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15550. /**
  15551. * The index in _textures that corresponds to the output texture.
  15552. * @hidden
  15553. */
  15554. _currentRenderTextureInd: number;
  15555. private _effect;
  15556. private _samplers;
  15557. private _fragmentUrl;
  15558. private _vertexUrl;
  15559. private _parameters;
  15560. private _scaleRatio;
  15561. protected _indexParameters: any;
  15562. private _shareOutputWithPostProcess;
  15563. private _texelSize;
  15564. private _forcedOutputTexture;
  15565. /**
  15566. * Returns the fragment url or shader name used in the post process.
  15567. * @returns the fragment url or name in the shader store.
  15568. */
  15569. getEffectName(): string;
  15570. /**
  15571. * An event triggered when the postprocess is activated.
  15572. */
  15573. onActivateObservable: Observable<Camera>;
  15574. private _onActivateObserver;
  15575. /**
  15576. * A function that is added to the onActivateObservable
  15577. */
  15578. onActivate: Nullable<(camera: Camera) => void>;
  15579. /**
  15580. * An event triggered when the postprocess changes its size.
  15581. */
  15582. onSizeChangedObservable: Observable<PostProcess>;
  15583. private _onSizeChangedObserver;
  15584. /**
  15585. * A function that is added to the onSizeChangedObservable
  15586. */
  15587. onSizeChanged: (postProcess: PostProcess) => void;
  15588. /**
  15589. * An event triggered when the postprocess applies its effect.
  15590. */
  15591. onApplyObservable: Observable<Effect>;
  15592. private _onApplyObserver;
  15593. /**
  15594. * A function that is added to the onApplyObservable
  15595. */
  15596. onApply: (effect: Effect) => void;
  15597. /**
  15598. * An event triggered before rendering the postprocess
  15599. */
  15600. onBeforeRenderObservable: Observable<Effect>;
  15601. private _onBeforeRenderObserver;
  15602. /**
  15603. * A function that is added to the onBeforeRenderObservable
  15604. */
  15605. onBeforeRender: (effect: Effect) => void;
  15606. /**
  15607. * An event triggered after rendering the postprocess
  15608. */
  15609. onAfterRenderObservable: Observable<Effect>;
  15610. private _onAfterRenderObserver;
  15611. /**
  15612. * A function that is added to the onAfterRenderObservable
  15613. */
  15614. onAfterRender: (efect: Effect) => void;
  15615. /**
  15616. * 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
  15617. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15618. */
  15619. inputTexture: InternalTexture;
  15620. /**
  15621. * Gets the camera which post process is applied to.
  15622. * @returns The camera the post process is applied to.
  15623. */
  15624. getCamera(): Camera;
  15625. /**
  15626. * Gets the texel size of the postprocess.
  15627. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15628. */
  15629. readonly texelSize: Vector2;
  15630. /**
  15631. * Creates a new instance PostProcess
  15632. * @param name The name of the PostProcess.
  15633. * @param fragmentUrl The url of the fragment shader to be used.
  15634. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15635. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15636. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15637. * @param camera The camera to apply the render pass to.
  15638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15639. * @param engine The engine which the post process will be applied. (default: current engine)
  15640. * @param reusable If the post process can be reused on the same frame. (default: false)
  15641. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15642. * @param textureType Type of textures used when performing the post process. (default: 0)
  15643. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15644. * @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
  15645. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15646. */
  15647. constructor(
  15648. /** Name of the PostProcess. */
  15649. 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);
  15650. /**
  15651. * Gets a string idenfifying the name of the class
  15652. * @returns "PostProcess" string
  15653. */
  15654. getClassName(): string;
  15655. /**
  15656. * Gets the engine which this post process belongs to.
  15657. * @returns The engine the post process was enabled with.
  15658. */
  15659. getEngine(): Engine;
  15660. /**
  15661. * The effect that is created when initializing the post process.
  15662. * @returns The created effect corresponding the the postprocess.
  15663. */
  15664. getEffect(): Effect;
  15665. /**
  15666. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15667. * @param postProcess The post process to share the output with.
  15668. * @returns This post process.
  15669. */
  15670. shareOutputWith(postProcess: PostProcess): PostProcess;
  15671. /**
  15672. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15673. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15674. */
  15675. useOwnOutput(): void;
  15676. /**
  15677. * Updates the effect with the current post process compile time values and recompiles the shader.
  15678. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15679. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15680. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15681. * @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
  15682. * @param onCompiled Called when the shader has been compiled.
  15683. * @param onError Called if there is an error when compiling a shader.
  15684. */
  15685. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15686. /**
  15687. * The post process is reusable if it can be used multiple times within one frame.
  15688. * @returns If the post process is reusable
  15689. */
  15690. isReusable(): boolean;
  15691. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15692. markTextureDirty(): void;
  15693. /**
  15694. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15695. * 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.
  15696. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15697. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15698. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15699. * @returns The target texture that was bound to be written to.
  15700. */
  15701. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15702. /**
  15703. * If the post process is supported.
  15704. */
  15705. readonly isSupported: boolean;
  15706. /**
  15707. * The aspect ratio of the output texture.
  15708. */
  15709. readonly aspectRatio: number;
  15710. /**
  15711. * Get a value indicating if the post-process is ready to be used
  15712. * @returns true if the post-process is ready (shader is compiled)
  15713. */
  15714. isReady(): boolean;
  15715. /**
  15716. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15717. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15718. */
  15719. apply(): Nullable<Effect>;
  15720. private _disposeTextures;
  15721. /**
  15722. * Disposes the post process.
  15723. * @param camera The camera to dispose the post process on.
  15724. */
  15725. dispose(camera?: Camera): void;
  15726. }
  15727. }
  15728. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15729. /** @hidden */
  15730. export var kernelBlurVaryingDeclaration: {
  15731. name: string;
  15732. shader: string;
  15733. };
  15734. }
  15735. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15736. /** @hidden */
  15737. export var kernelBlurFragment: {
  15738. name: string;
  15739. shader: string;
  15740. };
  15741. }
  15742. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15743. /** @hidden */
  15744. export var kernelBlurFragment2: {
  15745. name: string;
  15746. shader: string;
  15747. };
  15748. }
  15749. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15750. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15751. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15752. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15753. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15754. /** @hidden */
  15755. export var kernelBlurPixelShader: {
  15756. name: string;
  15757. shader: string;
  15758. };
  15759. }
  15760. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15761. /** @hidden */
  15762. export var kernelBlurVertex: {
  15763. name: string;
  15764. shader: string;
  15765. };
  15766. }
  15767. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15768. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15769. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15770. /** @hidden */
  15771. export var kernelBlurVertexShader: {
  15772. name: string;
  15773. shader: string;
  15774. };
  15775. }
  15776. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15777. import { Vector2 } from "babylonjs/Maths/math.vector";
  15778. import { Nullable } from "babylonjs/types";
  15779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15780. import { Camera } from "babylonjs/Cameras/camera";
  15781. import { Effect } from "babylonjs/Materials/effect";
  15782. import { Engine } from "babylonjs/Engines/engine";
  15783. import "babylonjs/Shaders/kernelBlur.fragment";
  15784. import "babylonjs/Shaders/kernelBlur.vertex";
  15785. /**
  15786. * The Blur Post Process which blurs an image based on a kernel and direction.
  15787. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15788. */
  15789. export class BlurPostProcess extends PostProcess {
  15790. /** The direction in which to blur the image. */
  15791. direction: Vector2;
  15792. private blockCompilation;
  15793. protected _kernel: number;
  15794. protected _idealKernel: number;
  15795. protected _packedFloat: boolean;
  15796. private _staticDefines;
  15797. /**
  15798. * Sets the length in pixels of the blur sample region
  15799. */
  15800. /**
  15801. * Gets the length in pixels of the blur sample region
  15802. */
  15803. kernel: number;
  15804. /**
  15805. * Sets wether or not the blur needs to unpack/repack floats
  15806. */
  15807. /**
  15808. * Gets wether or not the blur is unpacking/repacking floats
  15809. */
  15810. packedFloat: boolean;
  15811. /**
  15812. * Creates a new instance BlurPostProcess
  15813. * @param name The name of the effect.
  15814. * @param direction The direction in which to blur the image.
  15815. * @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.
  15816. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15817. * @param camera The camera to apply the render pass to.
  15818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15819. * @param engine The engine which the post process will be applied. (default: current engine)
  15820. * @param reusable If the post process can be reused on the same frame. (default: false)
  15821. * @param textureType Type of textures used when performing the post process. (default: 0)
  15822. * @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)
  15823. */
  15824. constructor(name: string,
  15825. /** The direction in which to blur the image. */
  15826. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15827. /**
  15828. * Updates the effect with the current post process compile time values and recompiles the shader.
  15829. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15830. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15831. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15832. * @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
  15833. * @param onCompiled Called when the shader has been compiled.
  15834. * @param onError Called if there is an error when compiling a shader.
  15835. */
  15836. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15837. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15838. /**
  15839. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15840. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15841. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15842. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15843. * The gaps between physical kernels are compensated for in the weighting of the samples
  15844. * @param idealKernel Ideal blur kernel.
  15845. * @return Nearest best kernel.
  15846. */
  15847. protected _nearestBestKernel(idealKernel: number): number;
  15848. /**
  15849. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15850. * @param x The point on the Gaussian distribution to sample.
  15851. * @return the value of the Gaussian function at x.
  15852. */
  15853. protected _gaussianWeight(x: number): number;
  15854. /**
  15855. * Generates a string that can be used as a floating point number in GLSL.
  15856. * @param x Value to print.
  15857. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15858. * @return GLSL float string.
  15859. */
  15860. protected _glslFloat(x: number, decimalFigures?: number): string;
  15861. }
  15862. }
  15863. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15864. import { Scene } from "babylonjs/scene";
  15865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15866. import { Plane } from "babylonjs/Maths/math.plane";
  15867. /**
  15868. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15869. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15870. * You can then easily use it as a reflectionTexture on a flat surface.
  15871. * In case the surface is not a plane, please consider relying on reflection probes.
  15872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15873. */
  15874. export class MirrorTexture extends RenderTargetTexture {
  15875. private scene;
  15876. /**
  15877. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15878. * 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.
  15879. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15880. */
  15881. mirrorPlane: Plane;
  15882. /**
  15883. * Define the blur ratio used to blur the reflection if needed.
  15884. */
  15885. blurRatio: number;
  15886. /**
  15887. * Define the adaptive blur kernel used to blur the reflection if needed.
  15888. * This will autocompute the closest best match for the `blurKernel`
  15889. */
  15890. adaptiveBlurKernel: number;
  15891. /**
  15892. * Define the blur kernel used to blur the reflection if needed.
  15893. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15894. */
  15895. blurKernel: number;
  15896. /**
  15897. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15898. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15899. */
  15900. blurKernelX: number;
  15901. /**
  15902. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15903. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15904. */
  15905. blurKernelY: number;
  15906. private _autoComputeBlurKernel;
  15907. protected _onRatioRescale(): void;
  15908. private _updateGammaSpace;
  15909. private _imageProcessingConfigChangeObserver;
  15910. private _transformMatrix;
  15911. private _mirrorMatrix;
  15912. private _savedViewMatrix;
  15913. private _blurX;
  15914. private _blurY;
  15915. private _adaptiveBlurKernel;
  15916. private _blurKernelX;
  15917. private _blurKernelY;
  15918. private _blurRatio;
  15919. /**
  15920. * Instantiates a Mirror Texture.
  15921. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15922. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15923. * You can then easily use it as a reflectionTexture on a flat surface.
  15924. * In case the surface is not a plane, please consider relying on reflection probes.
  15925. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15926. * @param name
  15927. * @param size
  15928. * @param scene
  15929. * @param generateMipMaps
  15930. * @param type
  15931. * @param samplingMode
  15932. * @param generateDepthBuffer
  15933. */
  15934. constructor(name: string, size: number | {
  15935. width: number;
  15936. height: number;
  15937. } | {
  15938. ratio: number;
  15939. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15940. private _preparePostProcesses;
  15941. /**
  15942. * Clone the mirror texture.
  15943. * @returns the cloned texture
  15944. */
  15945. clone(): MirrorTexture;
  15946. /**
  15947. * Serialize the texture to a JSON representation you could use in Parse later on
  15948. * @returns the serialized JSON representation
  15949. */
  15950. serialize(): any;
  15951. /**
  15952. * Dispose the texture and release its associated resources.
  15953. */
  15954. dispose(): void;
  15955. }
  15956. }
  15957. declare module "babylonjs/Materials/Textures/texture" {
  15958. import { Observable } from "babylonjs/Misc/observable";
  15959. import { Nullable } from "babylonjs/types";
  15960. import { Matrix } from "babylonjs/Maths/math.vector";
  15961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15962. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15963. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15964. import { Scene } from "babylonjs/scene";
  15965. /**
  15966. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15967. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15968. */
  15969. export class Texture extends BaseTexture {
  15970. /**
  15971. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15972. */
  15973. static SerializeBuffers: boolean;
  15974. /** @hidden */
  15975. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15976. /** @hidden */
  15977. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15978. /** @hidden */
  15979. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15980. /** nearest is mag = nearest and min = nearest and mip = linear */
  15981. static readonly NEAREST_SAMPLINGMODE: number;
  15982. /** nearest is mag = nearest and min = nearest and mip = linear */
  15983. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15984. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15985. static readonly BILINEAR_SAMPLINGMODE: number;
  15986. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15987. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15988. /** Trilinear is mag = linear and min = linear and mip = linear */
  15989. static readonly TRILINEAR_SAMPLINGMODE: number;
  15990. /** Trilinear is mag = linear and min = linear and mip = linear */
  15991. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15992. /** mag = nearest and min = nearest and mip = nearest */
  15993. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15994. /** mag = nearest and min = linear and mip = nearest */
  15995. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15996. /** mag = nearest and min = linear and mip = linear */
  15997. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15998. /** mag = nearest and min = linear and mip = none */
  15999. static readonly NEAREST_LINEAR: number;
  16000. /** mag = nearest and min = nearest and mip = none */
  16001. static readonly NEAREST_NEAREST: number;
  16002. /** mag = linear and min = nearest and mip = nearest */
  16003. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16004. /** mag = linear and min = nearest and mip = linear */
  16005. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16006. /** mag = linear and min = linear and mip = none */
  16007. static readonly LINEAR_LINEAR: number;
  16008. /** mag = linear and min = nearest and mip = none */
  16009. static readonly LINEAR_NEAREST: number;
  16010. /** Explicit coordinates mode */
  16011. static readonly EXPLICIT_MODE: number;
  16012. /** Spherical coordinates mode */
  16013. static readonly SPHERICAL_MODE: number;
  16014. /** Planar coordinates mode */
  16015. static readonly PLANAR_MODE: number;
  16016. /** Cubic coordinates mode */
  16017. static readonly CUBIC_MODE: number;
  16018. /** Projection coordinates mode */
  16019. static readonly PROJECTION_MODE: number;
  16020. /** Inverse Cubic coordinates mode */
  16021. static readonly SKYBOX_MODE: number;
  16022. /** Inverse Cubic coordinates mode */
  16023. static readonly INVCUBIC_MODE: number;
  16024. /** Equirectangular coordinates mode */
  16025. static readonly EQUIRECTANGULAR_MODE: number;
  16026. /** Equirectangular Fixed coordinates mode */
  16027. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16028. /** Equirectangular Fixed Mirrored coordinates mode */
  16029. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16030. /** Texture is not repeating outside of 0..1 UVs */
  16031. static readonly CLAMP_ADDRESSMODE: number;
  16032. /** Texture is repeating outside of 0..1 UVs */
  16033. static readonly WRAP_ADDRESSMODE: number;
  16034. /** Texture is repeating and mirrored */
  16035. static readonly MIRROR_ADDRESSMODE: number;
  16036. /**
  16037. * 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
  16038. */
  16039. static UseSerializedUrlIfAny: boolean;
  16040. /**
  16041. * Define the url of the texture.
  16042. */
  16043. url: Nullable<string>;
  16044. /**
  16045. * Define an offset on the texture to offset the u coordinates of the UVs
  16046. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16047. */
  16048. uOffset: number;
  16049. /**
  16050. * Define an offset on the texture to offset the v coordinates of the UVs
  16051. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16052. */
  16053. vOffset: number;
  16054. /**
  16055. * Define an offset on the texture to scale the u coordinates of the UVs
  16056. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16057. */
  16058. uScale: number;
  16059. /**
  16060. * Define an offset on the texture to scale the v coordinates of the UVs
  16061. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16062. */
  16063. vScale: number;
  16064. /**
  16065. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16066. * @see http://doc.babylonjs.com/how_to/more_materials
  16067. */
  16068. uAng: number;
  16069. /**
  16070. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16071. * @see http://doc.babylonjs.com/how_to/more_materials
  16072. */
  16073. vAng: number;
  16074. /**
  16075. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16076. * @see http://doc.babylonjs.com/how_to/more_materials
  16077. */
  16078. wAng: number;
  16079. /**
  16080. * Defines the center of rotation (U)
  16081. */
  16082. uRotationCenter: number;
  16083. /**
  16084. * Defines the center of rotation (V)
  16085. */
  16086. vRotationCenter: number;
  16087. /**
  16088. * Defines the center of rotation (W)
  16089. */
  16090. wRotationCenter: number;
  16091. /**
  16092. * Are mip maps generated for this texture or not.
  16093. */
  16094. readonly noMipmap: boolean;
  16095. /**
  16096. * List of inspectable custom properties (used by the Inspector)
  16097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16098. */
  16099. inspectableCustomProperties: Nullable<IInspectable[]>;
  16100. private _noMipmap;
  16101. /** @hidden */
  16102. _invertY: boolean;
  16103. private _rowGenerationMatrix;
  16104. private _cachedTextureMatrix;
  16105. private _projectionModeMatrix;
  16106. private _t0;
  16107. private _t1;
  16108. private _t2;
  16109. private _cachedUOffset;
  16110. private _cachedVOffset;
  16111. private _cachedUScale;
  16112. private _cachedVScale;
  16113. private _cachedUAng;
  16114. private _cachedVAng;
  16115. private _cachedWAng;
  16116. private _cachedProjectionMatrixId;
  16117. private _cachedCoordinatesMode;
  16118. /** @hidden */
  16119. protected _initialSamplingMode: number;
  16120. /** @hidden */
  16121. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16122. private _deleteBuffer;
  16123. protected _format: Nullable<number>;
  16124. private _delayedOnLoad;
  16125. private _delayedOnError;
  16126. private _mimeType?;
  16127. /**
  16128. * Observable triggered once the texture has been loaded.
  16129. */
  16130. onLoadObservable: Observable<Texture>;
  16131. protected _isBlocking: boolean;
  16132. /**
  16133. * Is the texture preventing material to render while loading.
  16134. * If false, a default texture will be used instead of the loading one during the preparation step.
  16135. */
  16136. isBlocking: boolean;
  16137. /**
  16138. * Get the current sampling mode associated with the texture.
  16139. */
  16140. readonly samplingMode: number;
  16141. /**
  16142. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16143. */
  16144. readonly invertY: boolean;
  16145. /**
  16146. * Instantiates a new texture.
  16147. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16148. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16149. * @param url defines the url of the picture to load as a texture
  16150. * @param scene defines the scene or engine the texture will belong to
  16151. * @param noMipmap defines if the texture will require mip maps or not
  16152. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16153. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16154. * @param onLoad defines a callback triggered when the texture has been loaded
  16155. * @param onError defines a callback triggered when an error occurred during the loading session
  16156. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16157. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16158. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16159. * @param mimeType defines an optional mime type information
  16160. */
  16161. 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);
  16162. /**
  16163. * Update the url (and optional buffer) of this texture if url was null during construction.
  16164. * @param url the url of the texture
  16165. * @param buffer the buffer of the texture (defaults to null)
  16166. * @param onLoad callback called when the texture is loaded (defaults to null)
  16167. */
  16168. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16169. /**
  16170. * Finish the loading sequence of a texture flagged as delayed load.
  16171. * @hidden
  16172. */
  16173. delayLoad(): void;
  16174. private _prepareRowForTextureGeneration;
  16175. /**
  16176. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16177. * @returns the transform matrix of the texture.
  16178. */
  16179. getTextureMatrix(): Matrix;
  16180. /**
  16181. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16182. * @returns The reflection texture transform
  16183. */
  16184. getReflectionTextureMatrix(): Matrix;
  16185. /**
  16186. * Clones the texture.
  16187. * @returns the cloned texture
  16188. */
  16189. clone(): Texture;
  16190. /**
  16191. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16192. * @returns The JSON representation of the texture
  16193. */
  16194. serialize(): any;
  16195. /**
  16196. * Get the current class name of the texture useful for serialization or dynamic coding.
  16197. * @returns "Texture"
  16198. */
  16199. getClassName(): string;
  16200. /**
  16201. * Dispose the texture and release its associated resources.
  16202. */
  16203. dispose(): void;
  16204. /**
  16205. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16206. * @param parsedTexture Define the JSON representation of the texture
  16207. * @param scene Define the scene the parsed texture should be instantiated in
  16208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16209. * @returns The parsed texture if successful
  16210. */
  16211. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16212. /**
  16213. * Creates a texture from its base 64 representation.
  16214. * @param data Define the base64 payload without the data: prefix
  16215. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16216. * @param scene Define the scene the texture should belong to
  16217. * @param noMipmap Forces the texture to not create mip map information if true
  16218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16220. * @param onLoad define a callback triggered when the texture has been loaded
  16221. * @param onError define a callback triggered when an error occurred during the loading session
  16222. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16223. * @returns the created texture
  16224. */
  16225. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16226. /**
  16227. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16228. * @param data Define the base64 payload without the data: prefix
  16229. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16230. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16231. * @param scene Define the scene the texture should belong to
  16232. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16233. * @param noMipmap Forces the texture to not create mip map information if true
  16234. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16235. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16236. * @param onLoad define a callback triggered when the texture has been loaded
  16237. * @param onError define a callback triggered when an error occurred during the loading session
  16238. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16239. * @returns the created texture
  16240. */
  16241. 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;
  16242. }
  16243. }
  16244. declare module "babylonjs/PostProcesses/postProcessManager" {
  16245. import { Nullable } from "babylonjs/types";
  16246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16248. import { Scene } from "babylonjs/scene";
  16249. /**
  16250. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16251. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16252. */
  16253. export class PostProcessManager {
  16254. private _scene;
  16255. private _indexBuffer;
  16256. private _vertexBuffers;
  16257. /**
  16258. * Creates a new instance PostProcess
  16259. * @param scene The scene that the post process is associated with.
  16260. */
  16261. constructor(scene: Scene);
  16262. private _prepareBuffers;
  16263. private _buildIndexBuffer;
  16264. /**
  16265. * Rebuilds the vertex buffers of the manager.
  16266. * @hidden
  16267. */
  16268. _rebuild(): void;
  16269. /**
  16270. * Prepares a frame to be run through a post process.
  16271. * @param sourceTexture The input texture to the post procesess. (default: null)
  16272. * @param postProcesses An array of post processes to be run. (default: null)
  16273. * @returns True if the post processes were able to be run.
  16274. * @hidden
  16275. */
  16276. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16277. /**
  16278. * Manually render a set of post processes to a texture.
  16279. * @param postProcesses An array of post processes to be run.
  16280. * @param targetTexture The target texture to render to.
  16281. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16282. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16283. * @param lodLevel defines which lod of the texture to render to
  16284. */
  16285. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16286. /**
  16287. * Finalize the result of the output of the postprocesses.
  16288. * @param doNotPresent If true the result will not be displayed to the screen.
  16289. * @param targetTexture The target texture to render to.
  16290. * @param faceIndex The index of the face to bind the target texture to.
  16291. * @param postProcesses The array of post processes to render.
  16292. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16293. * @hidden
  16294. */
  16295. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16296. /**
  16297. * Disposes of the post process manager.
  16298. */
  16299. dispose(): void;
  16300. }
  16301. }
  16302. declare module "babylonjs/Misc/gradients" {
  16303. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16304. /** Interface used by value gradients (color, factor, ...) */
  16305. export interface IValueGradient {
  16306. /**
  16307. * Gets or sets the gradient value (between 0 and 1)
  16308. */
  16309. gradient: number;
  16310. }
  16311. /** Class used to store color4 gradient */
  16312. export class ColorGradient implements IValueGradient {
  16313. /**
  16314. * Gets or sets the gradient value (between 0 and 1)
  16315. */
  16316. gradient: number;
  16317. /**
  16318. * Gets or sets first associated color
  16319. */
  16320. color1: Color4;
  16321. /**
  16322. * Gets or sets second associated color
  16323. */
  16324. color2?: Color4;
  16325. /**
  16326. * Will get a color picked randomly between color1 and color2.
  16327. * If color2 is undefined then color1 will be used
  16328. * @param result defines the target Color4 to store the result in
  16329. */
  16330. getColorToRef(result: Color4): void;
  16331. }
  16332. /** Class used to store color 3 gradient */
  16333. export class Color3Gradient implements IValueGradient {
  16334. /**
  16335. * Gets or sets the gradient value (between 0 and 1)
  16336. */
  16337. gradient: number;
  16338. /**
  16339. * Gets or sets the associated color
  16340. */
  16341. color: Color3;
  16342. }
  16343. /** Class used to store factor gradient */
  16344. export class FactorGradient implements IValueGradient {
  16345. /**
  16346. * Gets or sets the gradient value (between 0 and 1)
  16347. */
  16348. gradient: number;
  16349. /**
  16350. * Gets or sets first associated factor
  16351. */
  16352. factor1: number;
  16353. /**
  16354. * Gets or sets second associated factor
  16355. */
  16356. factor2?: number;
  16357. /**
  16358. * Will get a number picked randomly between factor1 and factor2.
  16359. * If factor2 is undefined then factor1 will be used
  16360. * @returns the picked number
  16361. */
  16362. getFactor(): number;
  16363. }
  16364. /**
  16365. * Helper used to simplify some generic gradient tasks
  16366. */
  16367. export class GradientHelper {
  16368. /**
  16369. * Gets the current gradient from an array of IValueGradient
  16370. * @param ratio defines the current ratio to get
  16371. * @param gradients defines the array of IValueGradient
  16372. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16373. */
  16374. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16375. }
  16376. }
  16377. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16379. import { Nullable } from "babylonjs/types";
  16380. module "babylonjs/Engines/thinEngine" {
  16381. interface ThinEngine {
  16382. /**
  16383. * Creates a dynamic texture
  16384. * @param width defines the width of the texture
  16385. * @param height defines the height of the texture
  16386. * @param generateMipMaps defines if the engine should generate the mip levels
  16387. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16388. * @returns the dynamic texture inside an InternalTexture
  16389. */
  16390. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16391. /**
  16392. * Update the content of a dynamic texture
  16393. * @param texture defines the texture to update
  16394. * @param canvas defines the canvas containing the source
  16395. * @param invertY defines if data must be stored with Y axis inverted
  16396. * @param premulAlpha defines if alpha is stored as premultiplied
  16397. * @param format defines the format of the data
  16398. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16399. */
  16400. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16401. }
  16402. }
  16403. }
  16404. declare module "babylonjs/Misc/canvasGenerator" {
  16405. /**
  16406. * Helper class used to generate a canvas to manipulate images
  16407. */
  16408. export class CanvasGenerator {
  16409. /**
  16410. * Create a new canvas (or offscreen canvas depending on the context)
  16411. * @param width defines the expected width
  16412. * @param height defines the expected height
  16413. * @return a new canvas or offscreen canvas
  16414. */
  16415. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16416. }
  16417. }
  16418. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16419. import { Scene } from "babylonjs/scene";
  16420. import { Texture } from "babylonjs/Materials/Textures/texture";
  16421. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16422. /**
  16423. * A class extending Texture allowing drawing on a texture
  16424. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16425. */
  16426. export class DynamicTexture extends Texture {
  16427. private _generateMipMaps;
  16428. private _canvas;
  16429. private _context;
  16430. private _engine;
  16431. /**
  16432. * Creates a DynamicTexture
  16433. * @param name defines the name of the texture
  16434. * @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
  16435. * @param scene defines the scene where you want the texture
  16436. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16437. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16438. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16439. */
  16440. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16441. /**
  16442. * Get the current class name of the texture useful for serialization or dynamic coding.
  16443. * @returns "DynamicTexture"
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Gets the current state of canRescale
  16448. */
  16449. readonly canRescale: boolean;
  16450. private _recreate;
  16451. /**
  16452. * Scales the texture
  16453. * @param ratio the scale factor to apply to both width and height
  16454. */
  16455. scale(ratio: number): void;
  16456. /**
  16457. * Resizes the texture
  16458. * @param width the new width
  16459. * @param height the new height
  16460. */
  16461. scaleTo(width: number, height: number): void;
  16462. /**
  16463. * Gets the context of the canvas used by the texture
  16464. * @returns the canvas context of the dynamic texture
  16465. */
  16466. getContext(): CanvasRenderingContext2D;
  16467. /**
  16468. * Clears the texture
  16469. */
  16470. clear(): void;
  16471. /**
  16472. * Updates the texture
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16475. */
  16476. update(invertY?: boolean, premulAlpha?: boolean): void;
  16477. /**
  16478. * Draws text onto the texture
  16479. * @param text defines the text to be drawn
  16480. * @param x defines the placement of the text from the left
  16481. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16482. * @param font defines the font to be used with font-style, font-size, font-name
  16483. * @param color defines the color used for the text
  16484. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16485. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16486. * @param update defines whether texture is immediately update (default is true)
  16487. */
  16488. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16489. /**
  16490. * Clones the texture
  16491. * @returns the clone of the texture.
  16492. */
  16493. clone(): DynamicTexture;
  16494. /**
  16495. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16496. * @returns a serialized dynamic texture object
  16497. */
  16498. serialize(): any;
  16499. /** @hidden */
  16500. _rebuild(): void;
  16501. }
  16502. }
  16503. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16504. import { Scene } from "babylonjs/scene";
  16505. import { ISceneComponent } from "babylonjs/sceneComponent";
  16506. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16507. module "babylonjs/abstractScene" {
  16508. interface AbstractScene {
  16509. /**
  16510. * The list of procedural textures added to the scene
  16511. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16512. */
  16513. proceduralTextures: Array<ProceduralTexture>;
  16514. }
  16515. }
  16516. /**
  16517. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16518. * in a given scene.
  16519. */
  16520. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16521. /**
  16522. * The component name helpfull to identify the component in the list of scene components.
  16523. */
  16524. readonly name: string;
  16525. /**
  16526. * The scene the component belongs to.
  16527. */
  16528. scene: Scene;
  16529. /**
  16530. * Creates a new instance of the component for the given scene
  16531. * @param scene Defines the scene to register the component in
  16532. */
  16533. constructor(scene: Scene);
  16534. /**
  16535. * Registers the component in a given scene
  16536. */
  16537. register(): void;
  16538. /**
  16539. * Rebuilds the elements related to this component in case of
  16540. * context lost for instance.
  16541. */
  16542. rebuild(): void;
  16543. /**
  16544. * Disposes the component and the associated ressources.
  16545. */
  16546. dispose(): void;
  16547. private _beforeClear;
  16548. }
  16549. }
  16550. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16552. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16553. module "babylonjs/Engines/thinEngine" {
  16554. interface ThinEngine {
  16555. /**
  16556. * Creates a new render target cube texture
  16557. * @param size defines the size of the texture
  16558. * @param options defines the options used to create the texture
  16559. * @returns a new render target cube texture stored in an InternalTexture
  16560. */
  16561. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16562. }
  16563. }
  16564. }
  16565. declare module "babylonjs/Shaders/procedural.vertex" {
  16566. /** @hidden */
  16567. export var proceduralVertexShader: {
  16568. name: string;
  16569. shader: string;
  16570. };
  16571. }
  16572. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16573. import { Observable } from "babylonjs/Misc/observable";
  16574. import { Nullable } from "babylonjs/types";
  16575. import { Scene } from "babylonjs/scene";
  16576. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16577. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16578. import { Effect } from "babylonjs/Materials/effect";
  16579. import { Texture } from "babylonjs/Materials/Textures/texture";
  16580. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16581. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16582. import "babylonjs/Shaders/procedural.vertex";
  16583. /**
  16584. * 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.
  16585. * This is the base class of any Procedural texture and contains most of the shareable code.
  16586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16587. */
  16588. export class ProceduralTexture extends Texture {
  16589. isCube: boolean;
  16590. /**
  16591. * Define if the texture is enabled or not (disabled texture will not render)
  16592. */
  16593. isEnabled: boolean;
  16594. /**
  16595. * Define if the texture must be cleared before rendering (default is true)
  16596. */
  16597. autoClear: boolean;
  16598. /**
  16599. * Callback called when the texture is generated
  16600. */
  16601. onGenerated: () => void;
  16602. /**
  16603. * Event raised when the texture is generated
  16604. */
  16605. onGeneratedObservable: Observable<ProceduralTexture>;
  16606. /** @hidden */
  16607. _generateMipMaps: boolean;
  16608. /** @hidden **/
  16609. _effect: Effect;
  16610. /** @hidden */
  16611. _textures: {
  16612. [key: string]: Texture;
  16613. };
  16614. private _size;
  16615. private _currentRefreshId;
  16616. private _refreshRate;
  16617. private _vertexBuffers;
  16618. private _indexBuffer;
  16619. private _uniforms;
  16620. private _samplers;
  16621. private _fragment;
  16622. private _floats;
  16623. private _ints;
  16624. private _floatsArrays;
  16625. private _colors3;
  16626. private _colors4;
  16627. private _vectors2;
  16628. private _vectors3;
  16629. private _matrices;
  16630. private _fallbackTexture;
  16631. private _fallbackTextureUsed;
  16632. private _engine;
  16633. private _cachedDefines;
  16634. private _contentUpdateId;
  16635. private _contentData;
  16636. /**
  16637. * Instantiates a new procedural texture.
  16638. * 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.
  16639. * This is the base class of any Procedural texture and contains most of the shareable code.
  16640. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16641. * @param name Define the name of the texture
  16642. * @param size Define the size of the texture to create
  16643. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16644. * @param scene Define the scene the texture belongs to
  16645. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16646. * @param generateMipMaps Define if the texture should creates mip maps or not
  16647. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16648. */
  16649. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16650. /**
  16651. * The effect that is created when initializing the post process.
  16652. * @returns The created effect corresponding the the postprocess.
  16653. */
  16654. getEffect(): Effect;
  16655. /**
  16656. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16657. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16658. */
  16659. getContent(): Nullable<ArrayBufferView>;
  16660. private _createIndexBuffer;
  16661. /** @hidden */
  16662. _rebuild(): void;
  16663. /**
  16664. * Resets the texture in order to recreate its associated resources.
  16665. * This can be called in case of context loss
  16666. */
  16667. reset(): void;
  16668. protected _getDefines(): string;
  16669. /**
  16670. * Is the texture ready to be used ? (rendered at least once)
  16671. * @returns true if ready, otherwise, false.
  16672. */
  16673. isReady(): boolean;
  16674. /**
  16675. * Resets the refresh counter of the texture and start bak from scratch.
  16676. * Could be useful to regenerate the texture if it is setup to render only once.
  16677. */
  16678. resetRefreshCounter(): void;
  16679. /**
  16680. * Set the fragment shader to use in order to render the texture.
  16681. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16682. */
  16683. setFragment(fragment: any): void;
  16684. /**
  16685. * Define the refresh rate of the texture or the rendering frequency.
  16686. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16687. */
  16688. refreshRate: number;
  16689. /** @hidden */
  16690. _shouldRender(): boolean;
  16691. /**
  16692. * Get the size the texture is rendering at.
  16693. * @returns the size (texture is always squared)
  16694. */
  16695. getRenderSize(): number;
  16696. /**
  16697. * Resize the texture to new value.
  16698. * @param size Define the new size the texture should have
  16699. * @param generateMipMaps Define whether the new texture should create mip maps
  16700. */
  16701. resize(size: number, generateMipMaps: boolean): void;
  16702. private _checkUniform;
  16703. /**
  16704. * Set a texture in the shader program used to render.
  16705. * @param name Define the name of the uniform samplers as defined in the shader
  16706. * @param texture Define the texture to bind to this sampler
  16707. * @return the texture itself allowing "fluent" like uniform updates
  16708. */
  16709. setTexture(name: string, texture: Texture): ProceduralTexture;
  16710. /**
  16711. * Set a float in the shader.
  16712. * @param name Define the name of the uniform as defined in the shader
  16713. * @param value Define the value to give to the uniform
  16714. * @return the texture itself allowing "fluent" like uniform updates
  16715. */
  16716. setFloat(name: string, value: number): ProceduralTexture;
  16717. /**
  16718. * Set a int in the shader.
  16719. * @param name Define the name of the uniform as defined in the shader
  16720. * @param value Define the value to give to the uniform
  16721. * @return the texture itself allowing "fluent" like uniform updates
  16722. */
  16723. setInt(name: string, value: number): ProceduralTexture;
  16724. /**
  16725. * Set an array of floats in the shader.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the texture itself allowing "fluent" like uniform updates
  16729. */
  16730. setFloats(name: string, value: number[]): ProceduralTexture;
  16731. /**
  16732. * Set a vec3 in the shader from a Color3.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the texture itself allowing "fluent" like uniform updates
  16736. */
  16737. setColor3(name: string, value: Color3): ProceduralTexture;
  16738. /**
  16739. * Set a vec4 in the shader from a Color4.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the texture itself allowing "fluent" like uniform updates
  16743. */
  16744. setColor4(name: string, value: Color4): ProceduralTexture;
  16745. /**
  16746. * Set a vec2 in the shader from a Vector2.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the texture itself allowing "fluent" like uniform updates
  16750. */
  16751. setVector2(name: string, value: Vector2): ProceduralTexture;
  16752. /**
  16753. * Set a vec3 in the shader from a Vector3.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the texture itself allowing "fluent" like uniform updates
  16757. */
  16758. setVector3(name: string, value: Vector3): ProceduralTexture;
  16759. /**
  16760. * Set a mat4 in the shader from a MAtrix.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the texture itself allowing "fluent" like uniform updates
  16764. */
  16765. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16766. /**
  16767. * Render the texture to its associated render target.
  16768. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16769. */
  16770. render(useCameraPostProcess?: boolean): void;
  16771. /**
  16772. * Clone the texture.
  16773. * @returns the cloned texture
  16774. */
  16775. clone(): ProceduralTexture;
  16776. /**
  16777. * Dispose the texture and release its asoociated resources.
  16778. */
  16779. dispose(): void;
  16780. }
  16781. }
  16782. declare module "babylonjs/Particles/baseParticleSystem" {
  16783. import { Nullable } from "babylonjs/types";
  16784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16786. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16787. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16788. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16789. import { Scene } from "babylonjs/scene";
  16790. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16791. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16792. import { Texture } from "babylonjs/Materials/Textures/texture";
  16793. import { Color4 } from "babylonjs/Maths/math.color";
  16794. import { Animation } from "babylonjs/Animations/animation";
  16795. /**
  16796. * This represents the base class for particle system in Babylon.
  16797. * 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.
  16798. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16799. * @example https://doc.babylonjs.com/babylon101/particles
  16800. */
  16801. export class BaseParticleSystem {
  16802. /**
  16803. * Source color is added to the destination color without alpha affecting the result
  16804. */
  16805. static BLENDMODE_ONEONE: number;
  16806. /**
  16807. * Blend current color and particle color using particle’s alpha
  16808. */
  16809. static BLENDMODE_STANDARD: number;
  16810. /**
  16811. * Add current color and particle color multiplied by particle’s alpha
  16812. */
  16813. static BLENDMODE_ADD: number;
  16814. /**
  16815. * Multiply current color with particle color
  16816. */
  16817. static BLENDMODE_MULTIPLY: number;
  16818. /**
  16819. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16820. */
  16821. static BLENDMODE_MULTIPLYADD: number;
  16822. /**
  16823. * List of animations used by the particle system.
  16824. */
  16825. animations: Animation[];
  16826. /**
  16827. * The id of the Particle system.
  16828. */
  16829. id: string;
  16830. /**
  16831. * The friendly name of the Particle system.
  16832. */
  16833. name: string;
  16834. /**
  16835. * The rendering group used by the Particle system to chose when to render.
  16836. */
  16837. renderingGroupId: number;
  16838. /**
  16839. * The emitter represents the Mesh or position we are attaching the particle system to.
  16840. */
  16841. emitter: Nullable<AbstractMesh | Vector3>;
  16842. /**
  16843. * The maximum number of particles to emit per frame
  16844. */
  16845. emitRate: number;
  16846. /**
  16847. * If you want to launch only a few particles at once, that can be done, as well.
  16848. */
  16849. manualEmitCount: number;
  16850. /**
  16851. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16852. */
  16853. updateSpeed: number;
  16854. /**
  16855. * The amount of time the particle system is running (depends of the overall update speed).
  16856. */
  16857. targetStopDuration: number;
  16858. /**
  16859. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16860. */
  16861. disposeOnStop: boolean;
  16862. /**
  16863. * Minimum power of emitting particles.
  16864. */
  16865. minEmitPower: number;
  16866. /**
  16867. * Maximum power of emitting particles.
  16868. */
  16869. maxEmitPower: number;
  16870. /**
  16871. * Minimum life time of emitting particles.
  16872. */
  16873. minLifeTime: number;
  16874. /**
  16875. * Maximum life time of emitting particles.
  16876. */
  16877. maxLifeTime: number;
  16878. /**
  16879. * Minimum Size of emitting particles.
  16880. */
  16881. minSize: number;
  16882. /**
  16883. * Maximum Size of emitting particles.
  16884. */
  16885. maxSize: number;
  16886. /**
  16887. * Minimum scale of emitting particles on X axis.
  16888. */
  16889. minScaleX: number;
  16890. /**
  16891. * Maximum scale of emitting particles on X axis.
  16892. */
  16893. maxScaleX: number;
  16894. /**
  16895. * Minimum scale of emitting particles on Y axis.
  16896. */
  16897. minScaleY: number;
  16898. /**
  16899. * Maximum scale of emitting particles on Y axis.
  16900. */
  16901. maxScaleY: number;
  16902. /**
  16903. * Gets or sets the minimal initial rotation in radians.
  16904. */
  16905. minInitialRotation: number;
  16906. /**
  16907. * Gets or sets the maximal initial rotation in radians.
  16908. */
  16909. maxInitialRotation: number;
  16910. /**
  16911. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16912. */
  16913. minAngularSpeed: number;
  16914. /**
  16915. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16916. */
  16917. maxAngularSpeed: number;
  16918. /**
  16919. * The texture used to render each particle. (this can be a spritesheet)
  16920. */
  16921. particleTexture: Nullable<Texture>;
  16922. /**
  16923. * The layer mask we are rendering the particles through.
  16924. */
  16925. layerMask: number;
  16926. /**
  16927. * This can help using your own shader to render the particle system.
  16928. * The according effect will be created
  16929. */
  16930. customShader: any;
  16931. /**
  16932. * By default particle system starts as soon as they are created. This prevents the
  16933. * automatic start to happen and let you decide when to start emitting particles.
  16934. */
  16935. preventAutoStart: boolean;
  16936. private _noiseTexture;
  16937. /**
  16938. * Gets or sets a texture used to add random noise to particle positions
  16939. */
  16940. noiseTexture: Nullable<ProceduralTexture>;
  16941. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16942. noiseStrength: Vector3;
  16943. /**
  16944. * Callback triggered when the particle animation is ending.
  16945. */
  16946. onAnimationEnd: Nullable<() => void>;
  16947. /**
  16948. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16949. */
  16950. blendMode: number;
  16951. /**
  16952. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16953. * to override the particles.
  16954. */
  16955. forceDepthWrite: boolean;
  16956. /** 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 */
  16957. preWarmCycles: number;
  16958. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16959. preWarmStepOffset: number;
  16960. /**
  16961. * 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)
  16962. */
  16963. spriteCellChangeSpeed: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16966. */
  16967. startSpriteCellID: number;
  16968. /**
  16969. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16970. */
  16971. endSpriteCellID: number;
  16972. /**
  16973. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16974. */
  16975. spriteCellWidth: number;
  16976. /**
  16977. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16978. */
  16979. spriteCellHeight: number;
  16980. /**
  16981. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16982. */
  16983. spriteRandomStartCell: boolean;
  16984. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16985. translationPivot: Vector2;
  16986. /** @hidden */
  16987. protected _isAnimationSheetEnabled: boolean;
  16988. /**
  16989. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16990. */
  16991. beginAnimationOnStart: boolean;
  16992. /**
  16993. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16994. */
  16995. beginAnimationFrom: number;
  16996. /**
  16997. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16998. */
  16999. beginAnimationTo: number;
  17000. /**
  17001. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17002. */
  17003. beginAnimationLoop: boolean;
  17004. /**
  17005. * Gets or sets a world offset applied to all particles
  17006. */
  17007. worldOffset: Vector3;
  17008. /**
  17009. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17010. */
  17011. isAnimationSheetEnabled: boolean;
  17012. /**
  17013. * Get hosting scene
  17014. * @returns the scene
  17015. */
  17016. getScene(): Scene;
  17017. /**
  17018. * You can use gravity if you want to give an orientation to your particles.
  17019. */
  17020. gravity: Vector3;
  17021. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17022. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17023. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17024. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17025. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17026. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17027. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17028. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17029. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17030. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17031. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17032. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17033. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17034. /**
  17035. * Defines the delay in milliseconds before starting the system (0 by default)
  17036. */
  17037. startDelay: number;
  17038. /**
  17039. * Gets the current list of drag gradients.
  17040. * You must use addDragGradient and removeDragGradient to udpate this list
  17041. * @returns the list of drag gradients
  17042. */
  17043. getDragGradients(): Nullable<Array<FactorGradient>>;
  17044. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17045. limitVelocityDamping: number;
  17046. /**
  17047. * Gets the current list of limit velocity gradients.
  17048. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17049. * @returns the list of limit velocity gradients
  17050. */
  17051. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17052. /**
  17053. * Gets the current list of color gradients.
  17054. * You must use addColorGradient and removeColorGradient to udpate this list
  17055. * @returns the list of color gradients
  17056. */
  17057. getColorGradients(): Nullable<Array<ColorGradient>>;
  17058. /**
  17059. * Gets the current list of size gradients.
  17060. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17061. * @returns the list of size gradients
  17062. */
  17063. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Gets the current list of color remap gradients.
  17066. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17067. * @returns the list of color remap gradients
  17068. */
  17069. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of alpha remap gradients.
  17072. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17073. * @returns the list of alpha remap gradients
  17074. */
  17075. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17076. /**
  17077. * Gets the current list of life time gradients.
  17078. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17079. * @returns the list of life time gradients
  17080. */
  17081. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of angular speed gradients.
  17084. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17085. * @returns the list of angular speed gradients
  17086. */
  17087. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of velocity gradients.
  17090. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17091. * @returns the list of velocity gradients
  17092. */
  17093. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Gets the current list of start size gradients.
  17096. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17097. * @returns the list of start size gradients
  17098. */
  17099. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17100. /**
  17101. * Gets the current list of emit rate gradients.
  17102. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17103. * @returns the list of emit rate gradients
  17104. */
  17105. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17106. /**
  17107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17108. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17109. */
  17110. direction1: Vector3;
  17111. /**
  17112. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17113. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17114. */
  17115. direction2: Vector3;
  17116. /**
  17117. * 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.
  17118. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17119. */
  17120. minEmitBox: Vector3;
  17121. /**
  17122. * 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.
  17123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17124. */
  17125. maxEmitBox: Vector3;
  17126. /**
  17127. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17128. */
  17129. color1: Color4;
  17130. /**
  17131. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17132. */
  17133. color2: Color4;
  17134. /**
  17135. * Color the particle will have at the end of its lifetime
  17136. */
  17137. colorDead: Color4;
  17138. /**
  17139. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17140. */
  17141. textureMask: Color4;
  17142. /**
  17143. * The particle emitter type defines the emitter used by the particle system.
  17144. * It can be for example box, sphere, or cone...
  17145. */
  17146. particleEmitterType: IParticleEmitterType;
  17147. /** @hidden */
  17148. _isSubEmitter: boolean;
  17149. /**
  17150. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17151. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17152. */
  17153. billboardMode: number;
  17154. protected _isBillboardBased: boolean;
  17155. /**
  17156. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17157. */
  17158. isBillboardBased: boolean;
  17159. /**
  17160. * The scene the particle system belongs to.
  17161. */
  17162. protected _scene: Scene;
  17163. /**
  17164. * Local cache of defines for image processing.
  17165. */
  17166. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17167. /**
  17168. * Default configuration related to image processing available in the standard Material.
  17169. */
  17170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17171. /**
  17172. * Gets the image processing configuration used either in this material.
  17173. */
  17174. /**
  17175. * Sets the Default image processing configuration used either in the this material.
  17176. *
  17177. * If sets to null, the scene one is in use.
  17178. */
  17179. imageProcessingConfiguration: ImageProcessingConfiguration;
  17180. /**
  17181. * Attaches a new image processing configuration to the Standard Material.
  17182. * @param configuration
  17183. */
  17184. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17185. /** @hidden */
  17186. protected _reset(): void;
  17187. /** @hidden */
  17188. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17189. /**
  17190. * Instantiates a particle system.
  17191. * 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.
  17192. * @param name The name of the particle system
  17193. */
  17194. constructor(name: string);
  17195. /**
  17196. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17199. * @returns the emitter
  17200. */
  17201. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17202. /**
  17203. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17204. * @param radius The radius of the hemisphere to emit from
  17205. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17206. * @returns the emitter
  17207. */
  17208. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17209. /**
  17210. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17211. * @param radius The radius of the sphere to emit from
  17212. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17213. * @returns the emitter
  17214. */
  17215. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17216. /**
  17217. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17218. * @param radius The radius of the sphere to emit from
  17219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17221. * @returns the emitter
  17222. */
  17223. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17224. /**
  17225. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17226. * @param radius The radius of the emission cylinder
  17227. * @param height The height of the emission cylinder
  17228. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17229. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17230. * @returns the emitter
  17231. */
  17232. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17233. /**
  17234. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17235. * @param radius The radius of the cylinder to emit from
  17236. * @param height The height of the emission cylinder
  17237. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17240. * @returns the emitter
  17241. */
  17242. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17243. /**
  17244. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17245. * @param radius The radius of the cone to emit from
  17246. * @param angle The base angle of the cone
  17247. * @returns the emitter
  17248. */
  17249. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17250. /**
  17251. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17252. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17253. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17254. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17255. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17256. * @returns the emitter
  17257. */
  17258. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17259. }
  17260. }
  17261. declare module "babylonjs/Particles/subEmitter" {
  17262. import { Scene } from "babylonjs/scene";
  17263. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17264. /**
  17265. * Type of sub emitter
  17266. */
  17267. export enum SubEmitterType {
  17268. /**
  17269. * Attached to the particle over it's lifetime
  17270. */
  17271. ATTACHED = 0,
  17272. /**
  17273. * Created when the particle dies
  17274. */
  17275. END = 1
  17276. }
  17277. /**
  17278. * Sub emitter class used to emit particles from an existing particle
  17279. */
  17280. export class SubEmitter {
  17281. /**
  17282. * the particle system to be used by the sub emitter
  17283. */
  17284. particleSystem: ParticleSystem;
  17285. /**
  17286. * Type of the submitter (Default: END)
  17287. */
  17288. type: SubEmitterType;
  17289. /**
  17290. * 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)
  17291. * Note: This only is supported when using an emitter of type Mesh
  17292. */
  17293. inheritDirection: boolean;
  17294. /**
  17295. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17296. */
  17297. inheritedVelocityAmount: number;
  17298. /**
  17299. * Creates a sub emitter
  17300. * @param particleSystem the particle system to be used by the sub emitter
  17301. */
  17302. constructor(
  17303. /**
  17304. * the particle system to be used by the sub emitter
  17305. */
  17306. particleSystem: ParticleSystem);
  17307. /**
  17308. * Clones the sub emitter
  17309. * @returns the cloned sub emitter
  17310. */
  17311. clone(): SubEmitter;
  17312. /**
  17313. * Serialize current object to a JSON object
  17314. * @returns the serialized object
  17315. */
  17316. serialize(): any;
  17317. /** @hidden */
  17318. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17319. /**
  17320. * Creates a new SubEmitter from a serialized JSON version
  17321. * @param serializationObject defines the JSON object to read from
  17322. * @param scene defines the hosting scene
  17323. * @param rootUrl defines the rootUrl for data loading
  17324. * @returns a new SubEmitter
  17325. */
  17326. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17327. /** Release associated resources */
  17328. dispose(): void;
  17329. }
  17330. }
  17331. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17332. /** @hidden */
  17333. export var clipPlaneFragmentDeclaration: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17339. /** @hidden */
  17340. export var imageProcessingDeclaration: {
  17341. name: string;
  17342. shader: string;
  17343. };
  17344. }
  17345. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17346. /** @hidden */
  17347. export var imageProcessingFunctions: {
  17348. name: string;
  17349. shader: string;
  17350. };
  17351. }
  17352. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17353. /** @hidden */
  17354. export var clipPlaneFragment: {
  17355. name: string;
  17356. shader: string;
  17357. };
  17358. }
  17359. declare module "babylonjs/Shaders/particles.fragment" {
  17360. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17361. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17362. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17363. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17364. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17365. /** @hidden */
  17366. export var particlesPixelShader: {
  17367. name: string;
  17368. shader: string;
  17369. };
  17370. }
  17371. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17372. /** @hidden */
  17373. export var clipPlaneVertexDeclaration: {
  17374. name: string;
  17375. shader: string;
  17376. };
  17377. }
  17378. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17379. /** @hidden */
  17380. export var clipPlaneVertex: {
  17381. name: string;
  17382. shader: string;
  17383. };
  17384. }
  17385. declare module "babylonjs/Shaders/particles.vertex" {
  17386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17387. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17388. /** @hidden */
  17389. export var particlesVertexShader: {
  17390. name: string;
  17391. shader: string;
  17392. };
  17393. }
  17394. declare module "babylonjs/Particles/particleSystem" {
  17395. import { Nullable } from "babylonjs/types";
  17396. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17397. import { Observable } from "babylonjs/Misc/observable";
  17398. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17399. import { Effect } from "babylonjs/Materials/effect";
  17400. import { Scene, IDisposable } from "babylonjs/scene";
  17401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17402. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17403. import { Particle } from "babylonjs/Particles/particle";
  17404. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17406. import "babylonjs/Shaders/particles.fragment";
  17407. import "babylonjs/Shaders/particles.vertex";
  17408. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17409. /**
  17410. * This represents a particle system in Babylon.
  17411. * 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.
  17412. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17413. * @example https://doc.babylonjs.com/babylon101/particles
  17414. */
  17415. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17416. /**
  17417. * Billboard mode will only apply to Y axis
  17418. */
  17419. static readonly BILLBOARDMODE_Y: number;
  17420. /**
  17421. * Billboard mode will apply to all axes
  17422. */
  17423. static readonly BILLBOARDMODE_ALL: number;
  17424. /**
  17425. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17426. */
  17427. static readonly BILLBOARDMODE_STRETCHED: number;
  17428. /**
  17429. * This function can be defined to provide custom update for active particles.
  17430. * This function will be called instead of regular update (age, position, color, etc.).
  17431. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17432. */
  17433. updateFunction: (particles: Particle[]) => void;
  17434. private _emitterWorldMatrix;
  17435. /**
  17436. * This function can be defined to specify initial direction for every new particle.
  17437. * It by default use the emitterType defined function
  17438. */
  17439. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17440. /**
  17441. * This function can be defined to specify initial position for every new particle.
  17442. * It by default use the emitterType defined function
  17443. */
  17444. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17445. /**
  17446. * @hidden
  17447. */
  17448. _inheritedVelocityOffset: Vector3;
  17449. /**
  17450. * An event triggered when the system is disposed
  17451. */
  17452. onDisposeObservable: Observable<ParticleSystem>;
  17453. private _onDisposeObserver;
  17454. /**
  17455. * Sets a callback that will be triggered when the system is disposed
  17456. */
  17457. onDispose: () => void;
  17458. private _particles;
  17459. private _epsilon;
  17460. private _capacity;
  17461. private _stockParticles;
  17462. private _newPartsExcess;
  17463. private _vertexData;
  17464. private _vertexBuffer;
  17465. private _vertexBuffers;
  17466. private _spriteBuffer;
  17467. private _indexBuffer;
  17468. private _effect;
  17469. private _customEffect;
  17470. private _cachedDefines;
  17471. private _scaledColorStep;
  17472. private _colorDiff;
  17473. private _scaledDirection;
  17474. private _scaledGravity;
  17475. private _currentRenderId;
  17476. private _alive;
  17477. private _useInstancing;
  17478. private _started;
  17479. private _stopped;
  17480. private _actualFrame;
  17481. private _scaledUpdateSpeed;
  17482. private _vertexBufferSize;
  17483. /** @hidden */
  17484. _currentEmitRateGradient: Nullable<FactorGradient>;
  17485. /** @hidden */
  17486. _currentEmitRate1: number;
  17487. /** @hidden */
  17488. _currentEmitRate2: number;
  17489. /** @hidden */
  17490. _currentStartSizeGradient: Nullable<FactorGradient>;
  17491. /** @hidden */
  17492. _currentStartSize1: number;
  17493. /** @hidden */
  17494. _currentStartSize2: number;
  17495. private readonly _rawTextureWidth;
  17496. private _rampGradientsTexture;
  17497. private _useRampGradients;
  17498. /** Gets or sets a boolean indicating that ramp gradients must be used
  17499. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17500. */
  17501. useRampGradients: boolean;
  17502. /**
  17503. * 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.
  17504. * 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: [])
  17505. */
  17506. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17507. private _subEmitters;
  17508. /**
  17509. * @hidden
  17510. * If the particle systems emitter should be disposed when the particle system is disposed
  17511. */
  17512. _disposeEmitterOnDispose: boolean;
  17513. /**
  17514. * The current active Sub-systems, this property is used by the root particle system only.
  17515. */
  17516. activeSubSystems: Array<ParticleSystem>;
  17517. private _rootParticleSystem;
  17518. /**
  17519. * Gets the current list of active particles
  17520. */
  17521. readonly particles: Particle[];
  17522. /**
  17523. * Returns the string "ParticleSystem"
  17524. * @returns a string containing the class name
  17525. */
  17526. getClassName(): string;
  17527. /**
  17528. * Instantiates a particle system.
  17529. * 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.
  17530. * @param name The name of the particle system
  17531. * @param capacity The max number of particles alive at the same time
  17532. * @param scene The scene the particle system belongs to
  17533. * @param customEffect a custom effect used to change the way particles are rendered by default
  17534. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17535. * @param epsilon Offset used to render the particles
  17536. */
  17537. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17538. private _addFactorGradient;
  17539. private _removeFactorGradient;
  17540. /**
  17541. * Adds a new life time gradient
  17542. * @param gradient defines the gradient to use (between 0 and 1)
  17543. * @param factor defines the life time factor to affect to the specified gradient
  17544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17545. * @returns the current particle system
  17546. */
  17547. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17548. /**
  17549. * Remove a specific life time gradient
  17550. * @param gradient defines the gradient to remove
  17551. * @returns the current particle system
  17552. */
  17553. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17554. /**
  17555. * Adds a new size gradient
  17556. * @param gradient defines the gradient to use (between 0 and 1)
  17557. * @param factor defines the size factor to affect to the specified gradient
  17558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17559. * @returns the current particle system
  17560. */
  17561. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17562. /**
  17563. * Remove a specific size gradient
  17564. * @param gradient defines the gradient to remove
  17565. * @returns the current particle system
  17566. */
  17567. removeSizeGradient(gradient: number): IParticleSystem;
  17568. /**
  17569. * Adds a new color remap gradient
  17570. * @param gradient defines the gradient to use (between 0 and 1)
  17571. * @param min defines the color remap minimal range
  17572. * @param max defines the color remap maximal range
  17573. * @returns the current particle system
  17574. */
  17575. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17576. /**
  17577. * Remove a specific color remap gradient
  17578. * @param gradient defines the gradient to remove
  17579. * @returns the current particle system
  17580. */
  17581. removeColorRemapGradient(gradient: number): IParticleSystem;
  17582. /**
  17583. * Adds a new alpha remap gradient
  17584. * @param gradient defines the gradient to use (between 0 and 1)
  17585. * @param min defines the alpha remap minimal range
  17586. * @param max defines the alpha remap maximal range
  17587. * @returns the current particle system
  17588. */
  17589. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17590. /**
  17591. * Remove a specific alpha remap gradient
  17592. * @param gradient defines the gradient to remove
  17593. * @returns the current particle system
  17594. */
  17595. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17596. /**
  17597. * Adds a new angular speed gradient
  17598. * @param gradient defines the gradient to use (between 0 and 1)
  17599. * @param factor defines the angular speed to affect to the specified gradient
  17600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17601. * @returns the current particle system
  17602. */
  17603. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17604. /**
  17605. * Remove a specific angular speed gradient
  17606. * @param gradient defines the gradient to remove
  17607. * @returns the current particle system
  17608. */
  17609. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17610. /**
  17611. * Adds a new velocity gradient
  17612. * @param gradient defines the gradient to use (between 0 and 1)
  17613. * @param factor defines the velocity to affect to the specified gradient
  17614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17615. * @returns the current particle system
  17616. */
  17617. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17618. /**
  17619. * Remove a specific velocity gradient
  17620. * @param gradient defines the gradient to remove
  17621. * @returns the current particle system
  17622. */
  17623. removeVelocityGradient(gradient: number): IParticleSystem;
  17624. /**
  17625. * Adds a new limit velocity gradient
  17626. * @param gradient defines the gradient to use (between 0 and 1)
  17627. * @param factor defines the limit velocity value to affect to the specified gradient
  17628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17629. * @returns the current particle system
  17630. */
  17631. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17632. /**
  17633. * Remove a specific limit velocity gradient
  17634. * @param gradient defines the gradient to remove
  17635. * @returns the current particle system
  17636. */
  17637. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17638. /**
  17639. * Adds a new drag gradient
  17640. * @param gradient defines the gradient to use (between 0 and 1)
  17641. * @param factor defines the drag value to affect to the specified gradient
  17642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17643. * @returns the current particle system
  17644. */
  17645. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17646. /**
  17647. * Remove a specific drag gradient
  17648. * @param gradient defines the gradient to remove
  17649. * @returns the current particle system
  17650. */
  17651. removeDragGradient(gradient: number): IParticleSystem;
  17652. /**
  17653. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17654. * @param gradient defines the gradient to use (between 0 and 1)
  17655. * @param factor defines the emit rate value to affect to the specified gradient
  17656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17657. * @returns the current particle system
  17658. */
  17659. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17660. /**
  17661. * Remove a specific emit rate gradient
  17662. * @param gradient defines the gradient to remove
  17663. * @returns the current particle system
  17664. */
  17665. removeEmitRateGradient(gradient: number): IParticleSystem;
  17666. /**
  17667. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17668. * @param gradient defines the gradient to use (between 0 and 1)
  17669. * @param factor defines the start size value to affect to the specified gradient
  17670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17671. * @returns the current particle system
  17672. */
  17673. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17674. /**
  17675. * Remove a specific start size gradient
  17676. * @param gradient defines the gradient to remove
  17677. * @returns the current particle system
  17678. */
  17679. removeStartSizeGradient(gradient: number): IParticleSystem;
  17680. private _createRampGradientTexture;
  17681. /**
  17682. * Gets the current list of ramp gradients.
  17683. * You must use addRampGradient and removeRampGradient to udpate this list
  17684. * @returns the list of ramp gradients
  17685. */
  17686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17687. /**
  17688. * Adds a new ramp gradient used to remap particle colors
  17689. * @param gradient defines the gradient to use (between 0 and 1)
  17690. * @param color defines the color to affect to the specified gradient
  17691. * @returns the current particle system
  17692. */
  17693. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17694. /**
  17695. * Remove a specific ramp gradient
  17696. * @param gradient defines the gradient to remove
  17697. * @returns the current particle system
  17698. */
  17699. removeRampGradient(gradient: number): ParticleSystem;
  17700. /**
  17701. * Adds a new color gradient
  17702. * @param gradient defines the gradient to use (between 0 and 1)
  17703. * @param color1 defines the color to affect to the specified gradient
  17704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17705. * @returns this particle system
  17706. */
  17707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17708. /**
  17709. * Remove a specific color gradient
  17710. * @param gradient defines the gradient to remove
  17711. * @returns this particle system
  17712. */
  17713. removeColorGradient(gradient: number): IParticleSystem;
  17714. private _fetchR;
  17715. protected _reset(): void;
  17716. private _resetEffect;
  17717. private _createVertexBuffers;
  17718. private _createIndexBuffer;
  17719. /**
  17720. * Gets the maximum number of particles active at the same time.
  17721. * @returns The max number of active particles.
  17722. */
  17723. getCapacity(): number;
  17724. /**
  17725. * Gets whether there are still active particles in the system.
  17726. * @returns True if it is alive, otherwise false.
  17727. */
  17728. isAlive(): boolean;
  17729. /**
  17730. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17731. * @returns True if it has been started, otherwise false.
  17732. */
  17733. isStarted(): boolean;
  17734. private _prepareSubEmitterInternalArray;
  17735. /**
  17736. * Starts the particle system and begins to emit
  17737. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17738. */
  17739. start(delay?: number): void;
  17740. /**
  17741. * Stops the particle system.
  17742. * @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.
  17743. */
  17744. stop(stopSubEmitters?: boolean): void;
  17745. /**
  17746. * Remove all active particles
  17747. */
  17748. reset(): void;
  17749. /**
  17750. * @hidden (for internal use only)
  17751. */
  17752. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17753. /**
  17754. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17755. * Its lifetime will start back at 0.
  17756. */
  17757. recycleParticle: (particle: Particle) => void;
  17758. private _stopSubEmitters;
  17759. private _createParticle;
  17760. private _removeFromRoot;
  17761. private _emitFromParticle;
  17762. private _update;
  17763. /** @hidden */
  17764. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17765. /** @hidden */
  17766. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17767. /** @hidden */
  17768. private _getEffect;
  17769. /**
  17770. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17771. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17772. */
  17773. animate(preWarmOnly?: boolean): void;
  17774. private _appendParticleVertices;
  17775. /**
  17776. * Rebuilds the particle system.
  17777. */
  17778. rebuild(): void;
  17779. /**
  17780. * Is this system ready to be used/rendered
  17781. * @return true if the system is ready
  17782. */
  17783. isReady(): boolean;
  17784. private _render;
  17785. /**
  17786. * Renders the particle system in its current state.
  17787. * @returns the current number of particles
  17788. */
  17789. render(): number;
  17790. /**
  17791. * Disposes the particle system and free the associated resources
  17792. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17793. */
  17794. dispose(disposeTexture?: boolean): void;
  17795. /**
  17796. * Clones the particle system.
  17797. * @param name The name of the cloned object
  17798. * @param newEmitter The new emitter to use
  17799. * @returns the cloned particle system
  17800. */
  17801. clone(name: string, newEmitter: any): ParticleSystem;
  17802. /**
  17803. * Serializes the particle system to a JSON object.
  17804. * @returns the JSON object
  17805. */
  17806. serialize(): any;
  17807. /** @hidden */
  17808. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17809. /** @hidden */
  17810. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17811. /**
  17812. * Parses a JSON object to create a particle system.
  17813. * @param parsedParticleSystem The JSON object to parse
  17814. * @param scene The scene to create the particle system in
  17815. * @param rootUrl The root url to use to load external dependencies like texture
  17816. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17817. * @returns the Parsed particle system
  17818. */
  17819. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17820. }
  17821. }
  17822. declare module "babylonjs/Particles/particle" {
  17823. import { Nullable } from "babylonjs/types";
  17824. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17825. import { Color4 } from "babylonjs/Maths/math.color";
  17826. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17827. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17828. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17829. /**
  17830. * A particle represents one of the element emitted by a particle system.
  17831. * This is mainly define by its coordinates, direction, velocity and age.
  17832. */
  17833. export class Particle {
  17834. /**
  17835. * The particle system the particle belongs to.
  17836. */
  17837. particleSystem: ParticleSystem;
  17838. private static _Count;
  17839. /**
  17840. * Unique ID of the particle
  17841. */
  17842. id: number;
  17843. /**
  17844. * The world position of the particle in the scene.
  17845. */
  17846. position: Vector3;
  17847. /**
  17848. * The world direction of the particle in the scene.
  17849. */
  17850. direction: Vector3;
  17851. /**
  17852. * The color of the particle.
  17853. */
  17854. color: Color4;
  17855. /**
  17856. * The color change of the particle per step.
  17857. */
  17858. colorStep: Color4;
  17859. /**
  17860. * Defines how long will the life of the particle be.
  17861. */
  17862. lifeTime: number;
  17863. /**
  17864. * The current age of the particle.
  17865. */
  17866. age: number;
  17867. /**
  17868. * The current size of the particle.
  17869. */
  17870. size: number;
  17871. /**
  17872. * The current scale of the particle.
  17873. */
  17874. scale: Vector2;
  17875. /**
  17876. * The current angle of the particle.
  17877. */
  17878. angle: number;
  17879. /**
  17880. * Defines how fast is the angle changing.
  17881. */
  17882. angularSpeed: number;
  17883. /**
  17884. * Defines the cell index used by the particle to be rendered from a sprite.
  17885. */
  17886. cellIndex: number;
  17887. /**
  17888. * The information required to support color remapping
  17889. */
  17890. remapData: Vector4;
  17891. /** @hidden */
  17892. _randomCellOffset?: number;
  17893. /** @hidden */
  17894. _initialDirection: Nullable<Vector3>;
  17895. /** @hidden */
  17896. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17897. /** @hidden */
  17898. _initialStartSpriteCellID: number;
  17899. /** @hidden */
  17900. _initialEndSpriteCellID: number;
  17901. /** @hidden */
  17902. _currentColorGradient: Nullable<ColorGradient>;
  17903. /** @hidden */
  17904. _currentColor1: Color4;
  17905. /** @hidden */
  17906. _currentColor2: Color4;
  17907. /** @hidden */
  17908. _currentSizeGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentSize1: number;
  17911. /** @hidden */
  17912. _currentSize2: number;
  17913. /** @hidden */
  17914. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentAngularSpeed1: number;
  17917. /** @hidden */
  17918. _currentAngularSpeed2: number;
  17919. /** @hidden */
  17920. _currentVelocityGradient: Nullable<FactorGradient>;
  17921. /** @hidden */
  17922. _currentVelocity1: number;
  17923. /** @hidden */
  17924. _currentVelocity2: number;
  17925. /** @hidden */
  17926. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17927. /** @hidden */
  17928. _currentLimitVelocity1: number;
  17929. /** @hidden */
  17930. _currentLimitVelocity2: number;
  17931. /** @hidden */
  17932. _currentDragGradient: Nullable<FactorGradient>;
  17933. /** @hidden */
  17934. _currentDrag1: number;
  17935. /** @hidden */
  17936. _currentDrag2: number;
  17937. /** @hidden */
  17938. _randomNoiseCoordinates1: Vector3;
  17939. /** @hidden */
  17940. _randomNoiseCoordinates2: Vector3;
  17941. /**
  17942. * Creates a new instance Particle
  17943. * @param particleSystem the particle system the particle belongs to
  17944. */
  17945. constructor(
  17946. /**
  17947. * The particle system the particle belongs to.
  17948. */
  17949. particleSystem: ParticleSystem);
  17950. private updateCellInfoFromSystem;
  17951. /**
  17952. * Defines how the sprite cell index is updated for the particle
  17953. */
  17954. updateCellIndex(): void;
  17955. /** @hidden */
  17956. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17957. /** @hidden */
  17958. _inheritParticleInfoToSubEmitters(): void;
  17959. /** @hidden */
  17960. _reset(): void;
  17961. /**
  17962. * Copy the properties of particle to another one.
  17963. * @param other the particle to copy the information to.
  17964. */
  17965. copyTo(other: Particle): void;
  17966. }
  17967. }
  17968. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17969. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17970. import { Effect } from "babylonjs/Materials/effect";
  17971. import { Particle } from "babylonjs/Particles/particle";
  17972. /**
  17973. * Particle emitter represents a volume emitting particles.
  17974. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17975. */
  17976. export interface IParticleEmitterType {
  17977. /**
  17978. * Called by the particle System when the direction is computed for the created particle.
  17979. * @param worldMatrix is the world matrix of the particle system
  17980. * @param directionToUpdate is the direction vector to update with the result
  17981. * @param particle is the particle we are computed the direction for
  17982. */
  17983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17984. /**
  17985. * Called by the particle System when the position is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param positionToUpdate is the position vector to update with the result
  17988. * @param particle is the particle we are computed the position for
  17989. */
  17990. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Clones the current emitter and returns a copy of it
  17993. * @returns the new emitter
  17994. */
  17995. clone(): IParticleEmitterType;
  17996. /**
  17997. * Called by the GPUParticleSystem to setup the update shader
  17998. * @param effect defines the update shader
  17999. */
  18000. applyToShader(effect: Effect): void;
  18001. /**
  18002. * Returns a string to use to update the GPU particles update shader
  18003. * @returns the effect defines string
  18004. */
  18005. getEffectDefines(): string;
  18006. /**
  18007. * Returns a string representing the class name
  18008. * @returns a string containing the class name
  18009. */
  18010. getClassName(): string;
  18011. /**
  18012. * Serializes the particle system to a JSON object.
  18013. * @returns the JSON object
  18014. */
  18015. serialize(): any;
  18016. /**
  18017. * Parse properties from a JSON object
  18018. * @param serializationObject defines the JSON object
  18019. */
  18020. parse(serializationObject: any): void;
  18021. }
  18022. }
  18023. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18024. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18025. import { Effect } from "babylonjs/Materials/effect";
  18026. import { Particle } from "babylonjs/Particles/particle";
  18027. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18028. /**
  18029. * Particle emitter emitting particles from the inside of a box.
  18030. * It emits the particles randomly between 2 given directions.
  18031. */
  18032. export class BoxParticleEmitter implements IParticleEmitterType {
  18033. /**
  18034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18035. */
  18036. direction1: Vector3;
  18037. /**
  18038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18039. */
  18040. direction2: Vector3;
  18041. /**
  18042. * 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.
  18043. */
  18044. minEmitBox: Vector3;
  18045. /**
  18046. * 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.
  18047. */
  18048. maxEmitBox: Vector3;
  18049. /**
  18050. * Creates a new instance BoxParticleEmitter
  18051. */
  18052. constructor();
  18053. /**
  18054. * Called by the particle System when the direction is computed for the created particle.
  18055. * @param worldMatrix is the world matrix of the particle system
  18056. * @param directionToUpdate is the direction vector to update with the result
  18057. * @param particle is the particle we are computed the direction for
  18058. */
  18059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18060. /**
  18061. * Called by the particle System when the position is computed for the created particle.
  18062. * @param worldMatrix is the world matrix of the particle system
  18063. * @param positionToUpdate is the position vector to update with the result
  18064. * @param particle is the particle we are computed the position for
  18065. */
  18066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18067. /**
  18068. * Clones the current emitter and returns a copy of it
  18069. * @returns the new emitter
  18070. */
  18071. clone(): BoxParticleEmitter;
  18072. /**
  18073. * Called by the GPUParticleSystem to setup the update shader
  18074. * @param effect defines the update shader
  18075. */
  18076. applyToShader(effect: Effect): void;
  18077. /**
  18078. * Returns a string to use to update the GPU particles update shader
  18079. * @returns a string containng the defines string
  18080. */
  18081. getEffectDefines(): string;
  18082. /**
  18083. * Returns the string "BoxParticleEmitter"
  18084. * @returns a string containing the class name
  18085. */
  18086. getClassName(): string;
  18087. /**
  18088. * Serializes the particle system to a JSON object.
  18089. * @returns the JSON object
  18090. */
  18091. serialize(): any;
  18092. /**
  18093. * Parse properties from a JSON object
  18094. * @param serializationObject defines the JSON object
  18095. */
  18096. parse(serializationObject: any): void;
  18097. }
  18098. }
  18099. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18100. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18101. import { Effect } from "babylonjs/Materials/effect";
  18102. import { Particle } from "babylonjs/Particles/particle";
  18103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18104. /**
  18105. * Particle emitter emitting particles from the inside of a cone.
  18106. * It emits the particles alongside the cone volume from the base to the particle.
  18107. * The emission direction might be randomized.
  18108. */
  18109. export class ConeParticleEmitter implements IParticleEmitterType {
  18110. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18111. directionRandomizer: number;
  18112. private _radius;
  18113. private _angle;
  18114. private _height;
  18115. /**
  18116. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18117. */
  18118. radiusRange: number;
  18119. /**
  18120. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18121. */
  18122. heightRange: number;
  18123. /**
  18124. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18125. */
  18126. emitFromSpawnPointOnly: boolean;
  18127. /**
  18128. * Gets or sets the radius of the emission cone
  18129. */
  18130. radius: number;
  18131. /**
  18132. * Gets or sets the angle of the emission cone
  18133. */
  18134. angle: number;
  18135. private _buildHeight;
  18136. /**
  18137. * Creates a new instance ConeParticleEmitter
  18138. * @param radius the radius of the emission cone (1 by default)
  18139. * @param angle the cone base angle (PI by default)
  18140. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18141. */
  18142. constructor(radius?: number, angle?: number,
  18143. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18144. directionRandomizer?: number);
  18145. /**
  18146. * Called by the particle System when the direction is computed for the created particle.
  18147. * @param worldMatrix is the world matrix of the particle system
  18148. * @param directionToUpdate is the direction vector to update with the result
  18149. * @param particle is the particle we are computed the direction for
  18150. */
  18151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18152. /**
  18153. * Called by the particle System when the position is computed for the created particle.
  18154. * @param worldMatrix is the world matrix of the particle system
  18155. * @param positionToUpdate is the position vector to update with the result
  18156. * @param particle is the particle we are computed the position for
  18157. */
  18158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18159. /**
  18160. * Clones the current emitter and returns a copy of it
  18161. * @returns the new emitter
  18162. */
  18163. clone(): ConeParticleEmitter;
  18164. /**
  18165. * Called by the GPUParticleSystem to setup the update shader
  18166. * @param effect defines the update shader
  18167. */
  18168. applyToShader(effect: Effect): void;
  18169. /**
  18170. * Returns a string to use to update the GPU particles update shader
  18171. * @returns a string containng the defines string
  18172. */
  18173. getEffectDefines(): string;
  18174. /**
  18175. * Returns the string "ConeParticleEmitter"
  18176. * @returns a string containing the class name
  18177. */
  18178. getClassName(): string;
  18179. /**
  18180. * Serializes the particle system to a JSON object.
  18181. * @returns the JSON object
  18182. */
  18183. serialize(): any;
  18184. /**
  18185. * Parse properties from a JSON object
  18186. * @param serializationObject defines the JSON object
  18187. */
  18188. parse(serializationObject: any): void;
  18189. }
  18190. }
  18191. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18192. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { Particle } from "babylonjs/Particles/particle";
  18195. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18196. /**
  18197. * Particle emitter emitting particles from the inside of a cylinder.
  18198. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18199. */
  18200. export class CylinderParticleEmitter implements IParticleEmitterType {
  18201. /**
  18202. * The radius of the emission cylinder.
  18203. */
  18204. radius: number;
  18205. /**
  18206. * The height of the emission cylinder.
  18207. */
  18208. height: number;
  18209. /**
  18210. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18211. */
  18212. radiusRange: number;
  18213. /**
  18214. * How much to randomize the particle direction [0-1].
  18215. */
  18216. directionRandomizer: number;
  18217. /**
  18218. * Creates a new instance CylinderParticleEmitter
  18219. * @param radius the radius of the emission cylinder (1 by default)
  18220. * @param height the height of the emission cylinder (1 by default)
  18221. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18222. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18223. */
  18224. constructor(
  18225. /**
  18226. * The radius of the emission cylinder.
  18227. */
  18228. radius?: number,
  18229. /**
  18230. * The height of the emission cylinder.
  18231. */
  18232. height?: number,
  18233. /**
  18234. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18235. */
  18236. radiusRange?: number,
  18237. /**
  18238. * How much to randomize the particle direction [0-1].
  18239. */
  18240. directionRandomizer?: number);
  18241. /**
  18242. * Called by the particle System when the direction is computed for the created particle.
  18243. * @param worldMatrix is the world matrix of the particle system
  18244. * @param directionToUpdate is the direction vector to update with the result
  18245. * @param particle is the particle we are computed the direction for
  18246. */
  18247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18248. /**
  18249. * Called by the particle System when the position is computed for the created particle.
  18250. * @param worldMatrix is the world matrix of the particle system
  18251. * @param positionToUpdate is the position vector to update with the result
  18252. * @param particle is the particle we are computed the position for
  18253. */
  18254. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18255. /**
  18256. * Clones the current emitter and returns a copy of it
  18257. * @returns the new emitter
  18258. */
  18259. clone(): CylinderParticleEmitter;
  18260. /**
  18261. * Called by the GPUParticleSystem to setup the update shader
  18262. * @param effect defines the update shader
  18263. */
  18264. applyToShader(effect: Effect): void;
  18265. /**
  18266. * Returns a string to use to update the GPU particles update shader
  18267. * @returns a string containng the defines string
  18268. */
  18269. getEffectDefines(): string;
  18270. /**
  18271. * Returns the string "CylinderParticleEmitter"
  18272. * @returns a string containing the class name
  18273. */
  18274. getClassName(): string;
  18275. /**
  18276. * Serializes the particle system to a JSON object.
  18277. * @returns the JSON object
  18278. */
  18279. serialize(): any;
  18280. /**
  18281. * Parse properties from a JSON object
  18282. * @param serializationObject defines the JSON object
  18283. */
  18284. parse(serializationObject: any): void;
  18285. }
  18286. /**
  18287. * Particle emitter emitting particles from the inside of a cylinder.
  18288. * It emits the particles randomly between two vectors.
  18289. */
  18290. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18291. /**
  18292. * The min limit of the emission direction.
  18293. */
  18294. direction1: Vector3;
  18295. /**
  18296. * The max limit of the emission direction.
  18297. */
  18298. direction2: Vector3;
  18299. /**
  18300. * Creates a new instance CylinderDirectedParticleEmitter
  18301. * @param radius the radius of the emission cylinder (1 by default)
  18302. * @param height the height of the emission cylinder (1 by default)
  18303. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18304. * @param direction1 the min limit of the emission direction (up vector by default)
  18305. * @param direction2 the max limit of the emission direction (up vector by default)
  18306. */
  18307. constructor(radius?: number, height?: number, radiusRange?: number,
  18308. /**
  18309. * The min limit of the emission direction.
  18310. */
  18311. direction1?: Vector3,
  18312. /**
  18313. * The max limit of the emission direction.
  18314. */
  18315. direction2?: Vector3);
  18316. /**
  18317. * Called by the particle System when the direction is computed for the created particle.
  18318. * @param worldMatrix is the world matrix of the particle system
  18319. * @param directionToUpdate is the direction vector to update with the result
  18320. * @param particle is the particle we are computed the direction for
  18321. */
  18322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18323. /**
  18324. * Clones the current emitter and returns a copy of it
  18325. * @returns the new emitter
  18326. */
  18327. clone(): CylinderDirectedParticleEmitter;
  18328. /**
  18329. * Called by the GPUParticleSystem to setup the update shader
  18330. * @param effect defines the update shader
  18331. */
  18332. applyToShader(effect: Effect): void;
  18333. /**
  18334. * Returns a string to use to update the GPU particles update shader
  18335. * @returns a string containng the defines string
  18336. */
  18337. getEffectDefines(): string;
  18338. /**
  18339. * Returns the string "CylinderDirectedParticleEmitter"
  18340. * @returns a string containing the class name
  18341. */
  18342. getClassName(): string;
  18343. /**
  18344. * Serializes the particle system to a JSON object.
  18345. * @returns the JSON object
  18346. */
  18347. serialize(): any;
  18348. /**
  18349. * Parse properties from a JSON object
  18350. * @param serializationObject defines the JSON object
  18351. */
  18352. parse(serializationObject: any): void;
  18353. }
  18354. }
  18355. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18356. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18357. import { Effect } from "babylonjs/Materials/effect";
  18358. import { Particle } from "babylonjs/Particles/particle";
  18359. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18360. /**
  18361. * Particle emitter emitting particles from the inside of a hemisphere.
  18362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18363. */
  18364. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18365. /**
  18366. * The radius of the emission hemisphere.
  18367. */
  18368. radius: number;
  18369. /**
  18370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18371. */
  18372. radiusRange: number;
  18373. /**
  18374. * How much to randomize the particle direction [0-1].
  18375. */
  18376. directionRandomizer: number;
  18377. /**
  18378. * Creates a new instance HemisphericParticleEmitter
  18379. * @param radius the radius of the emission hemisphere (1 by default)
  18380. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18382. */
  18383. constructor(
  18384. /**
  18385. * The radius of the emission hemisphere.
  18386. */
  18387. radius?: number,
  18388. /**
  18389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18390. */
  18391. radiusRange?: number,
  18392. /**
  18393. * How much to randomize the particle direction [0-1].
  18394. */
  18395. directionRandomizer?: number);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Called by the particle System when the position is computed for the created particle.
  18405. * @param worldMatrix is the world matrix of the particle system
  18406. * @param positionToUpdate is the position vector to update with the result
  18407. * @param particle is the particle we are computed the position for
  18408. */
  18409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18410. /**
  18411. * Clones the current emitter and returns a copy of it
  18412. * @returns the new emitter
  18413. */
  18414. clone(): HemisphericParticleEmitter;
  18415. /**
  18416. * Called by the GPUParticleSystem to setup the update shader
  18417. * @param effect defines the update shader
  18418. */
  18419. applyToShader(effect: Effect): void;
  18420. /**
  18421. * Returns a string to use to update the GPU particles update shader
  18422. * @returns a string containng the defines string
  18423. */
  18424. getEffectDefines(): string;
  18425. /**
  18426. * Returns the string "HemisphericParticleEmitter"
  18427. * @returns a string containing the class name
  18428. */
  18429. getClassName(): string;
  18430. /**
  18431. * Serializes the particle system to a JSON object.
  18432. * @returns the JSON object
  18433. */
  18434. serialize(): any;
  18435. /**
  18436. * Parse properties from a JSON object
  18437. * @param serializationObject defines the JSON object
  18438. */
  18439. parse(serializationObject: any): void;
  18440. }
  18441. }
  18442. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18443. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18444. import { Effect } from "babylonjs/Materials/effect";
  18445. import { Particle } from "babylonjs/Particles/particle";
  18446. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18447. /**
  18448. * Particle emitter emitting particles from a point.
  18449. * It emits the particles randomly between 2 given directions.
  18450. */
  18451. export class PointParticleEmitter implements IParticleEmitterType {
  18452. /**
  18453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18454. */
  18455. direction1: Vector3;
  18456. /**
  18457. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18458. */
  18459. direction2: Vector3;
  18460. /**
  18461. * Creates a new instance PointParticleEmitter
  18462. */
  18463. constructor();
  18464. /**
  18465. * Called by the particle System when the direction is computed for the created particle.
  18466. * @param worldMatrix is the world matrix of the particle system
  18467. * @param directionToUpdate is the direction vector to update with the result
  18468. * @param particle is the particle we are computed the direction for
  18469. */
  18470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18471. /**
  18472. * Called by the particle System when the position is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param positionToUpdate is the position vector to update with the result
  18475. * @param particle is the particle we are computed the position for
  18476. */
  18477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Clones the current emitter and returns a copy of it
  18480. * @returns the new emitter
  18481. */
  18482. clone(): PointParticleEmitter;
  18483. /**
  18484. * Called by the GPUParticleSystem to setup the update shader
  18485. * @param effect defines the update shader
  18486. */
  18487. applyToShader(effect: Effect): void;
  18488. /**
  18489. * Returns a string to use to update the GPU particles update shader
  18490. * @returns a string containng the defines string
  18491. */
  18492. getEffectDefines(): string;
  18493. /**
  18494. * Returns the string "PointParticleEmitter"
  18495. * @returns a string containing the class name
  18496. */
  18497. getClassName(): string;
  18498. /**
  18499. * Serializes the particle system to a JSON object.
  18500. * @returns the JSON object
  18501. */
  18502. serialize(): any;
  18503. /**
  18504. * Parse properties from a JSON object
  18505. * @param serializationObject defines the JSON object
  18506. */
  18507. parse(serializationObject: any): void;
  18508. }
  18509. }
  18510. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18511. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18512. import { Effect } from "babylonjs/Materials/effect";
  18513. import { Particle } from "babylonjs/Particles/particle";
  18514. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18515. /**
  18516. * Particle emitter emitting particles from the inside of a sphere.
  18517. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18518. */
  18519. export class SphereParticleEmitter implements IParticleEmitterType {
  18520. /**
  18521. * The radius of the emission sphere.
  18522. */
  18523. radius: number;
  18524. /**
  18525. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18526. */
  18527. radiusRange: number;
  18528. /**
  18529. * How much to randomize the particle direction [0-1].
  18530. */
  18531. directionRandomizer: number;
  18532. /**
  18533. * Creates a new instance SphereParticleEmitter
  18534. * @param radius the radius of the emission sphere (1 by default)
  18535. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18536. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18537. */
  18538. constructor(
  18539. /**
  18540. * The radius of the emission sphere.
  18541. */
  18542. radius?: number,
  18543. /**
  18544. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18545. */
  18546. radiusRange?: number,
  18547. /**
  18548. * How much to randomize the particle direction [0-1].
  18549. */
  18550. directionRandomizer?: number);
  18551. /**
  18552. * Called by the particle System when the direction is computed for the created particle.
  18553. * @param worldMatrix is the world matrix of the particle system
  18554. * @param directionToUpdate is the direction vector to update with the result
  18555. * @param particle is the particle we are computed the direction for
  18556. */
  18557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18558. /**
  18559. * Called by the particle System when the position is computed for the created particle.
  18560. * @param worldMatrix is the world matrix of the particle system
  18561. * @param positionToUpdate is the position vector to update with the result
  18562. * @param particle is the particle we are computed the position for
  18563. */
  18564. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18565. /**
  18566. * Clones the current emitter and returns a copy of it
  18567. * @returns the new emitter
  18568. */
  18569. clone(): SphereParticleEmitter;
  18570. /**
  18571. * Called by the GPUParticleSystem to setup the update shader
  18572. * @param effect defines the update shader
  18573. */
  18574. applyToShader(effect: Effect): void;
  18575. /**
  18576. * Returns a string to use to update the GPU particles update shader
  18577. * @returns a string containng the defines string
  18578. */
  18579. getEffectDefines(): string;
  18580. /**
  18581. * Returns the string "SphereParticleEmitter"
  18582. * @returns a string containing the class name
  18583. */
  18584. getClassName(): string;
  18585. /**
  18586. * Serializes the particle system to a JSON object.
  18587. * @returns the JSON object
  18588. */
  18589. serialize(): any;
  18590. /**
  18591. * Parse properties from a JSON object
  18592. * @param serializationObject defines the JSON object
  18593. */
  18594. parse(serializationObject: any): void;
  18595. }
  18596. /**
  18597. * Particle emitter emitting particles from the inside of a sphere.
  18598. * It emits the particles randomly between two vectors.
  18599. */
  18600. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18601. /**
  18602. * The min limit of the emission direction.
  18603. */
  18604. direction1: Vector3;
  18605. /**
  18606. * The max limit of the emission direction.
  18607. */
  18608. direction2: Vector3;
  18609. /**
  18610. * Creates a new instance SphereDirectedParticleEmitter
  18611. * @param radius the radius of the emission sphere (1 by default)
  18612. * @param direction1 the min limit of the emission direction (up vector by default)
  18613. * @param direction2 the max limit of the emission direction (up vector by default)
  18614. */
  18615. constructor(radius?: number,
  18616. /**
  18617. * The min limit of the emission direction.
  18618. */
  18619. direction1?: Vector3,
  18620. /**
  18621. * The max limit of the emission direction.
  18622. */
  18623. direction2?: Vector3);
  18624. /**
  18625. * Called by the particle System when the direction is computed for the created particle.
  18626. * @param worldMatrix is the world matrix of the particle system
  18627. * @param directionToUpdate is the direction vector to update with the result
  18628. * @param particle is the particle we are computed the direction for
  18629. */
  18630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18631. /**
  18632. * Clones the current emitter and returns a copy of it
  18633. * @returns the new emitter
  18634. */
  18635. clone(): SphereDirectedParticleEmitter;
  18636. /**
  18637. * Called by the GPUParticleSystem to setup the update shader
  18638. * @param effect defines the update shader
  18639. */
  18640. applyToShader(effect: Effect): void;
  18641. /**
  18642. * Returns a string to use to update the GPU particles update shader
  18643. * @returns a string containng the defines string
  18644. */
  18645. getEffectDefines(): string;
  18646. /**
  18647. * Returns the string "SphereDirectedParticleEmitter"
  18648. * @returns a string containing the class name
  18649. */
  18650. getClassName(): string;
  18651. /**
  18652. * Serializes the particle system to a JSON object.
  18653. * @returns the JSON object
  18654. */
  18655. serialize(): any;
  18656. /**
  18657. * Parse properties from a JSON object
  18658. * @param serializationObject defines the JSON object
  18659. */
  18660. parse(serializationObject: any): void;
  18661. }
  18662. }
  18663. declare module "babylonjs/Particles/EmitterTypes/index" {
  18664. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18665. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18666. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18667. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18668. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18669. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18670. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18671. }
  18672. declare module "babylonjs/Particles/IParticleSystem" {
  18673. import { Nullable } from "babylonjs/types";
  18674. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18675. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18678. import { Texture } from "babylonjs/Materials/Textures/texture";
  18679. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18680. import { Scene } from "babylonjs/scene";
  18681. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18682. import { Animation } from "babylonjs/Animations/animation";
  18683. /**
  18684. * Interface representing a particle system in Babylon.js.
  18685. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18686. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18687. */
  18688. export interface IParticleSystem {
  18689. /**
  18690. * List of animations used by the particle system.
  18691. */
  18692. animations: Animation[];
  18693. /**
  18694. * The id of the Particle system.
  18695. */
  18696. id: string;
  18697. /**
  18698. * The name of the Particle system.
  18699. */
  18700. name: string;
  18701. /**
  18702. * The emitter represents the Mesh or position we are attaching the particle system to.
  18703. */
  18704. emitter: Nullable<AbstractMesh | Vector3>;
  18705. /**
  18706. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18707. */
  18708. isBillboardBased: boolean;
  18709. /**
  18710. * The rendering group used by the Particle system to chose when to render.
  18711. */
  18712. renderingGroupId: number;
  18713. /**
  18714. * The layer mask we are rendering the particles through.
  18715. */
  18716. layerMask: number;
  18717. /**
  18718. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18719. */
  18720. updateSpeed: number;
  18721. /**
  18722. * The amount of time the particle system is running (depends of the overall update speed).
  18723. */
  18724. targetStopDuration: number;
  18725. /**
  18726. * The texture used to render each particle. (this can be a spritesheet)
  18727. */
  18728. particleTexture: Nullable<Texture>;
  18729. /**
  18730. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18731. */
  18732. blendMode: number;
  18733. /**
  18734. * Minimum life time of emitting particles.
  18735. */
  18736. minLifeTime: number;
  18737. /**
  18738. * Maximum life time of emitting particles.
  18739. */
  18740. maxLifeTime: number;
  18741. /**
  18742. * Minimum Size of emitting particles.
  18743. */
  18744. minSize: number;
  18745. /**
  18746. * Maximum Size of emitting particles.
  18747. */
  18748. maxSize: number;
  18749. /**
  18750. * Minimum scale of emitting particles on X axis.
  18751. */
  18752. minScaleX: number;
  18753. /**
  18754. * Maximum scale of emitting particles on X axis.
  18755. */
  18756. maxScaleX: number;
  18757. /**
  18758. * Minimum scale of emitting particles on Y axis.
  18759. */
  18760. minScaleY: number;
  18761. /**
  18762. * Maximum scale of emitting particles on Y axis.
  18763. */
  18764. maxScaleY: number;
  18765. /**
  18766. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18767. */
  18768. color1: Color4;
  18769. /**
  18770. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18771. */
  18772. color2: Color4;
  18773. /**
  18774. * Color the particle will have at the end of its lifetime.
  18775. */
  18776. colorDead: Color4;
  18777. /**
  18778. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18779. */
  18780. emitRate: number;
  18781. /**
  18782. * You can use gravity if you want to give an orientation to your particles.
  18783. */
  18784. gravity: Vector3;
  18785. /**
  18786. * Minimum power of emitting particles.
  18787. */
  18788. minEmitPower: number;
  18789. /**
  18790. * Maximum power of emitting particles.
  18791. */
  18792. maxEmitPower: number;
  18793. /**
  18794. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18795. */
  18796. minAngularSpeed: number;
  18797. /**
  18798. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18799. */
  18800. maxAngularSpeed: number;
  18801. /**
  18802. * Gets or sets the minimal initial rotation in radians.
  18803. */
  18804. minInitialRotation: number;
  18805. /**
  18806. * Gets or sets the maximal initial rotation in radians.
  18807. */
  18808. maxInitialRotation: number;
  18809. /**
  18810. * The particle emitter type defines the emitter used by the particle system.
  18811. * It can be for example box, sphere, or cone...
  18812. */
  18813. particleEmitterType: Nullable<IParticleEmitterType>;
  18814. /**
  18815. * Defines the delay in milliseconds before starting the system (0 by default)
  18816. */
  18817. startDelay: number;
  18818. /**
  18819. * 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
  18820. */
  18821. preWarmCycles: number;
  18822. /**
  18823. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18824. */
  18825. preWarmStepOffset: number;
  18826. /**
  18827. * 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)
  18828. */
  18829. spriteCellChangeSpeed: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18832. */
  18833. startSpriteCellID: number;
  18834. /**
  18835. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18836. */
  18837. endSpriteCellID: number;
  18838. /**
  18839. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18840. */
  18841. spriteCellWidth: number;
  18842. /**
  18843. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18844. */
  18845. spriteCellHeight: number;
  18846. /**
  18847. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18848. */
  18849. spriteRandomStartCell: boolean;
  18850. /**
  18851. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18852. */
  18853. isAnimationSheetEnabled: boolean;
  18854. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18855. translationPivot: Vector2;
  18856. /**
  18857. * Gets or sets a texture used to add random noise to particle positions
  18858. */
  18859. noiseTexture: Nullable<BaseTexture>;
  18860. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18861. noiseStrength: Vector3;
  18862. /**
  18863. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18864. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18865. */
  18866. billboardMode: number;
  18867. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18868. limitVelocityDamping: number;
  18869. /**
  18870. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18871. */
  18872. beginAnimationOnStart: boolean;
  18873. /**
  18874. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18875. */
  18876. beginAnimationFrom: number;
  18877. /**
  18878. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18879. */
  18880. beginAnimationTo: number;
  18881. /**
  18882. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18883. */
  18884. beginAnimationLoop: boolean;
  18885. /**
  18886. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18887. */
  18888. disposeOnStop: boolean;
  18889. /**
  18890. * Gets the maximum number of particles active at the same time.
  18891. * @returns The max number of active particles.
  18892. */
  18893. getCapacity(): number;
  18894. /**
  18895. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18896. * @returns True if it has been started, otherwise false.
  18897. */
  18898. isStarted(): boolean;
  18899. /**
  18900. * Animates the particle system for this frame.
  18901. */
  18902. animate(): void;
  18903. /**
  18904. * Renders the particle system in its current state.
  18905. * @returns the current number of particles
  18906. */
  18907. render(): number;
  18908. /**
  18909. * Dispose the particle system and frees its associated resources.
  18910. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18911. */
  18912. dispose(disposeTexture?: boolean): void;
  18913. /**
  18914. * Clones the particle system.
  18915. * @param name The name of the cloned object
  18916. * @param newEmitter The new emitter to use
  18917. * @returns the cloned particle system
  18918. */
  18919. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18920. /**
  18921. * Serializes the particle system to a JSON object.
  18922. * @returns the JSON object
  18923. */
  18924. serialize(): any;
  18925. /**
  18926. * Rebuild the particle system
  18927. */
  18928. rebuild(): void;
  18929. /**
  18930. * Starts the particle system and begins to emit
  18931. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18932. */
  18933. start(delay?: number): void;
  18934. /**
  18935. * Stops the particle system.
  18936. */
  18937. stop(): void;
  18938. /**
  18939. * Remove all active particles
  18940. */
  18941. reset(): void;
  18942. /**
  18943. * Is this system ready to be used/rendered
  18944. * @return true if the system is ready
  18945. */
  18946. isReady(): boolean;
  18947. /**
  18948. * Adds a new color gradient
  18949. * @param gradient defines the gradient to use (between 0 and 1)
  18950. * @param color1 defines the color to affect to the specified gradient
  18951. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18952. * @returns the current particle system
  18953. */
  18954. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18955. /**
  18956. * Remove a specific color gradient
  18957. * @param gradient defines the gradient to remove
  18958. * @returns the current particle system
  18959. */
  18960. removeColorGradient(gradient: number): IParticleSystem;
  18961. /**
  18962. * Adds a new size gradient
  18963. * @param gradient defines the gradient to use (between 0 and 1)
  18964. * @param factor defines the size factor to affect to the specified gradient
  18965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18966. * @returns the current particle system
  18967. */
  18968. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18969. /**
  18970. * Remove a specific size gradient
  18971. * @param gradient defines the gradient to remove
  18972. * @returns the current particle system
  18973. */
  18974. removeSizeGradient(gradient: number): IParticleSystem;
  18975. /**
  18976. * Gets the current list of color gradients.
  18977. * You must use addColorGradient and removeColorGradient to udpate this list
  18978. * @returns the list of color gradients
  18979. */
  18980. getColorGradients(): Nullable<Array<ColorGradient>>;
  18981. /**
  18982. * Gets the current list of size gradients.
  18983. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18984. * @returns the list of size gradients
  18985. */
  18986. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Gets the current list of angular speed gradients.
  18989. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18990. * @returns the list of angular speed gradients
  18991. */
  18992. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18993. /**
  18994. * Adds a new angular speed gradient
  18995. * @param gradient defines the gradient to use (between 0 and 1)
  18996. * @param factor defines the angular speed to affect to the specified gradient
  18997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18998. * @returns the current particle system
  18999. */
  19000. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19001. /**
  19002. * Remove a specific angular speed gradient
  19003. * @param gradient defines the gradient to remove
  19004. * @returns the current particle system
  19005. */
  19006. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19007. /**
  19008. * Gets the current list of velocity gradients.
  19009. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19010. * @returns the list of velocity gradients
  19011. */
  19012. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19013. /**
  19014. * Adds a new velocity gradient
  19015. * @param gradient defines the gradient to use (between 0 and 1)
  19016. * @param factor defines the velocity to affect to the specified gradient
  19017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19018. * @returns the current particle system
  19019. */
  19020. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19021. /**
  19022. * Remove a specific velocity gradient
  19023. * @param gradient defines the gradient to remove
  19024. * @returns the current particle system
  19025. */
  19026. removeVelocityGradient(gradient: number): IParticleSystem;
  19027. /**
  19028. * Gets the current list of limit velocity gradients.
  19029. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19030. * @returns the list of limit velocity gradients
  19031. */
  19032. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19033. /**
  19034. * Adds a new limit velocity gradient
  19035. * @param gradient defines the gradient to use (between 0 and 1)
  19036. * @param factor defines the limit velocity to affect to the specified gradient
  19037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19038. * @returns the current particle system
  19039. */
  19040. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19041. /**
  19042. * Remove a specific limit velocity gradient
  19043. * @param gradient defines the gradient to remove
  19044. * @returns the current particle system
  19045. */
  19046. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19047. /**
  19048. * Adds a new drag gradient
  19049. * @param gradient defines the gradient to use (between 0 and 1)
  19050. * @param factor defines the drag to affect to the specified gradient
  19051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19052. * @returns the current particle system
  19053. */
  19054. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19055. /**
  19056. * Remove a specific drag gradient
  19057. * @param gradient defines the gradient to remove
  19058. * @returns the current particle system
  19059. */
  19060. removeDragGradient(gradient: number): IParticleSystem;
  19061. /**
  19062. * Gets the current list of drag gradients.
  19063. * You must use addDragGradient and removeDragGradient to udpate this list
  19064. * @returns the list of drag gradients
  19065. */
  19066. getDragGradients(): Nullable<Array<FactorGradient>>;
  19067. /**
  19068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19069. * @param gradient defines the gradient to use (between 0 and 1)
  19070. * @param factor defines the emit rate to affect to the specified gradient
  19071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19072. * @returns the current particle system
  19073. */
  19074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19075. /**
  19076. * Remove a specific emit rate gradient
  19077. * @param gradient defines the gradient to remove
  19078. * @returns the current particle system
  19079. */
  19080. removeEmitRateGradient(gradient: number): IParticleSystem;
  19081. /**
  19082. * Gets the current list of emit rate gradients.
  19083. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19084. * @returns the list of emit rate gradients
  19085. */
  19086. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19087. /**
  19088. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19089. * @param gradient defines the gradient to use (between 0 and 1)
  19090. * @param factor defines the start size to affect to the specified gradient
  19091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19092. * @returns the current particle system
  19093. */
  19094. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19095. /**
  19096. * Remove a specific start size gradient
  19097. * @param gradient defines the gradient to remove
  19098. * @returns the current particle system
  19099. */
  19100. removeStartSizeGradient(gradient: number): IParticleSystem;
  19101. /**
  19102. * Gets the current list of start size gradients.
  19103. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19104. * @returns the list of start size gradients
  19105. */
  19106. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19107. /**
  19108. * Adds a new life time gradient
  19109. * @param gradient defines the gradient to use (between 0 and 1)
  19110. * @param factor defines the life time factor to affect to the specified gradient
  19111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19112. * @returns the current particle system
  19113. */
  19114. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19115. /**
  19116. * Remove a specific life time gradient
  19117. * @param gradient defines the gradient to remove
  19118. * @returns the current particle system
  19119. */
  19120. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19121. /**
  19122. * Gets the current list of life time gradients.
  19123. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19124. * @returns the list of life time gradients
  19125. */
  19126. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19127. /**
  19128. * Gets the current list of color gradients.
  19129. * You must use addColorGradient and removeColorGradient to udpate this list
  19130. * @returns the list of color gradients
  19131. */
  19132. getColorGradients(): Nullable<Array<ColorGradient>>;
  19133. /**
  19134. * Adds a new ramp gradient used to remap particle colors
  19135. * @param gradient defines the gradient to use (between 0 and 1)
  19136. * @param color defines the color to affect to the specified gradient
  19137. * @returns the current particle system
  19138. */
  19139. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19140. /**
  19141. * Gets the current list of ramp gradients.
  19142. * You must use addRampGradient and removeRampGradient to udpate this list
  19143. * @returns the list of ramp gradients
  19144. */
  19145. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19146. /** Gets or sets a boolean indicating that ramp gradients must be used
  19147. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19148. */
  19149. useRampGradients: boolean;
  19150. /**
  19151. * Adds a new color remap gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param min defines the color remap minimal range
  19154. * @param max defines the color remap maximal range
  19155. * @returns the current particle system
  19156. */
  19157. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19158. /**
  19159. * Gets the current list of color remap gradients.
  19160. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19161. * @returns the list of color remap gradients
  19162. */
  19163. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19164. /**
  19165. * Adds a new alpha remap gradient
  19166. * @param gradient defines the gradient to use (between 0 and 1)
  19167. * @param min defines the alpha remap minimal range
  19168. * @param max defines the alpha remap maximal range
  19169. * @returns the current particle system
  19170. */
  19171. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19172. /**
  19173. * Gets the current list of alpha remap gradients.
  19174. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19175. * @returns the list of alpha remap gradients
  19176. */
  19177. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19178. /**
  19179. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19182. * @returns the emitter
  19183. */
  19184. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19185. /**
  19186. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19187. * @param radius The radius of the hemisphere to emit from
  19188. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19189. * @returns the emitter
  19190. */
  19191. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19192. /**
  19193. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19194. * @param radius The radius of the sphere to emit from
  19195. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19196. * @returns the emitter
  19197. */
  19198. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19199. /**
  19200. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19201. * @param radius The radius of the sphere to emit from
  19202. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19203. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19204. * @returns the emitter
  19205. */
  19206. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19207. /**
  19208. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19209. * @param radius The radius of the emission cylinder
  19210. * @param height The height of the emission cylinder
  19211. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19212. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19213. * @returns the emitter
  19214. */
  19215. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19216. /**
  19217. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19218. * @param radius The radius of the cylinder to emit from
  19219. * @param height The height of the emission cylinder
  19220. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19223. * @returns the emitter
  19224. */
  19225. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19226. /**
  19227. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19228. * @param radius The radius of the cone to emit from
  19229. * @param angle The base angle of the cone
  19230. * @returns the emitter
  19231. */
  19232. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19233. /**
  19234. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19237. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19238. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19239. * @returns the emitter
  19240. */
  19241. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19242. /**
  19243. * Get hosting scene
  19244. * @returns the scene
  19245. */
  19246. getScene(): Scene;
  19247. }
  19248. }
  19249. declare module "babylonjs/Meshes/instancedMesh" {
  19250. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19251. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19252. import { Camera } from "babylonjs/Cameras/camera";
  19253. import { Node } from "babylonjs/node";
  19254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19255. import { Mesh } from "babylonjs/Meshes/mesh";
  19256. import { Material } from "babylonjs/Materials/material";
  19257. import { Skeleton } from "babylonjs/Bones/skeleton";
  19258. import { Light } from "babylonjs/Lights/light";
  19259. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19260. /**
  19261. * Creates an instance based on a source mesh.
  19262. */
  19263. export class InstancedMesh extends AbstractMesh {
  19264. private _sourceMesh;
  19265. private _currentLOD;
  19266. /** @hidden */
  19267. _indexInSourceMeshInstanceArray: number;
  19268. constructor(name: string, source: Mesh);
  19269. /**
  19270. * Returns the string "InstancedMesh".
  19271. */
  19272. getClassName(): string;
  19273. /** Gets the list of lights affecting that mesh */
  19274. readonly lightSources: Light[];
  19275. _resyncLightSources(): void;
  19276. _resyncLighSource(light: Light): void;
  19277. _removeLightSource(light: Light, dispose: boolean): void;
  19278. /**
  19279. * If the source mesh receives shadows
  19280. */
  19281. readonly receiveShadows: boolean;
  19282. /**
  19283. * The material of the source mesh
  19284. */
  19285. readonly material: Nullable<Material>;
  19286. /**
  19287. * Visibility of the source mesh
  19288. */
  19289. readonly visibility: number;
  19290. /**
  19291. * Skeleton of the source mesh
  19292. */
  19293. readonly skeleton: Nullable<Skeleton>;
  19294. /**
  19295. * Rendering ground id of the source mesh
  19296. */
  19297. renderingGroupId: number;
  19298. /**
  19299. * Returns the total number of vertices (integer).
  19300. */
  19301. getTotalVertices(): number;
  19302. /**
  19303. * Returns a positive integer : the total number of indices in this mesh geometry.
  19304. * @returns the numner of indices or zero if the mesh has no geometry.
  19305. */
  19306. getTotalIndices(): number;
  19307. /**
  19308. * The source mesh of the instance
  19309. */
  19310. readonly sourceMesh: Mesh;
  19311. /**
  19312. * Is this node ready to be used/rendered
  19313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19314. * @return {boolean} is it ready
  19315. */
  19316. isReady(completeCheck?: boolean): boolean;
  19317. /**
  19318. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19319. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19320. * @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.
  19321. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19322. */
  19323. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19324. /**
  19325. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19326. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19327. * The `data` are either a numeric array either a Float32Array.
  19328. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19329. * 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).
  19330. * Note that a new underlying VertexBuffer object is created each call.
  19331. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19332. *
  19333. * Possible `kind` values :
  19334. * - VertexBuffer.PositionKind
  19335. * - VertexBuffer.UVKind
  19336. * - VertexBuffer.UV2Kind
  19337. * - VertexBuffer.UV3Kind
  19338. * - VertexBuffer.UV4Kind
  19339. * - VertexBuffer.UV5Kind
  19340. * - VertexBuffer.UV6Kind
  19341. * - VertexBuffer.ColorKind
  19342. * - VertexBuffer.MatricesIndicesKind
  19343. * - VertexBuffer.MatricesIndicesExtraKind
  19344. * - VertexBuffer.MatricesWeightsKind
  19345. * - VertexBuffer.MatricesWeightsExtraKind
  19346. *
  19347. * Returns the Mesh.
  19348. */
  19349. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19350. /**
  19351. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19352. * If the mesh has no geometry, it is simply returned as it is.
  19353. * The `data` are either a numeric array either a Float32Array.
  19354. * No new underlying VertexBuffer object is created.
  19355. * 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.
  19356. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19357. *
  19358. * Possible `kind` values :
  19359. * - VertexBuffer.PositionKind
  19360. * - VertexBuffer.UVKind
  19361. * - VertexBuffer.UV2Kind
  19362. * - VertexBuffer.UV3Kind
  19363. * - VertexBuffer.UV4Kind
  19364. * - VertexBuffer.UV5Kind
  19365. * - VertexBuffer.UV6Kind
  19366. * - VertexBuffer.ColorKind
  19367. * - VertexBuffer.MatricesIndicesKind
  19368. * - VertexBuffer.MatricesIndicesExtraKind
  19369. * - VertexBuffer.MatricesWeightsKind
  19370. * - VertexBuffer.MatricesWeightsExtraKind
  19371. *
  19372. * Returns the Mesh.
  19373. */
  19374. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19375. /**
  19376. * Sets the mesh indices.
  19377. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19378. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19379. * This method creates a new index buffer each call.
  19380. * Returns the Mesh.
  19381. */
  19382. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19383. /**
  19384. * Boolean : True if the mesh owns the requested kind of data.
  19385. */
  19386. isVerticesDataPresent(kind: string): boolean;
  19387. /**
  19388. * Returns an array of indices (IndicesArray).
  19389. */
  19390. getIndices(): Nullable<IndicesArray>;
  19391. readonly _positions: Nullable<Vector3[]>;
  19392. /**
  19393. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19394. * This means the mesh underlying bounding box and sphere are recomputed.
  19395. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19396. * @returns the current mesh
  19397. */
  19398. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19399. /** @hidden */
  19400. _preActivate(): InstancedMesh;
  19401. /** @hidden */
  19402. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19403. /** @hidden */
  19404. _postActivate(): void;
  19405. getWorldMatrix(): Matrix;
  19406. readonly isAnInstance: boolean;
  19407. /**
  19408. * Returns the current associated LOD AbstractMesh.
  19409. */
  19410. getLOD(camera: Camera): AbstractMesh;
  19411. /** @hidden */
  19412. _syncSubMeshes(): InstancedMesh;
  19413. /** @hidden */
  19414. _generatePointsArray(): boolean;
  19415. /**
  19416. * Creates a new InstancedMesh from the current mesh.
  19417. * - name (string) : the cloned mesh name
  19418. * - newParent (optional Node) : the optional Node to parent the clone to.
  19419. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19420. *
  19421. * Returns the clone.
  19422. */
  19423. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19424. /**
  19425. * Disposes the InstancedMesh.
  19426. * Returns nothing.
  19427. */
  19428. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19429. }
  19430. module "babylonjs/Meshes/mesh" {
  19431. interface Mesh {
  19432. /**
  19433. * Register a custom buffer that will be instanced
  19434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19435. * @param kind defines the buffer kind
  19436. * @param stride defines the stride in floats
  19437. */
  19438. registerInstancedBuffer(kind: string, stride: number): void;
  19439. /** @hidden */
  19440. _userInstancedBuffersStorage: {
  19441. data: {
  19442. [key: string]: Float32Array;
  19443. };
  19444. sizes: {
  19445. [key: string]: number;
  19446. };
  19447. vertexBuffers: {
  19448. [key: string]: Nullable<VertexBuffer>;
  19449. };
  19450. strides: {
  19451. [key: string]: number;
  19452. };
  19453. };
  19454. }
  19455. }
  19456. module "babylonjs/Meshes/abstractMesh" {
  19457. interface AbstractMesh {
  19458. /**
  19459. * Object used to store instanced buffers defined by user
  19460. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19461. */
  19462. instancedBuffers: {
  19463. [key: string]: any;
  19464. };
  19465. }
  19466. }
  19467. }
  19468. declare module "babylonjs/Materials/shaderMaterial" {
  19469. import { Scene } from "babylonjs/scene";
  19470. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19472. import { Mesh } from "babylonjs/Meshes/mesh";
  19473. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19475. import { Texture } from "babylonjs/Materials/Textures/texture";
  19476. import { Material } from "babylonjs/Materials/material";
  19477. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19478. /**
  19479. * Defines the options associated with the creation of a shader material.
  19480. */
  19481. export interface IShaderMaterialOptions {
  19482. /**
  19483. * Does the material work in alpha blend mode
  19484. */
  19485. needAlphaBlending: boolean;
  19486. /**
  19487. * Does the material work in alpha test mode
  19488. */
  19489. needAlphaTesting: boolean;
  19490. /**
  19491. * The list of attribute names used in the shader
  19492. */
  19493. attributes: string[];
  19494. /**
  19495. * The list of unifrom names used in the shader
  19496. */
  19497. uniforms: string[];
  19498. /**
  19499. * The list of UBO names used in the shader
  19500. */
  19501. uniformBuffers: string[];
  19502. /**
  19503. * The list of sampler names used in the shader
  19504. */
  19505. samplers: string[];
  19506. /**
  19507. * The list of defines used in the shader
  19508. */
  19509. defines: string[];
  19510. }
  19511. /**
  19512. * 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.
  19513. *
  19514. * This returned material effects how the mesh will look based on the code in the shaders.
  19515. *
  19516. * @see http://doc.babylonjs.com/how_to/shader_material
  19517. */
  19518. export class ShaderMaterial extends Material {
  19519. private _shaderPath;
  19520. private _options;
  19521. private _textures;
  19522. private _textureArrays;
  19523. private _floats;
  19524. private _ints;
  19525. private _floatsArrays;
  19526. private _colors3;
  19527. private _colors3Arrays;
  19528. private _colors4;
  19529. private _colors4Arrays;
  19530. private _vectors2;
  19531. private _vectors3;
  19532. private _vectors4;
  19533. private _matrices;
  19534. private _matrices3x3;
  19535. private _matrices2x2;
  19536. private _vectors2Arrays;
  19537. private _vectors3Arrays;
  19538. private _vectors4Arrays;
  19539. private _cachedWorldViewMatrix;
  19540. private _cachedWorldViewProjectionMatrix;
  19541. private _renderId;
  19542. /**
  19543. * Instantiate a new shader material.
  19544. * 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.
  19545. * This returned material effects how the mesh will look based on the code in the shaders.
  19546. * @see http://doc.babylonjs.com/how_to/shader_material
  19547. * @param name Define the name of the material in the scene
  19548. * @param scene Define the scene the material belongs to
  19549. * @param shaderPath Defines the route to the shader code in one of three ways:
  19550. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19551. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19552. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19553. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19554. * @param options Define the options used to create the shader
  19555. */
  19556. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19557. /**
  19558. * Gets the options used to compile the shader.
  19559. * They can be modified to trigger a new compilation
  19560. */
  19561. readonly options: IShaderMaterialOptions;
  19562. /**
  19563. * Gets the current class name of the material e.g. "ShaderMaterial"
  19564. * Mainly use in serialization.
  19565. * @returns the class name
  19566. */
  19567. getClassName(): string;
  19568. /**
  19569. * Specifies if the material will require alpha blending
  19570. * @returns a boolean specifying if alpha blending is needed
  19571. */
  19572. needAlphaBlending(): boolean;
  19573. /**
  19574. * Specifies if this material should be rendered in alpha test mode
  19575. * @returns a boolean specifying if an alpha test is needed.
  19576. */
  19577. needAlphaTesting(): boolean;
  19578. private _checkUniform;
  19579. /**
  19580. * Set a texture in the shader.
  19581. * @param name Define the name of the uniform samplers as defined in the shader
  19582. * @param texture Define the texture to bind to this sampler
  19583. * @return the material itself allowing "fluent" like uniform updates
  19584. */
  19585. setTexture(name: string, texture: Texture): ShaderMaterial;
  19586. /**
  19587. * Set a texture array in the shader.
  19588. * @param name Define the name of the uniform sampler array as defined in the shader
  19589. * @param textures Define the list of textures to bind to this sampler
  19590. * @return the material itself allowing "fluent" like uniform updates
  19591. */
  19592. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19593. /**
  19594. * Set a float in the shader.
  19595. * @param name Define the name of the uniform as defined in the shader
  19596. * @param value Define the value to give to the uniform
  19597. * @return the material itself allowing "fluent" like uniform updates
  19598. */
  19599. setFloat(name: string, value: number): ShaderMaterial;
  19600. /**
  19601. * Set a int in the shader.
  19602. * @param name Define the name of the uniform as defined in the shader
  19603. * @param value Define the value to give to the uniform
  19604. * @return the material itself allowing "fluent" like uniform updates
  19605. */
  19606. setInt(name: string, value: number): ShaderMaterial;
  19607. /**
  19608. * Set an array of floats in the shader.
  19609. * @param name Define the name of the uniform as defined in the shader
  19610. * @param value Define the value to give to the uniform
  19611. * @return the material itself allowing "fluent" like uniform updates
  19612. */
  19613. setFloats(name: string, value: number[]): ShaderMaterial;
  19614. /**
  19615. * Set a vec3 in the shader from a Color3.
  19616. * @param name Define the name of the uniform as defined in the shader
  19617. * @param value Define the value to give to the uniform
  19618. * @return the material itself allowing "fluent" like uniform updates
  19619. */
  19620. setColor3(name: string, value: Color3): ShaderMaterial;
  19621. /**
  19622. * Set a vec3 array in the shader from a Color3 array.
  19623. * @param name Define the name of the uniform as defined in the shader
  19624. * @param value Define the value to give to the uniform
  19625. * @return the material itself allowing "fluent" like uniform updates
  19626. */
  19627. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19628. /**
  19629. * Set a vec4 in the shader from a Color4.
  19630. * @param name Define the name of the uniform as defined in the shader
  19631. * @param value Define the value to give to the uniform
  19632. * @return the material itself allowing "fluent" like uniform updates
  19633. */
  19634. setColor4(name: string, value: Color4): ShaderMaterial;
  19635. /**
  19636. * Set a vec4 array in the shader from a Color4 array.
  19637. * @param name Define the name of the uniform as defined in the shader
  19638. * @param value Define the value to give to the uniform
  19639. * @return the material itself allowing "fluent" like uniform updates
  19640. */
  19641. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19642. /**
  19643. * Set a vec2 in the shader from a Vector2.
  19644. * @param name Define the name of the uniform as defined in the shader
  19645. * @param value Define the value to give to the uniform
  19646. * @return the material itself allowing "fluent" like uniform updates
  19647. */
  19648. setVector2(name: string, value: Vector2): ShaderMaterial;
  19649. /**
  19650. * Set a vec3 in the shader from a Vector3.
  19651. * @param name Define the name of the uniform as defined in the shader
  19652. * @param value Define the value to give to the uniform
  19653. * @return the material itself allowing "fluent" like uniform updates
  19654. */
  19655. setVector3(name: string, value: Vector3): ShaderMaterial;
  19656. /**
  19657. * Set a vec4 in the shader from a Vector4.
  19658. * @param name Define the name of the uniform as defined in the shader
  19659. * @param value Define the value to give to the uniform
  19660. * @return the material itself allowing "fluent" like uniform updates
  19661. */
  19662. setVector4(name: string, value: Vector4): ShaderMaterial;
  19663. /**
  19664. * Set a mat4 in the shader from a Matrix.
  19665. * @param name Define the name of the uniform as defined in the shader
  19666. * @param value Define the value to give to the uniform
  19667. * @return the material itself allowing "fluent" like uniform updates
  19668. */
  19669. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19670. /**
  19671. * Set a mat3 in the shader from a Float32Array.
  19672. * @param name Define the name of the uniform as defined in the shader
  19673. * @param value Define the value to give to the uniform
  19674. * @return the material itself allowing "fluent" like uniform updates
  19675. */
  19676. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19677. /**
  19678. * Set a mat2 in the shader from a Float32Array.
  19679. * @param name Define the name of the uniform as defined in the shader
  19680. * @param value Define the value to give to the uniform
  19681. * @return the material itself allowing "fluent" like uniform updates
  19682. */
  19683. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19684. /**
  19685. * Set a vec2 array in the shader from a number array.
  19686. * @param name Define the name of the uniform as defined in the shader
  19687. * @param value Define the value to give to the uniform
  19688. * @return the material itself allowing "fluent" like uniform updates
  19689. */
  19690. setArray2(name: string, value: number[]): ShaderMaterial;
  19691. /**
  19692. * Set a vec3 array in the shader from a number array.
  19693. * @param name Define the name of the uniform as defined in the shader
  19694. * @param value Define the value to give to the uniform
  19695. * @return the material itself allowing "fluent" like uniform updates
  19696. */
  19697. setArray3(name: string, value: number[]): ShaderMaterial;
  19698. /**
  19699. * Set a vec4 array in the shader from a number array.
  19700. * @param name Define the name of the uniform as defined in the shader
  19701. * @param value Define the value to give to the uniform
  19702. * @return the material itself allowing "fluent" like uniform updates
  19703. */
  19704. setArray4(name: string, value: number[]): ShaderMaterial;
  19705. private _checkCache;
  19706. /**
  19707. * Specifies that the submesh is ready to be used
  19708. * @param mesh defines the mesh to check
  19709. * @param subMesh defines which submesh to check
  19710. * @param useInstances specifies that instances should be used
  19711. * @returns a boolean indicating that the submesh is ready or not
  19712. */
  19713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19714. /**
  19715. * Checks if the material is ready to render the requested mesh
  19716. * @param mesh Define the mesh to render
  19717. * @param useInstances Define whether or not the material is used with instances
  19718. * @returns true if ready, otherwise false
  19719. */
  19720. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19721. /**
  19722. * Binds the world matrix to the material
  19723. * @param world defines the world transformation matrix
  19724. */
  19725. bindOnlyWorldMatrix(world: Matrix): void;
  19726. /**
  19727. * Binds the material to the mesh
  19728. * @param world defines the world transformation matrix
  19729. * @param mesh defines the mesh to bind the material to
  19730. */
  19731. bind(world: Matrix, mesh?: Mesh): void;
  19732. /**
  19733. * Gets the active textures from the material
  19734. * @returns an array of textures
  19735. */
  19736. getActiveTextures(): BaseTexture[];
  19737. /**
  19738. * Specifies if the material uses a texture
  19739. * @param texture defines the texture to check against the material
  19740. * @returns a boolean specifying if the material uses the texture
  19741. */
  19742. hasTexture(texture: BaseTexture): boolean;
  19743. /**
  19744. * Makes a duplicate of the material, and gives it a new name
  19745. * @param name defines the new name for the duplicated material
  19746. * @returns the cloned material
  19747. */
  19748. clone(name: string): ShaderMaterial;
  19749. /**
  19750. * Disposes the material
  19751. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19752. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19753. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19754. */
  19755. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19756. /**
  19757. * Serializes this material in a JSON representation
  19758. * @returns the serialized material object
  19759. */
  19760. serialize(): any;
  19761. /**
  19762. * Creates a shader material from parsed shader material data
  19763. * @param source defines the JSON represnetation of the material
  19764. * @param scene defines the hosting scene
  19765. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19766. * @returns a new material
  19767. */
  19768. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19769. }
  19770. }
  19771. declare module "babylonjs/Shaders/color.fragment" {
  19772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19773. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19774. /** @hidden */
  19775. export var colorPixelShader: {
  19776. name: string;
  19777. shader: string;
  19778. };
  19779. }
  19780. declare module "babylonjs/Shaders/color.vertex" {
  19781. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19782. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19784. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19785. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19786. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19787. /** @hidden */
  19788. export var colorVertexShader: {
  19789. name: string;
  19790. shader: string;
  19791. };
  19792. }
  19793. declare module "babylonjs/Meshes/linesMesh" {
  19794. import { Nullable } from "babylonjs/types";
  19795. import { Scene } from "babylonjs/scene";
  19796. import { Color3 } from "babylonjs/Maths/math.color";
  19797. import { Node } from "babylonjs/node";
  19798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19799. import { Mesh } from "babylonjs/Meshes/mesh";
  19800. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19801. import { Effect } from "babylonjs/Materials/effect";
  19802. import { Material } from "babylonjs/Materials/material";
  19803. import "babylonjs/Shaders/color.fragment";
  19804. import "babylonjs/Shaders/color.vertex";
  19805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19806. /**
  19807. * Line mesh
  19808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19809. */
  19810. export class LinesMesh extends Mesh {
  19811. /**
  19812. * If vertex color should be applied to the mesh
  19813. */
  19814. readonly useVertexColor?: boolean | undefined;
  19815. /**
  19816. * If vertex alpha should be applied to the mesh
  19817. */
  19818. readonly useVertexAlpha?: boolean | undefined;
  19819. /**
  19820. * Color of the line (Default: White)
  19821. */
  19822. color: Color3;
  19823. /**
  19824. * Alpha of the line (Default: 1)
  19825. */
  19826. alpha: number;
  19827. /**
  19828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19829. * This margin is expressed in world space coordinates, so its value may vary.
  19830. * Default value is 0.1
  19831. */
  19832. intersectionThreshold: number;
  19833. private _colorShader;
  19834. private color4;
  19835. /**
  19836. * Creates a new LinesMesh
  19837. * @param name defines the name
  19838. * @param scene defines the hosting scene
  19839. * @param parent defines the parent mesh if any
  19840. * @param source defines the optional source LinesMesh used to clone data from
  19841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19842. * When false, achieved by calling a clone(), also passing False.
  19843. * This will make creation of children, recursive.
  19844. * @param useVertexColor defines if this LinesMesh supports vertex color
  19845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19846. */
  19847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19848. /**
  19849. * If vertex color should be applied to the mesh
  19850. */
  19851. useVertexColor?: boolean | undefined,
  19852. /**
  19853. * If vertex alpha should be applied to the mesh
  19854. */
  19855. useVertexAlpha?: boolean | undefined);
  19856. private _addClipPlaneDefine;
  19857. private _removeClipPlaneDefine;
  19858. isReady(): boolean;
  19859. /**
  19860. * Returns the string "LineMesh"
  19861. */
  19862. getClassName(): string;
  19863. /**
  19864. * @hidden
  19865. */
  19866. /**
  19867. * @hidden
  19868. */
  19869. material: Material;
  19870. /**
  19871. * @hidden
  19872. */
  19873. readonly checkCollisions: boolean;
  19874. /** @hidden */
  19875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19876. /** @hidden */
  19877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19878. /**
  19879. * Disposes of the line mesh
  19880. * @param doNotRecurse If children should be disposed
  19881. */
  19882. dispose(doNotRecurse?: boolean): void;
  19883. /**
  19884. * Returns a new LineMesh object cloned from the current one.
  19885. */
  19886. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19887. /**
  19888. * Creates a new InstancedLinesMesh object from the mesh model.
  19889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19890. * @param name defines the name of the new instance
  19891. * @returns a new InstancedLinesMesh
  19892. */
  19893. createInstance(name: string): InstancedLinesMesh;
  19894. }
  19895. /**
  19896. * Creates an instance based on a source LinesMesh
  19897. */
  19898. export class InstancedLinesMesh extends InstancedMesh {
  19899. /**
  19900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19901. * This margin is expressed in world space coordinates, so its value may vary.
  19902. * Initilized with the intersectionThreshold value of the source LinesMesh
  19903. */
  19904. intersectionThreshold: number;
  19905. constructor(name: string, source: LinesMesh);
  19906. /**
  19907. * Returns the string "InstancedLinesMesh".
  19908. */
  19909. getClassName(): string;
  19910. }
  19911. }
  19912. declare module "babylonjs/Shaders/line.fragment" {
  19913. /** @hidden */
  19914. export var linePixelShader: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module "babylonjs/Shaders/line.vertex" {
  19920. /** @hidden */
  19921. export var lineVertexShader: {
  19922. name: string;
  19923. shader: string;
  19924. };
  19925. }
  19926. declare module "babylonjs/Rendering/edgesRenderer" {
  19927. import { Nullable } from "babylonjs/types";
  19928. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19930. import { Vector3 } from "babylonjs/Maths/math.vector";
  19931. import { IDisposable } from "babylonjs/scene";
  19932. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19933. import "babylonjs/Shaders/line.fragment";
  19934. import "babylonjs/Shaders/line.vertex";
  19935. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19936. module "babylonjs/Meshes/abstractMesh" {
  19937. interface AbstractMesh {
  19938. /**
  19939. * Gets the edgesRenderer associated with the mesh
  19940. */
  19941. edgesRenderer: Nullable<EdgesRenderer>;
  19942. }
  19943. }
  19944. module "babylonjs/Meshes/linesMesh" {
  19945. interface LinesMesh {
  19946. /**
  19947. * Enables the edge rendering mode on the mesh.
  19948. * This mode makes the mesh edges visible
  19949. * @param epsilon defines the maximal distance between two angles to detect a face
  19950. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19951. * @returns the currentAbstractMesh
  19952. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19953. */
  19954. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19955. }
  19956. }
  19957. module "babylonjs/Meshes/linesMesh" {
  19958. interface InstancedLinesMesh {
  19959. /**
  19960. * Enables the edge rendering mode on the mesh.
  19961. * This mode makes the mesh edges visible
  19962. * @param epsilon defines the maximal distance between two angles to detect a face
  19963. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19964. * @returns the current InstancedLinesMesh
  19965. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19966. */
  19967. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19968. }
  19969. }
  19970. /**
  19971. * Defines the minimum contract an Edges renderer should follow.
  19972. */
  19973. export interface IEdgesRenderer extends IDisposable {
  19974. /**
  19975. * Gets or sets a boolean indicating if the edgesRenderer is active
  19976. */
  19977. isEnabled: boolean;
  19978. /**
  19979. * Renders the edges of the attached mesh,
  19980. */
  19981. render(): void;
  19982. /**
  19983. * Checks wether or not the edges renderer is ready to render.
  19984. * @return true if ready, otherwise false.
  19985. */
  19986. isReady(): boolean;
  19987. }
  19988. /**
  19989. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19990. */
  19991. export class EdgesRenderer implements IEdgesRenderer {
  19992. /**
  19993. * Define the size of the edges with an orthographic camera
  19994. */
  19995. edgesWidthScalerForOrthographic: number;
  19996. /**
  19997. * Define the size of the edges with a perspective camera
  19998. */
  19999. edgesWidthScalerForPerspective: number;
  20000. protected _source: AbstractMesh;
  20001. protected _linesPositions: number[];
  20002. protected _linesNormals: number[];
  20003. protected _linesIndices: number[];
  20004. protected _epsilon: number;
  20005. protected _indicesCount: number;
  20006. protected _lineShader: ShaderMaterial;
  20007. protected _ib: DataBuffer;
  20008. protected _buffers: {
  20009. [key: string]: Nullable<VertexBuffer>;
  20010. };
  20011. protected _checkVerticesInsteadOfIndices: boolean;
  20012. private _meshRebuildObserver;
  20013. private _meshDisposeObserver;
  20014. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20015. isEnabled: boolean;
  20016. /**
  20017. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20018. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20019. * @param source Mesh used to create edges
  20020. * @param epsilon sum of angles in adjacency to check for edge
  20021. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20022. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20023. */
  20024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20025. protected _prepareRessources(): void;
  20026. /** @hidden */
  20027. _rebuild(): void;
  20028. /**
  20029. * Releases the required resources for the edges renderer
  20030. */
  20031. dispose(): void;
  20032. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20033. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20034. /**
  20035. * Checks if the pair of p0 and p1 is en edge
  20036. * @param faceIndex
  20037. * @param edge
  20038. * @param faceNormals
  20039. * @param p0
  20040. * @param p1
  20041. * @private
  20042. */
  20043. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20044. /**
  20045. * push line into the position, normal and index buffer
  20046. * @protected
  20047. */
  20048. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20049. /**
  20050. * Generates lines edges from adjacencjes
  20051. * @private
  20052. */
  20053. _generateEdgesLines(): void;
  20054. /**
  20055. * Checks wether or not the edges renderer is ready to render.
  20056. * @return true if ready, otherwise false.
  20057. */
  20058. isReady(): boolean;
  20059. /**
  20060. * Renders the edges of the attached mesh,
  20061. */
  20062. render(): void;
  20063. }
  20064. /**
  20065. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20066. */
  20067. export class LineEdgesRenderer extends EdgesRenderer {
  20068. /**
  20069. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20070. * @param source LineMesh used to generate edges
  20071. * @param epsilon not important (specified angle for edge detection)
  20072. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20073. */
  20074. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20075. /**
  20076. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20077. */
  20078. _generateEdgesLines(): void;
  20079. }
  20080. }
  20081. declare module "babylonjs/Rendering/renderingGroup" {
  20082. import { SmartArray } from "babylonjs/Misc/smartArray";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20085. import { Nullable } from "babylonjs/types";
  20086. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20087. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20088. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20089. import { Material } from "babylonjs/Materials/material";
  20090. import { Scene } from "babylonjs/scene";
  20091. /**
  20092. * This represents the object necessary to create a rendering group.
  20093. * This is exclusively used and created by the rendering manager.
  20094. * To modify the behavior, you use the available helpers in your scene or meshes.
  20095. * @hidden
  20096. */
  20097. export class RenderingGroup {
  20098. index: number;
  20099. private static _zeroVector;
  20100. private _scene;
  20101. private _opaqueSubMeshes;
  20102. private _transparentSubMeshes;
  20103. private _alphaTestSubMeshes;
  20104. private _depthOnlySubMeshes;
  20105. private _particleSystems;
  20106. private _spriteManagers;
  20107. private _opaqueSortCompareFn;
  20108. private _alphaTestSortCompareFn;
  20109. private _transparentSortCompareFn;
  20110. private _renderOpaque;
  20111. private _renderAlphaTest;
  20112. private _renderTransparent;
  20113. /** @hidden */
  20114. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20115. onBeforeTransparentRendering: () => void;
  20116. /**
  20117. * Set the opaque sort comparison function.
  20118. * If null the sub meshes will be render in the order they were created
  20119. */
  20120. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20121. /**
  20122. * Set the alpha test sort comparison function.
  20123. * If null the sub meshes will be render in the order they were created
  20124. */
  20125. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20126. /**
  20127. * Set the transparent sort comparison function.
  20128. * If null the sub meshes will be render in the order they were created
  20129. */
  20130. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20131. /**
  20132. * Creates a new rendering group.
  20133. * @param index The rendering group index
  20134. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20135. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20136. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20137. */
  20138. 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>);
  20139. /**
  20140. * Render all the sub meshes contained in the group.
  20141. * @param customRenderFunction Used to override the default render behaviour of the group.
  20142. * @returns true if rendered some submeshes.
  20143. */
  20144. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20145. /**
  20146. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20147. * @param subMeshes The submeshes to render
  20148. */
  20149. private renderOpaqueSorted;
  20150. /**
  20151. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20152. * @param subMeshes The submeshes to render
  20153. */
  20154. private renderAlphaTestSorted;
  20155. /**
  20156. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20157. * @param subMeshes The submeshes to render
  20158. */
  20159. private renderTransparentSorted;
  20160. /**
  20161. * Renders the submeshes in a specified order.
  20162. * @param subMeshes The submeshes to sort before render
  20163. * @param sortCompareFn The comparison function use to sort
  20164. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20165. * @param transparent Specifies to activate blending if true
  20166. */
  20167. private static renderSorted;
  20168. /**
  20169. * Renders the submeshes in the order they were dispatched (no sort applied).
  20170. * @param subMeshes The submeshes to render
  20171. */
  20172. private static renderUnsorted;
  20173. /**
  20174. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20175. * are rendered back to front if in the same alpha index.
  20176. *
  20177. * @param a The first submesh
  20178. * @param b The second submesh
  20179. * @returns The result of the comparison
  20180. */
  20181. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20182. /**
  20183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20184. * are rendered back to front.
  20185. *
  20186. * @param a The first submesh
  20187. * @param b The second submesh
  20188. * @returns The result of the comparison
  20189. */
  20190. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20191. /**
  20192. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20193. * are rendered front to back (prevent overdraw).
  20194. *
  20195. * @param a The first submesh
  20196. * @param b The second submesh
  20197. * @returns The result of the comparison
  20198. */
  20199. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20200. /**
  20201. * Resets the different lists of submeshes to prepare a new frame.
  20202. */
  20203. prepare(): void;
  20204. dispose(): void;
  20205. /**
  20206. * Inserts the submesh in its correct queue depending on its material.
  20207. * @param subMesh The submesh to dispatch
  20208. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20209. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20210. */
  20211. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20212. dispatchSprites(spriteManager: ISpriteManager): void;
  20213. dispatchParticles(particleSystem: IParticleSystem): void;
  20214. private _renderParticles;
  20215. private _renderSprites;
  20216. }
  20217. }
  20218. declare module "babylonjs/Rendering/renderingManager" {
  20219. import { Nullable } from "babylonjs/types";
  20220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20222. import { SmartArray } from "babylonjs/Misc/smartArray";
  20223. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20224. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20225. import { Material } from "babylonjs/Materials/material";
  20226. import { Scene } from "babylonjs/scene";
  20227. import { Camera } from "babylonjs/Cameras/camera";
  20228. /**
  20229. * Interface describing the different options available in the rendering manager
  20230. * regarding Auto Clear between groups.
  20231. */
  20232. export interface IRenderingManagerAutoClearSetup {
  20233. /**
  20234. * Defines whether or not autoclear is enable.
  20235. */
  20236. autoClear: boolean;
  20237. /**
  20238. * Defines whether or not to autoclear the depth buffer.
  20239. */
  20240. depth: boolean;
  20241. /**
  20242. * Defines whether or not to autoclear the stencil buffer.
  20243. */
  20244. stencil: boolean;
  20245. }
  20246. /**
  20247. * This class is used by the onRenderingGroupObservable
  20248. */
  20249. export class RenderingGroupInfo {
  20250. /**
  20251. * The Scene that being rendered
  20252. */
  20253. scene: Scene;
  20254. /**
  20255. * The camera currently used for the rendering pass
  20256. */
  20257. camera: Nullable<Camera>;
  20258. /**
  20259. * The ID of the renderingGroup being processed
  20260. */
  20261. renderingGroupId: number;
  20262. }
  20263. /**
  20264. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20265. * It is enable to manage the different groups as well as the different necessary sort functions.
  20266. * This should not be used directly aside of the few static configurations
  20267. */
  20268. export class RenderingManager {
  20269. /**
  20270. * The max id used for rendering groups (not included)
  20271. */
  20272. static MAX_RENDERINGGROUPS: number;
  20273. /**
  20274. * The min id used for rendering groups (included)
  20275. */
  20276. static MIN_RENDERINGGROUPS: number;
  20277. /**
  20278. * Used to globally prevent autoclearing scenes.
  20279. */
  20280. static AUTOCLEAR: boolean;
  20281. /**
  20282. * @hidden
  20283. */
  20284. _useSceneAutoClearSetup: boolean;
  20285. private _scene;
  20286. private _renderingGroups;
  20287. private _depthStencilBufferAlreadyCleaned;
  20288. private _autoClearDepthStencil;
  20289. private _customOpaqueSortCompareFn;
  20290. private _customAlphaTestSortCompareFn;
  20291. private _customTransparentSortCompareFn;
  20292. private _renderingGroupInfo;
  20293. /**
  20294. * Instantiates a new rendering group for a particular scene
  20295. * @param scene Defines the scene the groups belongs to
  20296. */
  20297. constructor(scene: Scene);
  20298. private _clearDepthStencilBuffer;
  20299. /**
  20300. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20301. * @hidden
  20302. */
  20303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20304. /**
  20305. * Resets the different information of the group to prepare a new frame
  20306. * @hidden
  20307. */
  20308. reset(): void;
  20309. /**
  20310. * Dispose and release the group and its associated resources.
  20311. * @hidden
  20312. */
  20313. dispose(): void;
  20314. /**
  20315. * Clear the info related to rendering groups preventing retention points during dispose.
  20316. */
  20317. freeRenderingGroups(): void;
  20318. private _prepareRenderingGroup;
  20319. /**
  20320. * Add a sprite manager to the rendering manager in order to render it this frame.
  20321. * @param spriteManager Define the sprite manager to render
  20322. */
  20323. dispatchSprites(spriteManager: ISpriteManager): void;
  20324. /**
  20325. * Add a particle system to the rendering manager in order to render it this frame.
  20326. * @param particleSystem Define the particle system to render
  20327. */
  20328. dispatchParticles(particleSystem: IParticleSystem): void;
  20329. /**
  20330. * Add a submesh to the manager in order to render it this frame
  20331. * @param subMesh The submesh to dispatch
  20332. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20333. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20334. */
  20335. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20336. /**
  20337. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20338. * This allowed control for front to back rendering or reversly depending of the special needs.
  20339. *
  20340. * @param renderingGroupId The rendering group id corresponding to its index
  20341. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20342. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20343. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20344. */
  20345. 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;
  20346. /**
  20347. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20348. *
  20349. * @param renderingGroupId The rendering group id corresponding to its index
  20350. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20351. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20352. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20353. */
  20354. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20355. /**
  20356. * Gets the current auto clear configuration for one rendering group of the rendering
  20357. * manager.
  20358. * @param index the rendering group index to get the information for
  20359. * @returns The auto clear setup for the requested rendering group
  20360. */
  20361. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20362. }
  20363. }
  20364. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20365. import { Observable } from "babylonjs/Misc/observable";
  20366. import { SmartArray } from "babylonjs/Misc/smartArray";
  20367. import { Nullable } from "babylonjs/types";
  20368. import { Camera } from "babylonjs/Cameras/camera";
  20369. import { Scene } from "babylonjs/scene";
  20370. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20371. import { Color4 } from "babylonjs/Maths/math.color";
  20372. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20375. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20376. import { Texture } from "babylonjs/Materials/Textures/texture";
  20377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20378. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20379. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20380. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20381. import { Engine } from "babylonjs/Engines/engine";
  20382. /**
  20383. * This Helps creating a texture that will be created from a camera in your scene.
  20384. * It is basically a dynamic texture that could be used to create special effects for instance.
  20385. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20386. */
  20387. export class RenderTargetTexture extends Texture {
  20388. isCube: boolean;
  20389. /**
  20390. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20391. */
  20392. static readonly REFRESHRATE_RENDER_ONCE: number;
  20393. /**
  20394. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20395. */
  20396. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20397. /**
  20398. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20399. * the central point of your effect and can save a lot of performances.
  20400. */
  20401. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20402. /**
  20403. * Use this predicate to dynamically define the list of mesh you want to render.
  20404. * If set, the renderList property will be overwritten.
  20405. */
  20406. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20407. private _renderList;
  20408. /**
  20409. * Use this list to define the list of mesh you want to render.
  20410. */
  20411. renderList: Nullable<Array<AbstractMesh>>;
  20412. private _hookArray;
  20413. /**
  20414. * Define if particles should be rendered in your texture.
  20415. */
  20416. renderParticles: boolean;
  20417. /**
  20418. * Define if sprites should be rendered in your texture.
  20419. */
  20420. renderSprites: boolean;
  20421. /**
  20422. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20423. */
  20424. coordinatesMode: number;
  20425. /**
  20426. * Define the camera used to render the texture.
  20427. */
  20428. activeCamera: Nullable<Camera>;
  20429. /**
  20430. * Override the render function of the texture with your own one.
  20431. */
  20432. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20433. /**
  20434. * Define if camera post processes should be use while rendering the texture.
  20435. */
  20436. useCameraPostProcesses: boolean;
  20437. /**
  20438. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20439. */
  20440. ignoreCameraViewport: boolean;
  20441. private _postProcessManager;
  20442. private _postProcesses;
  20443. private _resizeObserver;
  20444. /**
  20445. * An event triggered when the texture is unbind.
  20446. */
  20447. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20448. /**
  20449. * An event triggered when the texture is unbind.
  20450. */
  20451. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20452. private _onAfterUnbindObserver;
  20453. /**
  20454. * Set a after unbind callback in the texture.
  20455. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20456. */
  20457. onAfterUnbind: () => void;
  20458. /**
  20459. * An event triggered before rendering the texture
  20460. */
  20461. onBeforeRenderObservable: Observable<number>;
  20462. private _onBeforeRenderObserver;
  20463. /**
  20464. * Set a before render callback in the texture.
  20465. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20466. */
  20467. onBeforeRender: (faceIndex: number) => void;
  20468. /**
  20469. * An event triggered after rendering the texture
  20470. */
  20471. onAfterRenderObservable: Observable<number>;
  20472. private _onAfterRenderObserver;
  20473. /**
  20474. * Set a after render callback in the texture.
  20475. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20476. */
  20477. onAfterRender: (faceIndex: number) => void;
  20478. /**
  20479. * An event triggered after the texture clear
  20480. */
  20481. onClearObservable: Observable<Engine>;
  20482. private _onClearObserver;
  20483. /**
  20484. * Set a clear callback in the texture.
  20485. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20486. */
  20487. onClear: (Engine: Engine) => void;
  20488. /**
  20489. * An event triggered when the texture is resized.
  20490. */
  20491. onResizeObservable: Observable<RenderTargetTexture>;
  20492. /**
  20493. * Define the clear color of the Render Target if it should be different from the scene.
  20494. */
  20495. clearColor: Color4;
  20496. protected _size: number | {
  20497. width: number;
  20498. height: number;
  20499. };
  20500. protected _initialSizeParameter: number | {
  20501. width: number;
  20502. height: number;
  20503. } | {
  20504. ratio: number;
  20505. };
  20506. protected _sizeRatio: Nullable<number>;
  20507. /** @hidden */
  20508. _generateMipMaps: boolean;
  20509. protected _renderingManager: RenderingManager;
  20510. /** @hidden */
  20511. _waitingRenderList: string[];
  20512. protected _doNotChangeAspectRatio: boolean;
  20513. protected _currentRefreshId: number;
  20514. protected _refreshRate: number;
  20515. protected _textureMatrix: Matrix;
  20516. protected _samples: number;
  20517. protected _renderTargetOptions: RenderTargetCreationOptions;
  20518. /**
  20519. * Gets render target creation options that were used.
  20520. */
  20521. readonly renderTargetOptions: RenderTargetCreationOptions;
  20522. protected _engine: Engine;
  20523. protected _onRatioRescale(): void;
  20524. /**
  20525. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20526. * It must define where the camera used to render the texture is set
  20527. */
  20528. boundingBoxPosition: Vector3;
  20529. private _boundingBoxSize;
  20530. /**
  20531. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20532. * When defined, the cubemap will switch to local mode
  20533. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20534. * @example https://www.babylonjs-playground.com/#RNASML
  20535. */
  20536. boundingBoxSize: Vector3;
  20537. /**
  20538. * In case the RTT has been created with a depth texture, get the associated
  20539. * depth texture.
  20540. * Otherwise, return null.
  20541. */
  20542. depthStencilTexture: Nullable<InternalTexture>;
  20543. /**
  20544. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20545. * or used a shadow, depth texture...
  20546. * @param name The friendly name of the texture
  20547. * @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)
  20548. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20549. * @param generateMipMaps True if mip maps need to be generated after render.
  20550. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20551. * @param type The type of the buffer in the RTT (int, half float, float...)
  20552. * @param isCube True if a cube texture needs to be created
  20553. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20554. * @param generateDepthBuffer True to generate a depth buffer
  20555. * @param generateStencilBuffer True to generate a stencil buffer
  20556. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20557. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20558. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20559. */
  20560. constructor(name: string, size: number | {
  20561. width: number;
  20562. height: number;
  20563. } | {
  20564. ratio: number;
  20565. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20566. /**
  20567. * Creates a depth stencil texture.
  20568. * This is only available in WebGL 2 or with the depth texture extension available.
  20569. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20570. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20571. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20572. */
  20573. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20574. private _processSizeParameter;
  20575. /**
  20576. * Define the number of samples to use in case of MSAA.
  20577. * It defaults to one meaning no MSAA has been enabled.
  20578. */
  20579. samples: number;
  20580. /**
  20581. * Resets the refresh counter of the texture and start bak from scratch.
  20582. * Could be useful to regenerate the texture if it is setup to render only once.
  20583. */
  20584. resetRefreshCounter(): void;
  20585. /**
  20586. * Define the refresh rate of the texture or the rendering frequency.
  20587. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20588. */
  20589. refreshRate: number;
  20590. /**
  20591. * Adds a post process to the render target rendering passes.
  20592. * @param postProcess define the post process to add
  20593. */
  20594. addPostProcess(postProcess: PostProcess): void;
  20595. /**
  20596. * Clear all the post processes attached to the render target
  20597. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20598. */
  20599. clearPostProcesses(dispose?: boolean): void;
  20600. /**
  20601. * Remove one of the post process from the list of attached post processes to the texture
  20602. * @param postProcess define the post process to remove from the list
  20603. */
  20604. removePostProcess(postProcess: PostProcess): void;
  20605. /** @hidden */
  20606. _shouldRender(): boolean;
  20607. /**
  20608. * Gets the actual render size of the texture.
  20609. * @returns the width of the render size
  20610. */
  20611. getRenderSize(): number;
  20612. /**
  20613. * Gets the actual render width of the texture.
  20614. * @returns the width of the render size
  20615. */
  20616. getRenderWidth(): number;
  20617. /**
  20618. * Gets the actual render height of the texture.
  20619. * @returns the height of the render size
  20620. */
  20621. getRenderHeight(): number;
  20622. /**
  20623. * Get if the texture can be rescaled or not.
  20624. */
  20625. readonly canRescale: boolean;
  20626. /**
  20627. * Resize the texture using a ratio.
  20628. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20629. */
  20630. scale(ratio: number): void;
  20631. /**
  20632. * Get the texture reflection matrix used to rotate/transform the reflection.
  20633. * @returns the reflection matrix
  20634. */
  20635. getReflectionTextureMatrix(): Matrix;
  20636. /**
  20637. * Resize the texture to a new desired size.
  20638. * Be carrefull as it will recreate all the data in the new texture.
  20639. * @param size Define the new size. It can be:
  20640. * - a number for squared texture,
  20641. * - an object containing { width: number, height: number }
  20642. * - or an object containing a ratio { ratio: number }
  20643. */
  20644. resize(size: number | {
  20645. width: number;
  20646. height: number;
  20647. } | {
  20648. ratio: number;
  20649. }): void;
  20650. /**
  20651. * Renders all the objects from the render list into the texture.
  20652. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20653. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20654. */
  20655. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20656. private _bestReflectionRenderTargetDimension;
  20657. /**
  20658. * @hidden
  20659. * @param faceIndex face index to bind to if this is a cubetexture
  20660. */
  20661. _bindFrameBuffer(faceIndex?: number): void;
  20662. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20663. private renderToTarget;
  20664. /**
  20665. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20666. * This allowed control for front to back rendering or reversly depending of the special needs.
  20667. *
  20668. * @param renderingGroupId The rendering group id corresponding to its index
  20669. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20670. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20671. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20672. */
  20673. 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;
  20674. /**
  20675. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20676. *
  20677. * @param renderingGroupId The rendering group id corresponding to its index
  20678. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20679. */
  20680. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20681. /**
  20682. * Clones the texture.
  20683. * @returns the cloned texture
  20684. */
  20685. clone(): RenderTargetTexture;
  20686. /**
  20687. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20688. * @returns The JSON representation of the texture
  20689. */
  20690. serialize(): any;
  20691. /**
  20692. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20693. */
  20694. disposeFramebufferObjects(): void;
  20695. /**
  20696. * Dispose the texture and release its associated resources.
  20697. */
  20698. dispose(): void;
  20699. /** @hidden */
  20700. _rebuild(): void;
  20701. /**
  20702. * Clear the info related to rendering groups preventing retention point in material dispose.
  20703. */
  20704. freeRenderingGroups(): void;
  20705. /**
  20706. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20707. * @returns the view count
  20708. */
  20709. getViewCount(): number;
  20710. }
  20711. }
  20712. declare module "babylonjs/Materials/material" {
  20713. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20714. import { SmartArray } from "babylonjs/Misc/smartArray";
  20715. import { Observable } from "babylonjs/Misc/observable";
  20716. import { Nullable } from "babylonjs/types";
  20717. import { Scene } from "babylonjs/scene";
  20718. import { Matrix } from "babylonjs/Maths/math.vector";
  20719. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20721. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20722. import { Effect } from "babylonjs/Materials/effect";
  20723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20725. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20726. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20727. import { Mesh } from "babylonjs/Meshes/mesh";
  20728. import { Animation } from "babylonjs/Animations/animation";
  20729. /**
  20730. * Base class for the main features of a material in Babylon.js
  20731. */
  20732. export class Material implements IAnimatable {
  20733. /**
  20734. * Returns the triangle fill mode
  20735. */
  20736. static readonly TriangleFillMode: number;
  20737. /**
  20738. * Returns the wireframe mode
  20739. */
  20740. static readonly WireFrameFillMode: number;
  20741. /**
  20742. * Returns the point fill mode
  20743. */
  20744. static readonly PointFillMode: number;
  20745. /**
  20746. * Returns the point list draw mode
  20747. */
  20748. static readonly PointListDrawMode: number;
  20749. /**
  20750. * Returns the line list draw mode
  20751. */
  20752. static readonly LineListDrawMode: number;
  20753. /**
  20754. * Returns the line loop draw mode
  20755. */
  20756. static readonly LineLoopDrawMode: number;
  20757. /**
  20758. * Returns the line strip draw mode
  20759. */
  20760. static readonly LineStripDrawMode: number;
  20761. /**
  20762. * Returns the triangle strip draw mode
  20763. */
  20764. static readonly TriangleStripDrawMode: number;
  20765. /**
  20766. * Returns the triangle fan draw mode
  20767. */
  20768. static readonly TriangleFanDrawMode: number;
  20769. /**
  20770. * Stores the clock-wise side orientation
  20771. */
  20772. static readonly ClockWiseSideOrientation: number;
  20773. /**
  20774. * Stores the counter clock-wise side orientation
  20775. */
  20776. static readonly CounterClockWiseSideOrientation: number;
  20777. /**
  20778. * The dirty texture flag value
  20779. */
  20780. static readonly TextureDirtyFlag: number;
  20781. /**
  20782. * The dirty light flag value
  20783. */
  20784. static readonly LightDirtyFlag: number;
  20785. /**
  20786. * The dirty fresnel flag value
  20787. */
  20788. static readonly FresnelDirtyFlag: number;
  20789. /**
  20790. * The dirty attribute flag value
  20791. */
  20792. static readonly AttributesDirtyFlag: number;
  20793. /**
  20794. * The dirty misc flag value
  20795. */
  20796. static readonly MiscDirtyFlag: number;
  20797. /**
  20798. * The all dirty flag value
  20799. */
  20800. static readonly AllDirtyFlag: number;
  20801. /**
  20802. * The ID of the material
  20803. */
  20804. id: string;
  20805. /**
  20806. * Gets or sets the unique id of the material
  20807. */
  20808. uniqueId: number;
  20809. /**
  20810. * The name of the material
  20811. */
  20812. name: string;
  20813. /**
  20814. * Gets or sets user defined metadata
  20815. */
  20816. metadata: any;
  20817. /**
  20818. * For internal use only. Please do not use.
  20819. */
  20820. reservedDataStore: any;
  20821. /**
  20822. * Specifies if the ready state should be checked on each call
  20823. */
  20824. checkReadyOnEveryCall: boolean;
  20825. /**
  20826. * Specifies if the ready state should be checked once
  20827. */
  20828. checkReadyOnlyOnce: boolean;
  20829. /**
  20830. * The state of the material
  20831. */
  20832. state: string;
  20833. /**
  20834. * The alpha value of the material
  20835. */
  20836. protected _alpha: number;
  20837. /**
  20838. * List of inspectable custom properties (used by the Inspector)
  20839. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20840. */
  20841. inspectableCustomProperties: IInspectable[];
  20842. /**
  20843. * Sets the alpha value of the material
  20844. */
  20845. /**
  20846. * Gets the alpha value of the material
  20847. */
  20848. alpha: number;
  20849. /**
  20850. * Specifies if back face culling is enabled
  20851. */
  20852. protected _backFaceCulling: boolean;
  20853. /**
  20854. * Sets the back-face culling state
  20855. */
  20856. /**
  20857. * Gets the back-face culling state
  20858. */
  20859. backFaceCulling: boolean;
  20860. /**
  20861. * Stores the value for side orientation
  20862. */
  20863. sideOrientation: number;
  20864. /**
  20865. * Callback triggered when the material is compiled
  20866. */
  20867. onCompiled: Nullable<(effect: Effect) => void>;
  20868. /**
  20869. * Callback triggered when an error occurs
  20870. */
  20871. onError: Nullable<(effect: Effect, errors: string) => void>;
  20872. /**
  20873. * Callback triggered to get the render target textures
  20874. */
  20875. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20876. /**
  20877. * Gets a boolean indicating that current material needs to register RTT
  20878. */
  20879. readonly hasRenderTargetTextures: boolean;
  20880. /**
  20881. * Specifies if the material should be serialized
  20882. */
  20883. doNotSerialize: boolean;
  20884. /**
  20885. * @hidden
  20886. */
  20887. _storeEffectOnSubMeshes: boolean;
  20888. /**
  20889. * Stores the animations for the material
  20890. */
  20891. animations: Nullable<Array<Animation>>;
  20892. /**
  20893. * An event triggered when the material is disposed
  20894. */
  20895. onDisposeObservable: Observable<Material>;
  20896. /**
  20897. * An observer which watches for dispose events
  20898. */
  20899. private _onDisposeObserver;
  20900. private _onUnBindObservable;
  20901. /**
  20902. * Called during a dispose event
  20903. */
  20904. onDispose: () => void;
  20905. private _onBindObservable;
  20906. /**
  20907. * An event triggered when the material is bound
  20908. */
  20909. readonly onBindObservable: Observable<AbstractMesh>;
  20910. /**
  20911. * An observer which watches for bind events
  20912. */
  20913. private _onBindObserver;
  20914. /**
  20915. * Called during a bind event
  20916. */
  20917. onBind: (Mesh: AbstractMesh) => void;
  20918. /**
  20919. * An event triggered when the material is unbound
  20920. */
  20921. readonly onUnBindObservable: Observable<Material>;
  20922. /**
  20923. * Stores the value of the alpha mode
  20924. */
  20925. private _alphaMode;
  20926. /**
  20927. * Sets the value of the alpha mode.
  20928. *
  20929. * | Value | Type | Description |
  20930. * | --- | --- | --- |
  20931. * | 0 | ALPHA_DISABLE | |
  20932. * | 1 | ALPHA_ADD | |
  20933. * | 2 | ALPHA_COMBINE | |
  20934. * | 3 | ALPHA_SUBTRACT | |
  20935. * | 4 | ALPHA_MULTIPLY | |
  20936. * | 5 | ALPHA_MAXIMIZED | |
  20937. * | 6 | ALPHA_ONEONE | |
  20938. * | 7 | ALPHA_PREMULTIPLIED | |
  20939. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20940. * | 9 | ALPHA_INTERPOLATE | |
  20941. * | 10 | ALPHA_SCREENMODE | |
  20942. *
  20943. */
  20944. /**
  20945. * Gets the value of the alpha mode
  20946. */
  20947. alphaMode: number;
  20948. /**
  20949. * Stores the state of the need depth pre-pass value
  20950. */
  20951. private _needDepthPrePass;
  20952. /**
  20953. * Sets the need depth pre-pass value
  20954. */
  20955. /**
  20956. * Gets the depth pre-pass value
  20957. */
  20958. needDepthPrePass: boolean;
  20959. /**
  20960. * Specifies if depth writing should be disabled
  20961. */
  20962. disableDepthWrite: boolean;
  20963. /**
  20964. * Specifies if depth writing should be forced
  20965. */
  20966. forceDepthWrite: boolean;
  20967. /**
  20968. * Specifies if there should be a separate pass for culling
  20969. */
  20970. separateCullingPass: boolean;
  20971. /**
  20972. * Stores the state specifing if fog should be enabled
  20973. */
  20974. private _fogEnabled;
  20975. /**
  20976. * Sets the state for enabling fog
  20977. */
  20978. /**
  20979. * Gets the value of the fog enabled state
  20980. */
  20981. fogEnabled: boolean;
  20982. /**
  20983. * Stores the size of points
  20984. */
  20985. pointSize: number;
  20986. /**
  20987. * Stores the z offset value
  20988. */
  20989. zOffset: number;
  20990. /**
  20991. * Gets a value specifying if wireframe mode is enabled
  20992. */
  20993. /**
  20994. * Sets the state of wireframe mode
  20995. */
  20996. wireframe: boolean;
  20997. /**
  20998. * Gets the value specifying if point clouds are enabled
  20999. */
  21000. /**
  21001. * Sets the state of point cloud mode
  21002. */
  21003. pointsCloud: boolean;
  21004. /**
  21005. * Gets the material fill mode
  21006. */
  21007. /**
  21008. * Sets the material fill mode
  21009. */
  21010. fillMode: number;
  21011. /**
  21012. * @hidden
  21013. * Stores the effects for the material
  21014. */
  21015. _effect: Nullable<Effect>;
  21016. /**
  21017. * @hidden
  21018. * Specifies if the material was previously ready
  21019. */
  21020. _wasPreviouslyReady: boolean;
  21021. /**
  21022. * Specifies if uniform buffers should be used
  21023. */
  21024. private _useUBO;
  21025. /**
  21026. * Stores a reference to the scene
  21027. */
  21028. private _scene;
  21029. /**
  21030. * Stores the fill mode state
  21031. */
  21032. private _fillMode;
  21033. /**
  21034. * Specifies if the depth write state should be cached
  21035. */
  21036. private _cachedDepthWriteState;
  21037. /**
  21038. * Stores the uniform buffer
  21039. */
  21040. protected _uniformBuffer: UniformBuffer;
  21041. /** @hidden */
  21042. _indexInSceneMaterialArray: number;
  21043. /** @hidden */
  21044. meshMap: Nullable<{
  21045. [id: string]: AbstractMesh | undefined;
  21046. }>;
  21047. /**
  21048. * Creates a material instance
  21049. * @param name defines the name of the material
  21050. * @param scene defines the scene to reference
  21051. * @param doNotAdd specifies if the material should be added to the scene
  21052. */
  21053. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21054. /**
  21055. * Returns a string representation of the current material
  21056. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21057. * @returns a string with material information
  21058. */
  21059. toString(fullDetails?: boolean): string;
  21060. /**
  21061. * Gets the class name of the material
  21062. * @returns a string with the class name of the material
  21063. */
  21064. getClassName(): string;
  21065. /**
  21066. * Specifies if updates for the material been locked
  21067. */
  21068. readonly isFrozen: boolean;
  21069. /**
  21070. * Locks updates for the material
  21071. */
  21072. freeze(): void;
  21073. /**
  21074. * Unlocks updates for the material
  21075. */
  21076. unfreeze(): void;
  21077. /**
  21078. * Specifies if the material is ready to be used
  21079. * @param mesh defines the mesh to check
  21080. * @param useInstances specifies if instances should be used
  21081. * @returns a boolean indicating if the material is ready to be used
  21082. */
  21083. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21084. /**
  21085. * Specifies that the submesh is ready to be used
  21086. * @param mesh defines the mesh to check
  21087. * @param subMesh defines which submesh to check
  21088. * @param useInstances specifies that instances should be used
  21089. * @returns a boolean indicating that the submesh is ready or not
  21090. */
  21091. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21092. /**
  21093. * Returns the material effect
  21094. * @returns the effect associated with the material
  21095. */
  21096. getEffect(): Nullable<Effect>;
  21097. /**
  21098. * Returns the current scene
  21099. * @returns a Scene
  21100. */
  21101. getScene(): Scene;
  21102. /**
  21103. * Specifies if the material will require alpha blending
  21104. * @returns a boolean specifying if alpha blending is needed
  21105. */
  21106. needAlphaBlending(): boolean;
  21107. /**
  21108. * Specifies if the mesh will require alpha blending
  21109. * @param mesh defines the mesh to check
  21110. * @returns a boolean specifying if alpha blending is needed for the mesh
  21111. */
  21112. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21113. /**
  21114. * Specifies if this material should be rendered in alpha test mode
  21115. * @returns a boolean specifying if an alpha test is needed.
  21116. */
  21117. needAlphaTesting(): boolean;
  21118. /**
  21119. * Gets the texture used for the alpha test
  21120. * @returns the texture to use for alpha testing
  21121. */
  21122. getAlphaTestTexture(): Nullable<BaseTexture>;
  21123. /**
  21124. * Marks the material to indicate that it needs to be re-calculated
  21125. */
  21126. markDirty(): void;
  21127. /** @hidden */
  21128. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21129. /**
  21130. * Binds the material to the mesh
  21131. * @param world defines the world transformation matrix
  21132. * @param mesh defines the mesh to bind the material to
  21133. */
  21134. bind(world: Matrix, mesh?: Mesh): void;
  21135. /**
  21136. * Binds the submesh to the material
  21137. * @param world defines the world transformation matrix
  21138. * @param mesh defines the mesh containing the submesh
  21139. * @param subMesh defines the submesh to bind the material to
  21140. */
  21141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21142. /**
  21143. * Binds the world matrix to the material
  21144. * @param world defines the world transformation matrix
  21145. */
  21146. bindOnlyWorldMatrix(world: Matrix): void;
  21147. /**
  21148. * Binds the scene's uniform buffer to the effect.
  21149. * @param effect defines the effect to bind to the scene uniform buffer
  21150. * @param sceneUbo defines the uniform buffer storing scene data
  21151. */
  21152. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21153. /**
  21154. * Binds the view matrix to the effect
  21155. * @param effect defines the effect to bind the view matrix to
  21156. */
  21157. bindView(effect: Effect): void;
  21158. /**
  21159. * Binds the view projection matrix to the effect
  21160. * @param effect defines the effect to bind the view projection matrix to
  21161. */
  21162. bindViewProjection(effect: Effect): void;
  21163. /**
  21164. * Specifies if material alpha testing should be turned on for the mesh
  21165. * @param mesh defines the mesh to check
  21166. */
  21167. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21168. /**
  21169. * Processes to execute after binding the material to a mesh
  21170. * @param mesh defines the rendered mesh
  21171. */
  21172. protected _afterBind(mesh?: Mesh): void;
  21173. /**
  21174. * Unbinds the material from the mesh
  21175. */
  21176. unbind(): void;
  21177. /**
  21178. * Gets the active textures from the material
  21179. * @returns an array of textures
  21180. */
  21181. getActiveTextures(): BaseTexture[];
  21182. /**
  21183. * Specifies if the material uses a texture
  21184. * @param texture defines the texture to check against the material
  21185. * @returns a boolean specifying if the material uses the texture
  21186. */
  21187. hasTexture(texture: BaseTexture): boolean;
  21188. /**
  21189. * Makes a duplicate of the material, and gives it a new name
  21190. * @param name defines the new name for the duplicated material
  21191. * @returns the cloned material
  21192. */
  21193. clone(name: string): Nullable<Material>;
  21194. /**
  21195. * Gets the meshes bound to the material
  21196. * @returns an array of meshes bound to the material
  21197. */
  21198. getBindedMeshes(): AbstractMesh[];
  21199. /**
  21200. * Force shader compilation
  21201. * @param mesh defines the mesh associated with this material
  21202. * @param onCompiled defines a function to execute once the material is compiled
  21203. * @param options defines the options to configure the compilation
  21204. * @param onError defines a function to execute if the material fails compiling
  21205. */
  21206. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21207. clipPlane: boolean;
  21208. }>, onError?: (reason: string) => void): void;
  21209. /**
  21210. * Force shader compilation
  21211. * @param mesh defines the mesh that will use this material
  21212. * @param options defines additional options for compiling the shaders
  21213. * @returns a promise that resolves when the compilation completes
  21214. */
  21215. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21216. clipPlane: boolean;
  21217. }>): Promise<void>;
  21218. private static readonly _AllDirtyCallBack;
  21219. private static readonly _ImageProcessingDirtyCallBack;
  21220. private static readonly _TextureDirtyCallBack;
  21221. private static readonly _FresnelDirtyCallBack;
  21222. private static readonly _MiscDirtyCallBack;
  21223. private static readonly _LightsDirtyCallBack;
  21224. private static readonly _AttributeDirtyCallBack;
  21225. private static _FresnelAndMiscDirtyCallBack;
  21226. private static _TextureAndMiscDirtyCallBack;
  21227. private static readonly _DirtyCallbackArray;
  21228. private static readonly _RunDirtyCallBacks;
  21229. /**
  21230. * Marks a define in the material to indicate that it needs to be re-computed
  21231. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21232. */
  21233. markAsDirty(flag: number): void;
  21234. /**
  21235. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21236. * @param func defines a function which checks material defines against the submeshes
  21237. */
  21238. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21239. /**
  21240. * Indicates that we need to re-calculated for all submeshes
  21241. */
  21242. protected _markAllSubMeshesAsAllDirty(): void;
  21243. /**
  21244. * Indicates that image processing needs to be re-calculated for all submeshes
  21245. */
  21246. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21247. /**
  21248. * Indicates that textures need to be re-calculated for all submeshes
  21249. */
  21250. protected _markAllSubMeshesAsTexturesDirty(): void;
  21251. /**
  21252. * Indicates that fresnel needs to be re-calculated for all submeshes
  21253. */
  21254. protected _markAllSubMeshesAsFresnelDirty(): void;
  21255. /**
  21256. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21257. */
  21258. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21259. /**
  21260. * Indicates that lights need to be re-calculated for all submeshes
  21261. */
  21262. protected _markAllSubMeshesAsLightsDirty(): void;
  21263. /**
  21264. * Indicates that attributes need to be re-calculated for all submeshes
  21265. */
  21266. protected _markAllSubMeshesAsAttributesDirty(): void;
  21267. /**
  21268. * Indicates that misc needs to be re-calculated for all submeshes
  21269. */
  21270. protected _markAllSubMeshesAsMiscDirty(): void;
  21271. /**
  21272. * Indicates that textures and misc need to be re-calculated for all submeshes
  21273. */
  21274. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21275. /**
  21276. * Disposes the material
  21277. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21278. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21279. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21280. */
  21281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21282. /** @hidden */
  21283. private releaseVertexArrayObject;
  21284. /**
  21285. * Serializes this material
  21286. * @returns the serialized material object
  21287. */
  21288. serialize(): any;
  21289. /**
  21290. * Creates a material from parsed material data
  21291. * @param parsedMaterial defines parsed material data
  21292. * @param scene defines the hosting scene
  21293. * @param rootUrl defines the root URL to use to load textures
  21294. * @returns a new material
  21295. */
  21296. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21297. }
  21298. }
  21299. declare module "babylonjs/Materials/multiMaterial" {
  21300. import { Nullable } from "babylonjs/types";
  21301. import { Scene } from "babylonjs/scene";
  21302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21303. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21305. import { Material } from "babylonjs/Materials/material";
  21306. /**
  21307. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21308. * separate meshes. This can be use to improve performances.
  21309. * @see http://doc.babylonjs.com/how_to/multi_materials
  21310. */
  21311. export class MultiMaterial extends Material {
  21312. private _subMaterials;
  21313. /**
  21314. * Gets or Sets the list of Materials used within the multi material.
  21315. * They need to be ordered according to the submeshes order in the associated mesh
  21316. */
  21317. subMaterials: Nullable<Material>[];
  21318. /**
  21319. * Function used to align with Node.getChildren()
  21320. * @returns the list of Materials used within the multi material
  21321. */
  21322. getChildren(): Nullable<Material>[];
  21323. /**
  21324. * Instantiates a new Multi Material
  21325. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21326. * separate meshes. This can be use to improve performances.
  21327. * @see http://doc.babylonjs.com/how_to/multi_materials
  21328. * @param name Define the name in the scene
  21329. * @param scene Define the scene the material belongs to
  21330. */
  21331. constructor(name: string, scene: Scene);
  21332. private _hookArray;
  21333. /**
  21334. * Get one of the submaterial by its index in the submaterials array
  21335. * @param index The index to look the sub material at
  21336. * @returns The Material if the index has been defined
  21337. */
  21338. getSubMaterial(index: number): Nullable<Material>;
  21339. /**
  21340. * Get the list of active textures for the whole sub materials list.
  21341. * @returns All the textures that will be used during the rendering
  21342. */
  21343. getActiveTextures(): BaseTexture[];
  21344. /**
  21345. * Gets the current class name of the material e.g. "MultiMaterial"
  21346. * Mainly use in serialization.
  21347. * @returns the class name
  21348. */
  21349. getClassName(): string;
  21350. /**
  21351. * Checks if the material is ready to render the requested sub mesh
  21352. * @param mesh Define the mesh the submesh belongs to
  21353. * @param subMesh Define the sub mesh to look readyness for
  21354. * @param useInstances Define whether or not the material is used with instances
  21355. * @returns true if ready, otherwise false
  21356. */
  21357. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21358. /**
  21359. * Clones the current material and its related sub materials
  21360. * @param name Define the name of the newly cloned material
  21361. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21362. * @returns the cloned material
  21363. */
  21364. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21365. /**
  21366. * Serializes the materials into a JSON representation.
  21367. * @returns the JSON representation
  21368. */
  21369. serialize(): any;
  21370. /**
  21371. * Dispose the material and release its associated resources
  21372. * @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)
  21373. * @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)
  21374. * @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)
  21375. */
  21376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21377. /**
  21378. * Creates a MultiMaterial from parsed MultiMaterial data.
  21379. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21380. * @param scene defines the hosting scene
  21381. * @returns a new MultiMaterial
  21382. */
  21383. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21384. }
  21385. }
  21386. declare module "babylonjs/Meshes/subMesh" {
  21387. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21388. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21389. import { Engine } from "babylonjs/Engines/engine";
  21390. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21391. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21392. import { Effect } from "babylonjs/Materials/effect";
  21393. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21394. import { Plane } from "babylonjs/Maths/math.plane";
  21395. import { Collider } from "babylonjs/Collisions/collider";
  21396. import { Material } from "babylonjs/Materials/material";
  21397. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21399. import { Mesh } from "babylonjs/Meshes/mesh";
  21400. import { Ray } from "babylonjs/Culling/ray";
  21401. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21402. /**
  21403. * Base class for submeshes
  21404. */
  21405. export class BaseSubMesh {
  21406. /** @hidden */
  21407. _materialDefines: Nullable<MaterialDefines>;
  21408. /** @hidden */
  21409. _materialEffect: Nullable<Effect>;
  21410. /**
  21411. * Gets associated effect
  21412. */
  21413. readonly effect: Nullable<Effect>;
  21414. /**
  21415. * Sets associated effect (effect used to render this submesh)
  21416. * @param effect defines the effect to associate with
  21417. * @param defines defines the set of defines used to compile this effect
  21418. */
  21419. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21420. }
  21421. /**
  21422. * Defines a subdivision inside a mesh
  21423. */
  21424. export class SubMesh extends BaseSubMesh implements ICullable {
  21425. /** the material index to use */
  21426. materialIndex: number;
  21427. /** vertex index start */
  21428. verticesStart: number;
  21429. /** vertices count */
  21430. verticesCount: number;
  21431. /** index start */
  21432. indexStart: number;
  21433. /** indices count */
  21434. indexCount: number;
  21435. /** @hidden */
  21436. _linesIndexCount: number;
  21437. private _mesh;
  21438. private _renderingMesh;
  21439. private _boundingInfo;
  21440. private _linesIndexBuffer;
  21441. /** @hidden */
  21442. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21443. /** @hidden */
  21444. _trianglePlanes: Plane[];
  21445. /** @hidden */
  21446. _lastColliderTransformMatrix: Nullable<Matrix>;
  21447. /** @hidden */
  21448. _renderId: number;
  21449. /** @hidden */
  21450. _alphaIndex: number;
  21451. /** @hidden */
  21452. _distanceToCamera: number;
  21453. /** @hidden */
  21454. _id: number;
  21455. private _currentMaterial;
  21456. /**
  21457. * Add a new submesh to a mesh
  21458. * @param materialIndex defines the material index to use
  21459. * @param verticesStart defines vertex index start
  21460. * @param verticesCount defines vertices count
  21461. * @param indexStart defines index start
  21462. * @param indexCount defines indices count
  21463. * @param mesh defines the parent mesh
  21464. * @param renderingMesh defines an optional rendering mesh
  21465. * @param createBoundingBox defines if bounding box should be created for this submesh
  21466. * @returns the new submesh
  21467. */
  21468. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21469. /**
  21470. * Creates a new submesh
  21471. * @param materialIndex defines the material index to use
  21472. * @param verticesStart defines vertex index start
  21473. * @param verticesCount defines vertices count
  21474. * @param indexStart defines index start
  21475. * @param indexCount defines indices count
  21476. * @param mesh defines the parent mesh
  21477. * @param renderingMesh defines an optional rendering mesh
  21478. * @param createBoundingBox defines if bounding box should be created for this submesh
  21479. */
  21480. constructor(
  21481. /** the material index to use */
  21482. materialIndex: number,
  21483. /** vertex index start */
  21484. verticesStart: number,
  21485. /** vertices count */
  21486. verticesCount: number,
  21487. /** index start */
  21488. indexStart: number,
  21489. /** indices count */
  21490. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21491. /**
  21492. * Returns true if this submesh covers the entire parent mesh
  21493. * @ignorenaming
  21494. */
  21495. readonly IsGlobal: boolean;
  21496. /**
  21497. * Returns the submesh BoudingInfo object
  21498. * @returns current bounding info (or mesh's one if the submesh is global)
  21499. */
  21500. getBoundingInfo(): BoundingInfo;
  21501. /**
  21502. * Sets the submesh BoundingInfo
  21503. * @param boundingInfo defines the new bounding info to use
  21504. * @returns the SubMesh
  21505. */
  21506. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21507. /**
  21508. * Returns the mesh of the current submesh
  21509. * @return the parent mesh
  21510. */
  21511. getMesh(): AbstractMesh;
  21512. /**
  21513. * Returns the rendering mesh of the submesh
  21514. * @returns the rendering mesh (could be different from parent mesh)
  21515. */
  21516. getRenderingMesh(): Mesh;
  21517. /**
  21518. * Returns the submesh material
  21519. * @returns null or the current material
  21520. */
  21521. getMaterial(): Nullable<Material>;
  21522. /**
  21523. * Sets a new updated BoundingInfo object to the submesh
  21524. * @param data defines an optional position array to use to determine the bounding info
  21525. * @returns the SubMesh
  21526. */
  21527. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21528. /** @hidden */
  21529. _checkCollision(collider: Collider): boolean;
  21530. /**
  21531. * Updates the submesh BoundingInfo
  21532. * @param world defines the world matrix to use to update the bounding info
  21533. * @returns the submesh
  21534. */
  21535. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21536. /**
  21537. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21538. * @param frustumPlanes defines the frustum planes
  21539. * @returns true if the submesh is intersecting with the frustum
  21540. */
  21541. isInFrustum(frustumPlanes: Plane[]): boolean;
  21542. /**
  21543. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21544. * @param frustumPlanes defines the frustum planes
  21545. * @returns true if the submesh is inside the frustum
  21546. */
  21547. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21548. /**
  21549. * Renders the submesh
  21550. * @param enableAlphaMode defines if alpha needs to be used
  21551. * @returns the submesh
  21552. */
  21553. render(enableAlphaMode: boolean): SubMesh;
  21554. /**
  21555. * @hidden
  21556. */
  21557. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21558. /**
  21559. * Checks if the submesh intersects with a ray
  21560. * @param ray defines the ray to test
  21561. * @returns true is the passed ray intersects the submesh bounding box
  21562. */
  21563. canIntersects(ray: Ray): boolean;
  21564. /**
  21565. * Intersects current submesh with a ray
  21566. * @param ray defines the ray to test
  21567. * @param positions defines mesh's positions array
  21568. * @param indices defines mesh's indices array
  21569. * @param fastCheck defines if only bounding info should be used
  21570. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21571. * @returns intersection info or null if no intersection
  21572. */
  21573. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21574. /** @hidden */
  21575. private _intersectLines;
  21576. /** @hidden */
  21577. private _intersectUnIndexedLines;
  21578. /** @hidden */
  21579. private _intersectTriangles;
  21580. /** @hidden */
  21581. private _intersectUnIndexedTriangles;
  21582. /** @hidden */
  21583. _rebuild(): void;
  21584. /**
  21585. * Creates a new submesh from the passed mesh
  21586. * @param newMesh defines the new hosting mesh
  21587. * @param newRenderingMesh defines an optional rendering mesh
  21588. * @returns the new submesh
  21589. */
  21590. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21591. /**
  21592. * Release associated resources
  21593. */
  21594. dispose(): void;
  21595. /**
  21596. * Gets the class name
  21597. * @returns the string "SubMesh".
  21598. */
  21599. getClassName(): string;
  21600. /**
  21601. * Creates a new submesh from indices data
  21602. * @param materialIndex the index of the main mesh material
  21603. * @param startIndex the index where to start the copy in the mesh indices array
  21604. * @param indexCount the number of indices to copy then from the startIndex
  21605. * @param mesh the main mesh to create the submesh from
  21606. * @param renderingMesh the optional rendering mesh
  21607. * @returns a new submesh
  21608. */
  21609. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21610. }
  21611. }
  21612. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21613. /**
  21614. * Class used to represent data loading progression
  21615. */
  21616. export class SceneLoaderFlags {
  21617. private static _ForceFullSceneLoadingForIncremental;
  21618. private static _ShowLoadingScreen;
  21619. private static _CleanBoneMatrixWeights;
  21620. private static _loggingLevel;
  21621. /**
  21622. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21623. */
  21624. static ForceFullSceneLoadingForIncremental: boolean;
  21625. /**
  21626. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21627. */
  21628. static ShowLoadingScreen: boolean;
  21629. /**
  21630. * Defines the current logging level (while loading the scene)
  21631. * @ignorenaming
  21632. */
  21633. static loggingLevel: number;
  21634. /**
  21635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21636. */
  21637. static CleanBoneMatrixWeights: boolean;
  21638. }
  21639. }
  21640. declare module "babylonjs/Meshes/geometry" {
  21641. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21642. import { Scene } from "babylonjs/scene";
  21643. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21644. import { Engine } from "babylonjs/Engines/engine";
  21645. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21646. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21647. import { Effect } from "babylonjs/Materials/effect";
  21648. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21649. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21650. import { Mesh } from "babylonjs/Meshes/mesh";
  21651. /**
  21652. * Class used to store geometry data (vertex buffers + index buffer)
  21653. */
  21654. export class Geometry implements IGetSetVerticesData {
  21655. /**
  21656. * Gets or sets the ID of the geometry
  21657. */
  21658. id: string;
  21659. /**
  21660. * Gets or sets the unique ID of the geometry
  21661. */
  21662. uniqueId: number;
  21663. /**
  21664. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21665. */
  21666. delayLoadState: number;
  21667. /**
  21668. * Gets the file containing the data to load when running in delay load state
  21669. */
  21670. delayLoadingFile: Nullable<string>;
  21671. /**
  21672. * Callback called when the geometry is updated
  21673. */
  21674. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21675. private _scene;
  21676. private _engine;
  21677. private _meshes;
  21678. private _totalVertices;
  21679. /** @hidden */
  21680. _indices: IndicesArray;
  21681. /** @hidden */
  21682. _vertexBuffers: {
  21683. [key: string]: VertexBuffer;
  21684. };
  21685. private _isDisposed;
  21686. private _extend;
  21687. private _boundingBias;
  21688. /** @hidden */
  21689. _delayInfo: Array<string>;
  21690. private _indexBuffer;
  21691. private _indexBufferIsUpdatable;
  21692. /** @hidden */
  21693. _boundingInfo: Nullable<BoundingInfo>;
  21694. /** @hidden */
  21695. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21696. /** @hidden */
  21697. _softwareSkinningFrameId: number;
  21698. private _vertexArrayObjects;
  21699. private _updatable;
  21700. /** @hidden */
  21701. _positions: Nullable<Vector3[]>;
  21702. /**
  21703. * 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
  21704. */
  21705. /**
  21706. * 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
  21707. */
  21708. boundingBias: Vector2;
  21709. /**
  21710. * Static function used to attach a new empty geometry to a mesh
  21711. * @param mesh defines the mesh to attach the geometry to
  21712. * @returns the new Geometry
  21713. */
  21714. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21715. /**
  21716. * Creates a new geometry
  21717. * @param id defines the unique ID
  21718. * @param scene defines the hosting scene
  21719. * @param vertexData defines the VertexData used to get geometry data
  21720. * @param updatable defines if geometry must be updatable (false by default)
  21721. * @param mesh defines the mesh that will be associated with the geometry
  21722. */
  21723. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21724. /**
  21725. * Gets the current extend of the geometry
  21726. */
  21727. readonly extend: {
  21728. minimum: Vector3;
  21729. maximum: Vector3;
  21730. };
  21731. /**
  21732. * Gets the hosting scene
  21733. * @returns the hosting Scene
  21734. */
  21735. getScene(): Scene;
  21736. /**
  21737. * Gets the hosting engine
  21738. * @returns the hosting Engine
  21739. */
  21740. getEngine(): Engine;
  21741. /**
  21742. * Defines if the geometry is ready to use
  21743. * @returns true if the geometry is ready to be used
  21744. */
  21745. isReady(): boolean;
  21746. /**
  21747. * Gets a value indicating that the geometry should not be serialized
  21748. */
  21749. readonly doNotSerialize: boolean;
  21750. /** @hidden */
  21751. _rebuild(): void;
  21752. /**
  21753. * Affects all geometry data in one call
  21754. * @param vertexData defines the geometry data
  21755. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21756. */
  21757. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21758. /**
  21759. * Set specific vertex data
  21760. * @param kind defines the data kind (Position, normal, etc...)
  21761. * @param data defines the vertex data to use
  21762. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21763. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21764. */
  21765. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21766. /**
  21767. * Removes a specific vertex data
  21768. * @param kind defines the data kind (Position, normal, etc...)
  21769. */
  21770. removeVerticesData(kind: string): void;
  21771. /**
  21772. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21773. * @param buffer defines the vertex buffer to use
  21774. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21775. */
  21776. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21777. /**
  21778. * Update a specific vertex buffer
  21779. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21780. * It will do nothing if the buffer is not updatable
  21781. * @param kind defines the data kind (Position, normal, etc...)
  21782. * @param data defines the data to use
  21783. * @param offset defines the offset in the target buffer where to store the data
  21784. * @param useBytes set to true if the offset is in bytes
  21785. */
  21786. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21787. /**
  21788. * Update a specific vertex buffer
  21789. * This function will create a new buffer if the current one is not updatable
  21790. * @param kind defines the data kind (Position, normal, etc...)
  21791. * @param data defines the data to use
  21792. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21793. */
  21794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21795. private _updateBoundingInfo;
  21796. /** @hidden */
  21797. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21798. /**
  21799. * Gets total number of vertices
  21800. * @returns the total number of vertices
  21801. */
  21802. getTotalVertices(): number;
  21803. /**
  21804. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21805. * @param kind defines the data kind (Position, normal, etc...)
  21806. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21807. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21808. * @returns a float array containing vertex data
  21809. */
  21810. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21811. /**
  21812. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21813. * @param kind defines the data kind (Position, normal, etc...)
  21814. * @returns true if the vertex buffer with the specified kind is updatable
  21815. */
  21816. isVertexBufferUpdatable(kind: string): boolean;
  21817. /**
  21818. * Gets a specific vertex buffer
  21819. * @param kind defines the data kind (Position, normal, etc...)
  21820. * @returns a VertexBuffer
  21821. */
  21822. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21823. /**
  21824. * Returns all vertex buffers
  21825. * @return an object holding all vertex buffers indexed by kind
  21826. */
  21827. getVertexBuffers(): Nullable<{
  21828. [key: string]: VertexBuffer;
  21829. }>;
  21830. /**
  21831. * Gets a boolean indicating if specific vertex buffer is present
  21832. * @param kind defines the data kind (Position, normal, etc...)
  21833. * @returns true if data is present
  21834. */
  21835. isVerticesDataPresent(kind: string): boolean;
  21836. /**
  21837. * Gets a list of all attached data kinds (Position, normal, etc...)
  21838. * @returns a list of string containing all kinds
  21839. */
  21840. getVerticesDataKinds(): string[];
  21841. /**
  21842. * Update index buffer
  21843. * @param indices defines the indices to store in the index buffer
  21844. * @param offset defines the offset in the target buffer where to store the data
  21845. * @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)
  21846. */
  21847. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21848. /**
  21849. * Creates a new index buffer
  21850. * @param indices defines the indices to store in the index buffer
  21851. * @param totalVertices defines the total number of vertices (could be null)
  21852. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21853. */
  21854. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21855. /**
  21856. * Return the total number of indices
  21857. * @returns the total number of indices
  21858. */
  21859. getTotalIndices(): number;
  21860. /**
  21861. * Gets the index buffer array
  21862. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21863. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21864. * @returns the index buffer array
  21865. */
  21866. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21867. /**
  21868. * Gets the index buffer
  21869. * @return the index buffer
  21870. */
  21871. getIndexBuffer(): Nullable<DataBuffer>;
  21872. /** @hidden */
  21873. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21874. /**
  21875. * Release the associated resources for a specific mesh
  21876. * @param mesh defines the source mesh
  21877. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21878. */
  21879. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21880. /**
  21881. * Apply current geometry to a given mesh
  21882. * @param mesh defines the mesh to apply geometry to
  21883. */
  21884. applyToMesh(mesh: Mesh): void;
  21885. private _updateExtend;
  21886. private _applyToMesh;
  21887. private notifyUpdate;
  21888. /**
  21889. * Load the geometry if it was flagged as delay loaded
  21890. * @param scene defines the hosting scene
  21891. * @param onLoaded defines a callback called when the geometry is loaded
  21892. */
  21893. load(scene: Scene, onLoaded?: () => void): void;
  21894. private _queueLoad;
  21895. /**
  21896. * Invert the geometry to move from a right handed system to a left handed one.
  21897. */
  21898. toLeftHanded(): void;
  21899. /** @hidden */
  21900. _resetPointsArrayCache(): void;
  21901. /** @hidden */
  21902. _generatePointsArray(): boolean;
  21903. /**
  21904. * Gets a value indicating if the geometry is disposed
  21905. * @returns true if the geometry was disposed
  21906. */
  21907. isDisposed(): boolean;
  21908. private _disposeVertexArrayObjects;
  21909. /**
  21910. * Free all associated resources
  21911. */
  21912. dispose(): void;
  21913. /**
  21914. * Clone the current geometry into a new geometry
  21915. * @param id defines the unique ID of the new geometry
  21916. * @returns a new geometry object
  21917. */
  21918. copy(id: string): Geometry;
  21919. /**
  21920. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21921. * @return a JSON representation of the current geometry data (without the vertices data)
  21922. */
  21923. serialize(): any;
  21924. private toNumberArray;
  21925. /**
  21926. * Serialize all vertices data into a JSON oject
  21927. * @returns a JSON representation of the current geometry data
  21928. */
  21929. serializeVerticeData(): any;
  21930. /**
  21931. * Extracts a clone of a mesh geometry
  21932. * @param mesh defines the source mesh
  21933. * @param id defines the unique ID of the new geometry object
  21934. * @returns the new geometry object
  21935. */
  21936. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21937. /**
  21938. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21939. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21940. * Be aware Math.random() could cause collisions, but:
  21941. * "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"
  21942. * @returns a string containing a new GUID
  21943. */
  21944. static RandomId(): string;
  21945. /** @hidden */
  21946. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21947. private static _CleanMatricesWeights;
  21948. /**
  21949. * Create a new geometry from persisted data (Using .babylon file format)
  21950. * @param parsedVertexData defines the persisted data
  21951. * @param scene defines the hosting scene
  21952. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21953. * @returns the new geometry object
  21954. */
  21955. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21956. }
  21957. }
  21958. declare module "babylonjs/Meshes/mesh.vertexData" {
  21959. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21960. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21961. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21962. import { Geometry } from "babylonjs/Meshes/geometry";
  21963. import { Mesh } from "babylonjs/Meshes/mesh";
  21964. /**
  21965. * Define an interface for all classes that will get and set the data on vertices
  21966. */
  21967. export interface IGetSetVerticesData {
  21968. /**
  21969. * Gets a boolean indicating if specific vertex data is present
  21970. * @param kind defines the vertex data kind to use
  21971. * @returns true is data kind is present
  21972. */
  21973. isVerticesDataPresent(kind: string): boolean;
  21974. /**
  21975. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21976. * @param kind defines the data kind (Position, normal, etc...)
  21977. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21978. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21979. * @returns a float array containing vertex data
  21980. */
  21981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21982. /**
  21983. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21984. * @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.
  21985. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21986. * @returns the indices array or an empty array if the mesh has no geometry
  21987. */
  21988. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21989. /**
  21990. * Set specific vertex data
  21991. * @param kind defines the data kind (Position, normal, etc...)
  21992. * @param data defines the vertex data to use
  21993. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21994. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21995. */
  21996. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21997. /**
  21998. * Update a specific associated vertex buffer
  21999. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22000. * - VertexBuffer.PositionKind
  22001. * - VertexBuffer.UVKind
  22002. * - VertexBuffer.UV2Kind
  22003. * - VertexBuffer.UV3Kind
  22004. * - VertexBuffer.UV4Kind
  22005. * - VertexBuffer.UV5Kind
  22006. * - VertexBuffer.UV6Kind
  22007. * - VertexBuffer.ColorKind
  22008. * - VertexBuffer.MatricesIndicesKind
  22009. * - VertexBuffer.MatricesIndicesExtraKind
  22010. * - VertexBuffer.MatricesWeightsKind
  22011. * - VertexBuffer.MatricesWeightsExtraKind
  22012. * @param data defines the data source
  22013. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22014. * @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)
  22015. */
  22016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22017. /**
  22018. * Creates a new index buffer
  22019. * @param indices defines the indices to store in the index buffer
  22020. * @param totalVertices defines the total number of vertices (could be null)
  22021. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22022. */
  22023. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22024. }
  22025. /**
  22026. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22027. */
  22028. export class VertexData {
  22029. /**
  22030. * Mesh side orientation : usually the external or front surface
  22031. */
  22032. static readonly FRONTSIDE: number;
  22033. /**
  22034. * Mesh side orientation : usually the internal or back surface
  22035. */
  22036. static readonly BACKSIDE: number;
  22037. /**
  22038. * Mesh side orientation : both internal and external or front and back surfaces
  22039. */
  22040. static readonly DOUBLESIDE: number;
  22041. /**
  22042. * Mesh side orientation : by default, `FRONTSIDE`
  22043. */
  22044. static readonly DEFAULTSIDE: number;
  22045. /**
  22046. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22047. */
  22048. positions: Nullable<FloatArray>;
  22049. /**
  22050. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22051. */
  22052. normals: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22055. */
  22056. tangents: Nullable<FloatArray>;
  22057. /**
  22058. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22059. */
  22060. uvs: Nullable<FloatArray>;
  22061. /**
  22062. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22063. */
  22064. uvs2: Nullable<FloatArray>;
  22065. /**
  22066. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22067. */
  22068. uvs3: Nullable<FloatArray>;
  22069. /**
  22070. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs4: Nullable<FloatArray>;
  22073. /**
  22074. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs5: Nullable<FloatArray>;
  22077. /**
  22078. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs6: Nullable<FloatArray>;
  22081. /**
  22082. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22083. */
  22084. colors: Nullable<FloatArray>;
  22085. /**
  22086. * 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).
  22087. */
  22088. matricesIndices: Nullable<FloatArray>;
  22089. /**
  22090. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22091. */
  22092. matricesWeights: Nullable<FloatArray>;
  22093. /**
  22094. * An array extending the number of possible indices
  22095. */
  22096. matricesIndicesExtra: Nullable<FloatArray>;
  22097. /**
  22098. * An array extending the number of possible weights when the number of indices is extended
  22099. */
  22100. matricesWeightsExtra: Nullable<FloatArray>;
  22101. /**
  22102. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22103. */
  22104. indices: Nullable<IndicesArray>;
  22105. /**
  22106. * Uses the passed data array to set the set the values for the specified kind of data
  22107. * @param data a linear array of floating numbers
  22108. * @param kind the type of data that is being set, eg positions, colors etc
  22109. */
  22110. set(data: FloatArray, kind: string): void;
  22111. /**
  22112. * Associates the vertexData to the passed Mesh.
  22113. * Sets it as updatable or not (default `false`)
  22114. * @param mesh the mesh the vertexData is applied to
  22115. * @param updatable when used and having the value true allows new data to update the vertexData
  22116. * @returns the VertexData
  22117. */
  22118. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22119. /**
  22120. * Associates the vertexData to the passed Geometry.
  22121. * Sets it as updatable or not (default `false`)
  22122. * @param geometry the geometry the vertexData is applied to
  22123. * @param updatable when used and having the value true allows new data to update the vertexData
  22124. * @returns VertexData
  22125. */
  22126. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22127. /**
  22128. * Updates the associated mesh
  22129. * @param mesh the mesh to be updated
  22130. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22131. * @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
  22132. * @returns VertexData
  22133. */
  22134. updateMesh(mesh: Mesh): VertexData;
  22135. /**
  22136. * Updates the associated geometry
  22137. * @param geometry the geometry to be updated
  22138. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22139. * @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
  22140. * @returns VertexData.
  22141. */
  22142. updateGeometry(geometry: Geometry): VertexData;
  22143. private _applyTo;
  22144. private _update;
  22145. /**
  22146. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22147. * @param matrix the transforming matrix
  22148. * @returns the VertexData
  22149. */
  22150. transform(matrix: Matrix): VertexData;
  22151. /**
  22152. * Merges the passed VertexData into the current one
  22153. * @param other the VertexData to be merged into the current one
  22154. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22155. * @returns the modified VertexData
  22156. */
  22157. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22158. private _mergeElement;
  22159. private _validate;
  22160. /**
  22161. * Serializes the VertexData
  22162. * @returns a serialized object
  22163. */
  22164. serialize(): any;
  22165. /**
  22166. * Extracts the vertexData from a mesh
  22167. * @param mesh the mesh from which to extract the VertexData
  22168. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22169. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22170. * @returns the object VertexData associated to the passed mesh
  22171. */
  22172. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22173. /**
  22174. * Extracts the vertexData from the geometry
  22175. * @param geometry the geometry from which to extract the VertexData
  22176. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22177. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22178. * @returns the object VertexData associated to the passed mesh
  22179. */
  22180. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22181. private static _ExtractFrom;
  22182. /**
  22183. * Creates the VertexData for a Ribbon
  22184. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22185. * * pathArray array of paths, each of which an array of successive Vector3
  22186. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22187. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22188. * * 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
  22189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22190. * * 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)
  22191. * * 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)
  22192. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22193. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22194. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22195. * @returns the VertexData of the ribbon
  22196. */
  22197. static CreateRibbon(options: {
  22198. pathArray: Vector3[][];
  22199. closeArray?: boolean;
  22200. closePath?: boolean;
  22201. offset?: number;
  22202. sideOrientation?: number;
  22203. frontUVs?: Vector4;
  22204. backUVs?: Vector4;
  22205. invertUV?: boolean;
  22206. uvs?: Vector2[];
  22207. colors?: Color4[];
  22208. }): VertexData;
  22209. /**
  22210. * Creates the VertexData for a box
  22211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22212. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22213. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22214. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22215. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22216. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22217. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22219. * * 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)
  22220. * * 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)
  22221. * @returns the VertexData of the box
  22222. */
  22223. static CreateBox(options: {
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. depth?: number;
  22228. faceUV?: Vector4[];
  22229. faceColors?: Color4[];
  22230. sideOrientation?: number;
  22231. frontUVs?: Vector4;
  22232. backUVs?: Vector4;
  22233. }): VertexData;
  22234. /**
  22235. * Creates the VertexData for a tiled box
  22236. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22237. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22238. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22239. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22241. * @returns the VertexData of the box
  22242. */
  22243. static CreateTiledBox(options: {
  22244. pattern?: number;
  22245. width?: number;
  22246. height?: number;
  22247. depth?: number;
  22248. tileSize?: number;
  22249. tileWidth?: number;
  22250. tileHeight?: number;
  22251. alignHorizontal?: number;
  22252. alignVertical?: number;
  22253. faceUV?: Vector4[];
  22254. faceColors?: Color4[];
  22255. sideOrientation?: number;
  22256. }): VertexData;
  22257. /**
  22258. * Creates the VertexData for a tiled plane
  22259. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22260. * * pattern a limited pattern arrangement depending on the number
  22261. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22262. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22263. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22265. * * 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)
  22266. * * 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)
  22267. * @returns the VertexData of the tiled plane
  22268. */
  22269. static CreateTiledPlane(options: {
  22270. pattern?: number;
  22271. tileSize?: number;
  22272. tileWidth?: number;
  22273. tileHeight?: number;
  22274. size?: number;
  22275. width?: number;
  22276. height?: number;
  22277. alignHorizontal?: number;
  22278. alignVertical?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. }): VertexData;
  22283. /**
  22284. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22286. * * segments sets the number of horizontal strips optional, default 32
  22287. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22288. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22289. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22290. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22291. * * 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
  22292. * * 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
  22293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22294. * * 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)
  22295. * * 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)
  22296. * @returns the VertexData of the ellipsoid
  22297. */
  22298. static CreateSphere(options: {
  22299. segments?: number;
  22300. diameter?: number;
  22301. diameterX?: number;
  22302. diameterY?: number;
  22303. diameterZ?: number;
  22304. arc?: number;
  22305. slice?: number;
  22306. sideOrientation?: number;
  22307. frontUVs?: Vector4;
  22308. backUVs?: Vector4;
  22309. }): VertexData;
  22310. /**
  22311. * Creates the VertexData for a cylinder, cone or prism
  22312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22313. * * height sets the height (y direction) of the cylinder, optional, default 2
  22314. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22315. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22316. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22317. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22318. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22319. * * 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
  22320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22321. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22322. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22323. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22325. * * 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)
  22326. * * 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)
  22327. * @returns the VertexData of the cylinder, cone or prism
  22328. */
  22329. static CreateCylinder(options: {
  22330. height?: number;
  22331. diameterTop?: number;
  22332. diameterBottom?: number;
  22333. diameter?: number;
  22334. tessellation?: number;
  22335. subdivisions?: number;
  22336. arc?: number;
  22337. faceColors?: Color4[];
  22338. faceUV?: Vector4[];
  22339. hasRings?: boolean;
  22340. enclose?: boolean;
  22341. sideOrientation?: number;
  22342. frontUVs?: Vector4;
  22343. backUVs?: Vector4;
  22344. }): VertexData;
  22345. /**
  22346. * Creates the VertexData for a torus
  22347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22348. * * diameter the diameter of the torus, optional default 1
  22349. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22352. * * 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)
  22353. * * 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)
  22354. * @returns the VertexData of the torus
  22355. */
  22356. static CreateTorus(options: {
  22357. diameter?: number;
  22358. thickness?: number;
  22359. tessellation?: number;
  22360. sideOrientation?: number;
  22361. frontUVs?: Vector4;
  22362. backUVs?: Vector4;
  22363. }): VertexData;
  22364. /**
  22365. * Creates the VertexData of the LineSystem
  22366. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22367. * - lines an array of lines, each line being an array of successive Vector3
  22368. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22369. * @returns the VertexData of the LineSystem
  22370. */
  22371. static CreateLineSystem(options: {
  22372. lines: Vector3[][];
  22373. colors?: Nullable<Color4[][]>;
  22374. }): VertexData;
  22375. /**
  22376. * Create the VertexData for a DashedLines
  22377. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22378. * - points an array successive Vector3
  22379. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22380. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22381. * - dashNb the intended total number of dashes, optional, default 200
  22382. * @returns the VertexData for the DashedLines
  22383. */
  22384. static CreateDashedLines(options: {
  22385. points: Vector3[];
  22386. dashSize?: number;
  22387. gapSize?: number;
  22388. dashNb?: number;
  22389. }): VertexData;
  22390. /**
  22391. * Creates the VertexData for a Ground
  22392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22393. * - width the width (x direction) of the ground, optional, default 1
  22394. * - height the height (z direction) of the ground, optional, default 1
  22395. * - subdivisions the number of subdivisions per side, optional, default 1
  22396. * @returns the VertexData of the Ground
  22397. */
  22398. static CreateGround(options: {
  22399. width?: number;
  22400. height?: number;
  22401. subdivisions?: number;
  22402. subdivisionsX?: number;
  22403. subdivisionsY?: number;
  22404. }): VertexData;
  22405. /**
  22406. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22407. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22408. * * xmin the ground minimum X coordinate, optional, default -1
  22409. * * zmin the ground minimum Z coordinate, optional, default -1
  22410. * * xmax the ground maximum X coordinate, optional, default 1
  22411. * * zmax the ground maximum Z coordinate, optional, default 1
  22412. * * 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}
  22413. * * 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}
  22414. * @returns the VertexData of the TiledGround
  22415. */
  22416. static CreateTiledGround(options: {
  22417. xmin: number;
  22418. zmin: number;
  22419. xmax: number;
  22420. zmax: number;
  22421. subdivisions?: {
  22422. w: number;
  22423. h: number;
  22424. };
  22425. precision?: {
  22426. w: number;
  22427. h: number;
  22428. };
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData of the Ground designed from a heightmap
  22432. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22433. * * width the width (x direction) of the ground
  22434. * * height the height (z direction) of the ground
  22435. * * subdivisions the number of subdivisions per side
  22436. * * minHeight the minimum altitude on the ground, optional, default 0
  22437. * * maxHeight the maximum altitude on the ground, optional default 1
  22438. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22439. * * buffer the array holding the image color data
  22440. * * bufferWidth the width of image
  22441. * * bufferHeight the height of image
  22442. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22443. * @returns the VertexData of the Ground designed from a heightmap
  22444. */
  22445. static CreateGroundFromHeightMap(options: {
  22446. width: number;
  22447. height: number;
  22448. subdivisions: number;
  22449. minHeight: number;
  22450. maxHeight: number;
  22451. colorFilter: Color3;
  22452. buffer: Uint8Array;
  22453. bufferWidth: number;
  22454. bufferHeight: number;
  22455. alphaFilter: number;
  22456. }): VertexData;
  22457. /**
  22458. * Creates the VertexData for a Plane
  22459. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22460. * * size sets the width and height of the plane to the value of size, optional default 1
  22461. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22462. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22464. * * 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)
  22465. * * 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)
  22466. * @returns the VertexData of the box
  22467. */
  22468. static CreatePlane(options: {
  22469. size?: number;
  22470. width?: number;
  22471. height?: number;
  22472. sideOrientation?: number;
  22473. frontUVs?: Vector4;
  22474. backUVs?: Vector4;
  22475. }): VertexData;
  22476. /**
  22477. * Creates the VertexData of the Disc or regular Polygon
  22478. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22479. * * radius the radius of the disc, optional default 0.5
  22480. * * tessellation the number of polygon sides, optional, default 64
  22481. * * 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
  22482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22483. * * 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)
  22484. * * 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)
  22485. * @returns the VertexData of the box
  22486. */
  22487. static CreateDisc(options: {
  22488. radius?: number;
  22489. tessellation?: number;
  22490. arc?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. }): VertexData;
  22495. /**
  22496. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22497. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22498. * @param polygon a mesh built from polygonTriangulation.build()
  22499. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22501. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22502. * @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)
  22503. * @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)
  22504. * @returns the VertexData of the Polygon
  22505. */
  22506. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22507. /**
  22508. * Creates the VertexData of the IcoSphere
  22509. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22510. * * radius the radius of the IcoSphere, optional default 1
  22511. * * radiusX allows stretching in the x direction, optional, default radius
  22512. * * radiusY allows stretching in the y direction, optional, default radius
  22513. * * radiusZ allows stretching in the z direction, optional, default radius
  22514. * * flat when true creates a flat shaded mesh, optional, default true
  22515. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the IcoSphere
  22520. */
  22521. static CreateIcoSphere(options: {
  22522. radius?: number;
  22523. radiusX?: number;
  22524. radiusY?: number;
  22525. radiusZ?: number;
  22526. flat?: boolean;
  22527. subdivisions?: number;
  22528. sideOrientation?: number;
  22529. frontUVs?: Vector4;
  22530. backUVs?: Vector4;
  22531. }): VertexData;
  22532. /**
  22533. * Creates the VertexData for a Polyhedron
  22534. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22535. * * type provided types are:
  22536. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22537. * * 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)
  22538. * * size the size of the IcoSphere, optional default 1
  22539. * * sizeX allows stretching in the x direction, optional, default size
  22540. * * sizeY allows stretching in the y direction, optional, default size
  22541. * * sizeZ allows stretching in the z direction, optional, default size
  22542. * * 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
  22543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22545. * * flat when true creates a flat shaded mesh, optional, default true
  22546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22548. * * 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)
  22549. * * 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)
  22550. * @returns the VertexData of the Polyhedron
  22551. */
  22552. static CreatePolyhedron(options: {
  22553. type?: number;
  22554. size?: number;
  22555. sizeX?: number;
  22556. sizeY?: number;
  22557. sizeZ?: number;
  22558. custom?: any;
  22559. faceUV?: Vector4[];
  22560. faceColors?: Color4[];
  22561. flat?: boolean;
  22562. sideOrientation?: number;
  22563. frontUVs?: Vector4;
  22564. backUVs?: Vector4;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a TorusKnot
  22568. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22569. * * radius the radius of the torus knot, optional, default 2
  22570. * * tube the thickness of the tube, optional, default 0.5
  22571. * * radialSegments the number of sides on each tube segments, optional, default 32
  22572. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22573. * * p the number of windings around the z axis, optional, default 2
  22574. * * q the number of windings around the x axis, optional, default 3
  22575. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22576. * * 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)
  22577. * * 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)
  22578. * @returns the VertexData of the Torus Knot
  22579. */
  22580. static CreateTorusKnot(options: {
  22581. radius?: number;
  22582. tube?: number;
  22583. radialSegments?: number;
  22584. tubularSegments?: number;
  22585. p?: number;
  22586. q?: number;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. }): VertexData;
  22591. /**
  22592. * Compute normals for given positions and indices
  22593. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22594. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22595. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22596. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22597. * * facetNormals : optional array of facet normals (vector3)
  22598. * * facetPositions : optional array of facet positions (vector3)
  22599. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22600. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22601. * * bInfo : optional bounding info, required for facetPartitioning computation
  22602. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22603. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22604. * * useRightHandedSystem: optional boolean to for right handed system computation
  22605. * * depthSort : optional boolean to enable the facet depth sort computation
  22606. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22607. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22608. */
  22609. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22610. facetNormals?: any;
  22611. facetPositions?: any;
  22612. facetPartitioning?: any;
  22613. ratio?: number;
  22614. bInfo?: any;
  22615. bbSize?: Vector3;
  22616. subDiv?: any;
  22617. useRightHandedSystem?: boolean;
  22618. depthSort?: boolean;
  22619. distanceTo?: Vector3;
  22620. depthSortedFacets?: any;
  22621. }): void;
  22622. /** @hidden */
  22623. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22624. /**
  22625. * Applies VertexData created from the imported parameters to the geometry
  22626. * @param parsedVertexData the parsed data from an imported file
  22627. * @param geometry the geometry to apply the VertexData to
  22628. */
  22629. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22630. }
  22631. }
  22632. declare module "babylonjs/Morph/morphTarget" {
  22633. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22634. import { Observable } from "babylonjs/Misc/observable";
  22635. import { Nullable, FloatArray } from "babylonjs/types";
  22636. import { Scene } from "babylonjs/scene";
  22637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22638. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22639. /**
  22640. * Defines a target to use with MorphTargetManager
  22641. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22642. */
  22643. export class MorphTarget implements IAnimatable {
  22644. /** defines the name of the target */
  22645. name: string;
  22646. /**
  22647. * Gets or sets the list of animations
  22648. */
  22649. animations: import("babylonjs/Animations/animation").Animation[];
  22650. private _scene;
  22651. private _positions;
  22652. private _normals;
  22653. private _tangents;
  22654. private _uvs;
  22655. private _influence;
  22656. /**
  22657. * Observable raised when the influence changes
  22658. */
  22659. onInfluenceChanged: Observable<boolean>;
  22660. /** @hidden */
  22661. _onDataLayoutChanged: Observable<void>;
  22662. /**
  22663. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22664. */
  22665. influence: number;
  22666. /**
  22667. * Gets or sets the id of the morph Target
  22668. */
  22669. id: string;
  22670. private _animationPropertiesOverride;
  22671. /**
  22672. * Gets or sets the animation properties override
  22673. */
  22674. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22675. /**
  22676. * Creates a new MorphTarget
  22677. * @param name defines the name of the target
  22678. * @param influence defines the influence to use
  22679. * @param scene defines the scene the morphtarget belongs to
  22680. */
  22681. constructor(
  22682. /** defines the name of the target */
  22683. name: string, influence?: number, scene?: Nullable<Scene>);
  22684. /**
  22685. * Gets a boolean defining if the target contains position data
  22686. */
  22687. readonly hasPositions: boolean;
  22688. /**
  22689. * Gets a boolean defining if the target contains normal data
  22690. */
  22691. readonly hasNormals: boolean;
  22692. /**
  22693. * Gets a boolean defining if the target contains tangent data
  22694. */
  22695. readonly hasTangents: boolean;
  22696. /**
  22697. * Gets a boolean defining if the target contains texture coordinates data
  22698. */
  22699. readonly hasUVs: boolean;
  22700. /**
  22701. * Affects position data to this target
  22702. * @param data defines the position data to use
  22703. */
  22704. setPositions(data: Nullable<FloatArray>): void;
  22705. /**
  22706. * Gets the position data stored in this target
  22707. * @returns a FloatArray containing the position data (or null if not present)
  22708. */
  22709. getPositions(): Nullable<FloatArray>;
  22710. /**
  22711. * Affects normal data to this target
  22712. * @param data defines the normal data to use
  22713. */
  22714. setNormals(data: Nullable<FloatArray>): void;
  22715. /**
  22716. * Gets the normal data stored in this target
  22717. * @returns a FloatArray containing the normal data (or null if not present)
  22718. */
  22719. getNormals(): Nullable<FloatArray>;
  22720. /**
  22721. * Affects tangent data to this target
  22722. * @param data defines the tangent data to use
  22723. */
  22724. setTangents(data: Nullable<FloatArray>): void;
  22725. /**
  22726. * Gets the tangent data stored in this target
  22727. * @returns a FloatArray containing the tangent data (or null if not present)
  22728. */
  22729. getTangents(): Nullable<FloatArray>;
  22730. /**
  22731. * Affects texture coordinates data to this target
  22732. * @param data defines the texture coordinates data to use
  22733. */
  22734. setUVs(data: Nullable<FloatArray>): void;
  22735. /**
  22736. * Gets the texture coordinates data stored in this target
  22737. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22738. */
  22739. getUVs(): Nullable<FloatArray>;
  22740. /**
  22741. * Serializes the current target into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. /**
  22746. * Returns the string "MorphTarget"
  22747. * @returns "MorphTarget"
  22748. */
  22749. getClassName(): string;
  22750. /**
  22751. * Creates a new target from serialized data
  22752. * @param serializationObject defines the serialized data to use
  22753. * @returns a new MorphTarget
  22754. */
  22755. static Parse(serializationObject: any): MorphTarget;
  22756. /**
  22757. * Creates a MorphTarget from mesh data
  22758. * @param mesh defines the source mesh
  22759. * @param name defines the name to use for the new target
  22760. * @param influence defines the influence to attach to the target
  22761. * @returns a new MorphTarget
  22762. */
  22763. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22764. }
  22765. }
  22766. declare module "babylonjs/Morph/morphTargetManager" {
  22767. import { Nullable } from "babylonjs/types";
  22768. import { Scene } from "babylonjs/scene";
  22769. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22770. /**
  22771. * This class is used to deform meshes using morphing between different targets
  22772. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22773. */
  22774. export class MorphTargetManager {
  22775. private _targets;
  22776. private _targetInfluenceChangedObservers;
  22777. private _targetDataLayoutChangedObservers;
  22778. private _activeTargets;
  22779. private _scene;
  22780. private _influences;
  22781. private _supportsNormals;
  22782. private _supportsTangents;
  22783. private _supportsUVs;
  22784. private _vertexCount;
  22785. private _uniqueId;
  22786. private _tempInfluences;
  22787. /**
  22788. * Gets or sets a boolean indicating if normals must be morphed
  22789. */
  22790. enableNormalMorphing: boolean;
  22791. /**
  22792. * Gets or sets a boolean indicating if tangents must be morphed
  22793. */
  22794. enableTangentMorphing: boolean;
  22795. /**
  22796. * Gets or sets a boolean indicating if UV must be morphed
  22797. */
  22798. enableUVMorphing: boolean;
  22799. /**
  22800. * Creates a new MorphTargetManager
  22801. * @param scene defines the current scene
  22802. */
  22803. constructor(scene?: Nullable<Scene>);
  22804. /**
  22805. * Gets the unique ID of this manager
  22806. */
  22807. readonly uniqueId: number;
  22808. /**
  22809. * Gets the number of vertices handled by this manager
  22810. */
  22811. readonly vertexCount: number;
  22812. /**
  22813. * Gets a boolean indicating if this manager supports morphing of normals
  22814. */
  22815. readonly supportsNormals: boolean;
  22816. /**
  22817. * Gets a boolean indicating if this manager supports morphing of tangents
  22818. */
  22819. readonly supportsTangents: boolean;
  22820. /**
  22821. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22822. */
  22823. readonly supportsUVs: boolean;
  22824. /**
  22825. * Gets the number of targets stored in this manager
  22826. */
  22827. readonly numTargets: number;
  22828. /**
  22829. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22830. */
  22831. readonly numInfluencers: number;
  22832. /**
  22833. * Gets the list of influences (one per target)
  22834. */
  22835. readonly influences: Float32Array;
  22836. /**
  22837. * Gets the active target at specified index. An active target is a target with an influence > 0
  22838. * @param index defines the index to check
  22839. * @returns the requested target
  22840. */
  22841. getActiveTarget(index: number): MorphTarget;
  22842. /**
  22843. * Gets the target at specified index
  22844. * @param index defines the index to check
  22845. * @returns the requested target
  22846. */
  22847. getTarget(index: number): MorphTarget;
  22848. /**
  22849. * Add a new target to this manager
  22850. * @param target defines the target to add
  22851. */
  22852. addTarget(target: MorphTarget): void;
  22853. /**
  22854. * Removes a target from the manager
  22855. * @param target defines the target to remove
  22856. */
  22857. removeTarget(target: MorphTarget): void;
  22858. /**
  22859. * Serializes the current manager into a Serialization object
  22860. * @returns the serialized object
  22861. */
  22862. serialize(): any;
  22863. private _syncActiveTargets;
  22864. /**
  22865. * Syncrhonize the targets with all the meshes using this morph target manager
  22866. */
  22867. synchronize(): void;
  22868. /**
  22869. * Creates a new MorphTargetManager from serialized data
  22870. * @param serializationObject defines the serialized data
  22871. * @param scene defines the hosting scene
  22872. * @returns the new MorphTargetManager
  22873. */
  22874. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22875. }
  22876. }
  22877. declare module "babylonjs/Meshes/meshLODLevel" {
  22878. import { Mesh } from "babylonjs/Meshes/mesh";
  22879. import { Nullable } from "babylonjs/types";
  22880. /**
  22881. * Class used to represent a specific level of detail of a mesh
  22882. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22883. */
  22884. export class MeshLODLevel {
  22885. /** Defines the distance where this level should start being displayed */
  22886. distance: number;
  22887. /** Defines the mesh to use to render this level */
  22888. mesh: Nullable<Mesh>;
  22889. /**
  22890. * Creates a new LOD level
  22891. * @param distance defines the distance where this level should star being displayed
  22892. * @param mesh defines the mesh to use to render this level
  22893. */
  22894. constructor(
  22895. /** Defines the distance where this level should start being displayed */
  22896. distance: number,
  22897. /** Defines the mesh to use to render this level */
  22898. mesh: Nullable<Mesh>);
  22899. }
  22900. }
  22901. declare module "babylonjs/Meshes/groundMesh" {
  22902. import { Scene } from "babylonjs/scene";
  22903. import { Vector3 } from "babylonjs/Maths/math.vector";
  22904. import { Mesh } from "babylonjs/Meshes/mesh";
  22905. /**
  22906. * Mesh representing the gorund
  22907. */
  22908. export class GroundMesh extends Mesh {
  22909. /** If octree should be generated */
  22910. generateOctree: boolean;
  22911. private _heightQuads;
  22912. /** @hidden */
  22913. _subdivisionsX: number;
  22914. /** @hidden */
  22915. _subdivisionsY: number;
  22916. /** @hidden */
  22917. _width: number;
  22918. /** @hidden */
  22919. _height: number;
  22920. /** @hidden */
  22921. _minX: number;
  22922. /** @hidden */
  22923. _maxX: number;
  22924. /** @hidden */
  22925. _minZ: number;
  22926. /** @hidden */
  22927. _maxZ: number;
  22928. constructor(name: string, scene: Scene);
  22929. /**
  22930. * "GroundMesh"
  22931. * @returns "GroundMesh"
  22932. */
  22933. getClassName(): string;
  22934. /**
  22935. * The minimum of x and y subdivisions
  22936. */
  22937. readonly subdivisions: number;
  22938. /**
  22939. * X subdivisions
  22940. */
  22941. readonly subdivisionsX: number;
  22942. /**
  22943. * Y subdivisions
  22944. */
  22945. readonly subdivisionsY: number;
  22946. /**
  22947. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22948. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22949. * @param chunksCount the number of subdivisions for x and y
  22950. * @param octreeBlocksSize (Default: 32)
  22951. */
  22952. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22953. /**
  22954. * Returns a height (y) value in the Worl system :
  22955. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22956. * @param x x coordinate
  22957. * @param z z coordinate
  22958. * @returns the ground y position if (x, z) are outside the ground surface.
  22959. */
  22960. getHeightAtCoordinates(x: number, z: number): number;
  22961. /**
  22962. * Returns a normalized vector (Vector3) orthogonal to the ground
  22963. * at the ground coordinates (x, z) expressed in the World system.
  22964. * @param x x coordinate
  22965. * @param z z coordinate
  22966. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22967. */
  22968. getNormalAtCoordinates(x: number, z: number): Vector3;
  22969. /**
  22970. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22971. * at the ground coordinates (x, z) expressed in the World system.
  22972. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22973. * @param x x coordinate
  22974. * @param z z coordinate
  22975. * @param ref vector to store the result
  22976. * @returns the GroundMesh.
  22977. */
  22978. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22979. /**
  22980. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22981. * if the ground has been updated.
  22982. * This can be used in the render loop.
  22983. * @returns the GroundMesh.
  22984. */
  22985. updateCoordinateHeights(): GroundMesh;
  22986. private _getFacetAt;
  22987. private _initHeightQuads;
  22988. private _computeHeightQuads;
  22989. /**
  22990. * Serializes this ground mesh
  22991. * @param serializationObject object to write serialization to
  22992. */
  22993. serialize(serializationObject: any): void;
  22994. /**
  22995. * Parses a serialized ground mesh
  22996. * @param parsedMesh the serialized mesh
  22997. * @param scene the scene to create the ground mesh in
  22998. * @returns the created ground mesh
  22999. */
  23000. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23001. }
  23002. }
  23003. declare module "babylonjs/Physics/physicsJoint" {
  23004. import { Vector3 } from "babylonjs/Maths/math.vector";
  23005. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23006. /**
  23007. * Interface for Physics-Joint data
  23008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23009. */
  23010. export interface PhysicsJointData {
  23011. /**
  23012. * The main pivot of the joint
  23013. */
  23014. mainPivot?: Vector3;
  23015. /**
  23016. * The connected pivot of the joint
  23017. */
  23018. connectedPivot?: Vector3;
  23019. /**
  23020. * The main axis of the joint
  23021. */
  23022. mainAxis?: Vector3;
  23023. /**
  23024. * The connected axis of the joint
  23025. */
  23026. connectedAxis?: Vector3;
  23027. /**
  23028. * The collision of the joint
  23029. */
  23030. collision?: boolean;
  23031. /**
  23032. * Native Oimo/Cannon/Energy data
  23033. */
  23034. nativeParams?: any;
  23035. }
  23036. /**
  23037. * This is a holder class for the physics joint created by the physics plugin
  23038. * It holds a set of functions to control the underlying joint
  23039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23040. */
  23041. export class PhysicsJoint {
  23042. /**
  23043. * The type of the physics joint
  23044. */
  23045. type: number;
  23046. /**
  23047. * The data for the physics joint
  23048. */
  23049. jointData: PhysicsJointData;
  23050. private _physicsJoint;
  23051. protected _physicsPlugin: IPhysicsEnginePlugin;
  23052. /**
  23053. * Initializes the physics joint
  23054. * @param type The type of the physics joint
  23055. * @param jointData The data for the physics joint
  23056. */
  23057. constructor(
  23058. /**
  23059. * The type of the physics joint
  23060. */
  23061. type: number,
  23062. /**
  23063. * The data for the physics joint
  23064. */
  23065. jointData: PhysicsJointData);
  23066. /**
  23067. * Gets the physics joint
  23068. */
  23069. /**
  23070. * Sets the physics joint
  23071. */
  23072. physicsJoint: any;
  23073. /**
  23074. * Sets the physics plugin
  23075. */
  23076. physicsPlugin: IPhysicsEnginePlugin;
  23077. /**
  23078. * Execute a function that is physics-plugin specific.
  23079. * @param {Function} func the function that will be executed.
  23080. * It accepts two parameters: the physics world and the physics joint
  23081. */
  23082. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23083. /**
  23084. * Distance-Joint type
  23085. */
  23086. static DistanceJoint: number;
  23087. /**
  23088. * Hinge-Joint type
  23089. */
  23090. static HingeJoint: number;
  23091. /**
  23092. * Ball-and-Socket joint type
  23093. */
  23094. static BallAndSocketJoint: number;
  23095. /**
  23096. * Wheel-Joint type
  23097. */
  23098. static WheelJoint: number;
  23099. /**
  23100. * Slider-Joint type
  23101. */
  23102. static SliderJoint: number;
  23103. /**
  23104. * Prismatic-Joint type
  23105. */
  23106. static PrismaticJoint: number;
  23107. /**
  23108. * Universal-Joint type
  23109. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23110. */
  23111. static UniversalJoint: number;
  23112. /**
  23113. * Hinge-Joint 2 type
  23114. */
  23115. static Hinge2Joint: number;
  23116. /**
  23117. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23118. */
  23119. static PointToPointJoint: number;
  23120. /**
  23121. * Spring-Joint type
  23122. */
  23123. static SpringJoint: number;
  23124. /**
  23125. * Lock-Joint type
  23126. */
  23127. static LockJoint: number;
  23128. }
  23129. /**
  23130. * A class representing a physics distance joint
  23131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23132. */
  23133. export class DistanceJoint extends PhysicsJoint {
  23134. /**
  23135. *
  23136. * @param jointData The data for the Distance-Joint
  23137. */
  23138. constructor(jointData: DistanceJointData);
  23139. /**
  23140. * Update the predefined distance.
  23141. * @param maxDistance The maximum preferred distance
  23142. * @param minDistance The minimum preferred distance
  23143. */
  23144. updateDistance(maxDistance: number, minDistance?: number): void;
  23145. }
  23146. /**
  23147. * Represents a Motor-Enabled Joint
  23148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23149. */
  23150. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23151. /**
  23152. * Initializes the Motor-Enabled Joint
  23153. * @param type The type of the joint
  23154. * @param jointData The physica joint data for the joint
  23155. */
  23156. constructor(type: number, jointData: PhysicsJointData);
  23157. /**
  23158. * Set the motor values.
  23159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23160. * @param force the force to apply
  23161. * @param maxForce max force for this motor.
  23162. */
  23163. setMotor(force?: number, maxForce?: number): void;
  23164. /**
  23165. * Set the motor's limits.
  23166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23167. * @param upperLimit The upper limit of the motor
  23168. * @param lowerLimit The lower limit of the motor
  23169. */
  23170. setLimit(upperLimit: number, lowerLimit?: number): void;
  23171. }
  23172. /**
  23173. * This class represents a single physics Hinge-Joint
  23174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23175. */
  23176. export class HingeJoint extends MotorEnabledJoint {
  23177. /**
  23178. * Initializes the Hinge-Joint
  23179. * @param jointData The joint data for the Hinge-Joint
  23180. */
  23181. constructor(jointData: PhysicsJointData);
  23182. /**
  23183. * Set the motor values.
  23184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23185. * @param {number} force the force to apply
  23186. * @param {number} maxForce max force for this motor.
  23187. */
  23188. setMotor(force?: number, maxForce?: number): void;
  23189. /**
  23190. * Set the motor's limits.
  23191. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23192. * @param upperLimit The upper limit of the motor
  23193. * @param lowerLimit The lower limit of the motor
  23194. */
  23195. setLimit(upperLimit: number, lowerLimit?: number): void;
  23196. }
  23197. /**
  23198. * This class represents a dual hinge physics joint (same as wheel joint)
  23199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23200. */
  23201. export class Hinge2Joint extends MotorEnabledJoint {
  23202. /**
  23203. * Initializes the Hinge2-Joint
  23204. * @param jointData The joint data for the Hinge2-Joint
  23205. */
  23206. constructor(jointData: PhysicsJointData);
  23207. /**
  23208. * Set the motor values.
  23209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23210. * @param {number} targetSpeed the speed the motor is to reach
  23211. * @param {number} maxForce max force for this motor.
  23212. * @param {motorIndex} the motor's index, 0 or 1.
  23213. */
  23214. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23215. /**
  23216. * Set the motor limits.
  23217. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23218. * @param {number} upperLimit the upper limit
  23219. * @param {number} lowerLimit lower limit
  23220. * @param {motorIndex} the motor's index, 0 or 1.
  23221. */
  23222. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23223. }
  23224. /**
  23225. * Interface for a motor enabled joint
  23226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23227. */
  23228. export interface IMotorEnabledJoint {
  23229. /**
  23230. * Physics joint
  23231. */
  23232. physicsJoint: any;
  23233. /**
  23234. * Sets the motor of the motor-enabled joint
  23235. * @param force The force of the motor
  23236. * @param maxForce The maximum force of the motor
  23237. * @param motorIndex The index of the motor
  23238. */
  23239. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23240. /**
  23241. * Sets the limit of the motor
  23242. * @param upperLimit The upper limit of the motor
  23243. * @param lowerLimit The lower limit of the motor
  23244. * @param motorIndex The index of the motor
  23245. */
  23246. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23247. }
  23248. /**
  23249. * Joint data for a Distance-Joint
  23250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23251. */
  23252. export interface DistanceJointData extends PhysicsJointData {
  23253. /**
  23254. * Max distance the 2 joint objects can be apart
  23255. */
  23256. maxDistance: number;
  23257. }
  23258. /**
  23259. * Joint data from a spring joint
  23260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23261. */
  23262. export interface SpringJointData extends PhysicsJointData {
  23263. /**
  23264. * Length of the spring
  23265. */
  23266. length: number;
  23267. /**
  23268. * Stiffness of the spring
  23269. */
  23270. stiffness: number;
  23271. /**
  23272. * Damping of the spring
  23273. */
  23274. damping: number;
  23275. /** this callback will be called when applying the force to the impostors. */
  23276. forceApplicationCallback: () => void;
  23277. }
  23278. }
  23279. declare module "babylonjs/Physics/physicsRaycastResult" {
  23280. import { Vector3 } from "babylonjs/Maths/math.vector";
  23281. /**
  23282. * Holds the data for the raycast result
  23283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23284. */
  23285. export class PhysicsRaycastResult {
  23286. private _hasHit;
  23287. private _hitDistance;
  23288. private _hitNormalWorld;
  23289. private _hitPointWorld;
  23290. private _rayFromWorld;
  23291. private _rayToWorld;
  23292. /**
  23293. * Gets if there was a hit
  23294. */
  23295. readonly hasHit: boolean;
  23296. /**
  23297. * Gets the distance from the hit
  23298. */
  23299. readonly hitDistance: number;
  23300. /**
  23301. * Gets the hit normal/direction in the world
  23302. */
  23303. readonly hitNormalWorld: Vector3;
  23304. /**
  23305. * Gets the hit point in the world
  23306. */
  23307. readonly hitPointWorld: Vector3;
  23308. /**
  23309. * Gets the ray "start point" of the ray in the world
  23310. */
  23311. readonly rayFromWorld: Vector3;
  23312. /**
  23313. * Gets the ray "end point" of the ray in the world
  23314. */
  23315. readonly rayToWorld: Vector3;
  23316. /**
  23317. * Sets the hit data (normal & point in world space)
  23318. * @param hitNormalWorld defines the normal in world space
  23319. * @param hitPointWorld defines the point in world space
  23320. */
  23321. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23322. /**
  23323. * Sets the distance from the start point to the hit point
  23324. * @param distance
  23325. */
  23326. setHitDistance(distance: number): void;
  23327. /**
  23328. * Calculates the distance manually
  23329. */
  23330. calculateHitDistance(): void;
  23331. /**
  23332. * Resets all the values to default
  23333. * @param from The from point on world space
  23334. * @param to The to point on world space
  23335. */
  23336. reset(from?: Vector3, to?: Vector3): void;
  23337. }
  23338. /**
  23339. * Interface for the size containing width and height
  23340. */
  23341. interface IXYZ {
  23342. /**
  23343. * X
  23344. */
  23345. x: number;
  23346. /**
  23347. * Y
  23348. */
  23349. y: number;
  23350. /**
  23351. * Z
  23352. */
  23353. z: number;
  23354. }
  23355. }
  23356. declare module "babylonjs/Physics/IPhysicsEngine" {
  23357. import { Nullable } from "babylonjs/types";
  23358. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23360. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23361. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23362. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23363. /**
  23364. * Interface used to describe a physics joint
  23365. */
  23366. export interface PhysicsImpostorJoint {
  23367. /** Defines the main impostor to which the joint is linked */
  23368. mainImpostor: PhysicsImpostor;
  23369. /** Defines the impostor that is connected to the main impostor using this joint */
  23370. connectedImpostor: PhysicsImpostor;
  23371. /** Defines the joint itself */
  23372. joint: PhysicsJoint;
  23373. }
  23374. /** @hidden */
  23375. export interface IPhysicsEnginePlugin {
  23376. world: any;
  23377. name: string;
  23378. setGravity(gravity: Vector3): void;
  23379. setTimeStep(timeStep: number): void;
  23380. getTimeStep(): number;
  23381. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23383. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23384. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23385. removePhysicsBody(impostor: PhysicsImpostor): void;
  23386. generateJoint(joint: PhysicsImpostorJoint): void;
  23387. removeJoint(joint: PhysicsImpostorJoint): void;
  23388. isSupported(): boolean;
  23389. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23390. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23391. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23392. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23393. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23394. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23395. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23396. getBodyMass(impostor: PhysicsImpostor): number;
  23397. getBodyFriction(impostor: PhysicsImpostor): number;
  23398. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23399. getBodyRestitution(impostor: PhysicsImpostor): number;
  23400. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23401. getBodyPressure?(impostor: PhysicsImpostor): number;
  23402. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23403. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23404. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23405. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23406. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23407. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23408. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23409. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23410. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23411. sleepBody(impostor: PhysicsImpostor): void;
  23412. wakeUpBody(impostor: PhysicsImpostor): void;
  23413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23414. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23415. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23416. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23417. getRadius(impostor: PhysicsImpostor): number;
  23418. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23419. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23420. dispose(): void;
  23421. }
  23422. /**
  23423. * Interface used to define a physics engine
  23424. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23425. */
  23426. export interface IPhysicsEngine {
  23427. /**
  23428. * Gets the gravity vector used by the simulation
  23429. */
  23430. gravity: Vector3;
  23431. /**
  23432. * Sets the gravity vector used by the simulation
  23433. * @param gravity defines the gravity vector to use
  23434. */
  23435. setGravity(gravity: Vector3): void;
  23436. /**
  23437. * Set the time step of the physics engine.
  23438. * Default is 1/60.
  23439. * To slow it down, enter 1/600 for example.
  23440. * To speed it up, 1/30
  23441. * @param newTimeStep the new timestep to apply to this world.
  23442. */
  23443. setTimeStep(newTimeStep: number): void;
  23444. /**
  23445. * Get the time step of the physics engine.
  23446. * @returns the current time step
  23447. */
  23448. getTimeStep(): number;
  23449. /**
  23450. * Release all resources
  23451. */
  23452. dispose(): void;
  23453. /**
  23454. * Gets the name of the current physics plugin
  23455. * @returns the name of the plugin
  23456. */
  23457. getPhysicsPluginName(): string;
  23458. /**
  23459. * Adding a new impostor for the impostor tracking.
  23460. * This will be done by the impostor itself.
  23461. * @param impostor the impostor to add
  23462. */
  23463. addImpostor(impostor: PhysicsImpostor): void;
  23464. /**
  23465. * Remove an impostor from the engine.
  23466. * This impostor and its mesh will not longer be updated by the physics engine.
  23467. * @param impostor the impostor to remove
  23468. */
  23469. removeImpostor(impostor: PhysicsImpostor): void;
  23470. /**
  23471. * Add a joint to the physics engine
  23472. * @param mainImpostor defines the main impostor to which the joint is added.
  23473. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23474. * @param joint defines the joint that will connect both impostors.
  23475. */
  23476. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23477. /**
  23478. * Removes a joint from the simulation
  23479. * @param mainImpostor defines the impostor used with the joint
  23480. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23481. * @param joint defines the joint to remove
  23482. */
  23483. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23484. /**
  23485. * Gets the current plugin used to run the simulation
  23486. * @returns current plugin
  23487. */
  23488. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23489. /**
  23490. * Gets the list of physic impostors
  23491. * @returns an array of PhysicsImpostor
  23492. */
  23493. getImpostors(): Array<PhysicsImpostor>;
  23494. /**
  23495. * Gets the impostor for a physics enabled object
  23496. * @param object defines the object impersonated by the impostor
  23497. * @returns the PhysicsImpostor or null if not found
  23498. */
  23499. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23500. /**
  23501. * Gets the impostor for a physics body object
  23502. * @param body defines physics body used by the impostor
  23503. * @returns the PhysicsImpostor or null if not found
  23504. */
  23505. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23506. /**
  23507. * Does a raycast in the physics world
  23508. * @param from when should the ray start?
  23509. * @param to when should the ray end?
  23510. * @returns PhysicsRaycastResult
  23511. */
  23512. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23513. /**
  23514. * Called by the scene. No need to call it.
  23515. * @param delta defines the timespam between frames
  23516. */
  23517. _step(delta: number): void;
  23518. }
  23519. }
  23520. declare module "babylonjs/Physics/physicsImpostor" {
  23521. import { Nullable, IndicesArray } from "babylonjs/types";
  23522. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23523. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23525. import { Scene } from "babylonjs/scene";
  23526. import { Bone } from "babylonjs/Bones/bone";
  23527. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23528. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23529. import { Space } from "babylonjs/Maths/math.axis";
  23530. /**
  23531. * The interface for the physics imposter parameters
  23532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23533. */
  23534. export interface PhysicsImpostorParameters {
  23535. /**
  23536. * The mass of the physics imposter
  23537. */
  23538. mass: number;
  23539. /**
  23540. * The friction of the physics imposter
  23541. */
  23542. friction?: number;
  23543. /**
  23544. * The coefficient of restitution of the physics imposter
  23545. */
  23546. restitution?: number;
  23547. /**
  23548. * The native options of the physics imposter
  23549. */
  23550. nativeOptions?: any;
  23551. /**
  23552. * Specifies if the parent should be ignored
  23553. */
  23554. ignoreParent?: boolean;
  23555. /**
  23556. * Specifies if bi-directional transformations should be disabled
  23557. */
  23558. disableBidirectionalTransformation?: boolean;
  23559. /**
  23560. * The pressure inside the physics imposter, soft object only
  23561. */
  23562. pressure?: number;
  23563. /**
  23564. * The stiffness the physics imposter, soft object only
  23565. */
  23566. stiffness?: number;
  23567. /**
  23568. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23569. */
  23570. velocityIterations?: number;
  23571. /**
  23572. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23573. */
  23574. positionIterations?: number;
  23575. /**
  23576. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23577. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23578. * Add to fix multiple points
  23579. */
  23580. fixedPoints?: number;
  23581. /**
  23582. * The collision margin around a soft object
  23583. */
  23584. margin?: number;
  23585. /**
  23586. * The collision margin around a soft object
  23587. */
  23588. damping?: number;
  23589. /**
  23590. * The path for a rope based on an extrusion
  23591. */
  23592. path?: any;
  23593. /**
  23594. * The shape of an extrusion used for a rope based on an extrusion
  23595. */
  23596. shape?: any;
  23597. }
  23598. /**
  23599. * Interface for a physics-enabled object
  23600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23601. */
  23602. export interface IPhysicsEnabledObject {
  23603. /**
  23604. * The position of the physics-enabled object
  23605. */
  23606. position: Vector3;
  23607. /**
  23608. * The rotation of the physics-enabled object
  23609. */
  23610. rotationQuaternion: Nullable<Quaternion>;
  23611. /**
  23612. * The scale of the physics-enabled object
  23613. */
  23614. scaling: Vector3;
  23615. /**
  23616. * The rotation of the physics-enabled object
  23617. */
  23618. rotation?: Vector3;
  23619. /**
  23620. * The parent of the physics-enabled object
  23621. */
  23622. parent?: any;
  23623. /**
  23624. * The bounding info of the physics-enabled object
  23625. * @returns The bounding info of the physics-enabled object
  23626. */
  23627. getBoundingInfo(): BoundingInfo;
  23628. /**
  23629. * Computes the world matrix
  23630. * @param force Specifies if the world matrix should be computed by force
  23631. * @returns A world matrix
  23632. */
  23633. computeWorldMatrix(force: boolean): Matrix;
  23634. /**
  23635. * Gets the world matrix
  23636. * @returns A world matrix
  23637. */
  23638. getWorldMatrix?(): Matrix;
  23639. /**
  23640. * Gets the child meshes
  23641. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23642. * @returns An array of abstract meshes
  23643. */
  23644. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23645. /**
  23646. * Gets the vertex data
  23647. * @param kind The type of vertex data
  23648. * @returns A nullable array of numbers, or a float32 array
  23649. */
  23650. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23651. /**
  23652. * Gets the indices from the mesh
  23653. * @returns A nullable array of index arrays
  23654. */
  23655. getIndices?(): Nullable<IndicesArray>;
  23656. /**
  23657. * Gets the scene from the mesh
  23658. * @returns the indices array or null
  23659. */
  23660. getScene?(): Scene;
  23661. /**
  23662. * Gets the absolute position from the mesh
  23663. * @returns the absolute position
  23664. */
  23665. getAbsolutePosition(): Vector3;
  23666. /**
  23667. * Gets the absolute pivot point from the mesh
  23668. * @returns the absolute pivot point
  23669. */
  23670. getAbsolutePivotPoint(): Vector3;
  23671. /**
  23672. * Rotates the mesh
  23673. * @param axis The axis of rotation
  23674. * @param amount The amount of rotation
  23675. * @param space The space of the rotation
  23676. * @returns The rotation transform node
  23677. */
  23678. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23679. /**
  23680. * Translates the mesh
  23681. * @param axis The axis of translation
  23682. * @param distance The distance of translation
  23683. * @param space The space of the translation
  23684. * @returns The transform node
  23685. */
  23686. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23687. /**
  23688. * Sets the absolute position of the mesh
  23689. * @param absolutePosition The absolute position of the mesh
  23690. * @returns The transform node
  23691. */
  23692. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23693. /**
  23694. * Gets the class name of the mesh
  23695. * @returns The class name
  23696. */
  23697. getClassName(): string;
  23698. }
  23699. /**
  23700. * Represents a physics imposter
  23701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23702. */
  23703. export class PhysicsImpostor {
  23704. /**
  23705. * The physics-enabled object used as the physics imposter
  23706. */
  23707. object: IPhysicsEnabledObject;
  23708. /**
  23709. * The type of the physics imposter
  23710. */
  23711. type: number;
  23712. private _options;
  23713. private _scene?;
  23714. /**
  23715. * The default object size of the imposter
  23716. */
  23717. static DEFAULT_OBJECT_SIZE: Vector3;
  23718. /**
  23719. * The identity quaternion of the imposter
  23720. */
  23721. static IDENTITY_QUATERNION: Quaternion;
  23722. /** @hidden */
  23723. _pluginData: any;
  23724. private _physicsEngine;
  23725. private _physicsBody;
  23726. private _bodyUpdateRequired;
  23727. private _onBeforePhysicsStepCallbacks;
  23728. private _onAfterPhysicsStepCallbacks;
  23729. /** @hidden */
  23730. _onPhysicsCollideCallbacks: Array<{
  23731. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23732. otherImpostors: Array<PhysicsImpostor>;
  23733. }>;
  23734. private _deltaPosition;
  23735. private _deltaRotation;
  23736. private _deltaRotationConjugated;
  23737. /** @hidden */
  23738. _isFromLine: boolean;
  23739. private _parent;
  23740. private _isDisposed;
  23741. private static _tmpVecs;
  23742. private static _tmpQuat;
  23743. /**
  23744. * Specifies if the physics imposter is disposed
  23745. */
  23746. readonly isDisposed: boolean;
  23747. /**
  23748. * Gets the mass of the physics imposter
  23749. */
  23750. mass: number;
  23751. /**
  23752. * Gets the coefficient of friction
  23753. */
  23754. /**
  23755. * Sets the coefficient of friction
  23756. */
  23757. friction: number;
  23758. /**
  23759. * Gets the coefficient of restitution
  23760. */
  23761. /**
  23762. * Sets the coefficient of restitution
  23763. */
  23764. restitution: number;
  23765. /**
  23766. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23767. */
  23768. /**
  23769. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23770. */
  23771. pressure: number;
  23772. /**
  23773. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23774. */
  23775. /**
  23776. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23777. */
  23778. stiffness: number;
  23779. /**
  23780. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23781. */
  23782. /**
  23783. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. velocityIterations: number;
  23786. /**
  23787. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. /**
  23790. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23791. */
  23792. positionIterations: number;
  23793. /**
  23794. * The unique id of the physics imposter
  23795. * set by the physics engine when adding this impostor to the array
  23796. */
  23797. uniqueId: number;
  23798. /**
  23799. * @hidden
  23800. */
  23801. soft: boolean;
  23802. /**
  23803. * @hidden
  23804. */
  23805. segments: number;
  23806. private _joints;
  23807. /**
  23808. * Initializes the physics imposter
  23809. * @param object The physics-enabled object used as the physics imposter
  23810. * @param type The type of the physics imposter
  23811. * @param _options The options for the physics imposter
  23812. * @param _scene The Babylon scene
  23813. */
  23814. constructor(
  23815. /**
  23816. * The physics-enabled object used as the physics imposter
  23817. */
  23818. object: IPhysicsEnabledObject,
  23819. /**
  23820. * The type of the physics imposter
  23821. */
  23822. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23823. /**
  23824. * This function will completly initialize this impostor.
  23825. * It will create a new body - but only if this mesh has no parent.
  23826. * If it has, this impostor will not be used other than to define the impostor
  23827. * of the child mesh.
  23828. * @hidden
  23829. */
  23830. _init(): void;
  23831. private _getPhysicsParent;
  23832. /**
  23833. * Should a new body be generated.
  23834. * @returns boolean specifying if body initialization is required
  23835. */
  23836. isBodyInitRequired(): boolean;
  23837. /**
  23838. * Sets the updated scaling
  23839. * @param updated Specifies if the scaling is updated
  23840. */
  23841. setScalingUpdated(): void;
  23842. /**
  23843. * Force a regeneration of this or the parent's impostor's body.
  23844. * Use under cautious - This will remove all joints already implemented.
  23845. */
  23846. forceUpdate(): void;
  23847. /**
  23848. * Gets the body that holds this impostor. Either its own, or its parent.
  23849. */
  23850. /**
  23851. * Set the physics body. Used mainly by the physics engine/plugin
  23852. */
  23853. physicsBody: any;
  23854. /**
  23855. * Get the parent of the physics imposter
  23856. * @returns Physics imposter or null
  23857. */
  23858. /**
  23859. * Sets the parent of the physics imposter
  23860. */
  23861. parent: Nullable<PhysicsImpostor>;
  23862. /**
  23863. * Resets the update flags
  23864. */
  23865. resetUpdateFlags(): void;
  23866. /**
  23867. * Gets the object extend size
  23868. * @returns the object extend size
  23869. */
  23870. getObjectExtendSize(): Vector3;
  23871. /**
  23872. * Gets the object center
  23873. * @returns The object center
  23874. */
  23875. getObjectCenter(): Vector3;
  23876. /**
  23877. * Get a specific parametes from the options parameter
  23878. * @param paramName The object parameter name
  23879. * @returns The object parameter
  23880. */
  23881. getParam(paramName: string): any;
  23882. /**
  23883. * Sets a specific parameter in the options given to the physics plugin
  23884. * @param paramName The parameter name
  23885. * @param value The value of the parameter
  23886. */
  23887. setParam(paramName: string, value: number): void;
  23888. /**
  23889. * Specifically change the body's mass option. Won't recreate the physics body object
  23890. * @param mass The mass of the physics imposter
  23891. */
  23892. setMass(mass: number): void;
  23893. /**
  23894. * Gets the linear velocity
  23895. * @returns linear velocity or null
  23896. */
  23897. getLinearVelocity(): Nullable<Vector3>;
  23898. /**
  23899. * Sets the linear velocity
  23900. * @param velocity linear velocity or null
  23901. */
  23902. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23903. /**
  23904. * Gets the angular velocity
  23905. * @returns angular velocity or null
  23906. */
  23907. getAngularVelocity(): Nullable<Vector3>;
  23908. /**
  23909. * Sets the angular velocity
  23910. * @param velocity The velocity or null
  23911. */
  23912. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23913. /**
  23914. * Execute a function with the physics plugin native code
  23915. * Provide a function the will have two variables - the world object and the physics body object
  23916. * @param func The function to execute with the physics plugin native code
  23917. */
  23918. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23919. /**
  23920. * Register a function that will be executed before the physics world is stepping forward
  23921. * @param func The function to execute before the physics world is stepped forward
  23922. */
  23923. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23924. /**
  23925. * Unregister a function that will be executed before the physics world is stepping forward
  23926. * @param func The function to execute before the physics world is stepped forward
  23927. */
  23928. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23929. /**
  23930. * Register a function that will be executed after the physics step
  23931. * @param func The function to execute after physics step
  23932. */
  23933. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23934. /**
  23935. * Unregisters a function that will be executed after the physics step
  23936. * @param func The function to execute after physics step
  23937. */
  23938. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23939. /**
  23940. * register a function that will be executed when this impostor collides against a different body
  23941. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23942. * @param func Callback that is executed on collision
  23943. */
  23944. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23945. /**
  23946. * Unregisters the physics imposter on contact
  23947. * @param collideAgainst The physics object to collide against
  23948. * @param func Callback to execute on collision
  23949. */
  23950. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23951. private _tmpQuat;
  23952. private _tmpQuat2;
  23953. /**
  23954. * Get the parent rotation
  23955. * @returns The parent rotation
  23956. */
  23957. getParentsRotation(): Quaternion;
  23958. /**
  23959. * this function is executed by the physics engine.
  23960. */
  23961. beforeStep: () => void;
  23962. /**
  23963. * this function is executed by the physics engine
  23964. */
  23965. afterStep: () => void;
  23966. /**
  23967. * Legacy collision detection event support
  23968. */
  23969. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23970. /**
  23971. * event and body object due to cannon's event-based architecture.
  23972. */
  23973. onCollide: (e: {
  23974. body: any;
  23975. }) => void;
  23976. /**
  23977. * Apply a force
  23978. * @param force The force to apply
  23979. * @param contactPoint The contact point for the force
  23980. * @returns The physics imposter
  23981. */
  23982. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23983. /**
  23984. * Apply an impulse
  23985. * @param force The impulse force
  23986. * @param contactPoint The contact point for the impulse force
  23987. * @returns The physics imposter
  23988. */
  23989. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23990. /**
  23991. * A help function to create a joint
  23992. * @param otherImpostor A physics imposter used to create a joint
  23993. * @param jointType The type of joint
  23994. * @param jointData The data for the joint
  23995. * @returns The physics imposter
  23996. */
  23997. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23998. /**
  23999. * Add a joint to this impostor with a different impostor
  24000. * @param otherImpostor A physics imposter used to add a joint
  24001. * @param joint The joint to add
  24002. * @returns The physics imposter
  24003. */
  24004. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24005. /**
  24006. * Add an anchor to a cloth impostor
  24007. * @param otherImpostor rigid impostor to anchor to
  24008. * @param width ratio across width from 0 to 1
  24009. * @param height ratio up height from 0 to 1
  24010. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24011. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24012. * @returns impostor the soft imposter
  24013. */
  24014. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24015. /**
  24016. * Add a hook to a rope impostor
  24017. * @param otherImpostor rigid impostor to anchor to
  24018. * @param length ratio across rope from 0 to 1
  24019. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24020. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24021. * @returns impostor the rope imposter
  24022. */
  24023. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24024. /**
  24025. * Will keep this body still, in a sleep mode.
  24026. * @returns the physics imposter
  24027. */
  24028. sleep(): PhysicsImpostor;
  24029. /**
  24030. * Wake the body up.
  24031. * @returns The physics imposter
  24032. */
  24033. wakeUp(): PhysicsImpostor;
  24034. /**
  24035. * Clones the physics imposter
  24036. * @param newObject The physics imposter clones to this physics-enabled object
  24037. * @returns A nullable physics imposter
  24038. */
  24039. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24040. /**
  24041. * Disposes the physics imposter
  24042. */
  24043. dispose(): void;
  24044. /**
  24045. * Sets the delta position
  24046. * @param position The delta position amount
  24047. */
  24048. setDeltaPosition(position: Vector3): void;
  24049. /**
  24050. * Sets the delta rotation
  24051. * @param rotation The delta rotation amount
  24052. */
  24053. setDeltaRotation(rotation: Quaternion): void;
  24054. /**
  24055. * Gets the box size of the physics imposter and stores the result in the input parameter
  24056. * @param result Stores the box size
  24057. * @returns The physics imposter
  24058. */
  24059. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24060. /**
  24061. * Gets the radius of the physics imposter
  24062. * @returns Radius of the physics imposter
  24063. */
  24064. getRadius(): number;
  24065. /**
  24066. * Sync a bone with this impostor
  24067. * @param bone The bone to sync to the impostor.
  24068. * @param boneMesh The mesh that the bone is influencing.
  24069. * @param jointPivot The pivot of the joint / bone in local space.
  24070. * @param distToJoint Optional distance from the impostor to the joint.
  24071. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24072. */
  24073. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24074. /**
  24075. * Sync impostor to a bone
  24076. * @param bone The bone that the impostor will be synced to.
  24077. * @param boneMesh The mesh that the bone is influencing.
  24078. * @param jointPivot The pivot of the joint / bone in local space.
  24079. * @param distToJoint Optional distance from the impostor to the joint.
  24080. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24081. * @param boneAxis Optional vector3 axis the bone is aligned with
  24082. */
  24083. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24084. /**
  24085. * No-Imposter type
  24086. */
  24087. static NoImpostor: number;
  24088. /**
  24089. * Sphere-Imposter type
  24090. */
  24091. static SphereImpostor: number;
  24092. /**
  24093. * Box-Imposter type
  24094. */
  24095. static BoxImpostor: number;
  24096. /**
  24097. * Plane-Imposter type
  24098. */
  24099. static PlaneImpostor: number;
  24100. /**
  24101. * Mesh-imposter type
  24102. */
  24103. static MeshImpostor: number;
  24104. /**
  24105. * Capsule-Impostor type (Ammo.js plugin only)
  24106. */
  24107. static CapsuleImpostor: number;
  24108. /**
  24109. * Cylinder-Imposter type
  24110. */
  24111. static CylinderImpostor: number;
  24112. /**
  24113. * Particle-Imposter type
  24114. */
  24115. static ParticleImpostor: number;
  24116. /**
  24117. * Heightmap-Imposter type
  24118. */
  24119. static HeightmapImpostor: number;
  24120. /**
  24121. * ConvexHull-Impostor type (Ammo.js plugin only)
  24122. */
  24123. static ConvexHullImpostor: number;
  24124. /**
  24125. * Rope-Imposter type
  24126. */
  24127. static RopeImpostor: number;
  24128. /**
  24129. * Cloth-Imposter type
  24130. */
  24131. static ClothImpostor: number;
  24132. /**
  24133. * Softbody-Imposter type
  24134. */
  24135. static SoftbodyImpostor: number;
  24136. }
  24137. }
  24138. declare module "babylonjs/Meshes/mesh" {
  24139. import { Observable } from "babylonjs/Misc/observable";
  24140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24141. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24142. import { Camera } from "babylonjs/Cameras/camera";
  24143. import { Scene } from "babylonjs/scene";
  24144. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24145. import { Color4 } from "babylonjs/Maths/math.color";
  24146. import { Engine } from "babylonjs/Engines/engine";
  24147. import { Node } from "babylonjs/node";
  24148. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24149. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24150. import { Buffer } from "babylonjs/Meshes/buffer";
  24151. import { Geometry } from "babylonjs/Meshes/geometry";
  24152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24154. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24155. import { Effect } from "babylonjs/Materials/effect";
  24156. import { Material } from "babylonjs/Materials/material";
  24157. import { Skeleton } from "babylonjs/Bones/skeleton";
  24158. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24159. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24160. import { Path3D } from "babylonjs/Maths/math.path";
  24161. import { Plane } from "babylonjs/Maths/math.plane";
  24162. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24163. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24164. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24165. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24166. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24167. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24168. /**
  24169. * @hidden
  24170. **/
  24171. export class _CreationDataStorage {
  24172. closePath?: boolean;
  24173. closeArray?: boolean;
  24174. idx: number[];
  24175. dashSize: number;
  24176. gapSize: number;
  24177. path3D: Path3D;
  24178. pathArray: Vector3[][];
  24179. arc: number;
  24180. radius: number;
  24181. cap: number;
  24182. tessellation: number;
  24183. }
  24184. /**
  24185. * @hidden
  24186. **/
  24187. class _InstanceDataStorage {
  24188. visibleInstances: any;
  24189. batchCache: _InstancesBatch;
  24190. instancesBufferSize: number;
  24191. instancesBuffer: Nullable<Buffer>;
  24192. instancesData: Float32Array;
  24193. overridenInstanceCount: number;
  24194. isFrozen: boolean;
  24195. previousBatch: Nullable<_InstancesBatch>;
  24196. hardwareInstancedRendering: boolean;
  24197. sideOrientation: number;
  24198. }
  24199. /**
  24200. * @hidden
  24201. **/
  24202. export class _InstancesBatch {
  24203. mustReturn: boolean;
  24204. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24205. renderSelf: boolean[];
  24206. hardwareInstancedRendering: boolean[];
  24207. }
  24208. /**
  24209. * Class used to represent renderable models
  24210. */
  24211. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24212. /**
  24213. * Mesh side orientation : usually the external or front surface
  24214. */
  24215. static readonly FRONTSIDE: number;
  24216. /**
  24217. * Mesh side orientation : usually the internal or back surface
  24218. */
  24219. static readonly BACKSIDE: number;
  24220. /**
  24221. * Mesh side orientation : both internal and external or front and back surfaces
  24222. */
  24223. static readonly DOUBLESIDE: number;
  24224. /**
  24225. * Mesh side orientation : by default, `FRONTSIDE`
  24226. */
  24227. static readonly DEFAULTSIDE: number;
  24228. /**
  24229. * Mesh cap setting : no cap
  24230. */
  24231. static readonly NO_CAP: number;
  24232. /**
  24233. * Mesh cap setting : one cap at the beginning of the mesh
  24234. */
  24235. static readonly CAP_START: number;
  24236. /**
  24237. * Mesh cap setting : one cap at the end of the mesh
  24238. */
  24239. static readonly CAP_END: number;
  24240. /**
  24241. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24242. */
  24243. static readonly CAP_ALL: number;
  24244. /**
  24245. * Mesh pattern setting : no flip or rotate
  24246. */
  24247. static readonly NO_FLIP: number;
  24248. /**
  24249. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24250. */
  24251. static readonly FLIP_TILE: number;
  24252. /**
  24253. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24254. */
  24255. static readonly ROTATE_TILE: number;
  24256. /**
  24257. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24258. */
  24259. static readonly FLIP_ROW: number;
  24260. /**
  24261. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24262. */
  24263. static readonly ROTATE_ROW: number;
  24264. /**
  24265. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24266. */
  24267. static readonly FLIP_N_ROTATE_TILE: number;
  24268. /**
  24269. * Mesh pattern setting : rotate pattern and rotate
  24270. */
  24271. static readonly FLIP_N_ROTATE_ROW: number;
  24272. /**
  24273. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24274. */
  24275. static readonly CENTER: number;
  24276. /**
  24277. * Mesh tile positioning : part tiles on left
  24278. */
  24279. static readonly LEFT: number;
  24280. /**
  24281. * Mesh tile positioning : part tiles on right
  24282. */
  24283. static readonly RIGHT: number;
  24284. /**
  24285. * Mesh tile positioning : part tiles on top
  24286. */
  24287. static readonly TOP: number;
  24288. /**
  24289. * Mesh tile positioning : part tiles on bottom
  24290. */
  24291. static readonly BOTTOM: number;
  24292. /**
  24293. * Gets the default side orientation.
  24294. * @param orientation the orientation to value to attempt to get
  24295. * @returns the default orientation
  24296. * @hidden
  24297. */
  24298. static _GetDefaultSideOrientation(orientation?: number): number;
  24299. private _internalMeshDataInfo;
  24300. /**
  24301. * An event triggered before rendering the mesh
  24302. */
  24303. readonly onBeforeRenderObservable: Observable<Mesh>;
  24304. /**
  24305. * An event triggered before binding the mesh
  24306. */
  24307. readonly onBeforeBindObservable: Observable<Mesh>;
  24308. /**
  24309. * An event triggered after rendering the mesh
  24310. */
  24311. readonly onAfterRenderObservable: Observable<Mesh>;
  24312. /**
  24313. * An event triggered before drawing the mesh
  24314. */
  24315. readonly onBeforeDrawObservable: Observable<Mesh>;
  24316. private _onBeforeDrawObserver;
  24317. /**
  24318. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24319. */
  24320. onBeforeDraw: () => void;
  24321. readonly hasInstances: boolean;
  24322. /**
  24323. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24324. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24325. */
  24326. delayLoadState: number;
  24327. /**
  24328. * Gets the list of instances created from this mesh
  24329. * it is not supposed to be modified manually.
  24330. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24331. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24332. */
  24333. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24334. /**
  24335. * Gets the file containing delay loading data for this mesh
  24336. */
  24337. delayLoadingFile: string;
  24338. /** @hidden */
  24339. _binaryInfo: any;
  24340. /**
  24341. * User defined function used to change how LOD level selection is done
  24342. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24343. */
  24344. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24345. /**
  24346. * Gets or sets the morph target manager
  24347. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24348. */
  24349. morphTargetManager: Nullable<MorphTargetManager>;
  24350. /** @hidden */
  24351. _creationDataStorage: Nullable<_CreationDataStorage>;
  24352. /** @hidden */
  24353. _geometry: Nullable<Geometry>;
  24354. /** @hidden */
  24355. _delayInfo: Array<string>;
  24356. /** @hidden */
  24357. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24358. /** @hidden */
  24359. _instanceDataStorage: _InstanceDataStorage;
  24360. private _effectiveMaterial;
  24361. /** @hidden */
  24362. _shouldGenerateFlatShading: boolean;
  24363. /** @hidden */
  24364. _originalBuilderSideOrientation: number;
  24365. /**
  24366. * Use this property to change the original side orientation defined at construction time
  24367. */
  24368. overrideMaterialSideOrientation: Nullable<number>;
  24369. /**
  24370. * Gets the source mesh (the one used to clone this one from)
  24371. */
  24372. readonly source: Nullable<Mesh>;
  24373. /**
  24374. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24375. */
  24376. isUnIndexed: boolean;
  24377. /**
  24378. * @constructor
  24379. * @param name The value used by scene.getMeshByName() to do a lookup.
  24380. * @param scene The scene to add this mesh to.
  24381. * @param parent The parent of this mesh, if it has one
  24382. * @param source An optional Mesh from which geometry is shared, cloned.
  24383. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24384. * When false, achieved by calling a clone(), also passing False.
  24385. * This will make creation of children, recursive.
  24386. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24387. */
  24388. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24389. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24390. /**
  24391. * Gets the class name
  24392. * @returns the string "Mesh".
  24393. */
  24394. getClassName(): string;
  24395. /** @hidden */
  24396. readonly _isMesh: boolean;
  24397. /**
  24398. * Returns a description of this mesh
  24399. * @param fullDetails define if full details about this mesh must be used
  24400. * @returns a descriptive string representing this mesh
  24401. */
  24402. toString(fullDetails?: boolean): string;
  24403. /** @hidden */
  24404. _unBindEffect(): void;
  24405. /**
  24406. * Gets a boolean indicating if this mesh has LOD
  24407. */
  24408. readonly hasLODLevels: boolean;
  24409. /**
  24410. * Gets the list of MeshLODLevel associated with the current mesh
  24411. * @returns an array of MeshLODLevel
  24412. */
  24413. getLODLevels(): MeshLODLevel[];
  24414. private _sortLODLevels;
  24415. /**
  24416. * Add a mesh as LOD level triggered at the given distance.
  24417. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24418. * @param distance The distance from the center of the object to show this level
  24419. * @param mesh The mesh to be added as LOD level (can be null)
  24420. * @return This mesh (for chaining)
  24421. */
  24422. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24423. /**
  24424. * Returns the LOD level mesh at the passed distance or null if not found.
  24425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24426. * @param distance The distance from the center of the object to show this level
  24427. * @returns a Mesh or `null`
  24428. */
  24429. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24430. /**
  24431. * Remove a mesh from the LOD array
  24432. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24433. * @param mesh defines the mesh to be removed
  24434. * @return This mesh (for chaining)
  24435. */
  24436. removeLODLevel(mesh: Mesh): Mesh;
  24437. /**
  24438. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24440. * @param camera defines the camera to use to compute distance
  24441. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24442. * @return This mesh (for chaining)
  24443. */
  24444. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24445. /**
  24446. * Gets the mesh internal Geometry object
  24447. */
  24448. readonly geometry: Nullable<Geometry>;
  24449. /**
  24450. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24451. * @returns the total number of vertices
  24452. */
  24453. getTotalVertices(): number;
  24454. /**
  24455. * Returns the content of an associated vertex buffer
  24456. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24457. * - VertexBuffer.PositionKind
  24458. * - VertexBuffer.UVKind
  24459. * - VertexBuffer.UV2Kind
  24460. * - VertexBuffer.UV3Kind
  24461. * - VertexBuffer.UV4Kind
  24462. * - VertexBuffer.UV5Kind
  24463. * - VertexBuffer.UV6Kind
  24464. * - VertexBuffer.ColorKind
  24465. * - VertexBuffer.MatricesIndicesKind
  24466. * - VertexBuffer.MatricesIndicesExtraKind
  24467. * - VertexBuffer.MatricesWeightsKind
  24468. * - VertexBuffer.MatricesWeightsExtraKind
  24469. * @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
  24470. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24471. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24472. */
  24473. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24474. /**
  24475. * Returns the mesh VertexBuffer object from the requested `kind`
  24476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24477. * - VertexBuffer.PositionKind
  24478. * - VertexBuffer.NormalKind
  24479. * - VertexBuffer.UVKind
  24480. * - VertexBuffer.UV2Kind
  24481. * - VertexBuffer.UV3Kind
  24482. * - VertexBuffer.UV4Kind
  24483. * - VertexBuffer.UV5Kind
  24484. * - VertexBuffer.UV6Kind
  24485. * - VertexBuffer.ColorKind
  24486. * - VertexBuffer.MatricesIndicesKind
  24487. * - VertexBuffer.MatricesIndicesExtraKind
  24488. * - VertexBuffer.MatricesWeightsKind
  24489. * - VertexBuffer.MatricesWeightsExtraKind
  24490. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24491. */
  24492. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24493. /**
  24494. * Tests if a specific vertex buffer is associated with this mesh
  24495. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24496. * - VertexBuffer.PositionKind
  24497. * - VertexBuffer.NormalKind
  24498. * - VertexBuffer.UVKind
  24499. * - VertexBuffer.UV2Kind
  24500. * - VertexBuffer.UV3Kind
  24501. * - VertexBuffer.UV4Kind
  24502. * - VertexBuffer.UV5Kind
  24503. * - VertexBuffer.UV6Kind
  24504. * - VertexBuffer.ColorKind
  24505. * - VertexBuffer.MatricesIndicesKind
  24506. * - VertexBuffer.MatricesIndicesExtraKind
  24507. * - VertexBuffer.MatricesWeightsKind
  24508. * - VertexBuffer.MatricesWeightsExtraKind
  24509. * @returns a boolean
  24510. */
  24511. isVerticesDataPresent(kind: string): boolean;
  24512. /**
  24513. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24514. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24515. * - VertexBuffer.PositionKind
  24516. * - VertexBuffer.UVKind
  24517. * - VertexBuffer.UV2Kind
  24518. * - VertexBuffer.UV3Kind
  24519. * - VertexBuffer.UV4Kind
  24520. * - VertexBuffer.UV5Kind
  24521. * - VertexBuffer.UV6Kind
  24522. * - VertexBuffer.ColorKind
  24523. * - VertexBuffer.MatricesIndicesKind
  24524. * - VertexBuffer.MatricesIndicesExtraKind
  24525. * - VertexBuffer.MatricesWeightsKind
  24526. * - VertexBuffer.MatricesWeightsExtraKind
  24527. * @returns a boolean
  24528. */
  24529. isVertexBufferUpdatable(kind: string): boolean;
  24530. /**
  24531. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24532. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24533. * - VertexBuffer.PositionKind
  24534. * - VertexBuffer.NormalKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @returns an array of strings
  24547. */
  24548. getVerticesDataKinds(): string[];
  24549. /**
  24550. * Returns a positive integer : the total number of indices in this mesh geometry.
  24551. * @returns the numner of indices or zero if the mesh has no geometry.
  24552. */
  24553. getTotalIndices(): number;
  24554. /**
  24555. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24556. * @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.
  24557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24558. * @returns the indices array or an empty array if the mesh has no geometry
  24559. */
  24560. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24561. readonly isBlocked: boolean;
  24562. /**
  24563. * Determine if the current mesh is ready to be rendered
  24564. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24565. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24566. * @returns true if all associated assets are ready (material, textures, shaders)
  24567. */
  24568. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24569. /**
  24570. * 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.
  24571. */
  24572. readonly areNormalsFrozen: boolean;
  24573. /**
  24574. * 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.
  24575. * @returns the current mesh
  24576. */
  24577. freezeNormals(): Mesh;
  24578. /**
  24579. * 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
  24580. * @returns the current mesh
  24581. */
  24582. unfreezeNormals(): Mesh;
  24583. /**
  24584. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24585. */
  24586. overridenInstanceCount: number;
  24587. /** @hidden */
  24588. _preActivate(): Mesh;
  24589. /** @hidden */
  24590. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24591. /** @hidden */
  24592. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24593. /**
  24594. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24595. * This means the mesh underlying bounding box and sphere are recomputed.
  24596. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24597. * @returns the current mesh
  24598. */
  24599. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24600. /** @hidden */
  24601. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24602. /**
  24603. * This function will subdivide the mesh into multiple submeshes
  24604. * @param count defines the expected number of submeshes
  24605. */
  24606. subdivide(count: number): void;
  24607. /**
  24608. * Copy a FloatArray into a specific associated vertex buffer
  24609. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24610. * - VertexBuffer.PositionKind
  24611. * - VertexBuffer.UVKind
  24612. * - VertexBuffer.UV2Kind
  24613. * - VertexBuffer.UV3Kind
  24614. * - VertexBuffer.UV4Kind
  24615. * - VertexBuffer.UV5Kind
  24616. * - VertexBuffer.UV6Kind
  24617. * - VertexBuffer.ColorKind
  24618. * - VertexBuffer.MatricesIndicesKind
  24619. * - VertexBuffer.MatricesIndicesExtraKind
  24620. * - VertexBuffer.MatricesWeightsKind
  24621. * - VertexBuffer.MatricesWeightsExtraKind
  24622. * @param data defines the data source
  24623. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24624. * @param stride defines the data stride size (can be null)
  24625. * @returns the current mesh
  24626. */
  24627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24628. /**
  24629. * Delete a vertex buffer associated with this mesh
  24630. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24631. * - VertexBuffer.PositionKind
  24632. * - VertexBuffer.UVKind
  24633. * - VertexBuffer.UV2Kind
  24634. * - VertexBuffer.UV3Kind
  24635. * - VertexBuffer.UV4Kind
  24636. * - VertexBuffer.UV5Kind
  24637. * - VertexBuffer.UV6Kind
  24638. * - VertexBuffer.ColorKind
  24639. * - VertexBuffer.MatricesIndicesKind
  24640. * - VertexBuffer.MatricesIndicesExtraKind
  24641. * - VertexBuffer.MatricesWeightsKind
  24642. * - VertexBuffer.MatricesWeightsExtraKind
  24643. */
  24644. removeVerticesData(kind: string): void;
  24645. /**
  24646. * Flags an associated vertex buffer as updatable
  24647. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24648. * - VertexBuffer.PositionKind
  24649. * - VertexBuffer.UVKind
  24650. * - VertexBuffer.UV2Kind
  24651. * - VertexBuffer.UV3Kind
  24652. * - VertexBuffer.UV4Kind
  24653. * - VertexBuffer.UV5Kind
  24654. * - VertexBuffer.UV6Kind
  24655. * - VertexBuffer.ColorKind
  24656. * - VertexBuffer.MatricesIndicesKind
  24657. * - VertexBuffer.MatricesIndicesExtraKind
  24658. * - VertexBuffer.MatricesWeightsKind
  24659. * - VertexBuffer.MatricesWeightsExtraKind
  24660. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24661. */
  24662. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24663. /**
  24664. * Sets the mesh global Vertex Buffer
  24665. * @param buffer defines the buffer to use
  24666. * @returns the current mesh
  24667. */
  24668. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24669. /**
  24670. * Update a specific associated vertex buffer
  24671. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24672. * - VertexBuffer.PositionKind
  24673. * - VertexBuffer.UVKind
  24674. * - VertexBuffer.UV2Kind
  24675. * - VertexBuffer.UV3Kind
  24676. * - VertexBuffer.UV4Kind
  24677. * - VertexBuffer.UV5Kind
  24678. * - VertexBuffer.UV6Kind
  24679. * - VertexBuffer.ColorKind
  24680. * - VertexBuffer.MatricesIndicesKind
  24681. * - VertexBuffer.MatricesIndicesExtraKind
  24682. * - VertexBuffer.MatricesWeightsKind
  24683. * - VertexBuffer.MatricesWeightsExtraKind
  24684. * @param data defines the data source
  24685. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24686. * @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)
  24687. * @returns the current mesh
  24688. */
  24689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24690. /**
  24691. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24692. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24693. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24694. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24695. * @returns the current mesh
  24696. */
  24697. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24698. /**
  24699. * Creates a un-shared specific occurence of the geometry for the mesh.
  24700. * @returns the current mesh
  24701. */
  24702. makeGeometryUnique(): Mesh;
  24703. /**
  24704. * Set the index buffer of this mesh
  24705. * @param indices defines the source data
  24706. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24707. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24708. * @returns the current mesh
  24709. */
  24710. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24711. /**
  24712. * Update the current index buffer
  24713. * @param indices defines the source data
  24714. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24715. * @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)
  24716. * @returns the current mesh
  24717. */
  24718. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24719. /**
  24720. * Invert the geometry to move from a right handed system to a left handed one.
  24721. * @returns the current mesh
  24722. */
  24723. toLeftHanded(): Mesh;
  24724. /** @hidden */
  24725. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24726. /** @hidden */
  24727. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24728. /**
  24729. * Registers for this mesh a javascript function called just before the rendering process
  24730. * @param func defines the function to call before rendering this mesh
  24731. * @returns the current mesh
  24732. */
  24733. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24734. /**
  24735. * Disposes a previously registered javascript function called before the rendering
  24736. * @param func defines the function to remove
  24737. * @returns the current mesh
  24738. */
  24739. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24740. /**
  24741. * Registers for this mesh a javascript function called just after the rendering is complete
  24742. * @param func defines the function to call after rendering this mesh
  24743. * @returns the current mesh
  24744. */
  24745. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24746. /**
  24747. * Disposes a previously registered javascript function called after the rendering.
  24748. * @param func defines the function to remove
  24749. * @returns the current mesh
  24750. */
  24751. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24752. /** @hidden */
  24753. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24754. /** @hidden */
  24755. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24756. /** @hidden */
  24757. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24758. /** @hidden */
  24759. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24760. /** @hidden */
  24761. _rebuild(): void;
  24762. /** @hidden */
  24763. _freeze(): void;
  24764. /** @hidden */
  24765. _unFreeze(): void;
  24766. /**
  24767. * 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
  24768. * @param subMesh defines the subMesh to render
  24769. * @param enableAlphaMode defines if alpha mode can be changed
  24770. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24771. * @returns the current mesh
  24772. */
  24773. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24774. private _onBeforeDraw;
  24775. /**
  24776. * Renormalize the mesh and patch it up if there are no weights
  24777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24778. * However in the case of zero weights then we set just a single influence to 1.
  24779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24780. */
  24781. cleanMatrixWeights(): void;
  24782. private normalizeSkinFourWeights;
  24783. private normalizeSkinWeightsAndExtra;
  24784. /**
  24785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24787. * the user know there was an issue with importing the mesh
  24788. * @returns a validation object with skinned, valid and report string
  24789. */
  24790. validateSkinning(): {
  24791. skinned: boolean;
  24792. valid: boolean;
  24793. report: string;
  24794. };
  24795. /** @hidden */
  24796. _checkDelayState(): Mesh;
  24797. private _queueLoad;
  24798. /**
  24799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24800. * A mesh is in the frustum if its bounding box intersects the frustum
  24801. * @param frustumPlanes defines the frustum to test
  24802. * @returns true if the mesh is in the frustum planes
  24803. */
  24804. isInFrustum(frustumPlanes: Plane[]): boolean;
  24805. /**
  24806. * Sets the mesh material by the material or multiMaterial `id` property
  24807. * @param id is a string identifying the material or the multiMaterial
  24808. * @returns the current mesh
  24809. */
  24810. setMaterialByID(id: string): Mesh;
  24811. /**
  24812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24813. * @returns an array of IAnimatable
  24814. */
  24815. getAnimatables(): IAnimatable[];
  24816. /**
  24817. * Modifies the mesh geometry according to the passed transformation matrix.
  24818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24819. * The mesh normals are modified using the same transformation.
  24820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24821. * @param transform defines the transform matrix to use
  24822. * @see http://doc.babylonjs.com/resources/baking_transformations
  24823. * @returns the current mesh
  24824. */
  24825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24826. /**
  24827. * Modifies the mesh geometry according to its own current World Matrix.
  24828. * The mesh World Matrix is then reset.
  24829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24831. * @see http://doc.babylonjs.com/resources/baking_transformations
  24832. * @returns the current mesh
  24833. */
  24834. bakeCurrentTransformIntoVertices(): Mesh;
  24835. /** @hidden */
  24836. readonly _positions: Nullable<Vector3[]>;
  24837. /** @hidden */
  24838. _resetPointsArrayCache(): Mesh;
  24839. /** @hidden */
  24840. _generatePointsArray(): boolean;
  24841. /**
  24842. * Returns a new Mesh object generated from the current mesh properties.
  24843. * This method must not get confused with createInstance()
  24844. * @param name is a string, the name given to the new mesh
  24845. * @param newParent can be any Node object (default `null`)
  24846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24848. * @returns a new mesh
  24849. */
  24850. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24851. /**
  24852. * Releases resources associated with this mesh.
  24853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24855. */
  24856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24857. /** @hidden */
  24858. _disposeInstanceSpecificData(): void;
  24859. /**
  24860. * Modifies the mesh geometry according to a displacement map.
  24861. * 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.
  24862. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24863. * @param url is a string, the URL from the image file is to be downloaded.
  24864. * @param minHeight is the lower limit of the displacement.
  24865. * @param maxHeight is the upper limit of the displacement.
  24866. * @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.
  24867. * @param uvOffset is an optional vector2 used to offset UV.
  24868. * @param uvScale is an optional vector2 used to scale UV.
  24869. * @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.
  24870. * @returns the Mesh.
  24871. */
  24872. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24873. /**
  24874. * Modifies the mesh geometry according to a displacementMap buffer.
  24875. * 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.
  24876. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24877. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24878. * @param heightMapWidth is the width of the buffer image.
  24879. * @param heightMapHeight is the height of the buffer image.
  24880. * @param minHeight is the lower limit of the displacement.
  24881. * @param maxHeight is the upper limit of the displacement.
  24882. * @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.
  24883. * @param uvOffset is an optional vector2 used to offset UV.
  24884. * @param uvScale is an optional vector2 used to scale UV.
  24885. * @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.
  24886. * @returns the Mesh.
  24887. */
  24888. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24889. /**
  24890. * Modify the mesh to get a flat shading rendering.
  24891. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24892. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24893. * @returns current mesh
  24894. */
  24895. convertToFlatShadedMesh(): Mesh;
  24896. /**
  24897. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24898. * In other words, more vertices, no more indices and a single bigger VBO.
  24899. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24900. * @returns current mesh
  24901. */
  24902. convertToUnIndexedMesh(): Mesh;
  24903. /**
  24904. * Inverses facet orientations.
  24905. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24906. * @param flipNormals will also inverts the normals
  24907. * @returns current mesh
  24908. */
  24909. flipFaces(flipNormals?: boolean): Mesh;
  24910. /**
  24911. * Increase the number of facets and hence vertices in a mesh
  24912. * Vertex normals are interpolated from existing vertex normals
  24913. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24914. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24915. */
  24916. increaseVertices(numberPerEdge: number): void;
  24917. /**
  24918. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24919. * This will undo any application of covertToFlatShadedMesh
  24920. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24921. */
  24922. forceSharedVertices(): void;
  24923. /** @hidden */
  24924. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24925. /** @hidden */
  24926. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24927. /**
  24928. * Creates a new InstancedMesh object from the mesh model.
  24929. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24930. * @param name defines the name of the new instance
  24931. * @returns a new InstancedMesh
  24932. */
  24933. createInstance(name: string): InstancedMesh;
  24934. /**
  24935. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24936. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24937. * @returns the current mesh
  24938. */
  24939. synchronizeInstances(): Mesh;
  24940. /**
  24941. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24942. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24943. * This should be used together with the simplification to avoid disappearing triangles.
  24944. * @param successCallback an optional success callback to be called after the optimization finished.
  24945. * @returns the current mesh
  24946. */
  24947. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24948. /**
  24949. * Serialize current mesh
  24950. * @param serializationObject defines the object which will receive the serialization data
  24951. */
  24952. serialize(serializationObject: any): void;
  24953. /** @hidden */
  24954. _syncGeometryWithMorphTargetManager(): void;
  24955. /** @hidden */
  24956. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24957. /**
  24958. * Returns a new Mesh object parsed from the source provided.
  24959. * @param parsedMesh is the source
  24960. * @param scene defines the hosting scene
  24961. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24962. * @returns a new Mesh
  24963. */
  24964. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24965. /**
  24966. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24967. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24968. * @param name defines the name of the mesh to create
  24969. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24970. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24971. * @param closePath creates a seam between the first and the last points of each path of the path array
  24972. * @param offset is taken in account only if the `pathArray` is containing a single path
  24973. * @param scene defines the hosting scene
  24974. * @param updatable defines if the mesh must be flagged as updatable
  24975. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24976. * @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)
  24977. * @returns a new Mesh
  24978. */
  24979. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24980. /**
  24981. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24982. * @param name defines the name of the mesh to create
  24983. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24984. * @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
  24985. * @param scene defines the hosting scene
  24986. * @param updatable defines if the mesh must be flagged as updatable
  24987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24988. * @returns a new Mesh
  24989. */
  24990. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24991. /**
  24992. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24993. * @param name defines the name of the mesh to create
  24994. * @param size sets the size (float) of each box side (default 1)
  24995. * @param scene defines the hosting scene
  24996. * @param updatable defines if the mesh must be flagged as updatable
  24997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24998. * @returns a new Mesh
  24999. */
  25000. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25001. /**
  25002. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25003. * @param name defines the name of the mesh to create
  25004. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25005. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25006. * @param scene defines the hosting scene
  25007. * @param updatable defines if the mesh must be flagged as updatable
  25008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25009. * @returns a new Mesh
  25010. */
  25011. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25012. /**
  25013. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25014. * @param name defines the name of the mesh to create
  25015. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25016. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25017. * @param scene defines the hosting scene
  25018. * @returns a new Mesh
  25019. */
  25020. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25021. /**
  25022. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25023. * @param name defines the name of the mesh to create
  25024. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25025. * @param diameterTop set the top cap diameter (floats, default 1)
  25026. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25027. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25028. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25035. /**
  25036. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param diameter sets the diameter size (float) of the torus (default 1)
  25039. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25040. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25041. * @param scene defines the hosting scene
  25042. * @param updatable defines if the mesh must be flagged as updatable
  25043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25044. * @returns a new Mesh
  25045. */
  25046. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25047. /**
  25048. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25049. * @param name defines the name of the mesh to create
  25050. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25051. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25052. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25053. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25054. * @param p the number of windings on X axis (positive integers, default 2)
  25055. * @param q the number of windings on Y axis (positive integers, default 3)
  25056. * @param scene defines the hosting scene
  25057. * @param updatable defines if the mesh must be flagged as updatable
  25058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25059. * @returns a new Mesh
  25060. */
  25061. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25062. /**
  25063. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25064. * @param name defines the name of the mesh to create
  25065. * @param points is an array successive Vector3
  25066. * @param scene defines the hosting scene
  25067. * @param updatable defines if the mesh must be flagged as updatable
  25068. * @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).
  25069. * @returns a new Mesh
  25070. */
  25071. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25072. /**
  25073. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25074. * @param name defines the name of the mesh to create
  25075. * @param points is an array successive Vector3
  25076. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25077. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25078. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25079. * @param scene defines the hosting scene
  25080. * @param updatable defines if the mesh must be flagged as updatable
  25081. * @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)
  25082. * @returns a new Mesh
  25083. */
  25084. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25085. /**
  25086. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25087. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25088. * 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.
  25089. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25090. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25091. * Remember you can only change the shape positions, not their number when updating a polygon.
  25092. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25093. * @param name defines the name of the mesh to create
  25094. * @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
  25095. * @param scene defines the hosting scene
  25096. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25097. * @param updatable defines if the mesh must be flagged as updatable
  25098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25099. * @param earcutInjection can be used to inject your own earcut reference
  25100. * @returns a new Mesh
  25101. */
  25102. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25103. /**
  25104. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25105. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25106. * @param name defines the name of the mesh to create
  25107. * @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
  25108. * @param depth defines the height of extrusion
  25109. * @param scene defines the hosting scene
  25110. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25111. * @param updatable defines if the mesh must be flagged as updatable
  25112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25113. * @param earcutInjection can be used to inject your own earcut reference
  25114. * @returns a new Mesh
  25115. */
  25116. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25117. /**
  25118. * Creates an extruded shape mesh.
  25119. * 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
  25120. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25122. * @param name defines the name of the mesh to create
  25123. * @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
  25124. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25125. * @param scale is the value to scale the shape
  25126. * @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
  25127. * @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
  25128. * @param scene defines the hosting scene
  25129. * @param updatable defines if the mesh must be flagged as updatable
  25130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25131. * @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)
  25132. * @returns a new Mesh
  25133. */
  25134. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25135. /**
  25136. * Creates an custom extruded shape mesh.
  25137. * The custom extrusion is a parametric shape.
  25138. * It has no predefined shape. Its final shape will depend on the input parameters.
  25139. * Please consider using the same method from the MeshBuilder class instead
  25140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25141. * @param name defines the name of the mesh to create
  25142. * @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
  25143. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25144. * @param scaleFunction is a custom Javascript function called on each path point
  25145. * @param rotationFunction is a custom Javascript function called on each path point
  25146. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25147. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25148. * @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
  25149. * @param scene defines the hosting scene
  25150. * @param updatable defines if the mesh must be flagged as updatable
  25151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25152. * @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)
  25153. * @returns a new Mesh
  25154. */
  25155. 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;
  25156. /**
  25157. * Creates lathe mesh.
  25158. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25159. * Please consider using the same method from the MeshBuilder class instead
  25160. * @param name defines the name of the mesh to create
  25161. * @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
  25162. * @param radius is the radius value of the lathe
  25163. * @param tessellation is the side number of the lathe.
  25164. * @param scene defines the hosting scene
  25165. * @param updatable defines if the mesh must be flagged as updatable
  25166. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25167. * @returns a new Mesh
  25168. */
  25169. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25170. /**
  25171. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25172. * @param name defines the name of the mesh to create
  25173. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25174. * @param scene defines the hosting scene
  25175. * @param updatable defines if the mesh must be flagged as updatable
  25176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25177. * @returns a new Mesh
  25178. */
  25179. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25180. /**
  25181. * Creates a ground mesh.
  25182. * Please consider using the same method from the MeshBuilder class instead
  25183. * @param name defines the name of the mesh to create
  25184. * @param width set the width of the ground
  25185. * @param height set the height of the ground
  25186. * @param subdivisions sets the number of subdivisions per side
  25187. * @param scene defines the hosting scene
  25188. * @param updatable defines if the mesh must be flagged as updatable
  25189. * @returns a new Mesh
  25190. */
  25191. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25192. /**
  25193. * Creates a tiled ground mesh.
  25194. * Please consider using the same method from the MeshBuilder class instead
  25195. * @param name defines the name of the mesh to create
  25196. * @param xmin set the ground minimum X coordinate
  25197. * @param zmin set the ground minimum Y coordinate
  25198. * @param xmax set the ground maximum X coordinate
  25199. * @param zmax set the ground maximum Z coordinate
  25200. * @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
  25201. * @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
  25202. * @param scene defines the hosting scene
  25203. * @param updatable defines if the mesh must be flagged as updatable
  25204. * @returns a new Mesh
  25205. */
  25206. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25207. w: number;
  25208. h: number;
  25209. }, precision: {
  25210. w: number;
  25211. h: number;
  25212. }, scene: Scene, updatable?: boolean): Mesh;
  25213. /**
  25214. * Creates a ground mesh from a height map.
  25215. * Please consider using the same method from the MeshBuilder class instead
  25216. * @see http://doc.babylonjs.com/babylon101/height_map
  25217. * @param name defines the name of the mesh to create
  25218. * @param url sets the URL of the height map image resource
  25219. * @param width set the ground width size
  25220. * @param height set the ground height size
  25221. * @param subdivisions sets the number of subdivision per side
  25222. * @param minHeight is the minimum altitude on the ground
  25223. * @param maxHeight is the maximum altitude on the ground
  25224. * @param scene defines the hosting scene
  25225. * @param updatable defines if the mesh must be flagged as updatable
  25226. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25227. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25228. * @returns a new Mesh
  25229. */
  25230. 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;
  25231. /**
  25232. * Creates a tube mesh.
  25233. * The tube is a parametric shape.
  25234. * It has no predefined shape. Its final shape will depend on the input parameters.
  25235. * Please consider using the same method from the MeshBuilder class instead
  25236. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25237. * @param name defines the name of the mesh to create
  25238. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25239. * @param radius sets the tube radius size
  25240. * @param tessellation is the number of sides on the tubular surface
  25241. * @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
  25242. * @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
  25243. * @param scene defines the hosting scene
  25244. * @param updatable defines if the mesh must be flagged as updatable
  25245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25246. * @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)
  25247. * @returns a new Mesh
  25248. */
  25249. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25250. (i: number, distance: number): number;
  25251. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25252. /**
  25253. * Creates a polyhedron mesh.
  25254. * Please consider using the same method from the MeshBuilder class instead.
  25255. * * 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
  25256. * * The parameter `size` (positive float, default 1) sets the polygon size
  25257. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25258. * * 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`
  25259. * * 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
  25260. * * 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)`)
  25261. * * 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
  25262. * * 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
  25263. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25264. * * If you create a double-sided mesh, you can choose what parts of 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
  25265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25266. * @param name defines the name of the mesh to create
  25267. * @param options defines the options used to create the mesh
  25268. * @param scene defines the hosting scene
  25269. * @returns a new Mesh
  25270. */
  25271. static CreatePolyhedron(name: string, options: {
  25272. type?: number;
  25273. size?: number;
  25274. sizeX?: number;
  25275. sizeY?: number;
  25276. sizeZ?: number;
  25277. custom?: any;
  25278. faceUV?: Vector4[];
  25279. faceColors?: Color4[];
  25280. updatable?: boolean;
  25281. sideOrientation?: number;
  25282. }, scene: Scene): Mesh;
  25283. /**
  25284. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25285. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25286. * * 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`)
  25287. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25288. * * 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
  25289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25290. * * If you create a double-sided mesh, you can choose what parts of 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
  25291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25292. * @param name defines the name of the mesh
  25293. * @param options defines the options used to create the mesh
  25294. * @param scene defines the hosting scene
  25295. * @returns a new Mesh
  25296. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25297. */
  25298. static CreateIcoSphere(name: string, options: {
  25299. radius?: number;
  25300. flat?: boolean;
  25301. subdivisions?: number;
  25302. sideOrientation?: number;
  25303. updatable?: boolean;
  25304. }, scene: Scene): Mesh;
  25305. /**
  25306. * Creates a decal mesh.
  25307. * Please consider using the same method from the MeshBuilder class instead.
  25308. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25309. * @param name defines the name of the mesh
  25310. * @param sourceMesh defines the mesh receiving the decal
  25311. * @param position sets the position of the decal in world coordinates
  25312. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25313. * @param size sets the decal scaling
  25314. * @param angle sets the angle to rotate the decal
  25315. * @returns a new Mesh
  25316. */
  25317. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25318. /**
  25319. * Prepare internal position array for software CPU skinning
  25320. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25321. */
  25322. setPositionsForCPUSkinning(): Float32Array;
  25323. /**
  25324. * Prepare internal normal array for software CPU skinning
  25325. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25326. */
  25327. setNormalsForCPUSkinning(): Float32Array;
  25328. /**
  25329. * Updates the vertex buffer by applying transformation from the bones
  25330. * @param skeleton defines the skeleton to apply to current mesh
  25331. * @returns the current mesh
  25332. */
  25333. applySkeleton(skeleton: Skeleton): Mesh;
  25334. /**
  25335. * 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
  25336. * @param meshes defines the list of meshes to scan
  25337. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25338. */
  25339. static MinMax(meshes: AbstractMesh[]): {
  25340. min: Vector3;
  25341. max: Vector3;
  25342. };
  25343. /**
  25344. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25345. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25346. * @returns a vector3
  25347. */
  25348. static Center(meshesOrMinMaxVector: {
  25349. min: Vector3;
  25350. max: Vector3;
  25351. } | AbstractMesh[]): Vector3;
  25352. /**
  25353. * Merge the array of meshes into a single mesh for performance reasons.
  25354. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25355. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25356. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25357. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25358. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25359. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25360. * @returns a new mesh
  25361. */
  25362. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25363. /** @hidden */
  25364. addInstance(instance: InstancedMesh): void;
  25365. /** @hidden */
  25366. removeInstance(instance: InstancedMesh): void;
  25367. }
  25368. }
  25369. declare module "babylonjs/Cameras/camera" {
  25370. import { SmartArray } from "babylonjs/Misc/smartArray";
  25371. import { Observable } from "babylonjs/Misc/observable";
  25372. import { Nullable } from "babylonjs/types";
  25373. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25374. import { Scene } from "babylonjs/scene";
  25375. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25376. import { Node } from "babylonjs/node";
  25377. import { Mesh } from "babylonjs/Meshes/mesh";
  25378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25379. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25380. import { Viewport } from "babylonjs/Maths/math.viewport";
  25381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25382. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25384. import { Ray } from "babylonjs/Culling/ray";
  25385. /**
  25386. * This is the base class of all the camera used in the application.
  25387. * @see http://doc.babylonjs.com/features/cameras
  25388. */
  25389. export class Camera extends Node {
  25390. /** @hidden */
  25391. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25392. /**
  25393. * This is the default projection mode used by the cameras.
  25394. * It helps recreating a feeling of perspective and better appreciate depth.
  25395. * This is the best way to simulate real life cameras.
  25396. */
  25397. static readonly PERSPECTIVE_CAMERA: number;
  25398. /**
  25399. * This helps creating camera with an orthographic mode.
  25400. * 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.
  25401. */
  25402. static readonly ORTHOGRAPHIC_CAMERA: number;
  25403. /**
  25404. * This is the default FOV mode for perspective cameras.
  25405. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25406. */
  25407. static readonly FOVMODE_VERTICAL_FIXED: number;
  25408. /**
  25409. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25410. */
  25411. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25412. /**
  25413. * This specifies ther is no need for a camera rig.
  25414. * Basically only one eye is rendered corresponding to the camera.
  25415. */
  25416. static readonly RIG_MODE_NONE: number;
  25417. /**
  25418. * Simulates a camera Rig with one blue eye and one red eye.
  25419. * This can be use with 3d blue and red glasses.
  25420. */
  25421. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25422. /**
  25423. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25424. */
  25425. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25426. /**
  25427. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25428. */
  25429. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25430. /**
  25431. * Defines that both eyes of the camera will be rendered over under each other.
  25432. */
  25433. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25434. /**
  25435. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25436. */
  25437. static readonly RIG_MODE_VR: number;
  25438. /**
  25439. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25440. */
  25441. static readonly RIG_MODE_WEBVR: number;
  25442. /**
  25443. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25444. */
  25445. static readonly RIG_MODE_CUSTOM: number;
  25446. /**
  25447. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25448. */
  25449. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25450. /**
  25451. * Define the input manager associated with the camera.
  25452. */
  25453. inputs: CameraInputsManager<Camera>;
  25454. /** @hidden */
  25455. _position: Vector3;
  25456. /**
  25457. * Define the current local position of the camera in the scene
  25458. */
  25459. position: Vector3;
  25460. /**
  25461. * The vector the camera should consider as up.
  25462. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25463. */
  25464. upVector: Vector3;
  25465. /**
  25466. * Define the current limit on the left side for an orthographic camera
  25467. * In scene unit
  25468. */
  25469. orthoLeft: Nullable<number>;
  25470. /**
  25471. * Define the current limit on the right side for an orthographic camera
  25472. * In scene unit
  25473. */
  25474. orthoRight: Nullable<number>;
  25475. /**
  25476. * Define the current limit on the bottom side for an orthographic camera
  25477. * In scene unit
  25478. */
  25479. orthoBottom: Nullable<number>;
  25480. /**
  25481. * Define the current limit on the top side for an orthographic camera
  25482. * In scene unit
  25483. */
  25484. orthoTop: Nullable<number>;
  25485. /**
  25486. * Field Of View is set in Radians. (default is 0.8)
  25487. */
  25488. fov: number;
  25489. /**
  25490. * Define the minimum distance the camera can see from.
  25491. * This is important to note that the depth buffer are not infinite and the closer it starts
  25492. * the more your scene might encounter depth fighting issue.
  25493. */
  25494. minZ: number;
  25495. /**
  25496. * Define the maximum distance the camera can see to.
  25497. * This is important to note that the depth buffer are not infinite and the further it end
  25498. * the more your scene might encounter depth fighting issue.
  25499. */
  25500. maxZ: number;
  25501. /**
  25502. * Define the default inertia of the camera.
  25503. * This helps giving a smooth feeling to the camera movement.
  25504. */
  25505. inertia: number;
  25506. /**
  25507. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25508. */
  25509. mode: number;
  25510. /**
  25511. * Define wether the camera is intermediate.
  25512. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25513. */
  25514. isIntermediate: boolean;
  25515. /**
  25516. * Define the viewport of the camera.
  25517. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25518. */
  25519. viewport: Viewport;
  25520. /**
  25521. * Restricts the camera to viewing objects with the same layerMask.
  25522. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25523. */
  25524. layerMask: number;
  25525. /**
  25526. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25527. */
  25528. fovMode: number;
  25529. /**
  25530. * Rig mode of the camera.
  25531. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25532. * This is normally controlled byt the camera themselves as internal use.
  25533. */
  25534. cameraRigMode: number;
  25535. /**
  25536. * Defines the distance between both "eyes" in case of a RIG
  25537. */
  25538. interaxialDistance: number;
  25539. /**
  25540. * Defines if stereoscopic rendering is done side by side or over under.
  25541. */
  25542. isStereoscopicSideBySide: boolean;
  25543. /**
  25544. * 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
  25545. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25546. * else in the scene. (Eg. security camera)
  25547. *
  25548. * 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)
  25549. */
  25550. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25551. /**
  25552. * When set, the camera will render to this render target instead of the default canvas
  25553. *
  25554. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25555. */
  25556. outputRenderTarget: Nullable<RenderTargetTexture>;
  25557. /**
  25558. * Observable triggered when the camera view matrix has changed.
  25559. */
  25560. onViewMatrixChangedObservable: Observable<Camera>;
  25561. /**
  25562. * Observable triggered when the camera Projection matrix has changed.
  25563. */
  25564. onProjectionMatrixChangedObservable: Observable<Camera>;
  25565. /**
  25566. * Observable triggered when the inputs have been processed.
  25567. */
  25568. onAfterCheckInputsObservable: Observable<Camera>;
  25569. /**
  25570. * Observable triggered when reset has been called and applied to the camera.
  25571. */
  25572. onRestoreStateObservable: Observable<Camera>;
  25573. /** @hidden */
  25574. _cameraRigParams: any;
  25575. /** @hidden */
  25576. _rigCameras: Camera[];
  25577. /** @hidden */
  25578. _rigPostProcess: Nullable<PostProcess>;
  25579. protected _webvrViewMatrix: Matrix;
  25580. /** @hidden */
  25581. _skipRendering: boolean;
  25582. /** @hidden */
  25583. _projectionMatrix: Matrix;
  25584. /** @hidden */
  25585. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25586. /** @hidden */
  25587. _activeMeshes: SmartArray<AbstractMesh>;
  25588. protected _globalPosition: Vector3;
  25589. /** @hidden */
  25590. _computedViewMatrix: Matrix;
  25591. private _doNotComputeProjectionMatrix;
  25592. private _transformMatrix;
  25593. private _frustumPlanes;
  25594. private _refreshFrustumPlanes;
  25595. private _storedFov;
  25596. private _stateStored;
  25597. /**
  25598. * Instantiates a new camera object.
  25599. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25600. * @see http://doc.babylonjs.com/features/cameras
  25601. * @param name Defines the name of the camera in the scene
  25602. * @param position Defines the position of the camera
  25603. * @param scene Defines the scene the camera belongs too
  25604. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25605. */
  25606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25607. /**
  25608. * Store current camera state (fov, position, etc..)
  25609. * @returns the camera
  25610. */
  25611. storeState(): Camera;
  25612. /**
  25613. * Restores the camera state values if it has been stored. You must call storeState() first
  25614. */
  25615. protected _restoreStateValues(): boolean;
  25616. /**
  25617. * Restored camera state. You must call storeState() first.
  25618. * @returns true if restored and false otherwise
  25619. */
  25620. restoreState(): boolean;
  25621. /**
  25622. * Gets the class name of the camera.
  25623. * @returns the class name
  25624. */
  25625. getClassName(): string;
  25626. /** @hidden */
  25627. readonly _isCamera: boolean;
  25628. /**
  25629. * Gets a string representation of the camera useful for debug purpose.
  25630. * @param fullDetails Defines that a more verboe level of logging is required
  25631. * @returns the string representation
  25632. */
  25633. toString(fullDetails?: boolean): string;
  25634. /**
  25635. * Gets the current world space position of the camera.
  25636. */
  25637. readonly globalPosition: Vector3;
  25638. /**
  25639. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25640. * @returns the active meshe list
  25641. */
  25642. getActiveMeshes(): SmartArray<AbstractMesh>;
  25643. /**
  25644. * Check wether a mesh is part of the current active mesh list of the camera
  25645. * @param mesh Defines the mesh to check
  25646. * @returns true if active, false otherwise
  25647. */
  25648. isActiveMesh(mesh: Mesh): boolean;
  25649. /**
  25650. * Is this camera ready to be used/rendered
  25651. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25652. * @return true if the camera is ready
  25653. */
  25654. isReady(completeCheck?: boolean): boolean;
  25655. /** @hidden */
  25656. _initCache(): void;
  25657. /** @hidden */
  25658. _updateCache(ignoreParentClass?: boolean): void;
  25659. /** @hidden */
  25660. _isSynchronized(): boolean;
  25661. /** @hidden */
  25662. _isSynchronizedViewMatrix(): boolean;
  25663. /** @hidden */
  25664. _isSynchronizedProjectionMatrix(): boolean;
  25665. /**
  25666. * Attach the input controls to a specific dom element to get the input from.
  25667. * @param element Defines the element the controls should be listened from
  25668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25669. */
  25670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25671. /**
  25672. * Detach the current controls from the specified dom element.
  25673. * @param element Defines the element to stop listening the inputs from
  25674. */
  25675. detachControl(element: HTMLElement): void;
  25676. /**
  25677. * Update the camera state according to the different inputs gathered during the frame.
  25678. */
  25679. update(): void;
  25680. /** @hidden */
  25681. _checkInputs(): void;
  25682. /** @hidden */
  25683. readonly rigCameras: Camera[];
  25684. /**
  25685. * Gets the post process used by the rig cameras
  25686. */
  25687. readonly rigPostProcess: Nullable<PostProcess>;
  25688. /**
  25689. * Internal, gets the first post proces.
  25690. * @returns the first post process to be run on this camera.
  25691. */
  25692. _getFirstPostProcess(): Nullable<PostProcess>;
  25693. private _cascadePostProcessesToRigCams;
  25694. /**
  25695. * Attach a post process to the camera.
  25696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25697. * @param postProcess The post process to attach to the camera
  25698. * @param insertAt The position of the post process in case several of them are in use in the scene
  25699. * @returns the position the post process has been inserted at
  25700. */
  25701. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25702. /**
  25703. * Detach a post process to the camera.
  25704. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25705. * @param postProcess The post process to detach from the camera
  25706. */
  25707. detachPostProcess(postProcess: PostProcess): void;
  25708. /**
  25709. * Gets the current world matrix of the camera
  25710. */
  25711. getWorldMatrix(): Matrix;
  25712. /** @hidden */
  25713. _getViewMatrix(): Matrix;
  25714. /**
  25715. * Gets the current view matrix of the camera.
  25716. * @param force forces the camera to recompute the matrix without looking at the cached state
  25717. * @returns the view matrix
  25718. */
  25719. getViewMatrix(force?: boolean): Matrix;
  25720. /**
  25721. * Freeze the projection matrix.
  25722. * It will prevent the cache check of the camera projection compute and can speed up perf
  25723. * if no parameter of the camera are meant to change
  25724. * @param projection Defines manually a projection if necessary
  25725. */
  25726. freezeProjectionMatrix(projection?: Matrix): void;
  25727. /**
  25728. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25729. */
  25730. unfreezeProjectionMatrix(): void;
  25731. /**
  25732. * Gets the current projection matrix of the camera.
  25733. * @param force forces the camera to recompute the matrix without looking at the cached state
  25734. * @returns the projection matrix
  25735. */
  25736. getProjectionMatrix(force?: boolean): Matrix;
  25737. /**
  25738. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25739. * @returns a Matrix
  25740. */
  25741. getTransformationMatrix(): Matrix;
  25742. private _updateFrustumPlanes;
  25743. /**
  25744. * Checks if a cullable object (mesh...) is in the camera frustum
  25745. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25746. * @param target The object to check
  25747. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25748. * @returns true if the object is in frustum otherwise false
  25749. */
  25750. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25751. /**
  25752. * Checks if a cullable object (mesh...) is in the camera frustum
  25753. * Unlike isInFrustum this cheks the full bounding box
  25754. * @param target The object to check
  25755. * @returns true if the object is in frustum otherwise false
  25756. */
  25757. isCompletelyInFrustum(target: ICullable): boolean;
  25758. /**
  25759. * Gets a ray in the forward direction from the camera.
  25760. * @param length Defines the length of the ray to create
  25761. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25762. * @param origin Defines the start point of the ray which defaults to the camera position
  25763. * @returns the forward ray
  25764. */
  25765. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25766. /**
  25767. * Releases resources associated with this node.
  25768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25770. */
  25771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25772. /** @hidden */
  25773. _isLeftCamera: boolean;
  25774. /**
  25775. * Gets the left camera of a rig setup in case of Rigged Camera
  25776. */
  25777. readonly isLeftCamera: boolean;
  25778. /** @hidden */
  25779. _isRightCamera: boolean;
  25780. /**
  25781. * Gets the right camera of a rig setup in case of Rigged Camera
  25782. */
  25783. readonly isRightCamera: boolean;
  25784. /**
  25785. * Gets the left camera of a rig setup in case of Rigged Camera
  25786. */
  25787. readonly leftCamera: Nullable<FreeCamera>;
  25788. /**
  25789. * Gets the right camera of a rig setup in case of Rigged Camera
  25790. */
  25791. readonly rightCamera: Nullable<FreeCamera>;
  25792. /**
  25793. * Gets the left camera target of a rig setup in case of Rigged Camera
  25794. * @returns the target position
  25795. */
  25796. getLeftTarget(): Nullable<Vector3>;
  25797. /**
  25798. * Gets the right camera target of a rig setup in case of Rigged Camera
  25799. * @returns the target position
  25800. */
  25801. getRightTarget(): Nullable<Vector3>;
  25802. /**
  25803. * @hidden
  25804. */
  25805. setCameraRigMode(mode: number, rigParams: any): void;
  25806. /** @hidden */
  25807. static _setStereoscopicRigMode(camera: Camera): void;
  25808. /** @hidden */
  25809. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25810. /** @hidden */
  25811. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25812. /** @hidden */
  25813. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25814. /** @hidden */
  25815. _getVRProjectionMatrix(): Matrix;
  25816. protected _updateCameraRotationMatrix(): void;
  25817. protected _updateWebVRCameraRotationMatrix(): void;
  25818. /**
  25819. * This function MUST be overwritten by the different WebVR cameras available.
  25820. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25821. * @hidden
  25822. */
  25823. _getWebVRProjectionMatrix(): Matrix;
  25824. /**
  25825. * This function MUST be overwritten by the different WebVR cameras available.
  25826. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25827. * @hidden
  25828. */
  25829. _getWebVRViewMatrix(): Matrix;
  25830. /** @hidden */
  25831. setCameraRigParameter(name: string, value: any): void;
  25832. /**
  25833. * needs to be overridden by children so sub has required properties to be copied
  25834. * @hidden
  25835. */
  25836. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25837. /**
  25838. * May need to be overridden by children
  25839. * @hidden
  25840. */
  25841. _updateRigCameras(): void;
  25842. /** @hidden */
  25843. _setupInputs(): void;
  25844. /**
  25845. * Serialiaze the camera setup to a json represention
  25846. * @returns the JSON representation
  25847. */
  25848. serialize(): any;
  25849. /**
  25850. * Clones the current camera.
  25851. * @param name The cloned camera name
  25852. * @returns the cloned camera
  25853. */
  25854. clone(name: string): Camera;
  25855. /**
  25856. * Gets the direction of the camera relative to a given local axis.
  25857. * @param localAxis Defines the reference axis to provide a relative direction.
  25858. * @return the direction
  25859. */
  25860. getDirection(localAxis: Vector3): Vector3;
  25861. /**
  25862. * Returns the current camera absolute rotation
  25863. */
  25864. readonly absoluteRotation: Quaternion;
  25865. /**
  25866. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25867. * @param localAxis Defines the reference axis to provide a relative direction.
  25868. * @param result Defines the vector to store the result in
  25869. */
  25870. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25871. /**
  25872. * Gets a camera constructor for a given camera type
  25873. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25874. * @param name The name of the camera the result will be able to instantiate
  25875. * @param scene The scene the result will construct the camera in
  25876. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25877. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25878. * @returns a factory method to construc the camera
  25879. */
  25880. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25881. /**
  25882. * Compute the world matrix of the camera.
  25883. * @returns the camera workd matrix
  25884. */
  25885. computeWorldMatrix(): Matrix;
  25886. /**
  25887. * Parse a JSON and creates the camera from the parsed information
  25888. * @param parsedCamera The JSON to parse
  25889. * @param scene The scene to instantiate the camera in
  25890. * @returns the newly constructed camera
  25891. */
  25892. static Parse(parsedCamera: any, scene: Scene): Camera;
  25893. }
  25894. }
  25895. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25896. import { Nullable } from "babylonjs/types";
  25897. import { Scene } from "babylonjs/scene";
  25898. import { Vector4 } from "babylonjs/Maths/math.vector";
  25899. import { Mesh } from "babylonjs/Meshes/mesh";
  25900. /**
  25901. * Class containing static functions to help procedurally build meshes
  25902. */
  25903. export class DiscBuilder {
  25904. /**
  25905. * Creates a plane polygonal mesh. By default, this is a disc
  25906. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25907. * * 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
  25908. * * 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
  25909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25912. * @param name defines the name of the mesh
  25913. * @param options defines the options used to create the mesh
  25914. * @param scene defines the hosting scene
  25915. * @returns the plane polygonal mesh
  25916. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25917. */
  25918. static CreateDisc(name: string, options: {
  25919. radius?: number;
  25920. tessellation?: number;
  25921. arc?: number;
  25922. updatable?: boolean;
  25923. sideOrientation?: number;
  25924. frontUVs?: Vector4;
  25925. backUVs?: Vector4;
  25926. }, scene?: Nullable<Scene>): Mesh;
  25927. }
  25928. }
  25929. declare module "babylonjs/Particles/solidParticleSystem" {
  25930. import { Vector3 } from "babylonjs/Maths/math.vector";
  25931. import { Mesh } from "babylonjs/Meshes/mesh";
  25932. import { Scene, IDisposable } from "babylonjs/scene";
  25933. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25934. /**
  25935. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25936. *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.
  25937. * The SPS is also a particle system. It provides some methods to manage the particles.
  25938. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25939. *
  25940. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25941. */
  25942. export class SolidParticleSystem implements IDisposable {
  25943. /**
  25944. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25945. * Example : var p = SPS.particles[i];
  25946. */
  25947. particles: SolidParticle[];
  25948. /**
  25949. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25950. */
  25951. nbParticles: number;
  25952. /**
  25953. * If the particles must ever face the camera (default false). Useful for planar particles.
  25954. */
  25955. billboard: boolean;
  25956. /**
  25957. * Recompute normals when adding a shape
  25958. */
  25959. recomputeNormals: boolean;
  25960. /**
  25961. * This a counter ofr your own usage. It's not set by any SPS functions.
  25962. */
  25963. counter: number;
  25964. /**
  25965. * The SPS name. This name is also given to the underlying mesh.
  25966. */
  25967. name: string;
  25968. /**
  25969. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25970. */
  25971. mesh: Mesh;
  25972. /**
  25973. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25974. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25975. */
  25976. vars: any;
  25977. /**
  25978. * This array is populated when the SPS is set as 'pickable'.
  25979. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25980. * Each element of this array is an object `{idx: int, faceId: int}`.
  25981. * `idx` is the picked particle index in the `SPS.particles` array
  25982. * `faceId` is the picked face index counted within this particle.
  25983. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25984. */
  25985. pickedParticles: {
  25986. idx: number;
  25987. faceId: number;
  25988. }[];
  25989. /**
  25990. * This array is populated when `enableDepthSort` is set to true.
  25991. * Each element of this array is an instance of the class DepthSortedParticle.
  25992. */
  25993. depthSortedParticles: DepthSortedParticle[];
  25994. /**
  25995. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25996. * @hidden
  25997. */
  25998. _bSphereOnly: boolean;
  25999. /**
  26000. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26001. * @hidden
  26002. */
  26003. _bSphereRadiusFactor: number;
  26004. private _scene;
  26005. private _positions;
  26006. private _indices;
  26007. private _normals;
  26008. private _colors;
  26009. private _uvs;
  26010. private _indices32;
  26011. private _positions32;
  26012. private _normals32;
  26013. private _fixedNormal32;
  26014. private _colors32;
  26015. private _uvs32;
  26016. private _index;
  26017. private _updatable;
  26018. private _pickable;
  26019. private _isVisibilityBoxLocked;
  26020. private _alwaysVisible;
  26021. private _depthSort;
  26022. private _expandable;
  26023. private _shapeCounter;
  26024. private _copy;
  26025. private _color;
  26026. private _computeParticleColor;
  26027. private _computeParticleTexture;
  26028. private _computeParticleRotation;
  26029. private _computeParticleVertex;
  26030. private _computeBoundingBox;
  26031. private _depthSortParticles;
  26032. private _camera;
  26033. private _mustUnrotateFixedNormals;
  26034. private _particlesIntersect;
  26035. private _needs32Bits;
  26036. private _isNotBuilt;
  26037. /**
  26038. * Creates a SPS (Solid Particle System) object.
  26039. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26040. * @param scene (Scene) is the scene in which the SPS is added.
  26041. * @param options defines the options of the sps e.g.
  26042. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26043. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26044. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26045. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26046. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26047. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26048. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26049. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26050. */
  26051. constructor(name: string, scene: Scene, options?: {
  26052. updatable?: boolean;
  26053. isPickable?: boolean;
  26054. enableDepthSort?: boolean;
  26055. particleIntersection?: boolean;
  26056. boundingSphereOnly?: boolean;
  26057. bSphereRadiusFactor?: number;
  26058. expandable?: boolean;
  26059. });
  26060. /**
  26061. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26062. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26063. * @returns the created mesh
  26064. */
  26065. buildMesh(): Mesh;
  26066. /**
  26067. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26068. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26069. * Thus the particles generated from `digest()` have their property `position` set yet.
  26070. * @param mesh ( Mesh ) is the mesh to be digested
  26071. * @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
  26072. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26073. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26074. * @returns the current SPS
  26075. */
  26076. digest(mesh: Mesh, options?: {
  26077. facetNb?: number;
  26078. number?: number;
  26079. delta?: number;
  26080. }): SolidParticleSystem;
  26081. private _unrotateFixedNormals;
  26082. private _resetCopy;
  26083. private _meshBuilder;
  26084. private _posToShape;
  26085. private _uvsToShapeUV;
  26086. private _addParticle;
  26087. /**
  26088. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26089. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26090. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26091. * @param nb (positive integer) the number of particles to be created from this model
  26092. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26093. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26094. * @returns the number of shapes in the system
  26095. */
  26096. addShape(mesh: Mesh, nb: number, options?: {
  26097. positionFunction?: any;
  26098. vertexFunction?: any;
  26099. }): number;
  26100. private _rebuildParticle;
  26101. /**
  26102. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26103. * @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.
  26104. * @returns the SPS.
  26105. */
  26106. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26107. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26108. * Returns an array with the removed particles.
  26109. * 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.
  26110. * The SPS can't be empty so at least one particle needs to remain in place.
  26111. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26112. * @param start index of the first particle to remove
  26113. * @param end index of the last particle to remove (included)
  26114. * @returns an array populated with the removed particles
  26115. */
  26116. removeParticles(start: number, end: number): SolidParticle[];
  26117. /**
  26118. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26119. * This method calls `updateParticle()` for each particle of the SPS.
  26120. * For an animated SPS, it is usually called within the render loop.
  26121. * 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.
  26122. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26123. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26124. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26125. * @returns the SPS.
  26126. */
  26127. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26128. /**
  26129. * Disposes the SPS.
  26130. */
  26131. dispose(): void;
  26132. /**
  26133. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26134. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26135. * @returns the SPS.
  26136. */
  26137. refreshVisibleSize(): SolidParticleSystem;
  26138. /**
  26139. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26140. * @param size the size (float) of the visibility box
  26141. * note : this doesn't lock the SPS mesh bounding box.
  26142. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26143. */
  26144. setVisibilityBox(size: number): void;
  26145. /**
  26146. * Gets whether the SPS as always visible or not
  26147. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26148. */
  26149. /**
  26150. * Sets the SPS as always visible or not
  26151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26152. */
  26153. isAlwaysVisible: boolean;
  26154. /**
  26155. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26157. */
  26158. /**
  26159. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26161. */
  26162. isVisibilityBoxLocked: boolean;
  26163. /**
  26164. * Tells to `setParticles()` to compute the particle rotations or not.
  26165. * Default value : true. The SPS is faster when it's set to false.
  26166. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26167. */
  26168. /**
  26169. * Gets if `setParticles()` computes the particle rotations or not.
  26170. * Default value : true. The SPS is faster when it's set to false.
  26171. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26172. */
  26173. computeParticleRotation: boolean;
  26174. /**
  26175. * Tells to `setParticles()` to compute the particle colors or not.
  26176. * Default value : true. The SPS is faster when it's set to false.
  26177. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26178. */
  26179. /**
  26180. * Gets if `setParticles()` computes the particle colors or not.
  26181. * Default value : true. The SPS is faster when it's set to false.
  26182. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26183. */
  26184. computeParticleColor: boolean;
  26185. /**
  26186. * Gets if `setParticles()` computes the particle textures or not.
  26187. * Default value : true. The SPS is faster when it's set to false.
  26188. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26189. */
  26190. computeParticleTexture: boolean;
  26191. /**
  26192. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26193. * Default value : false. The SPS is faster when it's set to false.
  26194. * Note : the particle custom vertex positions aren't stored values.
  26195. */
  26196. /**
  26197. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26198. * Default value : false. The SPS is faster when it's set to false.
  26199. * Note : the particle custom vertex positions aren't stored values.
  26200. */
  26201. computeParticleVertex: boolean;
  26202. /**
  26203. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26204. */
  26205. /**
  26206. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26207. */
  26208. computeBoundingBox: boolean;
  26209. /**
  26210. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26211. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26212. * Default : `true`
  26213. */
  26214. /**
  26215. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26216. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26217. * Default : `true`
  26218. */
  26219. depthSortParticles: boolean;
  26220. /**
  26221. * Gets if the SPS is created as expandable at construction time.
  26222. * Default : `false`
  26223. */
  26224. readonly expandable: boolean;
  26225. /**
  26226. * This function does nothing. It may be overwritten to set all the particle first values.
  26227. * The SPS doesn't call this function, you may have to call it by your own.
  26228. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26229. */
  26230. initParticles(): void;
  26231. /**
  26232. * This function does nothing. It may be overwritten to recycle a particle.
  26233. * The SPS doesn't call this function, you may have to call it by your own.
  26234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26235. * @param particle The particle to recycle
  26236. * @returns the recycled particle
  26237. */
  26238. recycleParticle(particle: SolidParticle): SolidParticle;
  26239. /**
  26240. * Updates a particle : this function should be overwritten by the user.
  26241. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26242. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26243. * @example : just set a particle position or velocity and recycle conditions
  26244. * @param particle The particle to update
  26245. * @returns the updated particle
  26246. */
  26247. updateParticle(particle: SolidParticle): SolidParticle;
  26248. /**
  26249. * Updates a vertex of a particle : it can be overwritten by the user.
  26250. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26251. * @param particle the current particle
  26252. * @param vertex the current index of the current particle
  26253. * @param pt the index of the current vertex in the particle shape
  26254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26255. * @example : just set a vertex particle position
  26256. * @returns the updated vertex
  26257. */
  26258. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26259. /**
  26260. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26261. * This does nothing and may be overwritten by the user.
  26262. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26263. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26264. * @param update the boolean update value actually passed to setParticles()
  26265. */
  26266. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26267. /**
  26268. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26269. * This will be passed three parameters.
  26270. * This does nothing and may be overwritten by the user.
  26271. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26272. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26273. * @param update the boolean update value actually passed to setParticles()
  26274. */
  26275. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26276. }
  26277. }
  26278. declare module "babylonjs/Particles/solidParticle" {
  26279. import { Nullable } from "babylonjs/types";
  26280. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26281. import { Color4 } from "babylonjs/Maths/math.color";
  26282. import { Mesh } from "babylonjs/Meshes/mesh";
  26283. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26284. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26285. import { Plane } from "babylonjs/Maths/math.plane";
  26286. /**
  26287. * Represents one particle of a solid particle system.
  26288. */
  26289. export class SolidParticle {
  26290. /**
  26291. * particle global index
  26292. */
  26293. idx: number;
  26294. /**
  26295. * The color of the particle
  26296. */
  26297. color: Nullable<Color4>;
  26298. /**
  26299. * The world space position of the particle.
  26300. */
  26301. position: Vector3;
  26302. /**
  26303. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26304. */
  26305. rotation: Vector3;
  26306. /**
  26307. * The world space rotation quaternion of the particle.
  26308. */
  26309. rotationQuaternion: Nullable<Quaternion>;
  26310. /**
  26311. * The scaling of the particle.
  26312. */
  26313. scaling: Vector3;
  26314. /**
  26315. * The uvs of the particle.
  26316. */
  26317. uvs: Vector4;
  26318. /**
  26319. * The current speed of the particle.
  26320. */
  26321. velocity: Vector3;
  26322. /**
  26323. * The pivot point in the particle local space.
  26324. */
  26325. pivot: Vector3;
  26326. /**
  26327. * Must the particle be translated from its pivot point in its local space ?
  26328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26329. * Default : false
  26330. */
  26331. translateFromPivot: boolean;
  26332. /**
  26333. * Is the particle active or not ?
  26334. */
  26335. alive: boolean;
  26336. /**
  26337. * Is the particle visible or not ?
  26338. */
  26339. isVisible: boolean;
  26340. /**
  26341. * Index of this particle in the global "positions" array (Internal use)
  26342. * @hidden
  26343. */
  26344. _pos: number;
  26345. /**
  26346. * @hidden Index of this particle in the global "indices" array (Internal use)
  26347. */
  26348. _ind: number;
  26349. /**
  26350. * @hidden ModelShape of this particle (Internal use)
  26351. */
  26352. _model: ModelShape;
  26353. /**
  26354. * ModelShape id of this particle
  26355. */
  26356. shapeId: number;
  26357. /**
  26358. * Index of the particle in its shape id
  26359. */
  26360. idxInShape: number;
  26361. /**
  26362. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26363. */
  26364. _modelBoundingInfo: BoundingInfo;
  26365. /**
  26366. * @hidden Particle BoundingInfo object (Internal use)
  26367. */
  26368. _boundingInfo: BoundingInfo;
  26369. /**
  26370. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26371. */
  26372. _sps: SolidParticleSystem;
  26373. /**
  26374. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26375. */
  26376. _stillInvisible: boolean;
  26377. /**
  26378. * @hidden Last computed particle rotation matrix
  26379. */
  26380. _rotationMatrix: number[];
  26381. /**
  26382. * Parent particle Id, if any.
  26383. * Default null.
  26384. */
  26385. parentId: Nullable<number>;
  26386. /**
  26387. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26388. * The possible values are :
  26389. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26390. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26391. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26392. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26393. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26394. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26395. * */
  26396. cullingStrategy: number;
  26397. /**
  26398. * @hidden Internal global position in the SPS.
  26399. */
  26400. _globalPosition: Vector3;
  26401. /**
  26402. * Creates a Solid Particle object.
  26403. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26404. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26405. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26406. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26407. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26408. * @param shapeId (integer) is the model shape identifier in the SPS.
  26409. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26410. * @param sps defines the sps it is associated to
  26411. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26412. */
  26413. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26414. /**
  26415. * Legacy support, changed scale to scaling
  26416. */
  26417. /**
  26418. * Legacy support, changed scale to scaling
  26419. */
  26420. scale: Vector3;
  26421. /**
  26422. * Legacy support, changed quaternion to rotationQuaternion
  26423. */
  26424. /**
  26425. * Legacy support, changed quaternion to rotationQuaternion
  26426. */
  26427. quaternion: Nullable<Quaternion>;
  26428. /**
  26429. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26430. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26431. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26432. * @returns true if it intersects
  26433. */
  26434. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26435. /**
  26436. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26437. * A particle is in the frustum if its bounding box intersects the frustum
  26438. * @param frustumPlanes defines the frustum to test
  26439. * @returns true if the particle is in the frustum planes
  26440. */
  26441. isInFrustum(frustumPlanes: Plane[]): boolean;
  26442. /**
  26443. * get the rotation matrix of the particle
  26444. * @hidden
  26445. */
  26446. getRotationMatrix(m: Matrix): void;
  26447. }
  26448. /**
  26449. * Represents the shape of the model used by one particle of a solid particle system.
  26450. * SPS internal tool, don't use it manually.
  26451. */
  26452. export class ModelShape {
  26453. /**
  26454. * The shape id
  26455. * @hidden
  26456. */
  26457. shapeID: number;
  26458. /**
  26459. * flat array of model positions (internal use)
  26460. * @hidden
  26461. */
  26462. _shape: Vector3[];
  26463. /**
  26464. * flat array of model UVs (internal use)
  26465. * @hidden
  26466. */
  26467. _shapeUV: number[];
  26468. /**
  26469. * color array of the model
  26470. * @hidden
  26471. */
  26472. _shapeColors: number[];
  26473. /**
  26474. * indices array of the model
  26475. * @hidden
  26476. */
  26477. _indices: number[];
  26478. /**
  26479. * normals array of the model
  26480. * @hidden
  26481. */
  26482. _normals: number[];
  26483. /**
  26484. * length of the shape in the model indices array (internal use)
  26485. * @hidden
  26486. */
  26487. _indicesLength: number;
  26488. /**
  26489. * Custom position function (internal use)
  26490. * @hidden
  26491. */
  26492. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26493. /**
  26494. * Custom vertex function (internal use)
  26495. * @hidden
  26496. */
  26497. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26498. /**
  26499. * 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.
  26500. * SPS internal tool, don't use it manually.
  26501. * @hidden
  26502. */
  26503. 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>);
  26504. }
  26505. /**
  26506. * Represents a Depth Sorted Particle in the solid particle system.
  26507. */
  26508. export class DepthSortedParticle {
  26509. /**
  26510. * Index of the particle in the "indices" array
  26511. */
  26512. ind: number;
  26513. /**
  26514. * Length of the particle shape in the "indices" array
  26515. */
  26516. indicesLength: number;
  26517. /**
  26518. * Squared distance from the particle to the camera
  26519. */
  26520. sqDistance: number;
  26521. }
  26522. }
  26523. declare module "babylonjs/Collisions/meshCollisionData" {
  26524. import { Collider } from "babylonjs/Collisions/collider";
  26525. import { Vector3 } from "babylonjs/Maths/math.vector";
  26526. import { Nullable } from "babylonjs/types";
  26527. import { Observer } from "babylonjs/Misc/observable";
  26528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26529. /**
  26530. * @hidden
  26531. */
  26532. export class _MeshCollisionData {
  26533. _checkCollisions: boolean;
  26534. _collisionMask: number;
  26535. _collisionGroup: number;
  26536. _collider: Nullable<Collider>;
  26537. _oldPositionForCollisions: Vector3;
  26538. _diffPositionForCollisions: Vector3;
  26539. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26540. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26541. }
  26542. }
  26543. declare module "babylonjs/Meshes/abstractMesh" {
  26544. import { Observable } from "babylonjs/Misc/observable";
  26545. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26546. import { Camera } from "babylonjs/Cameras/camera";
  26547. import { Scene, IDisposable } from "babylonjs/scene";
  26548. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26549. import { Node } from "babylonjs/node";
  26550. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26554. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26555. import { Material } from "babylonjs/Materials/material";
  26556. import { Light } from "babylonjs/Lights/light";
  26557. import { Skeleton } from "babylonjs/Bones/skeleton";
  26558. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26559. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26560. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26561. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26562. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26563. import { Plane } from "babylonjs/Maths/math.plane";
  26564. import { Ray } from "babylonjs/Culling/ray";
  26565. import { Collider } from "babylonjs/Collisions/collider";
  26566. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26567. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26568. /** @hidden */
  26569. class _FacetDataStorage {
  26570. facetPositions: Vector3[];
  26571. facetNormals: Vector3[];
  26572. facetPartitioning: number[][];
  26573. facetNb: number;
  26574. partitioningSubdivisions: number;
  26575. partitioningBBoxRatio: number;
  26576. facetDataEnabled: boolean;
  26577. facetParameters: any;
  26578. bbSize: Vector3;
  26579. subDiv: {
  26580. max: number;
  26581. X: number;
  26582. Y: number;
  26583. Z: number;
  26584. };
  26585. facetDepthSort: boolean;
  26586. facetDepthSortEnabled: boolean;
  26587. depthSortedIndices: IndicesArray;
  26588. depthSortedFacets: {
  26589. ind: number;
  26590. sqDistance: number;
  26591. }[];
  26592. facetDepthSortFunction: (f1: {
  26593. ind: number;
  26594. sqDistance: number;
  26595. }, f2: {
  26596. ind: number;
  26597. sqDistance: number;
  26598. }) => number;
  26599. facetDepthSortFrom: Vector3;
  26600. facetDepthSortOrigin: Vector3;
  26601. invertedMatrix: Matrix;
  26602. }
  26603. /**
  26604. * @hidden
  26605. **/
  26606. class _InternalAbstractMeshDataInfo {
  26607. _hasVertexAlpha: boolean;
  26608. _useVertexColors: boolean;
  26609. _numBoneInfluencers: number;
  26610. _applyFog: boolean;
  26611. _receiveShadows: boolean;
  26612. _facetData: _FacetDataStorage;
  26613. _visibility: number;
  26614. _skeleton: Nullable<Skeleton>;
  26615. _layerMask: number;
  26616. _computeBonesUsingShaders: boolean;
  26617. _isActive: boolean;
  26618. _onlyForInstances: boolean;
  26619. _isActiveIntermediate: boolean;
  26620. _onlyForInstancesIntermediate: boolean;
  26621. _actAsRegularMesh: boolean;
  26622. }
  26623. /**
  26624. * Class used to store all common mesh properties
  26625. */
  26626. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26627. /** No occlusion */
  26628. static OCCLUSION_TYPE_NONE: number;
  26629. /** Occlusion set to optimisitic */
  26630. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26631. /** Occlusion set to strict */
  26632. static OCCLUSION_TYPE_STRICT: number;
  26633. /** Use an accurante occlusion algorithm */
  26634. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26635. /** Use a conservative occlusion algorithm */
  26636. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26637. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26638. * Test order :
  26639. * Is the bounding sphere outside the frustum ?
  26640. * If not, are the bounding box vertices outside the frustum ?
  26641. * It not, then the cullable object is in the frustum.
  26642. */
  26643. static readonly CULLINGSTRATEGY_STANDARD: number;
  26644. /** Culling strategy : Bounding Sphere Only.
  26645. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26646. * It's also less accurate than the standard because some not visible objects can still be selected.
  26647. * Test : is the bounding sphere outside the frustum ?
  26648. * If not, then the cullable object is in the frustum.
  26649. */
  26650. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26651. /** Culling strategy : Optimistic Inclusion.
  26652. * This in an inclusion test first, then the standard exclusion test.
  26653. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26654. * 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.
  26655. * Anyway, it's as accurate as the standard strategy.
  26656. * Test :
  26657. * Is the cullable object bounding sphere center in the frustum ?
  26658. * If not, apply the default culling strategy.
  26659. */
  26660. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26661. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26662. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26663. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26664. * 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.
  26665. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26666. * Test :
  26667. * Is the cullable object bounding sphere center in the frustum ?
  26668. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26669. */
  26670. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26671. /**
  26672. * No billboard
  26673. */
  26674. static readonly BILLBOARDMODE_NONE: number;
  26675. /** Billboard on X axis */
  26676. static readonly BILLBOARDMODE_X: number;
  26677. /** Billboard on Y axis */
  26678. static readonly BILLBOARDMODE_Y: number;
  26679. /** Billboard on Z axis */
  26680. static readonly BILLBOARDMODE_Z: number;
  26681. /** Billboard on all axes */
  26682. static readonly BILLBOARDMODE_ALL: number;
  26683. /** Billboard on using position instead of orientation */
  26684. static readonly BILLBOARDMODE_USE_POSITION: number;
  26685. /** @hidden */
  26686. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26687. /**
  26688. * The culling strategy to use to check whether the mesh must be rendered or not.
  26689. * This value can be changed at any time and will be used on the next render mesh selection.
  26690. * The possible values are :
  26691. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26692. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26694. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26695. * Please read each static variable documentation to get details about the culling process.
  26696. * */
  26697. cullingStrategy: number;
  26698. /**
  26699. * Gets the number of facets in the mesh
  26700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26701. */
  26702. readonly facetNb: number;
  26703. /**
  26704. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26706. */
  26707. partitioningSubdivisions: number;
  26708. /**
  26709. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26710. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26712. */
  26713. partitioningBBoxRatio: number;
  26714. /**
  26715. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26716. * Works only for updatable meshes.
  26717. * Doesn't work with multi-materials
  26718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26719. */
  26720. mustDepthSortFacets: boolean;
  26721. /**
  26722. * The location (Vector3) where the facet depth sort must be computed from.
  26723. * By default, the active camera position.
  26724. * Used only when facet depth sort is enabled
  26725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26726. */
  26727. facetDepthSortFrom: Vector3;
  26728. /**
  26729. * gets a boolean indicating if facetData is enabled
  26730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26731. */
  26732. readonly isFacetDataEnabled: boolean;
  26733. /** @hidden */
  26734. _updateNonUniformScalingState(value: boolean): boolean;
  26735. /**
  26736. * An event triggered when this mesh collides with another one
  26737. */
  26738. onCollideObservable: Observable<AbstractMesh>;
  26739. /** Set a function to call when this mesh collides with another one */
  26740. onCollide: () => void;
  26741. /**
  26742. * An event triggered when the collision's position changes
  26743. */
  26744. onCollisionPositionChangeObservable: Observable<Vector3>;
  26745. /** Set a function to call when the collision's position changes */
  26746. onCollisionPositionChange: () => void;
  26747. /**
  26748. * An event triggered when material is changed
  26749. */
  26750. onMaterialChangedObservable: Observable<AbstractMesh>;
  26751. /**
  26752. * Gets or sets the orientation for POV movement & rotation
  26753. */
  26754. definedFacingForward: boolean;
  26755. /** @hidden */
  26756. _occlusionQuery: Nullable<WebGLQuery>;
  26757. /** @hidden */
  26758. _renderingGroup: Nullable<RenderingGroup>;
  26759. /**
  26760. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26761. */
  26762. /**
  26763. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26764. */
  26765. visibility: number;
  26766. /** Gets or sets the alpha index used to sort transparent meshes
  26767. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26768. */
  26769. alphaIndex: number;
  26770. /**
  26771. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26772. */
  26773. isVisible: boolean;
  26774. /**
  26775. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26776. */
  26777. isPickable: boolean;
  26778. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26779. showSubMeshesBoundingBox: boolean;
  26780. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26781. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26782. */
  26783. isBlocker: boolean;
  26784. /**
  26785. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26786. */
  26787. enablePointerMoveEvents: boolean;
  26788. /**
  26789. * Specifies the rendering group id for this mesh (0 by default)
  26790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26791. */
  26792. renderingGroupId: number;
  26793. private _material;
  26794. /** Gets or sets current material */
  26795. material: Nullable<Material>;
  26796. /**
  26797. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26798. * @see http://doc.babylonjs.com/babylon101/shadows
  26799. */
  26800. receiveShadows: boolean;
  26801. /** Defines color to use when rendering outline */
  26802. outlineColor: Color3;
  26803. /** Define width to use when rendering outline */
  26804. outlineWidth: number;
  26805. /** Defines color to use when rendering overlay */
  26806. overlayColor: Color3;
  26807. /** Defines alpha to use when rendering overlay */
  26808. overlayAlpha: number;
  26809. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26810. hasVertexAlpha: boolean;
  26811. /** 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) */
  26812. useVertexColors: boolean;
  26813. /**
  26814. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26815. */
  26816. computeBonesUsingShaders: boolean;
  26817. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26818. numBoneInfluencers: number;
  26819. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26820. applyFog: boolean;
  26821. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26822. useOctreeForRenderingSelection: boolean;
  26823. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26824. useOctreeForPicking: boolean;
  26825. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26826. useOctreeForCollisions: boolean;
  26827. /**
  26828. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26829. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26830. */
  26831. layerMask: number;
  26832. /**
  26833. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26834. */
  26835. alwaysSelectAsActiveMesh: boolean;
  26836. /**
  26837. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26838. */
  26839. doNotSyncBoundingInfo: boolean;
  26840. /**
  26841. * Gets or sets the current action manager
  26842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26843. */
  26844. actionManager: Nullable<AbstractActionManager>;
  26845. private _meshCollisionData;
  26846. /**
  26847. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26849. */
  26850. ellipsoid: Vector3;
  26851. /**
  26852. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26854. */
  26855. ellipsoidOffset: Vector3;
  26856. /**
  26857. * Gets or sets a collision mask used to mask collisions (default is -1).
  26858. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26859. */
  26860. collisionMask: number;
  26861. /**
  26862. * Gets or sets the current collision group mask (-1 by default).
  26863. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26864. */
  26865. collisionGroup: number;
  26866. /**
  26867. * Defines edge width used when edgesRenderer is enabled
  26868. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26869. */
  26870. edgesWidth: number;
  26871. /**
  26872. * Defines edge color used when edgesRenderer is enabled
  26873. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26874. */
  26875. edgesColor: Color4;
  26876. /** @hidden */
  26877. _edgesRenderer: Nullable<IEdgesRenderer>;
  26878. /** @hidden */
  26879. _masterMesh: Nullable<AbstractMesh>;
  26880. /** @hidden */
  26881. _boundingInfo: Nullable<BoundingInfo>;
  26882. /** @hidden */
  26883. _renderId: number;
  26884. /**
  26885. * Gets or sets the list of subMeshes
  26886. * @see http://doc.babylonjs.com/how_to/multi_materials
  26887. */
  26888. subMeshes: SubMesh[];
  26889. /** @hidden */
  26890. _intersectionsInProgress: AbstractMesh[];
  26891. /** @hidden */
  26892. _unIndexed: boolean;
  26893. /** @hidden */
  26894. _lightSources: Light[];
  26895. /** Gets the list of lights affecting that mesh */
  26896. readonly lightSources: Light[];
  26897. /** @hidden */
  26898. readonly _positions: Nullable<Vector3[]>;
  26899. /** @hidden */
  26900. _waitingData: {
  26901. lods: Nullable<any>;
  26902. actions: Nullable<any>;
  26903. freezeWorldMatrix: Nullable<boolean>;
  26904. };
  26905. /** @hidden */
  26906. _bonesTransformMatrices: Nullable<Float32Array>;
  26907. /** @hidden */
  26908. _transformMatrixTexture: Nullable<RawTexture>;
  26909. /**
  26910. * Gets or sets a skeleton to apply skining transformations
  26911. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26912. */
  26913. skeleton: Nullable<Skeleton>;
  26914. /**
  26915. * An event triggered when the mesh is rebuilt.
  26916. */
  26917. onRebuildObservable: Observable<AbstractMesh>;
  26918. /**
  26919. * Creates a new AbstractMesh
  26920. * @param name defines the name of the mesh
  26921. * @param scene defines the hosting scene
  26922. */
  26923. constructor(name: string, scene?: Nullable<Scene>);
  26924. /**
  26925. * Returns the string "AbstractMesh"
  26926. * @returns "AbstractMesh"
  26927. */
  26928. getClassName(): string;
  26929. /**
  26930. * Gets a string representation of the current mesh
  26931. * @param fullDetails defines a boolean indicating if full details must be included
  26932. * @returns a string representation of the current mesh
  26933. */
  26934. toString(fullDetails?: boolean): string;
  26935. /**
  26936. * @hidden
  26937. */
  26938. protected _getEffectiveParent(): Nullable<Node>;
  26939. /** @hidden */
  26940. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26941. /** @hidden */
  26942. _rebuild(): void;
  26943. /** @hidden */
  26944. _resyncLightSources(): void;
  26945. /** @hidden */
  26946. _resyncLighSource(light: Light): void;
  26947. /** @hidden */
  26948. _unBindEffect(): void;
  26949. /** @hidden */
  26950. _removeLightSource(light: Light, dispose: boolean): void;
  26951. private _markSubMeshesAsDirty;
  26952. /** @hidden */
  26953. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26954. /** @hidden */
  26955. _markSubMeshesAsAttributesDirty(): void;
  26956. /** @hidden */
  26957. _markSubMeshesAsMiscDirty(): void;
  26958. /**
  26959. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26960. */
  26961. scaling: Vector3;
  26962. /**
  26963. * Returns true if the mesh is blocked. Implemented by child classes
  26964. */
  26965. readonly isBlocked: boolean;
  26966. /**
  26967. * Returns the mesh itself by default. Implemented by child classes
  26968. * @param camera defines the camera to use to pick the right LOD level
  26969. * @returns the currentAbstractMesh
  26970. */
  26971. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26972. /**
  26973. * Returns 0 by default. Implemented by child classes
  26974. * @returns an integer
  26975. */
  26976. getTotalVertices(): number;
  26977. /**
  26978. * Returns a positive integer : the total number of indices in this mesh geometry.
  26979. * @returns the numner of indices or zero if the mesh has no geometry.
  26980. */
  26981. getTotalIndices(): number;
  26982. /**
  26983. * Returns null by default. Implemented by child classes
  26984. * @returns null
  26985. */
  26986. getIndices(): Nullable<IndicesArray>;
  26987. /**
  26988. * Returns the array of the requested vertex data kind. Implemented by child classes
  26989. * @param kind defines the vertex data kind to use
  26990. * @returns null
  26991. */
  26992. getVerticesData(kind: string): Nullable<FloatArray>;
  26993. /**
  26994. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26995. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26996. * Note that a new underlying VertexBuffer object is created each call.
  26997. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26998. * @param kind defines vertex data kind:
  26999. * * VertexBuffer.PositionKind
  27000. * * VertexBuffer.UVKind
  27001. * * VertexBuffer.UV2Kind
  27002. * * VertexBuffer.UV3Kind
  27003. * * VertexBuffer.UV4Kind
  27004. * * VertexBuffer.UV5Kind
  27005. * * VertexBuffer.UV6Kind
  27006. * * VertexBuffer.ColorKind
  27007. * * VertexBuffer.MatricesIndicesKind
  27008. * * VertexBuffer.MatricesIndicesExtraKind
  27009. * * VertexBuffer.MatricesWeightsKind
  27010. * * VertexBuffer.MatricesWeightsExtraKind
  27011. * @param data defines the data source
  27012. * @param updatable defines if the data must be flagged as updatable (or static)
  27013. * @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
  27014. * @returns the current mesh
  27015. */
  27016. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27017. /**
  27018. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27019. * If the mesh has no geometry, it is simply returned as it is.
  27020. * @param kind defines vertex data kind:
  27021. * * VertexBuffer.PositionKind
  27022. * * VertexBuffer.UVKind
  27023. * * VertexBuffer.UV2Kind
  27024. * * VertexBuffer.UV3Kind
  27025. * * VertexBuffer.UV4Kind
  27026. * * VertexBuffer.UV5Kind
  27027. * * VertexBuffer.UV6Kind
  27028. * * VertexBuffer.ColorKind
  27029. * * VertexBuffer.MatricesIndicesKind
  27030. * * VertexBuffer.MatricesIndicesExtraKind
  27031. * * VertexBuffer.MatricesWeightsKind
  27032. * * VertexBuffer.MatricesWeightsExtraKind
  27033. * @param data defines the data source
  27034. * @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
  27035. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27036. * @returns the current mesh
  27037. */
  27038. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27039. /**
  27040. * Sets the mesh indices,
  27041. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27042. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27043. * @param totalVertices Defines the total number of vertices
  27044. * @returns the current mesh
  27045. */
  27046. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27047. /**
  27048. * Gets a boolean indicating if specific vertex data is present
  27049. * @param kind defines the vertex data kind to use
  27050. * @returns true is data kind is present
  27051. */
  27052. isVerticesDataPresent(kind: string): boolean;
  27053. /**
  27054. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27055. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27056. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27057. * @returns a BoundingInfo
  27058. */
  27059. getBoundingInfo(): BoundingInfo;
  27060. /**
  27061. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27062. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27063. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27064. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27065. * @returns the current mesh
  27066. */
  27067. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27068. /**
  27069. * Overwrite the current bounding info
  27070. * @param boundingInfo defines the new bounding info
  27071. * @returns the current mesh
  27072. */
  27073. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27074. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27075. readonly useBones: boolean;
  27076. /** @hidden */
  27077. _preActivate(): void;
  27078. /** @hidden */
  27079. _preActivateForIntermediateRendering(renderId: number): void;
  27080. /** @hidden */
  27081. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27082. /** @hidden */
  27083. _postActivate(): void;
  27084. /** @hidden */
  27085. _freeze(): void;
  27086. /** @hidden */
  27087. _unFreeze(): void;
  27088. /**
  27089. * Gets the current world matrix
  27090. * @returns a Matrix
  27091. */
  27092. getWorldMatrix(): Matrix;
  27093. /** @hidden */
  27094. _getWorldMatrixDeterminant(): number;
  27095. /**
  27096. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27097. */
  27098. readonly isAnInstance: boolean;
  27099. /**
  27100. * Gets a boolean indicating if this mesh has instances
  27101. */
  27102. readonly hasInstances: boolean;
  27103. /**
  27104. * Perform relative position change from the point of view of behind the front of the mesh.
  27105. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27106. * Supports definition of mesh facing forward or backward
  27107. * @param amountRight defines the distance on the right axis
  27108. * @param amountUp defines the distance on the up axis
  27109. * @param amountForward defines the distance on the forward axis
  27110. * @returns the current mesh
  27111. */
  27112. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27113. /**
  27114. * Calculate relative position change from the point of view of behind the front of the mesh.
  27115. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27116. * Supports definition of mesh facing forward or backward
  27117. * @param amountRight defines the distance on the right axis
  27118. * @param amountUp defines the distance on the up axis
  27119. * @param amountForward defines the distance on the forward axis
  27120. * @returns the new displacement vector
  27121. */
  27122. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27123. /**
  27124. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27125. * Supports definition of mesh facing forward or backward
  27126. * @param flipBack defines the flip
  27127. * @param twirlClockwise defines the twirl
  27128. * @param tiltRight defines the tilt
  27129. * @returns the current mesh
  27130. */
  27131. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27132. /**
  27133. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27134. * Supports definition of mesh facing forward or backward.
  27135. * @param flipBack defines the flip
  27136. * @param twirlClockwise defines the twirl
  27137. * @param tiltRight defines the tilt
  27138. * @returns the new rotation vector
  27139. */
  27140. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27141. /**
  27142. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27143. * This means the mesh underlying bounding box and sphere are recomputed.
  27144. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27145. * @returns the current mesh
  27146. */
  27147. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27148. /** @hidden */
  27149. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27150. /** @hidden */
  27151. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27152. /** @hidden */
  27153. _updateBoundingInfo(): AbstractMesh;
  27154. /** @hidden */
  27155. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27156. /** @hidden */
  27157. protected _afterComputeWorldMatrix(): void;
  27158. /** @hidden */
  27159. readonly _effectiveMesh: AbstractMesh;
  27160. /**
  27161. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27162. * A mesh is in the frustum if its bounding box intersects the frustum
  27163. * @param frustumPlanes defines the frustum to test
  27164. * @returns true if the mesh is in the frustum planes
  27165. */
  27166. isInFrustum(frustumPlanes: Plane[]): boolean;
  27167. /**
  27168. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27169. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27170. * @param frustumPlanes defines the frustum to test
  27171. * @returns true if the mesh is completely in the frustum planes
  27172. */
  27173. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27174. /**
  27175. * True if the mesh intersects another mesh or a SolidParticle object
  27176. * @param mesh defines a target mesh or SolidParticle to test
  27177. * @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)
  27178. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27179. * @returns true if there is an intersection
  27180. */
  27181. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27182. /**
  27183. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27184. * @param point defines the point to test
  27185. * @returns true if there is an intersection
  27186. */
  27187. intersectsPoint(point: Vector3): boolean;
  27188. /**
  27189. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27191. */
  27192. checkCollisions: boolean;
  27193. /**
  27194. * Gets Collider object used to compute collisions (not physics)
  27195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27196. */
  27197. readonly collider: Nullable<Collider>;
  27198. /**
  27199. * Move the mesh using collision engine
  27200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27201. * @param displacement defines the requested displacement vector
  27202. * @returns the current mesh
  27203. */
  27204. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27205. private _onCollisionPositionChange;
  27206. /** @hidden */
  27207. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27208. /** @hidden */
  27209. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27210. /** @hidden */
  27211. _checkCollision(collider: Collider): AbstractMesh;
  27212. /** @hidden */
  27213. _generatePointsArray(): boolean;
  27214. /**
  27215. * Checks if the passed Ray intersects with the mesh
  27216. * @param ray defines the ray to use
  27217. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27218. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27219. * @returns the picking info
  27220. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27221. */
  27222. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27223. /**
  27224. * Clones the current mesh
  27225. * @param name defines the mesh name
  27226. * @param newParent defines the new mesh parent
  27227. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27228. * @returns the new mesh
  27229. */
  27230. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27231. /**
  27232. * Disposes all the submeshes of the current meshnp
  27233. * @returns the current mesh
  27234. */
  27235. releaseSubMeshes(): AbstractMesh;
  27236. /**
  27237. * Releases resources associated with this abstract mesh.
  27238. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27239. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27240. */
  27241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27242. /**
  27243. * Adds the passed mesh as a child to the current mesh
  27244. * @param mesh defines the child mesh
  27245. * @returns the current mesh
  27246. */
  27247. addChild(mesh: AbstractMesh): AbstractMesh;
  27248. /**
  27249. * Removes the passed mesh from the current mesh children list
  27250. * @param mesh defines the child mesh
  27251. * @returns the current mesh
  27252. */
  27253. removeChild(mesh: AbstractMesh): AbstractMesh;
  27254. /** @hidden */
  27255. private _initFacetData;
  27256. /**
  27257. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27258. * This method can be called within the render loop.
  27259. * 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
  27260. * @returns the current mesh
  27261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27262. */
  27263. updateFacetData(): AbstractMesh;
  27264. /**
  27265. * Returns the facetLocalNormals array.
  27266. * The normals are expressed in the mesh local spac
  27267. * @returns an array of Vector3
  27268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27269. */
  27270. getFacetLocalNormals(): Vector3[];
  27271. /**
  27272. * Returns the facetLocalPositions array.
  27273. * The facet positions are expressed in the mesh local space
  27274. * @returns an array of Vector3
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27276. */
  27277. getFacetLocalPositions(): Vector3[];
  27278. /**
  27279. * Returns the facetLocalPartioning array
  27280. * @returns an array of array of numbers
  27281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27282. */
  27283. getFacetLocalPartitioning(): number[][];
  27284. /**
  27285. * Returns the i-th facet position in the world system.
  27286. * This method allocates a new Vector3 per call
  27287. * @param i defines the facet index
  27288. * @returns a new Vector3
  27289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27290. */
  27291. getFacetPosition(i: number): Vector3;
  27292. /**
  27293. * Sets the reference Vector3 with the i-th facet position in the world system
  27294. * @param i defines the facet index
  27295. * @param ref defines the target vector
  27296. * @returns the current mesh
  27297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27298. */
  27299. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27300. /**
  27301. * Returns the i-th facet normal in the world system.
  27302. * This method allocates a new Vector3 per call
  27303. * @param i defines the facet index
  27304. * @returns a new Vector3
  27305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27306. */
  27307. getFacetNormal(i: number): Vector3;
  27308. /**
  27309. * Sets the reference Vector3 with the i-th facet normal in the world system
  27310. * @param i defines the facet index
  27311. * @param ref defines the target vector
  27312. * @returns the current mesh
  27313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27314. */
  27315. getFacetNormalToRef(i: number, ref: Vector3): this;
  27316. /**
  27317. * 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)
  27318. * @param x defines x coordinate
  27319. * @param y defines y coordinate
  27320. * @param z defines z coordinate
  27321. * @returns the array of facet indexes
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27323. */
  27324. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27325. /**
  27326. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27327. * @param projected sets as the (x,y,z) world projection on the facet
  27328. * @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
  27329. * @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
  27330. * @param x defines x coordinate
  27331. * @param y defines y coordinate
  27332. * @param z defines z coordinate
  27333. * @returns the face index if found (or null instead)
  27334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27335. */
  27336. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27337. /**
  27338. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27339. * @param projected sets as the (x,y,z) local projection on the facet
  27340. * @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
  27341. * @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
  27342. * @param x defines x coordinate
  27343. * @param y defines y coordinate
  27344. * @param z defines z coordinate
  27345. * @returns the face index if found (or null instead)
  27346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27347. */
  27348. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27349. /**
  27350. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27351. * @returns the parameters
  27352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27353. */
  27354. getFacetDataParameters(): any;
  27355. /**
  27356. * Disables the feature FacetData and frees the related memory
  27357. * @returns the current mesh
  27358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27359. */
  27360. disableFacetData(): AbstractMesh;
  27361. /**
  27362. * Updates the AbstractMesh indices array
  27363. * @param indices defines the data source
  27364. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27365. * @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)
  27366. * @returns the current mesh
  27367. */
  27368. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27369. /**
  27370. * Creates new normals data for the mesh
  27371. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27372. * @returns the current mesh
  27373. */
  27374. createNormals(updatable: boolean): AbstractMesh;
  27375. /**
  27376. * Align the mesh with a normal
  27377. * @param normal defines the normal to use
  27378. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27379. * @returns the current mesh
  27380. */
  27381. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27382. /** @hidden */
  27383. _checkOcclusionQuery(): boolean;
  27384. /**
  27385. * Disables the mesh edge rendering mode
  27386. * @returns the currentAbstractMesh
  27387. */
  27388. disableEdgesRendering(): AbstractMesh;
  27389. /**
  27390. * Enables the edge rendering mode on the mesh.
  27391. * This mode makes the mesh edges visible
  27392. * @param epsilon defines the maximal distance between two angles to detect a face
  27393. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27394. * @returns the currentAbstractMesh
  27395. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27396. */
  27397. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27398. }
  27399. }
  27400. declare module "babylonjs/Actions/actionEvent" {
  27401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27402. import { Nullable } from "babylonjs/types";
  27403. import { Sprite } from "babylonjs/Sprites/sprite";
  27404. import { Scene } from "babylonjs/scene";
  27405. import { Vector2 } from "babylonjs/Maths/math.vector";
  27406. /**
  27407. * Interface used to define ActionEvent
  27408. */
  27409. export interface IActionEvent {
  27410. /** The mesh or sprite that triggered the action */
  27411. source: any;
  27412. /** The X mouse cursor position at the time of the event */
  27413. pointerX: number;
  27414. /** The Y mouse cursor position at the time of the event */
  27415. pointerY: number;
  27416. /** The mesh that is currently pointed at (can be null) */
  27417. meshUnderPointer: Nullable<AbstractMesh>;
  27418. /** the original (browser) event that triggered the ActionEvent */
  27419. sourceEvent?: any;
  27420. /** additional data for the event */
  27421. additionalData?: any;
  27422. }
  27423. /**
  27424. * ActionEvent is the event being sent when an action is triggered.
  27425. */
  27426. export class ActionEvent implements IActionEvent {
  27427. /** The mesh or sprite that triggered the action */
  27428. source: any;
  27429. /** The X mouse cursor position at the time of the event */
  27430. pointerX: number;
  27431. /** The Y mouse cursor position at the time of the event */
  27432. pointerY: number;
  27433. /** The mesh that is currently pointed at (can be null) */
  27434. meshUnderPointer: Nullable<AbstractMesh>;
  27435. /** the original (browser) event that triggered the ActionEvent */
  27436. sourceEvent?: any;
  27437. /** additional data for the event */
  27438. additionalData?: any;
  27439. /**
  27440. * Creates a new ActionEvent
  27441. * @param source The mesh or sprite that triggered the action
  27442. * @param pointerX The X mouse cursor position at the time of the event
  27443. * @param pointerY The Y mouse cursor position at the time of the event
  27444. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27445. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27446. * @param additionalData additional data for the event
  27447. */
  27448. constructor(
  27449. /** The mesh or sprite that triggered the action */
  27450. source: any,
  27451. /** The X mouse cursor position at the time of the event */
  27452. pointerX: number,
  27453. /** The Y mouse cursor position at the time of the event */
  27454. pointerY: number,
  27455. /** The mesh that is currently pointed at (can be null) */
  27456. meshUnderPointer: Nullable<AbstractMesh>,
  27457. /** the original (browser) event that triggered the ActionEvent */
  27458. sourceEvent?: any,
  27459. /** additional data for the event */
  27460. additionalData?: any);
  27461. /**
  27462. * Helper function to auto-create an ActionEvent from a source mesh.
  27463. * @param source The source mesh that triggered the event
  27464. * @param evt The original (browser) event
  27465. * @param additionalData additional data for the event
  27466. * @returns the new ActionEvent
  27467. */
  27468. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27469. /**
  27470. * Helper function to auto-create an ActionEvent from a source sprite
  27471. * @param source The source sprite that triggered the event
  27472. * @param scene Scene associated with the sprite
  27473. * @param evt The original (browser) event
  27474. * @param additionalData additional data for the event
  27475. * @returns the new ActionEvent
  27476. */
  27477. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27478. /**
  27479. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27480. * @param scene the scene where the event occurred
  27481. * @param evt The original (browser) event
  27482. * @returns the new ActionEvent
  27483. */
  27484. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27485. /**
  27486. * Helper function to auto-create an ActionEvent from a primitive
  27487. * @param prim defines the target primitive
  27488. * @param pointerPos defines the pointer position
  27489. * @param evt The original (browser) event
  27490. * @param additionalData additional data for the event
  27491. * @returns the new ActionEvent
  27492. */
  27493. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27494. }
  27495. }
  27496. declare module "babylonjs/Actions/abstractActionManager" {
  27497. import { IDisposable } from "babylonjs/scene";
  27498. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27499. import { IAction } from "babylonjs/Actions/action";
  27500. import { Nullable } from "babylonjs/types";
  27501. /**
  27502. * Abstract class used to decouple action Manager from scene and meshes.
  27503. * Do not instantiate.
  27504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27505. */
  27506. export abstract class AbstractActionManager implements IDisposable {
  27507. /** Gets the list of active triggers */
  27508. static Triggers: {
  27509. [key: string]: number;
  27510. };
  27511. /** Gets the cursor to use when hovering items */
  27512. hoverCursor: string;
  27513. /** Gets the list of actions */
  27514. actions: IAction[];
  27515. /**
  27516. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27517. */
  27518. isRecursive: boolean;
  27519. /**
  27520. * Releases all associated resources
  27521. */
  27522. abstract dispose(): void;
  27523. /**
  27524. * Does this action manager has pointer triggers
  27525. */
  27526. abstract readonly hasPointerTriggers: boolean;
  27527. /**
  27528. * Does this action manager has pick triggers
  27529. */
  27530. abstract readonly hasPickTriggers: boolean;
  27531. /**
  27532. * Process a specific trigger
  27533. * @param trigger defines the trigger to process
  27534. * @param evt defines the event details to be processed
  27535. */
  27536. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27537. /**
  27538. * Does this action manager handles actions of any of the given triggers
  27539. * @param triggers defines the triggers to be tested
  27540. * @return a boolean indicating whether one (or more) of the triggers is handled
  27541. */
  27542. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27543. /**
  27544. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27545. * speed.
  27546. * @param triggerA defines the trigger to be tested
  27547. * @param triggerB defines the trigger to be tested
  27548. * @return a boolean indicating whether one (or more) of the triggers is handled
  27549. */
  27550. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27551. /**
  27552. * Does this action manager handles actions of a given trigger
  27553. * @param trigger defines the trigger to be tested
  27554. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27555. * @return whether the trigger is handled
  27556. */
  27557. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27558. /**
  27559. * Serialize this manager to a JSON object
  27560. * @param name defines the property name to store this manager
  27561. * @returns a JSON representation of this manager
  27562. */
  27563. abstract serialize(name: string): any;
  27564. /**
  27565. * Registers an action to this action manager
  27566. * @param action defines the action to be registered
  27567. * @return the action amended (prepared) after registration
  27568. */
  27569. abstract registerAction(action: IAction): Nullable<IAction>;
  27570. /**
  27571. * Unregisters an action to this action manager
  27572. * @param action defines the action to be unregistered
  27573. * @return a boolean indicating whether the action has been unregistered
  27574. */
  27575. abstract unregisterAction(action: IAction): Boolean;
  27576. /**
  27577. * Does exist one action manager with at least one trigger
  27578. **/
  27579. static readonly HasTriggers: boolean;
  27580. /**
  27581. * Does exist one action manager with at least one pick trigger
  27582. **/
  27583. static readonly HasPickTriggers: boolean;
  27584. /**
  27585. * Does exist one action manager that handles actions of a given trigger
  27586. * @param trigger defines the trigger to be tested
  27587. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27588. **/
  27589. static HasSpecificTrigger(trigger: number): boolean;
  27590. }
  27591. }
  27592. declare module "babylonjs/node" {
  27593. import { Scene } from "babylonjs/scene";
  27594. import { Nullable } from "babylonjs/types";
  27595. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27596. import { Engine } from "babylonjs/Engines/engine";
  27597. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27598. import { Observable } from "babylonjs/Misc/observable";
  27599. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27600. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27601. import { Animatable } from "babylonjs/Animations/animatable";
  27602. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27603. import { Animation } from "babylonjs/Animations/animation";
  27604. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27606. /**
  27607. * Defines how a node can be built from a string name.
  27608. */
  27609. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27610. /**
  27611. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27612. */
  27613. export class Node implements IBehaviorAware<Node> {
  27614. /** @hidden */
  27615. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27616. private static _NodeConstructors;
  27617. /**
  27618. * Add a new node constructor
  27619. * @param type defines the type name of the node to construct
  27620. * @param constructorFunc defines the constructor function
  27621. */
  27622. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27623. /**
  27624. * Returns a node constructor based on type name
  27625. * @param type defines the type name
  27626. * @param name defines the new node name
  27627. * @param scene defines the hosting scene
  27628. * @param options defines optional options to transmit to constructors
  27629. * @returns the new constructor or null
  27630. */
  27631. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27632. /**
  27633. * Gets or sets the name of the node
  27634. */
  27635. name: string;
  27636. /**
  27637. * Gets or sets the id of the node
  27638. */
  27639. id: string;
  27640. /**
  27641. * Gets or sets the unique id of the node
  27642. */
  27643. uniqueId: number;
  27644. /**
  27645. * Gets or sets a string used to store user defined state for the node
  27646. */
  27647. state: string;
  27648. /**
  27649. * Gets or sets an object used to store user defined information for the node
  27650. */
  27651. metadata: any;
  27652. /**
  27653. * For internal use only. Please do not use.
  27654. */
  27655. reservedDataStore: any;
  27656. /**
  27657. * List of inspectable custom properties (used by the Inspector)
  27658. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27659. */
  27660. inspectableCustomProperties: IInspectable[];
  27661. private _doNotSerialize;
  27662. /**
  27663. * Gets or sets a boolean used to define if the node must be serialized
  27664. */
  27665. doNotSerialize: boolean;
  27666. /** @hidden */
  27667. _isDisposed: boolean;
  27668. /**
  27669. * Gets a list of Animations associated with the node
  27670. */
  27671. animations: import("babylonjs/Animations/animation").Animation[];
  27672. protected _ranges: {
  27673. [name: string]: Nullable<AnimationRange>;
  27674. };
  27675. /**
  27676. * Callback raised when the node is ready to be used
  27677. */
  27678. onReady: Nullable<(node: Node) => void>;
  27679. private _isEnabled;
  27680. private _isParentEnabled;
  27681. private _isReady;
  27682. /** @hidden */
  27683. _currentRenderId: number;
  27684. private _parentUpdateId;
  27685. /** @hidden */
  27686. _childUpdateId: number;
  27687. /** @hidden */
  27688. _waitingParentId: Nullable<string>;
  27689. /** @hidden */
  27690. _scene: Scene;
  27691. /** @hidden */
  27692. _cache: any;
  27693. private _parentNode;
  27694. private _children;
  27695. /** @hidden */
  27696. _worldMatrix: Matrix;
  27697. /** @hidden */
  27698. _worldMatrixDeterminant: number;
  27699. /** @hidden */
  27700. _worldMatrixDeterminantIsDirty: boolean;
  27701. /** @hidden */
  27702. private _sceneRootNodesIndex;
  27703. /**
  27704. * Gets a boolean indicating if the node has been disposed
  27705. * @returns true if the node was disposed
  27706. */
  27707. isDisposed(): boolean;
  27708. /**
  27709. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27710. * @see https://doc.babylonjs.com/how_to/parenting
  27711. */
  27712. parent: Nullable<Node>;
  27713. private addToSceneRootNodes;
  27714. private removeFromSceneRootNodes;
  27715. private _animationPropertiesOverride;
  27716. /**
  27717. * Gets or sets the animation properties override
  27718. */
  27719. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27720. /**
  27721. * Gets a string idenfifying the name of the class
  27722. * @returns "Node" string
  27723. */
  27724. getClassName(): string;
  27725. /** @hidden */
  27726. readonly _isNode: boolean;
  27727. /**
  27728. * An event triggered when the mesh is disposed
  27729. */
  27730. onDisposeObservable: Observable<Node>;
  27731. private _onDisposeObserver;
  27732. /**
  27733. * Sets a callback that will be raised when the node will be disposed
  27734. */
  27735. onDispose: () => void;
  27736. /**
  27737. * Creates a new Node
  27738. * @param name the name and id to be given to this node
  27739. * @param scene the scene this node will be added to
  27740. * @param addToRootNodes the node will be added to scene.rootNodes
  27741. */
  27742. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27743. /**
  27744. * Gets the scene of the node
  27745. * @returns a scene
  27746. */
  27747. getScene(): Scene;
  27748. /**
  27749. * Gets the engine of the node
  27750. * @returns a Engine
  27751. */
  27752. getEngine(): Engine;
  27753. private _behaviors;
  27754. /**
  27755. * Attach a behavior to the node
  27756. * @see http://doc.babylonjs.com/features/behaviour
  27757. * @param behavior defines the behavior to attach
  27758. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27759. * @returns the current Node
  27760. */
  27761. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27762. /**
  27763. * Remove an attached behavior
  27764. * @see http://doc.babylonjs.com/features/behaviour
  27765. * @param behavior defines the behavior to attach
  27766. * @returns the current Node
  27767. */
  27768. removeBehavior(behavior: Behavior<Node>): Node;
  27769. /**
  27770. * Gets the list of attached behaviors
  27771. * @see http://doc.babylonjs.com/features/behaviour
  27772. */
  27773. readonly behaviors: Behavior<Node>[];
  27774. /**
  27775. * Gets an attached behavior by name
  27776. * @param name defines the name of the behavior to look for
  27777. * @see http://doc.babylonjs.com/features/behaviour
  27778. * @returns null if behavior was not found else the requested behavior
  27779. */
  27780. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27781. /**
  27782. * Returns the latest update of the World matrix
  27783. * @returns a Matrix
  27784. */
  27785. getWorldMatrix(): Matrix;
  27786. /** @hidden */
  27787. _getWorldMatrixDeterminant(): number;
  27788. /**
  27789. * Returns directly the latest state of the mesh World matrix.
  27790. * A Matrix is returned.
  27791. */
  27792. readonly worldMatrixFromCache: Matrix;
  27793. /** @hidden */
  27794. _initCache(): void;
  27795. /** @hidden */
  27796. updateCache(force?: boolean): void;
  27797. /** @hidden */
  27798. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27799. /** @hidden */
  27800. _updateCache(ignoreParentClass?: boolean): void;
  27801. /** @hidden */
  27802. _isSynchronized(): boolean;
  27803. /** @hidden */
  27804. _markSyncedWithParent(): void;
  27805. /** @hidden */
  27806. isSynchronizedWithParent(): boolean;
  27807. /** @hidden */
  27808. isSynchronized(): boolean;
  27809. /**
  27810. * Is this node ready to be used/rendered
  27811. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27812. * @return true if the node is ready
  27813. */
  27814. isReady(completeCheck?: boolean): boolean;
  27815. /**
  27816. * Is this node enabled?
  27817. * 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
  27818. * @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
  27819. * @return whether this node (and its parent) is enabled
  27820. */
  27821. isEnabled(checkAncestors?: boolean): boolean;
  27822. /** @hidden */
  27823. protected _syncParentEnabledState(): void;
  27824. /**
  27825. * Set the enabled state of this node
  27826. * @param value defines the new enabled state
  27827. */
  27828. setEnabled(value: boolean): void;
  27829. /**
  27830. * Is this node a descendant of the given node?
  27831. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27832. * @param ancestor defines the parent node to inspect
  27833. * @returns a boolean indicating if this node is a descendant of the given node
  27834. */
  27835. isDescendantOf(ancestor: Node): boolean;
  27836. /** @hidden */
  27837. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27838. /**
  27839. * Will return all nodes that have this node as ascendant
  27840. * @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
  27841. * @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
  27842. * @return all children nodes of all types
  27843. */
  27844. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27845. /**
  27846. * Get all child-meshes of this node
  27847. * @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)
  27848. * @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
  27849. * @returns an array of AbstractMesh
  27850. */
  27851. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27852. /**
  27853. * Get all direct children of this node
  27854. * @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
  27855. * @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)
  27856. * @returns an array of Node
  27857. */
  27858. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27859. /** @hidden */
  27860. _setReady(state: boolean): void;
  27861. /**
  27862. * Get an animation by name
  27863. * @param name defines the name of the animation to look for
  27864. * @returns null if not found else the requested animation
  27865. */
  27866. getAnimationByName(name: string): Nullable<Animation>;
  27867. /**
  27868. * Creates an animation range for this node
  27869. * @param name defines the name of the range
  27870. * @param from defines the starting key
  27871. * @param to defines the end key
  27872. */
  27873. createAnimationRange(name: string, from: number, to: number): void;
  27874. /**
  27875. * Delete a specific animation range
  27876. * @param name defines the name of the range to delete
  27877. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27878. */
  27879. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27880. /**
  27881. * Get an animation range by name
  27882. * @param name defines the name of the animation range to look for
  27883. * @returns null if not found else the requested animation range
  27884. */
  27885. getAnimationRange(name: string): Nullable<AnimationRange>;
  27886. /**
  27887. * Gets the list of all animation ranges defined on this node
  27888. * @returns an array
  27889. */
  27890. getAnimationRanges(): Nullable<AnimationRange>[];
  27891. /**
  27892. * Will start the animation sequence
  27893. * @param name defines the range frames for animation sequence
  27894. * @param loop defines if the animation should loop (false by default)
  27895. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27896. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27897. * @returns the object created for this animation. If range does not exist, it will return null
  27898. */
  27899. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27900. /**
  27901. * Serialize animation ranges into a JSON compatible object
  27902. * @returns serialization object
  27903. */
  27904. serializeAnimationRanges(): any;
  27905. /**
  27906. * Computes the world matrix of the node
  27907. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27908. * @returns the world matrix
  27909. */
  27910. computeWorldMatrix(force?: boolean): Matrix;
  27911. /**
  27912. * Releases resources associated with this node.
  27913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27915. */
  27916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27917. /**
  27918. * Parse animation range data from a serialization object and store them into a given node
  27919. * @param node defines where to store the animation ranges
  27920. * @param parsedNode defines the serialization object to read data from
  27921. * @param scene defines the hosting scene
  27922. */
  27923. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27924. /**
  27925. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27926. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27927. * @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
  27928. * @returns the new bounding vectors
  27929. */
  27930. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27931. min: Vector3;
  27932. max: Vector3;
  27933. };
  27934. }
  27935. }
  27936. declare module "babylonjs/Animations/animation" {
  27937. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27938. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27939. import { Color3 } from "babylonjs/Maths/math.color";
  27940. import { Nullable } from "babylonjs/types";
  27941. import { Scene } from "babylonjs/scene";
  27942. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27943. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27944. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27945. import { Node } from "babylonjs/node";
  27946. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27947. import { Size } from "babylonjs/Maths/math.size";
  27948. import { Animatable } from "babylonjs/Animations/animatable";
  27949. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27950. /**
  27951. * @hidden
  27952. */
  27953. export class _IAnimationState {
  27954. key: number;
  27955. repeatCount: number;
  27956. workValue?: any;
  27957. loopMode?: number;
  27958. offsetValue?: any;
  27959. highLimitValue?: any;
  27960. }
  27961. /**
  27962. * Class used to store any kind of animation
  27963. */
  27964. export class Animation {
  27965. /**Name of the animation */
  27966. name: string;
  27967. /**Property to animate */
  27968. targetProperty: string;
  27969. /**The frames per second of the animation */
  27970. framePerSecond: number;
  27971. /**The data type of the animation */
  27972. dataType: number;
  27973. /**The loop mode of the animation */
  27974. loopMode?: number | undefined;
  27975. /**Specifies if blending should be enabled */
  27976. enableBlending?: boolean | undefined;
  27977. /**
  27978. * Use matrix interpolation instead of using direct key value when animating matrices
  27979. */
  27980. static AllowMatricesInterpolation: boolean;
  27981. /**
  27982. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27983. */
  27984. static AllowMatrixDecomposeForInterpolation: boolean;
  27985. /**
  27986. * Stores the key frames of the animation
  27987. */
  27988. private _keys;
  27989. /**
  27990. * Stores the easing function of the animation
  27991. */
  27992. private _easingFunction;
  27993. /**
  27994. * @hidden Internal use only
  27995. */
  27996. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27997. /**
  27998. * The set of event that will be linked to this animation
  27999. */
  28000. private _events;
  28001. /**
  28002. * Stores an array of target property paths
  28003. */
  28004. targetPropertyPath: string[];
  28005. /**
  28006. * Stores the blending speed of the animation
  28007. */
  28008. blendingSpeed: number;
  28009. /**
  28010. * Stores the animation ranges for the animation
  28011. */
  28012. private _ranges;
  28013. /**
  28014. * @hidden Internal use
  28015. */
  28016. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28017. /**
  28018. * Sets up an animation
  28019. * @param property The property to animate
  28020. * @param animationType The animation type to apply
  28021. * @param framePerSecond The frames per second of the animation
  28022. * @param easingFunction The easing function used in the animation
  28023. * @returns The created animation
  28024. */
  28025. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28026. /**
  28027. * Create and start an animation on a node
  28028. * @param name defines the name of the global animation that will be run on all nodes
  28029. * @param node defines the root node where the animation will take place
  28030. * @param targetProperty defines property to animate
  28031. * @param framePerSecond defines the number of frame per second yo use
  28032. * @param totalFrame defines the number of frames in total
  28033. * @param from defines the initial value
  28034. * @param to defines the final value
  28035. * @param loopMode defines which loop mode you want to use (off by default)
  28036. * @param easingFunction defines the easing function to use (linear by default)
  28037. * @param onAnimationEnd defines the callback to call when animation end
  28038. * @returns the animatable created for this animation
  28039. */
  28040. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28041. /**
  28042. * Create and start an animation on a node and its descendants
  28043. * @param name defines the name of the global animation that will be run on all nodes
  28044. * @param node defines the root node where the animation will take place
  28045. * @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
  28046. * @param targetProperty defines property to animate
  28047. * @param framePerSecond defines the number of frame per second to use
  28048. * @param totalFrame defines the number of frames in total
  28049. * @param from defines the initial value
  28050. * @param to defines the final value
  28051. * @param loopMode defines which loop mode you want to use (off by default)
  28052. * @param easingFunction defines the easing function to use (linear by default)
  28053. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28054. * @returns the list of animatables created for all nodes
  28055. * @example https://www.babylonjs-playground.com/#MH0VLI
  28056. */
  28057. 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[]>;
  28058. /**
  28059. * Creates a new animation, merges it with the existing animations and starts it
  28060. * @param name Name of the animation
  28061. * @param node Node which contains the scene that begins the animations
  28062. * @param targetProperty Specifies which property to animate
  28063. * @param framePerSecond The frames per second of the animation
  28064. * @param totalFrame The total number of frames
  28065. * @param from The frame at the beginning of the animation
  28066. * @param to The frame at the end of the animation
  28067. * @param loopMode Specifies the loop mode of the animation
  28068. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28069. * @param onAnimationEnd Callback to run once the animation is complete
  28070. * @returns Nullable animation
  28071. */
  28072. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28073. /**
  28074. * Transition property of an host to the target Value
  28075. * @param property The property to transition
  28076. * @param targetValue The target Value of the property
  28077. * @param host The object where the property to animate belongs
  28078. * @param scene Scene used to run the animation
  28079. * @param frameRate Framerate (in frame/s) to use
  28080. * @param transition The transition type we want to use
  28081. * @param duration The duration of the animation, in milliseconds
  28082. * @param onAnimationEnd Callback trigger at the end of the animation
  28083. * @returns Nullable animation
  28084. */
  28085. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28086. /**
  28087. * Return the array of runtime animations currently using this animation
  28088. */
  28089. readonly runtimeAnimations: RuntimeAnimation[];
  28090. /**
  28091. * Specifies if any of the runtime animations are currently running
  28092. */
  28093. readonly hasRunningRuntimeAnimations: boolean;
  28094. /**
  28095. * Initializes the animation
  28096. * @param name Name of the animation
  28097. * @param targetProperty Property to animate
  28098. * @param framePerSecond The frames per second of the animation
  28099. * @param dataType The data type of the animation
  28100. * @param loopMode The loop mode of the animation
  28101. * @param enableBlending Specifies if blending should be enabled
  28102. */
  28103. constructor(
  28104. /**Name of the animation */
  28105. name: string,
  28106. /**Property to animate */
  28107. targetProperty: string,
  28108. /**The frames per second of the animation */
  28109. framePerSecond: number,
  28110. /**The data type of the animation */
  28111. dataType: number,
  28112. /**The loop mode of the animation */
  28113. loopMode?: number | undefined,
  28114. /**Specifies if blending should be enabled */
  28115. enableBlending?: boolean | undefined);
  28116. /**
  28117. * Converts the animation to a string
  28118. * @param fullDetails support for multiple levels of logging within scene loading
  28119. * @returns String form of the animation
  28120. */
  28121. toString(fullDetails?: boolean): string;
  28122. /**
  28123. * Add an event to this animation
  28124. * @param event Event to add
  28125. */
  28126. addEvent(event: AnimationEvent): void;
  28127. /**
  28128. * Remove all events found at the given frame
  28129. * @param frame The frame to remove events from
  28130. */
  28131. removeEvents(frame: number): void;
  28132. /**
  28133. * Retrieves all the events from the animation
  28134. * @returns Events from the animation
  28135. */
  28136. getEvents(): AnimationEvent[];
  28137. /**
  28138. * Creates an animation range
  28139. * @param name Name of the animation range
  28140. * @param from Starting frame of the animation range
  28141. * @param to Ending frame of the animation
  28142. */
  28143. createRange(name: string, from: number, to: number): void;
  28144. /**
  28145. * Deletes an animation range by name
  28146. * @param name Name of the animation range to delete
  28147. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28148. */
  28149. deleteRange(name: string, deleteFrames?: boolean): void;
  28150. /**
  28151. * Gets the animation range by name, or null if not defined
  28152. * @param name Name of the animation range
  28153. * @returns Nullable animation range
  28154. */
  28155. getRange(name: string): Nullable<AnimationRange>;
  28156. /**
  28157. * Gets the key frames from the animation
  28158. * @returns The key frames of the animation
  28159. */
  28160. getKeys(): Array<IAnimationKey>;
  28161. /**
  28162. * Gets the highest frame rate of the animation
  28163. * @returns Highest frame rate of the animation
  28164. */
  28165. getHighestFrame(): number;
  28166. /**
  28167. * Gets the easing function of the animation
  28168. * @returns Easing function of the animation
  28169. */
  28170. getEasingFunction(): IEasingFunction;
  28171. /**
  28172. * Sets the easing function of the animation
  28173. * @param easingFunction A custom mathematical formula for animation
  28174. */
  28175. setEasingFunction(easingFunction: EasingFunction): void;
  28176. /**
  28177. * Interpolates a scalar linearly
  28178. * @param startValue Start value of the animation curve
  28179. * @param endValue End value of the animation curve
  28180. * @param gradient Scalar amount to interpolate
  28181. * @returns Interpolated scalar value
  28182. */
  28183. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28184. /**
  28185. * Interpolates a scalar cubically
  28186. * @param startValue Start value of the animation curve
  28187. * @param outTangent End tangent of the animation
  28188. * @param endValue End value of the animation curve
  28189. * @param inTangent Start tangent of the animation curve
  28190. * @param gradient Scalar amount to interpolate
  28191. * @returns Interpolated scalar value
  28192. */
  28193. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28194. /**
  28195. * Interpolates a quaternion using a spherical linear interpolation
  28196. * @param startValue Start value of the animation curve
  28197. * @param endValue End value of the animation curve
  28198. * @param gradient Scalar amount to interpolate
  28199. * @returns Interpolated quaternion value
  28200. */
  28201. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28202. /**
  28203. * Interpolates a quaternion cubically
  28204. * @param startValue Start value of the animation curve
  28205. * @param outTangent End tangent of the animation curve
  28206. * @param endValue End value of the animation curve
  28207. * @param inTangent Start tangent of the animation curve
  28208. * @param gradient Scalar amount to interpolate
  28209. * @returns Interpolated quaternion value
  28210. */
  28211. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28212. /**
  28213. * Interpolates a Vector3 linearl
  28214. * @param startValue Start value of the animation curve
  28215. * @param endValue End value of the animation curve
  28216. * @param gradient Scalar amount to interpolate
  28217. * @returns Interpolated scalar value
  28218. */
  28219. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28220. /**
  28221. * Interpolates a Vector3 cubically
  28222. * @param startValue Start value of the animation curve
  28223. * @param outTangent End tangent of the animation
  28224. * @param endValue End value of the animation curve
  28225. * @param inTangent Start tangent of the animation curve
  28226. * @param gradient Scalar amount to interpolate
  28227. * @returns InterpolatedVector3 value
  28228. */
  28229. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28230. /**
  28231. * Interpolates a Vector2 linearly
  28232. * @param startValue Start value of the animation curve
  28233. * @param endValue End value of the animation curve
  28234. * @param gradient Scalar amount to interpolate
  28235. * @returns Interpolated Vector2 value
  28236. */
  28237. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28238. /**
  28239. * Interpolates a Vector2 cubically
  28240. * @param startValue Start value of the animation curve
  28241. * @param outTangent End tangent of the animation
  28242. * @param endValue End value of the animation curve
  28243. * @param inTangent Start tangent of the animation curve
  28244. * @param gradient Scalar amount to interpolate
  28245. * @returns Interpolated Vector2 value
  28246. */
  28247. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28248. /**
  28249. * Interpolates a size linearly
  28250. * @param startValue Start value of the animation curve
  28251. * @param endValue End value of the animation curve
  28252. * @param gradient Scalar amount to interpolate
  28253. * @returns Interpolated Size value
  28254. */
  28255. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28256. /**
  28257. * Interpolates a Color3 linearly
  28258. * @param startValue Start value of the animation curve
  28259. * @param endValue End value of the animation curve
  28260. * @param gradient Scalar amount to interpolate
  28261. * @returns Interpolated Color3 value
  28262. */
  28263. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28264. /**
  28265. * @hidden Internal use only
  28266. */
  28267. _getKeyValue(value: any): any;
  28268. /**
  28269. * @hidden Internal use only
  28270. */
  28271. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28272. /**
  28273. * Defines the function to use to interpolate matrices
  28274. * @param startValue defines the start matrix
  28275. * @param endValue defines the end matrix
  28276. * @param gradient defines the gradient between both matrices
  28277. * @param result defines an optional target matrix where to store the interpolation
  28278. * @returns the interpolated matrix
  28279. */
  28280. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28281. /**
  28282. * Makes a copy of the animation
  28283. * @returns Cloned animation
  28284. */
  28285. clone(): Animation;
  28286. /**
  28287. * Sets the key frames of the animation
  28288. * @param values The animation key frames to set
  28289. */
  28290. setKeys(values: Array<IAnimationKey>): void;
  28291. /**
  28292. * Serializes the animation to an object
  28293. * @returns Serialized object
  28294. */
  28295. serialize(): any;
  28296. /**
  28297. * Float animation type
  28298. */
  28299. private static _ANIMATIONTYPE_FLOAT;
  28300. /**
  28301. * Vector3 animation type
  28302. */
  28303. private static _ANIMATIONTYPE_VECTOR3;
  28304. /**
  28305. * Quaternion animation type
  28306. */
  28307. private static _ANIMATIONTYPE_QUATERNION;
  28308. /**
  28309. * Matrix animation type
  28310. */
  28311. private static _ANIMATIONTYPE_MATRIX;
  28312. /**
  28313. * Color3 animation type
  28314. */
  28315. private static _ANIMATIONTYPE_COLOR3;
  28316. /**
  28317. * Vector2 animation type
  28318. */
  28319. private static _ANIMATIONTYPE_VECTOR2;
  28320. /**
  28321. * Size animation type
  28322. */
  28323. private static _ANIMATIONTYPE_SIZE;
  28324. /**
  28325. * Relative Loop Mode
  28326. */
  28327. private static _ANIMATIONLOOPMODE_RELATIVE;
  28328. /**
  28329. * Cycle Loop Mode
  28330. */
  28331. private static _ANIMATIONLOOPMODE_CYCLE;
  28332. /**
  28333. * Constant Loop Mode
  28334. */
  28335. private static _ANIMATIONLOOPMODE_CONSTANT;
  28336. /**
  28337. * Get the float animation type
  28338. */
  28339. static readonly ANIMATIONTYPE_FLOAT: number;
  28340. /**
  28341. * Get the Vector3 animation type
  28342. */
  28343. static readonly ANIMATIONTYPE_VECTOR3: number;
  28344. /**
  28345. * Get the Vector2 animation type
  28346. */
  28347. static readonly ANIMATIONTYPE_VECTOR2: number;
  28348. /**
  28349. * Get the Size animation type
  28350. */
  28351. static readonly ANIMATIONTYPE_SIZE: number;
  28352. /**
  28353. * Get the Quaternion animation type
  28354. */
  28355. static readonly ANIMATIONTYPE_QUATERNION: number;
  28356. /**
  28357. * Get the Matrix animation type
  28358. */
  28359. static readonly ANIMATIONTYPE_MATRIX: number;
  28360. /**
  28361. * Get the Color3 animation type
  28362. */
  28363. static readonly ANIMATIONTYPE_COLOR3: number;
  28364. /**
  28365. * Get the Relative Loop Mode
  28366. */
  28367. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28368. /**
  28369. * Get the Cycle Loop Mode
  28370. */
  28371. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28372. /**
  28373. * Get the Constant Loop Mode
  28374. */
  28375. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28376. /** @hidden */
  28377. static _UniversalLerp(left: any, right: any, amount: number): any;
  28378. /**
  28379. * Parses an animation object and creates an animation
  28380. * @param parsedAnimation Parsed animation object
  28381. * @returns Animation object
  28382. */
  28383. static Parse(parsedAnimation: any): Animation;
  28384. /**
  28385. * Appends the serialized animations from the source animations
  28386. * @param source Source containing the animations
  28387. * @param destination Target to store the animations
  28388. */
  28389. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28390. }
  28391. }
  28392. declare module "babylonjs/Animations/animatable.interface" {
  28393. import { Nullable } from "babylonjs/types";
  28394. import { Animation } from "babylonjs/Animations/animation";
  28395. /**
  28396. * Interface containing an array of animations
  28397. */
  28398. export interface IAnimatable {
  28399. /**
  28400. * Array of animations
  28401. */
  28402. animations: Nullable<Array<Animation>>;
  28403. }
  28404. }
  28405. declare module "babylonjs/Materials/fresnelParameters" {
  28406. import { Color3 } from "babylonjs/Maths/math.color";
  28407. /**
  28408. * This represents all the required information to add a fresnel effect on a material:
  28409. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28410. */
  28411. export class FresnelParameters {
  28412. private _isEnabled;
  28413. /**
  28414. * Define if the fresnel effect is enable or not.
  28415. */
  28416. isEnabled: boolean;
  28417. /**
  28418. * Define the color used on edges (grazing angle)
  28419. */
  28420. leftColor: Color3;
  28421. /**
  28422. * Define the color used on center
  28423. */
  28424. rightColor: Color3;
  28425. /**
  28426. * Define bias applied to computed fresnel term
  28427. */
  28428. bias: number;
  28429. /**
  28430. * Defined the power exponent applied to fresnel term
  28431. */
  28432. power: number;
  28433. /**
  28434. * Clones the current fresnel and its valuues
  28435. * @returns a clone fresnel configuration
  28436. */
  28437. clone(): FresnelParameters;
  28438. /**
  28439. * Serializes the current fresnel parameters to a JSON representation.
  28440. * @return the JSON serialization
  28441. */
  28442. serialize(): any;
  28443. /**
  28444. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28445. * @param parsedFresnelParameters Define the JSON representation
  28446. * @returns the parsed parameters
  28447. */
  28448. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28449. }
  28450. }
  28451. declare module "babylonjs/Misc/decorators" {
  28452. import { Nullable } from "babylonjs/types";
  28453. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28454. import { Scene } from "babylonjs/scene";
  28455. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28456. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28457. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28458. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28459. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28460. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28461. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28462. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28463. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28464. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28465. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28466. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28467. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28468. /**
  28469. * Decorator used to define property that can be serialized as reference to a camera
  28470. * @param sourceName defines the name of the property to decorate
  28471. */
  28472. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28473. /**
  28474. * Class used to help serialization objects
  28475. */
  28476. export class SerializationHelper {
  28477. /** @hidden */
  28478. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28479. /** @hidden */
  28480. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28481. /** @hidden */
  28482. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28483. /** @hidden */
  28484. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28485. /**
  28486. * Appends the serialized animations from the source animations
  28487. * @param source Source containing the animations
  28488. * @param destination Target to store the animations
  28489. */
  28490. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28491. /**
  28492. * Static function used to serialized a specific entity
  28493. * @param entity defines the entity to serialize
  28494. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28495. * @returns a JSON compatible object representing the serialization of the entity
  28496. */
  28497. static Serialize<T>(entity: T, serializationObject?: any): any;
  28498. /**
  28499. * Creates a new entity from a serialization data object
  28500. * @param creationFunction defines a function used to instanciated the new entity
  28501. * @param source defines the source serialization data
  28502. * @param scene defines the hosting scene
  28503. * @param rootUrl defines the root url for resources
  28504. * @returns a new entity
  28505. */
  28506. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28507. /**
  28508. * Clones an object
  28509. * @param creationFunction defines the function used to instanciate the new object
  28510. * @param source defines the source object
  28511. * @returns the cloned object
  28512. */
  28513. static Clone<T>(creationFunction: () => T, source: T): T;
  28514. /**
  28515. * Instanciates a new object based on a source one (some data will be shared between both object)
  28516. * @param creationFunction defines the function used to instanciate the new object
  28517. * @param source defines the source object
  28518. * @returns the new object
  28519. */
  28520. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28521. }
  28522. }
  28523. declare module "babylonjs/Misc/guid" {
  28524. /**
  28525. * Class used to manipulate GUIDs
  28526. */
  28527. export class GUID {
  28528. /**
  28529. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28530. * Be aware Math.random() could cause collisions, but:
  28531. * "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"
  28532. * @returns a pseudo random id
  28533. */
  28534. static RandomId(): string;
  28535. }
  28536. }
  28537. declare module "babylonjs/Materials/Textures/baseTexture" {
  28538. import { Observable } from "babylonjs/Misc/observable";
  28539. import { Nullable } from "babylonjs/types";
  28540. import { Scene } from "babylonjs/scene";
  28541. import { Matrix } from "babylonjs/Maths/math.vector";
  28542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28543. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28544. import { ISize } from "babylonjs/Maths/math.size";
  28545. /**
  28546. * Base class of all the textures in babylon.
  28547. * It groups all the common properties the materials, post process, lights... might need
  28548. * in order to make a correct use of the texture.
  28549. */
  28550. export class BaseTexture implements IAnimatable {
  28551. /**
  28552. * Default anisotropic filtering level for the application.
  28553. * It is set to 4 as a good tradeoff between perf and quality.
  28554. */
  28555. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28556. /**
  28557. * Gets or sets the unique id of the texture
  28558. */
  28559. uniqueId: number;
  28560. /**
  28561. * Define the name of the texture.
  28562. */
  28563. name: string;
  28564. /**
  28565. * Gets or sets an object used to store user defined information.
  28566. */
  28567. metadata: any;
  28568. /**
  28569. * For internal use only. Please do not use.
  28570. */
  28571. reservedDataStore: any;
  28572. private _hasAlpha;
  28573. /**
  28574. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28575. */
  28576. hasAlpha: boolean;
  28577. /**
  28578. * Defines if the alpha value should be determined via the rgb values.
  28579. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28580. */
  28581. getAlphaFromRGB: boolean;
  28582. /**
  28583. * Intensity or strength of the texture.
  28584. * It is commonly used by materials to fine tune the intensity of the texture
  28585. */
  28586. level: number;
  28587. /**
  28588. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28589. * This is part of the texture as textures usually maps to one uv set.
  28590. */
  28591. coordinatesIndex: number;
  28592. private _coordinatesMode;
  28593. /**
  28594. * How a texture is mapped.
  28595. *
  28596. * | Value | Type | Description |
  28597. * | ----- | ----------------------------------- | ----------- |
  28598. * | 0 | EXPLICIT_MODE | |
  28599. * | 1 | SPHERICAL_MODE | |
  28600. * | 2 | PLANAR_MODE | |
  28601. * | 3 | CUBIC_MODE | |
  28602. * | 4 | PROJECTION_MODE | |
  28603. * | 5 | SKYBOX_MODE | |
  28604. * | 6 | INVCUBIC_MODE | |
  28605. * | 7 | EQUIRECTANGULAR_MODE | |
  28606. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28607. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28608. */
  28609. coordinatesMode: number;
  28610. /**
  28611. * | Value | Type | Description |
  28612. * | ----- | ------------------ | ----------- |
  28613. * | 0 | CLAMP_ADDRESSMODE | |
  28614. * | 1 | WRAP_ADDRESSMODE | |
  28615. * | 2 | MIRROR_ADDRESSMODE | |
  28616. */
  28617. wrapU: number;
  28618. /**
  28619. * | Value | Type | Description |
  28620. * | ----- | ------------------ | ----------- |
  28621. * | 0 | CLAMP_ADDRESSMODE | |
  28622. * | 1 | WRAP_ADDRESSMODE | |
  28623. * | 2 | MIRROR_ADDRESSMODE | |
  28624. */
  28625. wrapV: number;
  28626. /**
  28627. * | Value | Type | Description |
  28628. * | ----- | ------------------ | ----------- |
  28629. * | 0 | CLAMP_ADDRESSMODE | |
  28630. * | 1 | WRAP_ADDRESSMODE | |
  28631. * | 2 | MIRROR_ADDRESSMODE | |
  28632. */
  28633. wrapR: number;
  28634. /**
  28635. * With compliant hardware and browser (supporting anisotropic filtering)
  28636. * this defines the level of anisotropic filtering in the texture.
  28637. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28638. */
  28639. anisotropicFilteringLevel: number;
  28640. /**
  28641. * Define if the texture is a cube texture or if false a 2d texture.
  28642. */
  28643. isCube: boolean;
  28644. /**
  28645. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28646. */
  28647. is3D: boolean;
  28648. /**
  28649. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28650. * HDR texture are usually stored in linear space.
  28651. * This only impacts the PBR and Background materials
  28652. */
  28653. gammaSpace: boolean;
  28654. /**
  28655. * Gets or sets whether or not the texture contains RGBD data.
  28656. */
  28657. isRGBD: boolean;
  28658. /**
  28659. * Is Z inverted in the texture (useful in a cube texture).
  28660. */
  28661. invertZ: boolean;
  28662. /**
  28663. * Are mip maps generated for this texture or not.
  28664. */
  28665. readonly noMipmap: boolean;
  28666. /**
  28667. * @hidden
  28668. */
  28669. lodLevelInAlpha: boolean;
  28670. /**
  28671. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28672. */
  28673. lodGenerationOffset: number;
  28674. /**
  28675. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28676. */
  28677. lodGenerationScale: number;
  28678. /**
  28679. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28680. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28681. * average roughness values.
  28682. */
  28683. linearSpecularLOD: boolean;
  28684. /**
  28685. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28686. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28687. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28688. */
  28689. irradianceTexture: Nullable<BaseTexture>;
  28690. /**
  28691. * Define if the texture is a render target.
  28692. */
  28693. isRenderTarget: boolean;
  28694. /**
  28695. * Define the unique id of the texture in the scene.
  28696. */
  28697. readonly uid: string;
  28698. /**
  28699. * Return a string representation of the texture.
  28700. * @returns the texture as a string
  28701. */
  28702. toString(): string;
  28703. /**
  28704. * Get the class name of the texture.
  28705. * @returns "BaseTexture"
  28706. */
  28707. getClassName(): string;
  28708. /**
  28709. * Define the list of animation attached to the texture.
  28710. */
  28711. animations: import("babylonjs/Animations/animation").Animation[];
  28712. /**
  28713. * An event triggered when the texture is disposed.
  28714. */
  28715. onDisposeObservable: Observable<BaseTexture>;
  28716. private _onDisposeObserver;
  28717. /**
  28718. * Callback triggered when the texture has been disposed.
  28719. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28720. */
  28721. onDispose: () => void;
  28722. /**
  28723. * Define the current state of the loading sequence when in delayed load mode.
  28724. */
  28725. delayLoadState: number;
  28726. private _scene;
  28727. /** @hidden */
  28728. _texture: Nullable<InternalTexture>;
  28729. private _uid;
  28730. /**
  28731. * Define if the texture is preventinga material to render or not.
  28732. * If not and the texture is not ready, the engine will use a default black texture instead.
  28733. */
  28734. readonly isBlocking: boolean;
  28735. /**
  28736. * Instantiates a new BaseTexture.
  28737. * Base class of all the textures in babylon.
  28738. * It groups all the common properties the materials, post process, lights... might need
  28739. * in order to make a correct use of the texture.
  28740. * @param scene Define the scene the texture blongs to
  28741. */
  28742. constructor(scene: Nullable<Scene>);
  28743. /**
  28744. * Get the scene the texture belongs to.
  28745. * @returns the scene or null if undefined
  28746. */
  28747. getScene(): Nullable<Scene>;
  28748. /**
  28749. * Get the texture transform matrix used to offset tile the texture for istance.
  28750. * @returns the transformation matrix
  28751. */
  28752. getTextureMatrix(): Matrix;
  28753. /**
  28754. * Get the texture reflection matrix used to rotate/transform the reflection.
  28755. * @returns the reflection matrix
  28756. */
  28757. getReflectionTextureMatrix(): Matrix;
  28758. /**
  28759. * Get the underlying lower level texture from Babylon.
  28760. * @returns the insternal texture
  28761. */
  28762. getInternalTexture(): Nullable<InternalTexture>;
  28763. /**
  28764. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28765. * @returns true if ready or not blocking
  28766. */
  28767. isReadyOrNotBlocking(): boolean;
  28768. /**
  28769. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28770. * @returns true if fully ready
  28771. */
  28772. isReady(): boolean;
  28773. private _cachedSize;
  28774. /**
  28775. * Get the size of the texture.
  28776. * @returns the texture size.
  28777. */
  28778. getSize(): ISize;
  28779. /**
  28780. * Get the base size of the texture.
  28781. * It can be different from the size if the texture has been resized for POT for instance
  28782. * @returns the base size
  28783. */
  28784. getBaseSize(): ISize;
  28785. /**
  28786. * Update the sampling mode of the texture.
  28787. * Default is Trilinear mode.
  28788. *
  28789. * | Value | Type | Description |
  28790. * | ----- | ------------------ | ----------- |
  28791. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28792. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28793. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28794. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28795. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28796. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28797. * | 7 | NEAREST_LINEAR | |
  28798. * | 8 | NEAREST_NEAREST | |
  28799. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28800. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28801. * | 11 | LINEAR_LINEAR | |
  28802. * | 12 | LINEAR_NEAREST | |
  28803. *
  28804. * > _mag_: magnification filter (close to the viewer)
  28805. * > _min_: minification filter (far from the viewer)
  28806. * > _mip_: filter used between mip map levels
  28807. *@param samplingMode Define the new sampling mode of the texture
  28808. */
  28809. updateSamplingMode(samplingMode: number): void;
  28810. /**
  28811. * Scales the texture if is `canRescale()`
  28812. * @param ratio the resize factor we want to use to rescale
  28813. */
  28814. scale(ratio: number): void;
  28815. /**
  28816. * Get if the texture can rescale.
  28817. */
  28818. readonly canRescale: boolean;
  28819. /** @hidden */
  28820. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28821. /** @hidden */
  28822. _rebuild(): void;
  28823. /**
  28824. * Triggers the load sequence in delayed load mode.
  28825. */
  28826. delayLoad(): void;
  28827. /**
  28828. * Clones the texture.
  28829. * @returns the cloned texture
  28830. */
  28831. clone(): Nullable<BaseTexture>;
  28832. /**
  28833. * Get the texture underlying type (INT, FLOAT...)
  28834. */
  28835. readonly textureType: number;
  28836. /**
  28837. * Get the texture underlying format (RGB, RGBA...)
  28838. */
  28839. readonly textureFormat: number;
  28840. /**
  28841. * Indicates that textures need to be re-calculated for all materials
  28842. */
  28843. protected _markAllSubMeshesAsTexturesDirty(): void;
  28844. /**
  28845. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28846. * This will returns an RGBA array buffer containing either in values (0-255) or
  28847. * float values (0-1) depending of the underlying buffer type.
  28848. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28849. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28850. * @param buffer defines a user defined buffer to fill with data (can be null)
  28851. * @returns The Array buffer containing the pixels data.
  28852. */
  28853. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28854. /**
  28855. * Release and destroy the underlying lower level texture aka internalTexture.
  28856. */
  28857. releaseInternalTexture(): void;
  28858. /** @hidden */
  28859. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28860. /** @hidden */
  28861. readonly _lodTextureMid: Nullable<BaseTexture>;
  28862. /** @hidden */
  28863. readonly _lodTextureLow: Nullable<BaseTexture>;
  28864. /**
  28865. * Dispose the texture and release its associated resources.
  28866. */
  28867. dispose(): void;
  28868. /**
  28869. * Serialize the texture into a JSON representation that can be parsed later on.
  28870. * @returns the JSON representation of the texture
  28871. */
  28872. serialize(): any;
  28873. /**
  28874. * Helper function to be called back once a list of texture contains only ready textures.
  28875. * @param textures Define the list of textures to wait for
  28876. * @param callback Define the callback triggered once the entire list will be ready
  28877. */
  28878. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28879. }
  28880. }
  28881. declare module "babylonjs/Materials/effect" {
  28882. import { Observable } from "babylonjs/Misc/observable";
  28883. import { Nullable } from "babylonjs/types";
  28884. import { IDisposable } from "babylonjs/scene";
  28885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28886. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28887. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28888. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28889. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28890. import { Engine } from "babylonjs/Engines/engine";
  28891. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28893. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28895. /**
  28896. * Options to be used when creating an effect.
  28897. */
  28898. export interface IEffectCreationOptions {
  28899. /**
  28900. * Atrributes that will be used in the shader.
  28901. */
  28902. attributes: string[];
  28903. /**
  28904. * Uniform varible names that will be set in the shader.
  28905. */
  28906. uniformsNames: string[];
  28907. /**
  28908. * Uniform buffer varible names that will be set in the shader.
  28909. */
  28910. uniformBuffersNames: string[];
  28911. /**
  28912. * Sampler texture variable names that will be set in the shader.
  28913. */
  28914. samplers: string[];
  28915. /**
  28916. * Define statements that will be set in the shader.
  28917. */
  28918. defines: any;
  28919. /**
  28920. * Possible fallbacks for this effect to improve performance when needed.
  28921. */
  28922. fallbacks: Nullable<IEffectFallbacks>;
  28923. /**
  28924. * Callback that will be called when the shader is compiled.
  28925. */
  28926. onCompiled: Nullable<(effect: Effect) => void>;
  28927. /**
  28928. * Callback that will be called if an error occurs during shader compilation.
  28929. */
  28930. onError: Nullable<(effect: Effect, errors: string) => void>;
  28931. /**
  28932. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28933. */
  28934. indexParameters?: any;
  28935. /**
  28936. * Max number of lights that can be used in the shader.
  28937. */
  28938. maxSimultaneousLights?: number;
  28939. /**
  28940. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28941. */
  28942. transformFeedbackVaryings?: Nullable<string[]>;
  28943. }
  28944. /**
  28945. * Effect containing vertex and fragment shader that can be executed on an object.
  28946. */
  28947. export class Effect implements IDisposable {
  28948. /**
  28949. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28950. */
  28951. static ShadersRepository: string;
  28952. /**
  28953. * Name of the effect.
  28954. */
  28955. name: any;
  28956. /**
  28957. * String container all the define statements that should be set on the shader.
  28958. */
  28959. defines: string;
  28960. /**
  28961. * Callback that will be called when the shader is compiled.
  28962. */
  28963. onCompiled: Nullable<(effect: Effect) => void>;
  28964. /**
  28965. * Callback that will be called if an error occurs during shader compilation.
  28966. */
  28967. onError: Nullable<(effect: Effect, errors: string) => void>;
  28968. /**
  28969. * Callback that will be called when effect is bound.
  28970. */
  28971. onBind: Nullable<(effect: Effect) => void>;
  28972. /**
  28973. * Unique ID of the effect.
  28974. */
  28975. uniqueId: number;
  28976. /**
  28977. * Observable that will be called when the shader is compiled.
  28978. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28979. */
  28980. onCompileObservable: Observable<Effect>;
  28981. /**
  28982. * Observable that will be called if an error occurs during shader compilation.
  28983. */
  28984. onErrorObservable: Observable<Effect>;
  28985. /** @hidden */
  28986. _onBindObservable: Nullable<Observable<Effect>>;
  28987. /**
  28988. * Observable that will be called when effect is bound.
  28989. */
  28990. readonly onBindObservable: Observable<Effect>;
  28991. /** @hidden */
  28992. _bonesComputationForcedToCPU: boolean;
  28993. private static _uniqueIdSeed;
  28994. private _engine;
  28995. private _uniformBuffersNames;
  28996. private _uniformsNames;
  28997. private _samplerList;
  28998. private _samplers;
  28999. private _isReady;
  29000. private _compilationError;
  29001. private _allFallbacksProcessed;
  29002. private _attributesNames;
  29003. private _attributes;
  29004. private _uniforms;
  29005. /**
  29006. * Key for the effect.
  29007. * @hidden
  29008. */
  29009. _key: string;
  29010. private _indexParameters;
  29011. private _fallbacks;
  29012. private _vertexSourceCode;
  29013. private _fragmentSourceCode;
  29014. private _vertexSourceCodeOverride;
  29015. private _fragmentSourceCodeOverride;
  29016. private _transformFeedbackVaryings;
  29017. /**
  29018. * Compiled shader to webGL program.
  29019. * @hidden
  29020. */
  29021. _pipelineContext: Nullable<IPipelineContext>;
  29022. private _valueCache;
  29023. private static _baseCache;
  29024. /**
  29025. * Instantiates an effect.
  29026. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29027. * @param baseName Name of the effect.
  29028. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29029. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29030. * @param samplers List of sampler variables that will be passed to the shader.
  29031. * @param engine Engine to be used to render the effect
  29032. * @param defines Define statements to be added to the shader.
  29033. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29034. * @param onCompiled Callback that will be called when the shader is compiled.
  29035. * @param onError Callback that will be called if an error occurs during shader compilation.
  29036. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29037. */
  29038. 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);
  29039. private _useFinalCode;
  29040. /**
  29041. * Unique key for this effect
  29042. */
  29043. readonly key: string;
  29044. /**
  29045. * If the effect has been compiled and prepared.
  29046. * @returns if the effect is compiled and prepared.
  29047. */
  29048. isReady(): boolean;
  29049. private _isReadyInternal;
  29050. /**
  29051. * The engine the effect was initialized with.
  29052. * @returns the engine.
  29053. */
  29054. getEngine(): Engine;
  29055. /**
  29056. * The pipeline context for this effect
  29057. * @returns the associated pipeline context
  29058. */
  29059. getPipelineContext(): Nullable<IPipelineContext>;
  29060. /**
  29061. * The set of names of attribute variables for the shader.
  29062. * @returns An array of attribute names.
  29063. */
  29064. getAttributesNames(): string[];
  29065. /**
  29066. * Returns the attribute at the given index.
  29067. * @param index The index of the attribute.
  29068. * @returns The location of the attribute.
  29069. */
  29070. getAttributeLocation(index: number): number;
  29071. /**
  29072. * Returns the attribute based on the name of the variable.
  29073. * @param name of the attribute to look up.
  29074. * @returns the attribute location.
  29075. */
  29076. getAttributeLocationByName(name: string): number;
  29077. /**
  29078. * The number of attributes.
  29079. * @returns the numnber of attributes.
  29080. */
  29081. getAttributesCount(): number;
  29082. /**
  29083. * Gets the index of a uniform variable.
  29084. * @param uniformName of the uniform to look up.
  29085. * @returns the index.
  29086. */
  29087. getUniformIndex(uniformName: string): number;
  29088. /**
  29089. * Returns the attribute based on the name of the variable.
  29090. * @param uniformName of the uniform to look up.
  29091. * @returns the location of the uniform.
  29092. */
  29093. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29094. /**
  29095. * Returns an array of sampler variable names
  29096. * @returns The array of sampler variable neames.
  29097. */
  29098. getSamplers(): string[];
  29099. /**
  29100. * The error from the last compilation.
  29101. * @returns the error string.
  29102. */
  29103. getCompilationError(): string;
  29104. /**
  29105. * Gets a boolean indicating that all fallbacks were used during compilation
  29106. * @returns true if all fallbacks were used
  29107. */
  29108. allFallbacksProcessed(): boolean;
  29109. /**
  29110. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29111. * @param func The callback to be used.
  29112. */
  29113. executeWhenCompiled(func: (effect: Effect) => void): void;
  29114. private _checkIsReady;
  29115. private _loadShader;
  29116. /**
  29117. * Recompiles the webGL program
  29118. * @param vertexSourceCode The source code for the vertex shader.
  29119. * @param fragmentSourceCode The source code for the fragment shader.
  29120. * @param onCompiled Callback called when completed.
  29121. * @param onError Callback called on error.
  29122. * @hidden
  29123. */
  29124. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29125. /**
  29126. * Prepares the effect
  29127. * @hidden
  29128. */
  29129. _prepareEffect(): void;
  29130. private _processCompilationErrors;
  29131. /**
  29132. * Checks if the effect is supported. (Must be called after compilation)
  29133. */
  29134. readonly isSupported: boolean;
  29135. /**
  29136. * Binds a texture to the engine to be used as output of the shader.
  29137. * @param channel Name of the output variable.
  29138. * @param texture Texture to bind.
  29139. * @hidden
  29140. */
  29141. _bindTexture(channel: string, texture: InternalTexture): void;
  29142. /**
  29143. * Sets a texture on the engine to be used in the shader.
  29144. * @param channel Name of the sampler variable.
  29145. * @param texture Texture to set.
  29146. */
  29147. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29148. /**
  29149. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29150. * @param channel Name of the sampler variable.
  29151. * @param texture Texture to set.
  29152. */
  29153. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29154. /**
  29155. * Sets an array of textures on the engine to be used in the shader.
  29156. * @param channel Name of the variable.
  29157. * @param textures Textures to set.
  29158. */
  29159. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29160. /**
  29161. * 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)
  29162. * @param channel Name of the sampler variable.
  29163. * @param postProcess Post process to get the input texture from.
  29164. */
  29165. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29166. /**
  29167. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29168. * 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)
  29169. * @param channel Name of the sampler variable.
  29170. * @param postProcess Post process to get the output texture from.
  29171. */
  29172. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29173. /** @hidden */
  29174. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29175. /** @hidden */
  29176. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29177. /** @hidden */
  29178. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29179. /** @hidden */
  29180. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29181. /**
  29182. * Binds a buffer to a uniform.
  29183. * @param buffer Buffer to bind.
  29184. * @param name Name of the uniform variable to bind to.
  29185. */
  29186. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29187. /**
  29188. * Binds block to a uniform.
  29189. * @param blockName Name of the block to bind.
  29190. * @param index Index to bind.
  29191. */
  29192. bindUniformBlock(blockName: string, index: number): void;
  29193. /**
  29194. * Sets an interger value on a uniform variable.
  29195. * @param uniformName Name of the variable.
  29196. * @param value Value to be set.
  29197. * @returns this effect.
  29198. */
  29199. setInt(uniformName: string, value: number): Effect;
  29200. /**
  29201. * Sets an int array on a uniform variable.
  29202. * @param uniformName Name of the variable.
  29203. * @param array array to be set.
  29204. * @returns this effect.
  29205. */
  29206. setIntArray(uniformName: string, array: Int32Array): Effect;
  29207. /**
  29208. * 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)
  29209. * @param uniformName Name of the variable.
  29210. * @param array array to be set.
  29211. * @returns this effect.
  29212. */
  29213. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29214. /**
  29215. * 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)
  29216. * @param uniformName Name of the variable.
  29217. * @param array array to be set.
  29218. * @returns this effect.
  29219. */
  29220. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29221. /**
  29222. * 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)
  29223. * @param uniformName Name of the variable.
  29224. * @param array array to be set.
  29225. * @returns this effect.
  29226. */
  29227. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29228. /**
  29229. * Sets an float array on a uniform variable.
  29230. * @param uniformName Name of the variable.
  29231. * @param array array to be set.
  29232. * @returns this effect.
  29233. */
  29234. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29235. /**
  29236. * 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)
  29237. * @param uniformName Name of the variable.
  29238. * @param array array to be set.
  29239. * @returns this effect.
  29240. */
  29241. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29242. /**
  29243. * 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)
  29244. * @param uniformName Name of the variable.
  29245. * @param array array to be set.
  29246. * @returns this effect.
  29247. */
  29248. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29249. /**
  29250. * 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)
  29251. * @param uniformName Name of the variable.
  29252. * @param array array to be set.
  29253. * @returns this effect.
  29254. */
  29255. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29256. /**
  29257. * Sets an array on a uniform variable.
  29258. * @param uniformName Name of the variable.
  29259. * @param array array to be set.
  29260. * @returns this effect.
  29261. */
  29262. setArray(uniformName: string, array: number[]): Effect;
  29263. /**
  29264. * 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)
  29265. * @param uniformName Name of the variable.
  29266. * @param array array to be set.
  29267. * @returns this effect.
  29268. */
  29269. setArray2(uniformName: string, array: number[]): Effect;
  29270. /**
  29271. * 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)
  29272. * @param uniformName Name of the variable.
  29273. * @param array array to be set.
  29274. * @returns this effect.
  29275. */
  29276. setArray3(uniformName: string, array: number[]): Effect;
  29277. /**
  29278. * 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)
  29279. * @param uniformName Name of the variable.
  29280. * @param array array to be set.
  29281. * @returns this effect.
  29282. */
  29283. setArray4(uniformName: string, array: number[]): Effect;
  29284. /**
  29285. * Sets matrices on a uniform variable.
  29286. * @param uniformName Name of the variable.
  29287. * @param matrices matrices to be set.
  29288. * @returns this effect.
  29289. */
  29290. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29291. /**
  29292. * Sets matrix on a uniform variable.
  29293. * @param uniformName Name of the variable.
  29294. * @param matrix matrix to be set.
  29295. * @returns this effect.
  29296. */
  29297. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29298. /**
  29299. * 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)
  29300. * @param uniformName Name of the variable.
  29301. * @param matrix matrix to be set.
  29302. * @returns this effect.
  29303. */
  29304. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29305. /**
  29306. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29307. * @param uniformName Name of the variable.
  29308. * @param matrix matrix to be set.
  29309. * @returns this effect.
  29310. */
  29311. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29312. /**
  29313. * Sets a float on a uniform variable.
  29314. * @param uniformName Name of the variable.
  29315. * @param value value to be set.
  29316. * @returns this effect.
  29317. */
  29318. setFloat(uniformName: string, value: number): Effect;
  29319. /**
  29320. * Sets a boolean on a uniform variable.
  29321. * @param uniformName Name of the variable.
  29322. * @param bool value to be set.
  29323. * @returns this effect.
  29324. */
  29325. setBool(uniformName: string, bool: boolean): Effect;
  29326. /**
  29327. * Sets a Vector2 on a uniform variable.
  29328. * @param uniformName Name of the variable.
  29329. * @param vector2 vector2 to be set.
  29330. * @returns this effect.
  29331. */
  29332. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29333. /**
  29334. * Sets a float2 on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param x First float in float2.
  29337. * @param y Second float in float2.
  29338. * @returns this effect.
  29339. */
  29340. setFloat2(uniformName: string, x: number, y: number): Effect;
  29341. /**
  29342. * Sets a Vector3 on a uniform variable.
  29343. * @param uniformName Name of the variable.
  29344. * @param vector3 Value to be set.
  29345. * @returns this effect.
  29346. */
  29347. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29348. /**
  29349. * Sets a float3 on a uniform variable.
  29350. * @param uniformName Name of the variable.
  29351. * @param x First float in float3.
  29352. * @param y Second float in float3.
  29353. * @param z Third float in float3.
  29354. * @returns this effect.
  29355. */
  29356. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29357. /**
  29358. * Sets a Vector4 on a uniform variable.
  29359. * @param uniformName Name of the variable.
  29360. * @param vector4 Value to be set.
  29361. * @returns this effect.
  29362. */
  29363. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29364. /**
  29365. * Sets a float4 on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param x First float in float4.
  29368. * @param y Second float in float4.
  29369. * @param z Third float in float4.
  29370. * @param w Fourth float in float4.
  29371. * @returns this effect.
  29372. */
  29373. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29374. /**
  29375. * Sets a Color3 on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param color3 Value to be set.
  29378. * @returns this effect.
  29379. */
  29380. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29381. /**
  29382. * Sets a Color4 on a uniform variable.
  29383. * @param uniformName Name of the variable.
  29384. * @param color3 Value to be set.
  29385. * @param alpha Alpha value to be set.
  29386. * @returns this effect.
  29387. */
  29388. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29389. /**
  29390. * Sets a Color4 on a uniform variable
  29391. * @param uniformName defines the name of the variable
  29392. * @param color4 defines the value to be set
  29393. * @returns this effect.
  29394. */
  29395. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29396. /** Release all associated resources */
  29397. dispose(): void;
  29398. /**
  29399. * This function will add a new shader to the shader store
  29400. * @param name the name of the shader
  29401. * @param pixelShader optional pixel shader content
  29402. * @param vertexShader optional vertex shader content
  29403. */
  29404. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29405. /**
  29406. * Store of each shader (The can be looked up using effect.key)
  29407. */
  29408. static ShadersStore: {
  29409. [key: string]: string;
  29410. };
  29411. /**
  29412. * Store of each included file for a shader (The can be looked up using effect.key)
  29413. */
  29414. static IncludesShadersStore: {
  29415. [key: string]: string;
  29416. };
  29417. /**
  29418. * Resets the cache of effects.
  29419. */
  29420. static ResetCache(): void;
  29421. }
  29422. }
  29423. declare module "babylonjs/Engines/engineCapabilities" {
  29424. import { Nullable } from "babylonjs/types";
  29425. /**
  29426. * Class used to describe the capabilities of the engine relatively to the current browser
  29427. */
  29428. export class EngineCapabilities {
  29429. /** Maximum textures units per fragment shader */
  29430. maxTexturesImageUnits: number;
  29431. /** Maximum texture units per vertex shader */
  29432. maxVertexTextureImageUnits: number;
  29433. /** Maximum textures units in the entire pipeline */
  29434. maxCombinedTexturesImageUnits: number;
  29435. /** Maximum texture size */
  29436. maxTextureSize: number;
  29437. /** Maximum cube texture size */
  29438. maxCubemapTextureSize: number;
  29439. /** Maximum render texture size */
  29440. maxRenderTextureSize: number;
  29441. /** Maximum number of vertex attributes */
  29442. maxVertexAttribs: number;
  29443. /** Maximum number of varyings */
  29444. maxVaryingVectors: number;
  29445. /** Maximum number of uniforms per vertex shader */
  29446. maxVertexUniformVectors: number;
  29447. /** Maximum number of uniforms per fragment shader */
  29448. maxFragmentUniformVectors: number;
  29449. /** Defines if standard derivates (dx/dy) are supported */
  29450. standardDerivatives: boolean;
  29451. /** Defines if s3tc texture compression is supported */
  29452. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29453. /** Defines if pvrtc texture compression is supported */
  29454. pvrtc: any;
  29455. /** Defines if etc1 texture compression is supported */
  29456. etc1: any;
  29457. /** Defines if etc2 texture compression is supported */
  29458. etc2: any;
  29459. /** Defines if astc texture compression is supported */
  29460. astc: any;
  29461. /** Defines if float textures are supported */
  29462. textureFloat: boolean;
  29463. /** Defines if vertex array objects are supported */
  29464. vertexArrayObject: boolean;
  29465. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29466. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29467. /** Gets the maximum level of anisotropy supported */
  29468. maxAnisotropy: number;
  29469. /** Defines if instancing is supported */
  29470. instancedArrays: boolean;
  29471. /** Defines if 32 bits indices are supported */
  29472. uintIndices: boolean;
  29473. /** Defines if high precision shaders are supported */
  29474. highPrecisionShaderSupported: boolean;
  29475. /** Defines if depth reading in the fragment shader is supported */
  29476. fragmentDepthSupported: boolean;
  29477. /** Defines if float texture linear filtering is supported*/
  29478. textureFloatLinearFiltering: boolean;
  29479. /** Defines if rendering to float textures is supported */
  29480. textureFloatRender: boolean;
  29481. /** Defines if half float textures are supported*/
  29482. textureHalfFloat: boolean;
  29483. /** Defines if half float texture linear filtering is supported*/
  29484. textureHalfFloatLinearFiltering: boolean;
  29485. /** Defines if rendering to half float textures is supported */
  29486. textureHalfFloatRender: boolean;
  29487. /** Defines if textureLOD shader command is supported */
  29488. textureLOD: boolean;
  29489. /** Defines if draw buffers extension is supported */
  29490. drawBuffersExtension: boolean;
  29491. /** Defines if depth textures are supported */
  29492. depthTextureExtension: boolean;
  29493. /** Defines if float color buffer are supported */
  29494. colorBufferFloat: boolean;
  29495. /** Gets disjoint timer query extension (null if not supported) */
  29496. timerQuery: EXT_disjoint_timer_query;
  29497. /** Defines if timestamp can be used with timer query */
  29498. canUseTimestampForTimerQuery: boolean;
  29499. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29500. multiview: any;
  29501. /** Function used to let the system compiles shaders in background */
  29502. parallelShaderCompile: {
  29503. COMPLETION_STATUS_KHR: number;
  29504. };
  29505. /** Max number of texture samples for MSAA */
  29506. maxMSAASamples: number;
  29507. /** Defines if the blend min max extension is supported */
  29508. blendMinMax: boolean;
  29509. }
  29510. }
  29511. declare module "babylonjs/States/depthCullingState" {
  29512. import { Nullable } from "babylonjs/types";
  29513. /**
  29514. * @hidden
  29515. **/
  29516. export class DepthCullingState {
  29517. private _isDepthTestDirty;
  29518. private _isDepthMaskDirty;
  29519. private _isDepthFuncDirty;
  29520. private _isCullFaceDirty;
  29521. private _isCullDirty;
  29522. private _isZOffsetDirty;
  29523. private _isFrontFaceDirty;
  29524. private _depthTest;
  29525. private _depthMask;
  29526. private _depthFunc;
  29527. private _cull;
  29528. private _cullFace;
  29529. private _zOffset;
  29530. private _frontFace;
  29531. /**
  29532. * Initializes the state.
  29533. */
  29534. constructor();
  29535. readonly isDirty: boolean;
  29536. zOffset: number;
  29537. cullFace: Nullable<number>;
  29538. cull: Nullable<boolean>;
  29539. depthFunc: Nullable<number>;
  29540. depthMask: boolean;
  29541. depthTest: boolean;
  29542. frontFace: Nullable<number>;
  29543. reset(): void;
  29544. apply(gl: WebGLRenderingContext): void;
  29545. }
  29546. }
  29547. declare module "babylonjs/States/stencilState" {
  29548. /**
  29549. * @hidden
  29550. **/
  29551. export class StencilState {
  29552. /** 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 */
  29553. static readonly ALWAYS: number;
  29554. /** Passed to stencilOperation to specify that stencil value must be kept */
  29555. static readonly KEEP: number;
  29556. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29557. static readonly REPLACE: number;
  29558. private _isStencilTestDirty;
  29559. private _isStencilMaskDirty;
  29560. private _isStencilFuncDirty;
  29561. private _isStencilOpDirty;
  29562. private _stencilTest;
  29563. private _stencilMask;
  29564. private _stencilFunc;
  29565. private _stencilFuncRef;
  29566. private _stencilFuncMask;
  29567. private _stencilOpStencilFail;
  29568. private _stencilOpDepthFail;
  29569. private _stencilOpStencilDepthPass;
  29570. readonly isDirty: boolean;
  29571. stencilFunc: number;
  29572. stencilFuncRef: number;
  29573. stencilFuncMask: number;
  29574. stencilOpStencilFail: number;
  29575. stencilOpDepthFail: number;
  29576. stencilOpStencilDepthPass: number;
  29577. stencilMask: number;
  29578. stencilTest: boolean;
  29579. constructor();
  29580. reset(): void;
  29581. apply(gl: WebGLRenderingContext): void;
  29582. }
  29583. }
  29584. declare module "babylonjs/States/alphaCullingState" {
  29585. /**
  29586. * @hidden
  29587. **/
  29588. export class AlphaState {
  29589. private _isAlphaBlendDirty;
  29590. private _isBlendFunctionParametersDirty;
  29591. private _isBlendEquationParametersDirty;
  29592. private _isBlendConstantsDirty;
  29593. private _alphaBlend;
  29594. private _blendFunctionParameters;
  29595. private _blendEquationParameters;
  29596. private _blendConstants;
  29597. /**
  29598. * Initializes the state.
  29599. */
  29600. constructor();
  29601. readonly isDirty: boolean;
  29602. alphaBlend: boolean;
  29603. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29604. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29605. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29606. reset(): void;
  29607. apply(gl: WebGLRenderingContext): void;
  29608. }
  29609. }
  29610. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29611. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29612. /** @hidden */
  29613. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29614. attributeProcessor(attribute: string): string;
  29615. varyingProcessor(varying: string, isFragment: boolean): string;
  29616. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29617. }
  29618. }
  29619. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29620. /**
  29621. * Interface for attribute information associated with buffer instanciation
  29622. */
  29623. export class InstancingAttributeInfo {
  29624. /**
  29625. * Index/offset of the attribute in the vertex shader
  29626. */
  29627. index: number;
  29628. /**
  29629. * size of the attribute, 1, 2, 3 or 4
  29630. */
  29631. attributeSize: number;
  29632. /**
  29633. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29634. * default is FLOAT
  29635. */
  29636. attribyteType: number;
  29637. /**
  29638. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29639. */
  29640. normalized: boolean;
  29641. /**
  29642. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29643. */
  29644. offset: number;
  29645. /**
  29646. * Name of the GLSL attribute, for debugging purpose only
  29647. */
  29648. attributeName: string;
  29649. }
  29650. }
  29651. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29652. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29653. import { Nullable } from "babylonjs/types";
  29654. module "babylonjs/Engines/thinEngine" {
  29655. interface ThinEngine {
  29656. /**
  29657. * Update a video texture
  29658. * @param texture defines the texture to update
  29659. * @param video defines the video element to use
  29660. * @param invertY defines if data must be stored with Y axis inverted
  29661. */
  29662. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29663. }
  29664. }
  29665. }
  29666. declare module "babylonjs/Materials/Textures/videoTexture" {
  29667. import { Observable } from "babylonjs/Misc/observable";
  29668. import { Nullable } from "babylonjs/types";
  29669. import { Scene } from "babylonjs/scene";
  29670. import { Texture } from "babylonjs/Materials/Textures/texture";
  29671. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29672. /**
  29673. * Settings for finer control over video usage
  29674. */
  29675. export interface VideoTextureSettings {
  29676. /**
  29677. * Applies `autoplay` to video, if specified
  29678. */
  29679. autoPlay?: boolean;
  29680. /**
  29681. * Applies `loop` to video, if specified
  29682. */
  29683. loop?: boolean;
  29684. /**
  29685. * Automatically updates internal texture from video at every frame in the render loop
  29686. */
  29687. autoUpdateTexture: boolean;
  29688. /**
  29689. * Image src displayed during the video loading or until the user interacts with the video.
  29690. */
  29691. poster?: string;
  29692. }
  29693. /**
  29694. * If you want to display a video in your scene, this is the special texture for that.
  29695. * This special texture works similar to other textures, with the exception of a few parameters.
  29696. * @see https://doc.babylonjs.com/how_to/video_texture
  29697. */
  29698. export class VideoTexture extends Texture {
  29699. /**
  29700. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29701. */
  29702. readonly autoUpdateTexture: boolean;
  29703. /**
  29704. * The video instance used by the texture internally
  29705. */
  29706. readonly video: HTMLVideoElement;
  29707. private _onUserActionRequestedObservable;
  29708. /**
  29709. * Event triggerd when a dom action is required by the user to play the video.
  29710. * This happens due to recent changes in browser policies preventing video to auto start.
  29711. */
  29712. readonly onUserActionRequestedObservable: Observable<Texture>;
  29713. private _generateMipMaps;
  29714. private _engine;
  29715. private _stillImageCaptured;
  29716. private _displayingPosterTexture;
  29717. private _settings;
  29718. private _createInternalTextureOnEvent;
  29719. private _frameId;
  29720. /**
  29721. * Creates a video texture.
  29722. * If you want to display a video in your scene, this is the special texture for that.
  29723. * This special texture works similar to other textures, with the exception of a few parameters.
  29724. * @see https://doc.babylonjs.com/how_to/video_texture
  29725. * @param name optional name, will detect from video source, if not defined
  29726. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29727. * @param scene is obviously the current scene.
  29728. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29729. * @param invertY is false by default but can be used to invert video on Y axis
  29730. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29731. * @param settings allows finer control over video usage
  29732. */
  29733. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29734. private _getName;
  29735. private _getVideo;
  29736. private _createInternalTexture;
  29737. private reset;
  29738. /**
  29739. * @hidden Internal method to initiate `update`.
  29740. */
  29741. _rebuild(): void;
  29742. /**
  29743. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29744. */
  29745. update(): void;
  29746. /**
  29747. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29748. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29749. */
  29750. updateTexture(isVisible: boolean): void;
  29751. protected _updateInternalTexture: () => void;
  29752. /**
  29753. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29754. * @param url New url.
  29755. */
  29756. updateURL(url: string): void;
  29757. /**
  29758. * Dispose the texture and release its associated resources.
  29759. */
  29760. dispose(): void;
  29761. /**
  29762. * Creates a video texture straight from a stream.
  29763. * @param scene Define the scene the texture should be created in
  29764. * @param stream Define the stream the texture should be created from
  29765. * @returns The created video texture as a promise
  29766. */
  29767. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29768. /**
  29769. * Creates a video texture straight from your WebCam video feed.
  29770. * @param scene Define the scene the texture should be created in
  29771. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29772. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29773. * @returns The created video texture as a promise
  29774. */
  29775. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29776. minWidth: number;
  29777. maxWidth: number;
  29778. minHeight: number;
  29779. maxHeight: number;
  29780. deviceId: string;
  29781. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29782. /**
  29783. * Creates a video texture straight from your WebCam video feed.
  29784. * @param scene Define the scene the texture should be created in
  29785. * @param onReady Define a callback to triggered once the texture will be ready
  29786. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29787. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29788. */
  29789. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29790. minWidth: number;
  29791. maxWidth: number;
  29792. minHeight: number;
  29793. maxHeight: number;
  29794. deviceId: string;
  29795. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29796. }
  29797. }
  29798. declare module "babylonjs/Engines/thinEngine" {
  29799. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29800. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29801. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29802. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29803. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29804. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29805. import { Observable } from "babylonjs/Misc/observable";
  29806. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29807. import { StencilState } from "babylonjs/States/stencilState";
  29808. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29810. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29811. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29812. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29813. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29814. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29815. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29816. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29817. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29819. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29820. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29821. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29822. /**
  29823. * Defines the interface used by objects working like Scene
  29824. * @hidden
  29825. */
  29826. interface ISceneLike {
  29827. _addPendingData(data: any): void;
  29828. _removePendingData(data: any): void;
  29829. offlineProvider: IOfflineProvider;
  29830. }
  29831. /** Interface defining initialization parameters for Engine class */
  29832. export interface EngineOptions extends WebGLContextAttributes {
  29833. /**
  29834. * Defines if the engine should no exceed a specified device ratio
  29835. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29836. */
  29837. limitDeviceRatio?: number;
  29838. /**
  29839. * Defines if webvr should be enabled automatically
  29840. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29841. */
  29842. autoEnableWebVR?: boolean;
  29843. /**
  29844. * Defines if webgl2 should be turned off even if supported
  29845. * @see http://doc.babylonjs.com/features/webgl2
  29846. */
  29847. disableWebGL2Support?: boolean;
  29848. /**
  29849. * Defines if webaudio should be initialized as well
  29850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29851. */
  29852. audioEngine?: boolean;
  29853. /**
  29854. * Defines if animations should run using a deterministic lock step
  29855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29856. */
  29857. deterministicLockstep?: boolean;
  29858. /** Defines the maximum steps to use with deterministic lock step mode */
  29859. lockstepMaxSteps?: number;
  29860. /**
  29861. * Defines that engine should ignore context lost events
  29862. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29863. */
  29864. doNotHandleContextLost?: boolean;
  29865. /**
  29866. * Defines that engine should ignore modifying touch action attribute and style
  29867. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29868. */
  29869. doNotHandleTouchAction?: boolean;
  29870. /**
  29871. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29872. */
  29873. useHighPrecisionFloats?: boolean;
  29874. }
  29875. /**
  29876. * The base engine class (root of all engines)
  29877. */
  29878. export class ThinEngine {
  29879. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29880. static ExceptionList: ({
  29881. key: string;
  29882. capture: string;
  29883. captureConstraint: number;
  29884. targets: string[];
  29885. } | {
  29886. key: string;
  29887. capture: null;
  29888. captureConstraint: null;
  29889. targets: string[];
  29890. })[];
  29891. /** @hidden */
  29892. static _TextureLoaders: IInternalTextureLoader[];
  29893. /**
  29894. * Returns the current npm package of the sdk
  29895. */
  29896. static readonly NpmPackage: string;
  29897. /**
  29898. * Returns the current version of the framework
  29899. */
  29900. static readonly Version: string;
  29901. /**
  29902. * Returns a string describing the current engine
  29903. */
  29904. readonly description: string;
  29905. /**
  29906. * Gets or sets the epsilon value used by collision engine
  29907. */
  29908. static CollisionsEpsilon: number;
  29909. /**
  29910. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29911. */
  29912. static ShadersRepository: string;
  29913. /** @hidden */
  29914. _shaderProcessor: IShaderProcessor;
  29915. /**
  29916. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29917. */
  29918. forcePOTTextures: boolean;
  29919. /**
  29920. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29921. */
  29922. isFullscreen: boolean;
  29923. /**
  29924. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29925. */
  29926. cullBackFaces: boolean;
  29927. /**
  29928. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29929. */
  29930. renderEvenInBackground: boolean;
  29931. /**
  29932. * Gets or sets a boolean indicating that cache can be kept between frames
  29933. */
  29934. preventCacheWipeBetweenFrames: boolean;
  29935. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29936. validateShaderPrograms: boolean;
  29937. /**
  29938. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29939. */
  29940. disableUniformBuffers: boolean;
  29941. /** @hidden */
  29942. _uniformBuffers: UniformBuffer[];
  29943. /**
  29944. * Gets a boolean indicating that the engine supports uniform buffers
  29945. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29946. */
  29947. readonly supportsUniformBuffers: boolean;
  29948. /** @hidden */
  29949. _gl: WebGLRenderingContext;
  29950. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29951. protected _windowIsBackground: boolean;
  29952. protected _webGLVersion: number;
  29953. protected _highPrecisionShadersAllowed: boolean;
  29954. /** @hidden */
  29955. readonly _shouldUseHighPrecisionShader: boolean;
  29956. /**
  29957. * Gets a boolean indicating that only power of 2 textures are supported
  29958. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29959. */
  29960. readonly needPOTTextures: boolean;
  29961. /** @hidden */
  29962. _badOS: boolean;
  29963. /** @hidden */
  29964. _badDesktopOS: boolean;
  29965. private _hardwareScalingLevel;
  29966. /** @hidden */
  29967. _caps: EngineCapabilities;
  29968. private _isStencilEnable;
  29969. protected _colorWrite: boolean;
  29970. private _glVersion;
  29971. private _glRenderer;
  29972. private _glVendor;
  29973. /** @hidden */
  29974. _videoTextureSupported: boolean;
  29975. protected _renderingQueueLaunched: boolean;
  29976. protected _activeRenderLoops: (() => void)[];
  29977. /**
  29978. * Observable signaled when a context lost event is raised
  29979. */
  29980. onContextLostObservable: Observable<ThinEngine>;
  29981. /**
  29982. * Observable signaled when a context restored event is raised
  29983. */
  29984. onContextRestoredObservable: Observable<ThinEngine>;
  29985. private _onContextLost;
  29986. private _onContextRestored;
  29987. protected _contextWasLost: boolean;
  29988. /** @hidden */
  29989. _doNotHandleContextLost: boolean;
  29990. /**
  29991. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29993. */
  29994. doNotHandleContextLost: boolean;
  29995. /**
  29996. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29997. */
  29998. disableVertexArrayObjects: boolean;
  29999. /** @hidden */
  30000. protected _depthCullingState: DepthCullingState;
  30001. /** @hidden */
  30002. protected _stencilState: StencilState;
  30003. /** @hidden */
  30004. protected _alphaState: AlphaState;
  30005. /** @hidden */
  30006. _internalTexturesCache: InternalTexture[];
  30007. /** @hidden */
  30008. protected _activeChannel: number;
  30009. private _currentTextureChannel;
  30010. /** @hidden */
  30011. protected _boundTexturesCache: {
  30012. [key: string]: Nullable<InternalTexture>;
  30013. };
  30014. /** @hidden */
  30015. protected _currentEffect: Nullable<Effect>;
  30016. /** @hidden */
  30017. protected _currentProgram: Nullable<WebGLProgram>;
  30018. private _compiledEffects;
  30019. private _vertexAttribArraysEnabled;
  30020. /** @hidden */
  30021. protected _cachedViewport: Nullable<IViewportLike>;
  30022. private _cachedVertexArrayObject;
  30023. /** @hidden */
  30024. protected _cachedVertexBuffers: any;
  30025. /** @hidden */
  30026. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30027. /** @hidden */
  30028. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30029. /** @hidden */
  30030. _currentRenderTarget: Nullable<InternalTexture>;
  30031. private _uintIndicesCurrentlySet;
  30032. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30033. /** @hidden */
  30034. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30035. private _currentBufferPointers;
  30036. private _currentInstanceLocations;
  30037. private _currentInstanceBuffers;
  30038. private _textureUnits;
  30039. /** @hidden */
  30040. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30041. /** @hidden */
  30042. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30043. /** @hidden */
  30044. _bindedRenderFunction: any;
  30045. private _vaoRecordInProgress;
  30046. private _mustWipeVertexAttributes;
  30047. private _emptyTexture;
  30048. private _emptyCubeTexture;
  30049. private _emptyTexture3D;
  30050. /** @hidden */
  30051. _frameHandler: number;
  30052. private _nextFreeTextureSlots;
  30053. private _maxSimultaneousTextures;
  30054. private _activeRequests;
  30055. protected _texturesSupported: string[];
  30056. /** @hidden */
  30057. _textureFormatInUse: Nullable<string>;
  30058. protected readonly _supportsHardwareTextureRescaling: boolean;
  30059. /**
  30060. * Gets the list of texture formats supported
  30061. */
  30062. readonly texturesSupported: Array<string>;
  30063. /**
  30064. * Gets the list of texture formats in use
  30065. */
  30066. readonly textureFormatInUse: Nullable<string>;
  30067. /**
  30068. * Gets the current viewport
  30069. */
  30070. readonly currentViewport: Nullable<IViewportLike>;
  30071. /**
  30072. * Gets the default empty texture
  30073. */
  30074. readonly emptyTexture: InternalTexture;
  30075. /**
  30076. * Gets the default empty 3D texture
  30077. */
  30078. readonly emptyTexture3D: InternalTexture;
  30079. /**
  30080. * Gets the default empty cube texture
  30081. */
  30082. readonly emptyCubeTexture: InternalTexture;
  30083. /**
  30084. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30085. */
  30086. readonly premultipliedAlpha: boolean;
  30087. /**
  30088. * Observable event triggered before each texture is initialized
  30089. */
  30090. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30091. /**
  30092. * Creates a new engine
  30093. * @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
  30094. * @param antialias defines enable antialiasing (default: false)
  30095. * @param options defines further options to be sent to the getContext() function
  30096. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30097. */
  30098. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30099. private _rebuildInternalTextures;
  30100. private _rebuildEffects;
  30101. /**
  30102. * Gets a boolean indicating if all created effects are ready
  30103. * @returns true if all effects are ready
  30104. */
  30105. areAllEffectsReady(): boolean;
  30106. protected _rebuildBuffers(): void;
  30107. private _initGLContext;
  30108. /**
  30109. * Gets version of the current webGL context
  30110. */
  30111. readonly webGLVersion: number;
  30112. /**
  30113. * Gets a string idenfifying the name of the class
  30114. * @returns "Engine" string
  30115. */
  30116. getClassName(): string;
  30117. /**
  30118. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30119. */
  30120. readonly isStencilEnable: boolean;
  30121. /** @hidden */
  30122. _prepareWorkingCanvas(): void;
  30123. /**
  30124. * Reset the texture cache to empty state
  30125. */
  30126. resetTextureCache(): void;
  30127. /**
  30128. * Gets an object containing information about the current webGL context
  30129. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30130. */
  30131. getGlInfo(): {
  30132. vendor: string;
  30133. renderer: string;
  30134. version: string;
  30135. };
  30136. /**
  30137. * Defines the hardware scaling level.
  30138. * By default the hardware scaling level is computed from the window device ratio.
  30139. * 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.
  30140. * @param level defines the level to use
  30141. */
  30142. setHardwareScalingLevel(level: number): void;
  30143. /**
  30144. * Gets the current hardware scaling level.
  30145. * By default the hardware scaling level is computed from the window device ratio.
  30146. * 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.
  30147. * @returns a number indicating the current hardware scaling level
  30148. */
  30149. getHardwareScalingLevel(): number;
  30150. /**
  30151. * Gets the list of loaded textures
  30152. * @returns an array containing all loaded textures
  30153. */
  30154. getLoadedTexturesCache(): InternalTexture[];
  30155. /**
  30156. * Gets the object containing all engine capabilities
  30157. * @returns the EngineCapabilities object
  30158. */
  30159. getCaps(): EngineCapabilities;
  30160. /**
  30161. * stop executing a render loop function and remove it from the execution array
  30162. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30163. */
  30164. stopRenderLoop(renderFunction?: () => void): void;
  30165. /** @hidden */
  30166. _renderLoop(): void;
  30167. /**
  30168. * Gets the HTML canvas attached with the current webGL context
  30169. * @returns a HTML canvas
  30170. */
  30171. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30172. /**
  30173. * Gets host window
  30174. * @returns the host window object
  30175. */
  30176. getHostWindow(): Nullable<Window>;
  30177. /**
  30178. * Gets the current render width
  30179. * @param useScreen defines if screen size must be used (or the current render target if any)
  30180. * @returns a number defining the current render width
  30181. */
  30182. getRenderWidth(useScreen?: boolean): number;
  30183. /**
  30184. * Gets the current render height
  30185. * @param useScreen defines if screen size must be used (or the current render target if any)
  30186. * @returns a number defining the current render height
  30187. */
  30188. getRenderHeight(useScreen?: boolean): number;
  30189. /**
  30190. * Can be used to override the current requestAnimationFrame requester.
  30191. * @hidden
  30192. */
  30193. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30194. /**
  30195. * Register and execute a render loop. The engine can have more than one render function
  30196. * @param renderFunction defines the function to continuously execute
  30197. */
  30198. runRenderLoop(renderFunction: () => void): void;
  30199. /**
  30200. * Clear the current render buffer or the current render target (if any is set up)
  30201. * @param color defines the color to use
  30202. * @param backBuffer defines if the back buffer must be cleared
  30203. * @param depth defines if the depth buffer must be cleared
  30204. * @param stencil defines if the stencil buffer must be cleared
  30205. */
  30206. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30207. private _viewportCached;
  30208. /** @hidden */
  30209. _viewport(x: number, y: number, width: number, height: number): void;
  30210. /**
  30211. * Set the WebGL's viewport
  30212. * @param viewport defines the viewport element to be used
  30213. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30214. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30215. */
  30216. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30217. /**
  30218. * Begin a new frame
  30219. */
  30220. beginFrame(): void;
  30221. /**
  30222. * Enf the current frame
  30223. */
  30224. endFrame(): void;
  30225. /**
  30226. * Resize the view according to the canvas' size
  30227. */
  30228. resize(): void;
  30229. /**
  30230. * Force a specific size of the canvas
  30231. * @param width defines the new canvas' width
  30232. * @param height defines the new canvas' height
  30233. */
  30234. setSize(width: number, height: number): void;
  30235. /**
  30236. * Binds the frame buffer to the specified texture.
  30237. * @param texture The texture to render to or null for the default canvas
  30238. * @param faceIndex The face of the texture to render to in case of cube texture
  30239. * @param requiredWidth The width of the target to render to
  30240. * @param requiredHeight The height of the target to render to
  30241. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30242. * @param depthStencilTexture The depth stencil texture to use to render
  30243. * @param lodLevel defines le lod level to bind to the frame buffer
  30244. */
  30245. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30246. /** @hidden */
  30247. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30248. /**
  30249. * Unbind the current render target texture from the webGL context
  30250. * @param texture defines the render target texture to unbind
  30251. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30252. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30253. */
  30254. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30255. /**
  30256. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30257. */
  30258. flushFramebuffer(): void;
  30259. /**
  30260. * Unbind the current render target and bind the default framebuffer
  30261. */
  30262. restoreDefaultFramebuffer(): void;
  30263. private _resetVertexBufferBinding;
  30264. /**
  30265. * Creates a vertex buffer
  30266. * @param data the data for the vertex buffer
  30267. * @returns the new WebGL static buffer
  30268. */
  30269. createVertexBuffer(data: DataArray): DataBuffer;
  30270. private _createVertexBuffer;
  30271. /**
  30272. * Creates a dynamic vertex buffer
  30273. * @param data the data for the dynamic vertex buffer
  30274. * @returns the new WebGL dynamic buffer
  30275. */
  30276. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30277. /**
  30278. * Updates a dynamic vertex buffer.
  30279. * @param vertexBuffer the vertex buffer to update
  30280. * @param data the data used to update the vertex buffer
  30281. * @param byteOffset the byte offset of the data
  30282. * @param byteLength the byte length of the data
  30283. */
  30284. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30285. protected _resetIndexBufferBinding(): void;
  30286. /**
  30287. * Creates a new index buffer
  30288. * @param indices defines the content of the index buffer
  30289. * @param updatable defines if the index buffer must be updatable
  30290. * @returns a new webGL buffer
  30291. */
  30292. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30293. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30294. /**
  30295. * Bind a webGL buffer to the webGL context
  30296. * @param buffer defines the buffer to bind
  30297. */
  30298. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30299. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30300. private bindBuffer;
  30301. /**
  30302. * update the bound buffer with the given data
  30303. * @param data defines the data to update
  30304. */
  30305. updateArrayBuffer(data: Float32Array): void;
  30306. private _vertexAttribPointer;
  30307. private _bindIndexBufferWithCache;
  30308. private _bindVertexBuffersAttributes;
  30309. /**
  30310. * Records a vertex array object
  30311. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30312. * @param vertexBuffers defines the list of vertex buffers to store
  30313. * @param indexBuffer defines the index buffer to store
  30314. * @param effect defines the effect to store
  30315. * @returns the new vertex array object
  30316. */
  30317. recordVertexArrayObject(vertexBuffers: {
  30318. [key: string]: VertexBuffer;
  30319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30320. /**
  30321. * Bind a specific vertex array object
  30322. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30323. * @param vertexArrayObject defines the vertex array object to bind
  30324. * @param indexBuffer defines the index buffer to bind
  30325. */
  30326. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30327. /**
  30328. * Bind webGl buffers directly to the webGL context
  30329. * @param vertexBuffer defines the vertex buffer to bind
  30330. * @param indexBuffer defines the index buffer to bind
  30331. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30332. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30333. * @param effect defines the effect associated with the vertex buffer
  30334. */
  30335. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30336. private _unbindVertexArrayObject;
  30337. /**
  30338. * Bind a list of vertex buffers to the webGL context
  30339. * @param vertexBuffers defines the list of vertex buffers to bind
  30340. * @param indexBuffer defines the index buffer to bind
  30341. * @param effect defines the effect associated with the vertex buffers
  30342. */
  30343. bindBuffers(vertexBuffers: {
  30344. [key: string]: Nullable<VertexBuffer>;
  30345. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30346. /**
  30347. * Unbind all instance attributes
  30348. */
  30349. unbindInstanceAttributes(): void;
  30350. /**
  30351. * Release and free the memory of a vertex array object
  30352. * @param vao defines the vertex array object to delete
  30353. */
  30354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30355. /** @hidden */
  30356. _releaseBuffer(buffer: DataBuffer): boolean;
  30357. protected _deleteBuffer(buffer: DataBuffer): void;
  30358. /**
  30359. * Creates a webGL buffer to use with instanciation
  30360. * @param capacity defines the size of the buffer
  30361. * @returns the webGL buffer
  30362. */
  30363. createInstancesBuffer(capacity: number): DataBuffer;
  30364. /**
  30365. * Delete a webGL buffer used with instanciation
  30366. * @param buffer defines the webGL buffer to delete
  30367. */
  30368. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30369. /**
  30370. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30371. * @param instancesBuffer defines the webGL buffer to update and bind
  30372. * @param data defines the data to store in the buffer
  30373. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30374. */
  30375. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30376. /**
  30377. * Apply all cached states (depth, culling, stencil and alpha)
  30378. */
  30379. applyStates(): void;
  30380. /**
  30381. * Send a draw order
  30382. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30383. * @param indexStart defines the starting index
  30384. * @param indexCount defines the number of index to draw
  30385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30386. */
  30387. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30388. /**
  30389. * Draw a list of points
  30390. * @param verticesStart defines the index of first vertex to draw
  30391. * @param verticesCount defines the count of vertices to draw
  30392. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30393. */
  30394. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30395. /**
  30396. * Draw a list of unindexed primitives
  30397. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30398. * @param verticesStart defines the index of first vertex to draw
  30399. * @param verticesCount defines the count of vertices to draw
  30400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30401. */
  30402. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30403. /**
  30404. * Draw a list of indexed primitives
  30405. * @param fillMode defines the primitive to use
  30406. * @param indexStart defines the starting index
  30407. * @param indexCount defines the number of index to draw
  30408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30409. */
  30410. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30411. /**
  30412. * Draw a list of unindexed primitives
  30413. * @param fillMode defines the primitive to use
  30414. * @param verticesStart defines the index of first vertex to draw
  30415. * @param verticesCount defines the count of vertices to draw
  30416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30417. */
  30418. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30419. private _drawMode;
  30420. /** @hidden */
  30421. protected _reportDrawCall(): void;
  30422. /** @hidden */
  30423. _releaseEffect(effect: Effect): void;
  30424. /** @hidden */
  30425. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30426. /**
  30427. * Create a new effect (used to store vertex/fragment shaders)
  30428. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30429. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30430. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30431. * @param samplers defines an array of string used to represent textures
  30432. * @param defines defines the string containing the defines to use to compile the shaders
  30433. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30434. * @param onCompiled defines a function to call when the effect creation is successful
  30435. * @param onError defines a function to call when the effect creation has failed
  30436. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30437. * @returns the new Effect
  30438. */
  30439. 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;
  30440. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30441. private _compileShader;
  30442. private _compileRawShader;
  30443. /**
  30444. * Directly creates a webGL program
  30445. * @param pipelineContext defines the pipeline context to attach to
  30446. * @param vertexCode defines the vertex shader code to use
  30447. * @param fragmentCode defines the fragment shader code to use
  30448. * @param context defines the webGL context to use (if not set, the current one will be used)
  30449. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30450. * @returns the new webGL program
  30451. */
  30452. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30453. /**
  30454. * Creates a webGL program
  30455. * @param pipelineContext defines the pipeline context to attach to
  30456. * @param vertexCode defines the vertex shader code to use
  30457. * @param fragmentCode defines the fragment shader code to use
  30458. * @param defines defines the string containing the defines to use to compile the shaders
  30459. * @param context defines the webGL context to use (if not set, the current one will be used)
  30460. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30461. * @returns the new webGL program
  30462. */
  30463. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30464. /**
  30465. * Creates a new pipeline context
  30466. * @returns the new pipeline
  30467. */
  30468. createPipelineContext(): IPipelineContext;
  30469. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30470. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30471. /** @hidden */
  30472. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30473. /** @hidden */
  30474. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30475. /** @hidden */
  30476. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30477. /**
  30478. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30479. * @param pipelineContext defines the pipeline context to use
  30480. * @param uniformsNames defines the list of uniform names
  30481. * @returns an array of webGL uniform locations
  30482. */
  30483. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30484. /**
  30485. * Gets the lsit of active attributes for a given webGL program
  30486. * @param pipelineContext defines the pipeline context to use
  30487. * @param attributesNames defines the list of attribute names to get
  30488. * @returns an array of indices indicating the offset of each attribute
  30489. */
  30490. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30491. /**
  30492. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30493. * @param effect defines the effect to activate
  30494. */
  30495. enableEffect(effect: Nullable<Effect>): void;
  30496. /**
  30497. * Set the value of an uniform to an array of int32
  30498. * @param uniform defines the webGL uniform location where to store the value
  30499. * @param array defines the array of int32 to store
  30500. */
  30501. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30502. /**
  30503. * Set the value of an uniform to an array of int32 (stored as vec2)
  30504. * @param uniform defines the webGL uniform location where to store the value
  30505. * @param array defines the array of int32 to store
  30506. */
  30507. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30508. /**
  30509. * Set the value of an uniform to an array of int32 (stored as vec3)
  30510. * @param uniform defines the webGL uniform location where to store the value
  30511. * @param array defines the array of int32 to store
  30512. */
  30513. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30514. /**
  30515. * Set the value of an uniform to an array of int32 (stored as vec4)
  30516. * @param uniform defines the webGL uniform location where to store the value
  30517. * @param array defines the array of int32 to store
  30518. */
  30519. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30520. /**
  30521. * Set the value of an uniform to an array of float32
  30522. * @param uniform defines the webGL uniform location where to store the value
  30523. * @param array defines the array of float32 to store
  30524. */
  30525. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30526. /**
  30527. * Set the value of an uniform to an array of float32 (stored as vec2)
  30528. * @param uniform defines the webGL uniform location where to store the value
  30529. * @param array defines the array of float32 to store
  30530. */
  30531. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30532. /**
  30533. * Set the value of an uniform to an array of float32 (stored as vec3)
  30534. * @param uniform defines the webGL uniform location where to store the value
  30535. * @param array defines the array of float32 to store
  30536. */
  30537. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30538. /**
  30539. * Set the value of an uniform to an array of float32 (stored as vec4)
  30540. * @param uniform defines the webGL uniform location where to store the value
  30541. * @param array defines the array of float32 to store
  30542. */
  30543. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30544. /**
  30545. * Set the value of an uniform to an array of number
  30546. * @param uniform defines the webGL uniform location where to store the value
  30547. * @param array defines the array of number to store
  30548. */
  30549. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30550. /**
  30551. * Set the value of an uniform to an array of number (stored as vec2)
  30552. * @param uniform defines the webGL uniform location where to store the value
  30553. * @param array defines the array of number to store
  30554. */
  30555. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30556. /**
  30557. * Set the value of an uniform to an array of number (stored as vec3)
  30558. * @param uniform defines the webGL uniform location where to store the value
  30559. * @param array defines the array of number to store
  30560. */
  30561. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30562. /**
  30563. * Set the value of an uniform to an array of number (stored as vec4)
  30564. * @param uniform defines the webGL uniform location where to store the value
  30565. * @param array defines the array of number to store
  30566. */
  30567. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30568. /**
  30569. * Set the value of an uniform to an array of float32 (stored as matrices)
  30570. * @param uniform defines the webGL uniform location where to store the value
  30571. * @param matrices defines the array of float32 to store
  30572. */
  30573. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30574. /**
  30575. * Set the value of an uniform to a matrix (3x3)
  30576. * @param uniform defines the webGL uniform location where to store the value
  30577. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30578. */
  30579. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30580. /**
  30581. * Set the value of an uniform to a matrix (2x2)
  30582. * @param uniform defines the webGL uniform location where to store the value
  30583. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30584. */
  30585. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30586. /**
  30587. * Set the value of an uniform to a number (int)
  30588. * @param uniform defines the webGL uniform location where to store the value
  30589. * @param value defines the int number to store
  30590. */
  30591. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30592. /**
  30593. * Set the value of an uniform to a number (float)
  30594. * @param uniform defines the webGL uniform location where to store the value
  30595. * @param value defines the float number to store
  30596. */
  30597. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30598. /**
  30599. * Set the value of an uniform to a vec2
  30600. * @param uniform defines the webGL uniform location where to store the value
  30601. * @param x defines the 1st component of the value
  30602. * @param y defines the 2nd component of the value
  30603. */
  30604. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30605. /**
  30606. * Set the value of an uniform to a vec3
  30607. * @param uniform defines the webGL uniform location where to store the value
  30608. * @param x defines the 1st component of the value
  30609. * @param y defines the 2nd component of the value
  30610. * @param z defines the 3rd component of the value
  30611. */
  30612. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30613. /**
  30614. * Set the value of an uniform to a boolean
  30615. * @param uniform defines the webGL uniform location where to store the value
  30616. * @param bool defines the boolean to store
  30617. */
  30618. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30619. /**
  30620. * Set the value of an uniform to a vec4
  30621. * @param uniform defines the webGL uniform location where to store the value
  30622. * @param x defines the 1st component of the value
  30623. * @param y defines the 2nd component of the value
  30624. * @param z defines the 3rd component of the value
  30625. * @param w defines the 4th component of the value
  30626. */
  30627. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30628. /**
  30629. * Sets a Color4 on a uniform variable
  30630. * @param uniform defines the uniform location
  30631. * @param color4 defines the value to be set
  30632. */
  30633. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30634. /**
  30635. * Gets the depth culling state manager
  30636. */
  30637. readonly depthCullingState: DepthCullingState;
  30638. /**
  30639. * Gets the alpha state manager
  30640. */
  30641. readonly alphaState: AlphaState;
  30642. /**
  30643. * Gets the stencil state manager
  30644. */
  30645. readonly stencilState: StencilState;
  30646. /**
  30647. * Clears the list of texture accessible through engine.
  30648. * This can help preventing texture load conflict due to name collision.
  30649. */
  30650. clearInternalTexturesCache(): void;
  30651. /**
  30652. * Force the entire cache to be cleared
  30653. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30654. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30655. */
  30656. wipeCaches(bruteForce?: boolean): void;
  30657. /** @hidden */
  30658. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30659. min: number;
  30660. mag: number;
  30661. };
  30662. /** @hidden */
  30663. _createTexture(): WebGLTexture;
  30664. /**
  30665. * Usually called from Texture.ts.
  30666. * Passed information to create a WebGLTexture
  30667. * @param urlArg defines a value which contains one of the following:
  30668. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30669. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30670. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30671. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30672. * @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)
  30673. * @param scene needed for loading to the correct scene
  30674. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30675. * @param onLoad optional callback to be called upon successful completion
  30676. * @param onError optional callback to be called upon failure
  30677. * @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
  30678. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30679. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30680. * @param forcedExtension defines the extension to use to pick the right loader
  30681. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30682. * @param mimeType defines an optional mime type
  30683. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30684. */
  30685. 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;
  30686. /**
  30687. * @hidden
  30688. */
  30689. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30690. /**
  30691. * Creates a raw texture
  30692. * @param data defines the data to store in the texture
  30693. * @param width defines the width of the texture
  30694. * @param height defines the height of the texture
  30695. * @param format defines the format of the data
  30696. * @param generateMipMaps defines if the engine should generate the mip levels
  30697. * @param invertY defines if data must be stored with Y axis inverted
  30698. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30699. * @param compression defines the compression used (null by default)
  30700. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30701. * @returns the raw texture inside an InternalTexture
  30702. */
  30703. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30704. /**
  30705. * Creates a new raw cube texture
  30706. * @param data defines the array of data to use to create each face
  30707. * @param size defines the size of the textures
  30708. * @param format defines the format of the data
  30709. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30710. * @param generateMipMaps defines if the engine should generate the mip levels
  30711. * @param invertY defines if data must be stored with Y axis inverted
  30712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30713. * @param compression defines the compression used (null by default)
  30714. * @returns the cube texture as an InternalTexture
  30715. */
  30716. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30717. /**
  30718. * Creates a new raw 3D texture
  30719. * @param data defines the data used to create the texture
  30720. * @param width defines the width of the texture
  30721. * @param height defines the height of the texture
  30722. * @param depth defines the depth of the texture
  30723. * @param format defines the format of the texture
  30724. * @param generateMipMaps defines if the engine must generate mip levels
  30725. * @param invertY defines if data must be stored with Y axis inverted
  30726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30727. * @param compression defines the compressed used (can be null)
  30728. * @param textureType defines the compressed used (can be null)
  30729. * @returns a new raw 3D texture (stored in an InternalTexture)
  30730. */
  30731. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30732. private _unpackFlipYCached;
  30733. /**
  30734. * In case you are sharing the context with other applications, it might
  30735. * be interested to not cache the unpack flip y state to ensure a consistent
  30736. * value would be set.
  30737. */
  30738. enableUnpackFlipYCached: boolean;
  30739. /** @hidden */
  30740. _unpackFlipY(value: boolean): void;
  30741. /** @hidden */
  30742. _getUnpackAlignement(): number;
  30743. /**
  30744. * Update the sampling mode of a given texture
  30745. * @param samplingMode defines the required sampling mode
  30746. * @param texture defines the texture to update
  30747. */
  30748. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30749. /**
  30750. * Updates a depth texture Comparison Mode and Function.
  30751. * If the comparison Function is equal to 0, the mode will be set to none.
  30752. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30753. * @param texture The texture to set the comparison function for
  30754. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30755. */
  30756. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30757. /** @hidden */
  30758. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30759. width: number;
  30760. height: number;
  30761. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30762. /**
  30763. * Creates a depth stencil texture.
  30764. * This is only available in WebGL 2 or with the depth texture extension available.
  30765. * @param size The size of face edge in the texture.
  30766. * @param options The options defining the texture.
  30767. * @returns The texture
  30768. */
  30769. createDepthStencilTexture(size: number | {
  30770. width: number;
  30771. height: number;
  30772. }, options: DepthTextureCreationOptions): InternalTexture;
  30773. /**
  30774. * Creates a depth stencil texture.
  30775. * This is only available in WebGL 2 or with the depth texture extension available.
  30776. * @param size The size of face edge in the texture.
  30777. * @param options The options defining the texture.
  30778. * @returns The texture
  30779. */
  30780. private _createDepthStencilTexture;
  30781. /** @hidden */
  30782. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30783. /** @hidden */
  30784. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30785. /** @hidden */
  30786. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30787. /** @hidden */
  30788. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  30789. /**
  30790. * @hidden
  30791. */
  30792. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30793. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30794. private _prepareWebGLTexture;
  30795. /** @hidden */
  30796. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30797. /** @hidden */
  30798. _releaseFramebufferObjects(texture: InternalTexture): void;
  30799. /** @hidden */
  30800. _releaseTexture(texture: InternalTexture): void;
  30801. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30802. protected _setProgram(program: WebGLProgram): void;
  30803. protected _boundUniforms: {
  30804. [key: number]: WebGLUniformLocation;
  30805. };
  30806. /**
  30807. * Binds an effect to the webGL context
  30808. * @param effect defines the effect to bind
  30809. */
  30810. bindSamplers(effect: Effect): void;
  30811. private _activateCurrentTexture;
  30812. /** @hidden */
  30813. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30814. /** @hidden */
  30815. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30816. /**
  30817. * Unbind all textures from the webGL context
  30818. */
  30819. unbindAllTextures(): void;
  30820. /**
  30821. * Sets a texture to the according uniform.
  30822. * @param channel The texture channel
  30823. * @param uniform The uniform to set
  30824. * @param texture The texture to apply
  30825. */
  30826. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30827. private _bindSamplerUniformToChannel;
  30828. private _getTextureWrapMode;
  30829. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30830. /**
  30831. * Sets an array of texture to the webGL context
  30832. * @param channel defines the channel where the texture array must be set
  30833. * @param uniform defines the associated uniform location
  30834. * @param textures defines the array of textures to bind
  30835. */
  30836. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30837. /** @hidden */
  30838. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30839. private _setTextureParameterFloat;
  30840. private _setTextureParameterInteger;
  30841. /**
  30842. * Unbind all vertex attributes from the webGL context
  30843. */
  30844. unbindAllAttributes(): void;
  30845. /**
  30846. * 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
  30847. */
  30848. releaseEffects(): void;
  30849. /**
  30850. * Dispose and release all associated resources
  30851. */
  30852. dispose(): void;
  30853. /**
  30854. * Attach a new callback raised when context lost event is fired
  30855. * @param callback defines the callback to call
  30856. */
  30857. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30858. /**
  30859. * Attach a new callback raised when context restored event is fired
  30860. * @param callback defines the callback to call
  30861. */
  30862. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30863. /**
  30864. * Get the current error code of the webGL context
  30865. * @returns the error code
  30866. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30867. */
  30868. getError(): number;
  30869. private _canRenderToFloatFramebuffer;
  30870. private _canRenderToHalfFloatFramebuffer;
  30871. private _canRenderToFramebuffer;
  30872. /** @hidden */
  30873. _getWebGLTextureType(type: number): number;
  30874. /** @hidden */
  30875. _getInternalFormat(format: number): number;
  30876. /** @hidden */
  30877. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30878. /** @hidden */
  30879. _getRGBAMultiSampleBufferFormat(type: number): number;
  30880. /** @hidden */
  30881. _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;
  30882. /**
  30883. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30884. * @returns true if the engine can be created
  30885. * @ignorenaming
  30886. */
  30887. static isSupported(): boolean;
  30888. /**
  30889. * Find the next highest power of two.
  30890. * @param x Number to start search from.
  30891. * @return Next highest power of two.
  30892. */
  30893. static CeilingPOT(x: number): number;
  30894. /**
  30895. * Find the next lowest power of two.
  30896. * @param x Number to start search from.
  30897. * @return Next lowest power of two.
  30898. */
  30899. static FloorPOT(x: number): number;
  30900. /**
  30901. * Find the nearest power of two.
  30902. * @param x Number to start search from.
  30903. * @return Next nearest power of two.
  30904. */
  30905. static NearestPOT(x: number): number;
  30906. /**
  30907. * Get the closest exponent of two
  30908. * @param value defines the value to approximate
  30909. * @param max defines the maximum value to return
  30910. * @param mode defines how to define the closest value
  30911. * @returns closest exponent of two of the given value
  30912. */
  30913. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30914. /**
  30915. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30916. * @param func - the function to be called
  30917. * @param requester - the object that will request the next frame. Falls back to window.
  30918. * @returns frame number
  30919. */
  30920. static QueueNewFrame(func: () => void, requester?: any): number;
  30921. }
  30922. }
  30923. declare module "babylonjs/Maths/sphericalPolynomial" {
  30924. import { Vector3 } from "babylonjs/Maths/math.vector";
  30925. import { Color3 } from "babylonjs/Maths/math.color";
  30926. /**
  30927. * Class representing spherical harmonics coefficients to the 3rd degree
  30928. */
  30929. export class SphericalHarmonics {
  30930. /**
  30931. * Defines whether or not the harmonics have been prescaled for rendering.
  30932. */
  30933. preScaled: boolean;
  30934. /**
  30935. * The l0,0 coefficients of the spherical harmonics
  30936. */
  30937. l00: Vector3;
  30938. /**
  30939. * The l1,-1 coefficients of the spherical harmonics
  30940. */
  30941. l1_1: Vector3;
  30942. /**
  30943. * The l1,0 coefficients of the spherical harmonics
  30944. */
  30945. l10: Vector3;
  30946. /**
  30947. * The l1,1 coefficients of the spherical harmonics
  30948. */
  30949. l11: Vector3;
  30950. /**
  30951. * The l2,-2 coefficients of the spherical harmonics
  30952. */
  30953. l2_2: Vector3;
  30954. /**
  30955. * The l2,-1 coefficients of the spherical harmonics
  30956. */
  30957. l2_1: Vector3;
  30958. /**
  30959. * The l2,0 coefficients of the spherical harmonics
  30960. */
  30961. l20: Vector3;
  30962. /**
  30963. * The l2,1 coefficients of the spherical harmonics
  30964. */
  30965. l21: Vector3;
  30966. /**
  30967. * The l2,2 coefficients of the spherical harmonics
  30968. */
  30969. l22: Vector3;
  30970. /**
  30971. * Adds a light to the spherical harmonics
  30972. * @param direction the direction of the light
  30973. * @param color the color of the light
  30974. * @param deltaSolidAngle the delta solid angle of the light
  30975. */
  30976. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30977. /**
  30978. * Scales the spherical harmonics by the given amount
  30979. * @param scale the amount to scale
  30980. */
  30981. scaleInPlace(scale: number): void;
  30982. /**
  30983. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30984. *
  30985. * ```
  30986. * E_lm = A_l * L_lm
  30987. * ```
  30988. *
  30989. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30990. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30991. * the scaling factors are given in equation 9.
  30992. */
  30993. convertIncidentRadianceToIrradiance(): void;
  30994. /**
  30995. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30996. *
  30997. * ```
  30998. * L = (1/pi) * E * rho
  30999. * ```
  31000. *
  31001. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31002. */
  31003. convertIrradianceToLambertianRadiance(): void;
  31004. /**
  31005. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31006. * required operations at run time.
  31007. *
  31008. * This is simply done by scaling back the SH with Ylm constants parameter.
  31009. * The trigonometric part being applied by the shader at run time.
  31010. */
  31011. preScaleForRendering(): void;
  31012. /**
  31013. * Constructs a spherical harmonics from an array.
  31014. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31015. * @returns the spherical harmonics
  31016. */
  31017. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31018. /**
  31019. * Gets the spherical harmonics from polynomial
  31020. * @param polynomial the spherical polynomial
  31021. * @returns the spherical harmonics
  31022. */
  31023. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31024. }
  31025. /**
  31026. * Class representing spherical polynomial coefficients to the 3rd degree
  31027. */
  31028. export class SphericalPolynomial {
  31029. private _harmonics;
  31030. /**
  31031. * The spherical harmonics used to create the polynomials.
  31032. */
  31033. readonly preScaledHarmonics: SphericalHarmonics;
  31034. /**
  31035. * The x coefficients of the spherical polynomial
  31036. */
  31037. x: Vector3;
  31038. /**
  31039. * The y coefficients of the spherical polynomial
  31040. */
  31041. y: Vector3;
  31042. /**
  31043. * The z coefficients of the spherical polynomial
  31044. */
  31045. z: Vector3;
  31046. /**
  31047. * The xx coefficients of the spherical polynomial
  31048. */
  31049. xx: Vector3;
  31050. /**
  31051. * The yy coefficients of the spherical polynomial
  31052. */
  31053. yy: Vector3;
  31054. /**
  31055. * The zz coefficients of the spherical polynomial
  31056. */
  31057. zz: Vector3;
  31058. /**
  31059. * The xy coefficients of the spherical polynomial
  31060. */
  31061. xy: Vector3;
  31062. /**
  31063. * The yz coefficients of the spherical polynomial
  31064. */
  31065. yz: Vector3;
  31066. /**
  31067. * The zx coefficients of the spherical polynomial
  31068. */
  31069. zx: Vector3;
  31070. /**
  31071. * Adds an ambient color to the spherical polynomial
  31072. * @param color the color to add
  31073. */
  31074. addAmbient(color: Color3): void;
  31075. /**
  31076. * Scales the spherical polynomial by the given amount
  31077. * @param scale the amount to scale
  31078. */
  31079. scaleInPlace(scale: number): void;
  31080. /**
  31081. * Gets the spherical polynomial from harmonics
  31082. * @param harmonics the spherical harmonics
  31083. * @returns the spherical polynomial
  31084. */
  31085. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31086. /**
  31087. * Constructs a spherical polynomial from an array.
  31088. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31089. * @returns the spherical polynomial
  31090. */
  31091. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31092. }
  31093. }
  31094. declare module "babylonjs/Materials/Textures/internalTexture" {
  31095. import { Observable } from "babylonjs/Misc/observable";
  31096. import { Nullable, int } from "babylonjs/types";
  31097. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31099. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31100. /**
  31101. * Defines the source of the internal texture
  31102. */
  31103. export enum InternalTextureSource {
  31104. /**
  31105. * The source of the texture data is unknown
  31106. */
  31107. Unknown = 0,
  31108. /**
  31109. * Texture data comes from an URL
  31110. */
  31111. Url = 1,
  31112. /**
  31113. * Texture data is only used for temporary storage
  31114. */
  31115. Temp = 2,
  31116. /**
  31117. * Texture data comes from raw data (ArrayBuffer)
  31118. */
  31119. Raw = 3,
  31120. /**
  31121. * Texture content is dynamic (video or dynamic texture)
  31122. */
  31123. Dynamic = 4,
  31124. /**
  31125. * Texture content is generated by rendering to it
  31126. */
  31127. RenderTarget = 5,
  31128. /**
  31129. * Texture content is part of a multi render target process
  31130. */
  31131. MultiRenderTarget = 6,
  31132. /**
  31133. * Texture data comes from a cube data file
  31134. */
  31135. Cube = 7,
  31136. /**
  31137. * Texture data comes from a raw cube data
  31138. */
  31139. CubeRaw = 8,
  31140. /**
  31141. * Texture data come from a prefiltered cube data file
  31142. */
  31143. CubePrefiltered = 9,
  31144. /**
  31145. * Texture content is raw 3D data
  31146. */
  31147. Raw3D = 10,
  31148. /**
  31149. * Texture content is a depth texture
  31150. */
  31151. Depth = 11,
  31152. /**
  31153. * Texture data comes from a raw cube data encoded with RGBD
  31154. */
  31155. CubeRawRGBD = 12
  31156. }
  31157. /**
  31158. * Class used to store data associated with WebGL texture data for the engine
  31159. * This class should not be used directly
  31160. */
  31161. export class InternalTexture {
  31162. /** @hidden */
  31163. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31164. /**
  31165. * Defines if the texture is ready
  31166. */
  31167. isReady: boolean;
  31168. /**
  31169. * Defines if the texture is a cube texture
  31170. */
  31171. isCube: boolean;
  31172. /**
  31173. * Defines if the texture contains 3D data
  31174. */
  31175. is3D: boolean;
  31176. /**
  31177. * Defines if the texture contains multiview data
  31178. */
  31179. isMultiview: boolean;
  31180. /**
  31181. * Gets the URL used to load this texture
  31182. */
  31183. url: string;
  31184. /**
  31185. * Gets the sampling mode of the texture
  31186. */
  31187. samplingMode: number;
  31188. /**
  31189. * Gets a boolean indicating if the texture needs mipmaps generation
  31190. */
  31191. generateMipMaps: boolean;
  31192. /**
  31193. * Gets the number of samples used by the texture (WebGL2+ only)
  31194. */
  31195. samples: number;
  31196. /**
  31197. * Gets the type of the texture (int, float...)
  31198. */
  31199. type: number;
  31200. /**
  31201. * Gets the format of the texture (RGB, RGBA...)
  31202. */
  31203. format: number;
  31204. /**
  31205. * Observable called when the texture is loaded
  31206. */
  31207. onLoadedObservable: Observable<InternalTexture>;
  31208. /**
  31209. * Gets the width of the texture
  31210. */
  31211. width: number;
  31212. /**
  31213. * Gets the height of the texture
  31214. */
  31215. height: number;
  31216. /**
  31217. * Gets the depth of the texture
  31218. */
  31219. depth: number;
  31220. /**
  31221. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31222. */
  31223. baseWidth: number;
  31224. /**
  31225. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31226. */
  31227. baseHeight: number;
  31228. /**
  31229. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31230. */
  31231. baseDepth: number;
  31232. /**
  31233. * Gets a boolean indicating if the texture is inverted on Y axis
  31234. */
  31235. invertY: boolean;
  31236. /** @hidden */
  31237. _invertVScale: boolean;
  31238. /** @hidden */
  31239. _associatedChannel: number;
  31240. /** @hidden */
  31241. _source: InternalTextureSource;
  31242. /** @hidden */
  31243. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31244. /** @hidden */
  31245. _bufferView: Nullable<ArrayBufferView>;
  31246. /** @hidden */
  31247. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31248. /** @hidden */
  31249. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31250. /** @hidden */
  31251. _size: number;
  31252. /** @hidden */
  31253. _extension: string;
  31254. /** @hidden */
  31255. _files: Nullable<string[]>;
  31256. /** @hidden */
  31257. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31258. /** @hidden */
  31259. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31260. /** @hidden */
  31261. _framebuffer: Nullable<WebGLFramebuffer>;
  31262. /** @hidden */
  31263. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31264. /** @hidden */
  31265. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31266. /** @hidden */
  31267. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31268. /** @hidden */
  31269. _attachments: Nullable<number[]>;
  31270. /** @hidden */
  31271. _cachedCoordinatesMode: Nullable<number>;
  31272. /** @hidden */
  31273. _cachedWrapU: Nullable<number>;
  31274. /** @hidden */
  31275. _cachedWrapV: Nullable<number>;
  31276. /** @hidden */
  31277. _cachedWrapR: Nullable<number>;
  31278. /** @hidden */
  31279. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31280. /** @hidden */
  31281. _isDisabled: boolean;
  31282. /** @hidden */
  31283. _compression: Nullable<string>;
  31284. /** @hidden */
  31285. _generateStencilBuffer: boolean;
  31286. /** @hidden */
  31287. _generateDepthBuffer: boolean;
  31288. /** @hidden */
  31289. _comparisonFunction: number;
  31290. /** @hidden */
  31291. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31292. /** @hidden */
  31293. _lodGenerationScale: number;
  31294. /** @hidden */
  31295. _lodGenerationOffset: number;
  31296. /** @hidden */
  31297. _colorTextureArray: Nullable<WebGLTexture>;
  31298. /** @hidden */
  31299. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31300. /** @hidden */
  31301. _lodTextureHigh: Nullable<BaseTexture>;
  31302. /** @hidden */
  31303. _lodTextureMid: Nullable<BaseTexture>;
  31304. /** @hidden */
  31305. _lodTextureLow: Nullable<BaseTexture>;
  31306. /** @hidden */
  31307. _isRGBD: boolean;
  31308. /** @hidden */
  31309. _linearSpecularLOD: boolean;
  31310. /** @hidden */
  31311. _irradianceTexture: Nullable<BaseTexture>;
  31312. /** @hidden */
  31313. _webGLTexture: Nullable<WebGLTexture>;
  31314. /** @hidden */
  31315. _references: number;
  31316. private _engine;
  31317. /**
  31318. * Gets the Engine the texture belongs to.
  31319. * @returns The babylon engine
  31320. */
  31321. getEngine(): ThinEngine;
  31322. /**
  31323. * Gets the data source type of the texture
  31324. */
  31325. readonly source: InternalTextureSource;
  31326. /**
  31327. * Creates a new InternalTexture
  31328. * @param engine defines the engine to use
  31329. * @param source defines the type of data that will be used
  31330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31331. */
  31332. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31333. /**
  31334. * Increments the number of references (ie. the number of Texture that point to it)
  31335. */
  31336. incrementReferences(): void;
  31337. /**
  31338. * Change the size of the texture (not the size of the content)
  31339. * @param width defines the new width
  31340. * @param height defines the new height
  31341. * @param depth defines the new depth (1 by default)
  31342. */
  31343. updateSize(width: int, height: int, depth?: int): void;
  31344. /** @hidden */
  31345. _rebuild(): void;
  31346. /** @hidden */
  31347. _swapAndDie(target: InternalTexture): void;
  31348. /**
  31349. * Dispose the current allocated resources
  31350. */
  31351. dispose(): void;
  31352. }
  31353. }
  31354. declare module "babylonjs/Audio/analyser" {
  31355. import { Scene } from "babylonjs/scene";
  31356. /**
  31357. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31359. */
  31360. export class Analyser {
  31361. /**
  31362. * Gets or sets the smoothing
  31363. * @ignorenaming
  31364. */
  31365. SMOOTHING: number;
  31366. /**
  31367. * Gets or sets the FFT table size
  31368. * @ignorenaming
  31369. */
  31370. FFT_SIZE: number;
  31371. /**
  31372. * Gets or sets the bar graph amplitude
  31373. * @ignorenaming
  31374. */
  31375. BARGRAPHAMPLITUDE: number;
  31376. /**
  31377. * Gets or sets the position of the debug canvas
  31378. * @ignorenaming
  31379. */
  31380. DEBUGCANVASPOS: {
  31381. x: number;
  31382. y: number;
  31383. };
  31384. /**
  31385. * Gets or sets the debug canvas size
  31386. * @ignorenaming
  31387. */
  31388. DEBUGCANVASSIZE: {
  31389. width: number;
  31390. height: number;
  31391. };
  31392. private _byteFreqs;
  31393. private _byteTime;
  31394. private _floatFreqs;
  31395. private _webAudioAnalyser;
  31396. private _debugCanvas;
  31397. private _debugCanvasContext;
  31398. private _scene;
  31399. private _registerFunc;
  31400. private _audioEngine;
  31401. /**
  31402. * Creates a new analyser
  31403. * @param scene defines hosting scene
  31404. */
  31405. constructor(scene: Scene);
  31406. /**
  31407. * Get the number of data values you will have to play with for the visualization
  31408. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31409. * @returns a number
  31410. */
  31411. getFrequencyBinCount(): number;
  31412. /**
  31413. * Gets the current frequency data as a byte array
  31414. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31415. * @returns a Uint8Array
  31416. */
  31417. getByteFrequencyData(): Uint8Array;
  31418. /**
  31419. * Gets the current waveform as a byte array
  31420. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31421. * @returns a Uint8Array
  31422. */
  31423. getByteTimeDomainData(): Uint8Array;
  31424. /**
  31425. * Gets the current frequency data as a float array
  31426. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31427. * @returns a Float32Array
  31428. */
  31429. getFloatFrequencyData(): Float32Array;
  31430. /**
  31431. * Renders the debug canvas
  31432. */
  31433. drawDebugCanvas(): void;
  31434. /**
  31435. * Stops rendering the debug canvas and removes it
  31436. */
  31437. stopDebugCanvas(): void;
  31438. /**
  31439. * Connects two audio nodes
  31440. * @param inputAudioNode defines first node to connect
  31441. * @param outputAudioNode defines second node to connect
  31442. */
  31443. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31444. /**
  31445. * Releases all associated resources
  31446. */
  31447. dispose(): void;
  31448. }
  31449. }
  31450. declare module "babylonjs/Audio/audioEngine" {
  31451. import { IDisposable } from "babylonjs/scene";
  31452. import { Analyser } from "babylonjs/Audio/analyser";
  31453. import { Nullable } from "babylonjs/types";
  31454. import { Observable } from "babylonjs/Misc/observable";
  31455. /**
  31456. * This represents an audio engine and it is responsible
  31457. * to play, synchronize and analyse sounds throughout the application.
  31458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31459. */
  31460. export interface IAudioEngine extends IDisposable {
  31461. /**
  31462. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31463. */
  31464. readonly canUseWebAudio: boolean;
  31465. /**
  31466. * Gets the current AudioContext if available.
  31467. */
  31468. readonly audioContext: Nullable<AudioContext>;
  31469. /**
  31470. * The master gain node defines the global audio volume of your audio engine.
  31471. */
  31472. readonly masterGain: GainNode;
  31473. /**
  31474. * Gets whether or not mp3 are supported by your browser.
  31475. */
  31476. readonly isMP3supported: boolean;
  31477. /**
  31478. * Gets whether or not ogg are supported by your browser.
  31479. */
  31480. readonly isOGGsupported: boolean;
  31481. /**
  31482. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31483. * @ignoreNaming
  31484. */
  31485. WarnedWebAudioUnsupported: boolean;
  31486. /**
  31487. * Defines if the audio engine relies on a custom unlocked button.
  31488. * In this case, the embedded button will not be displayed.
  31489. */
  31490. useCustomUnlockedButton: boolean;
  31491. /**
  31492. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31493. */
  31494. readonly unlocked: boolean;
  31495. /**
  31496. * Event raised when audio has been unlocked on the browser.
  31497. */
  31498. onAudioUnlockedObservable: Observable<AudioEngine>;
  31499. /**
  31500. * Event raised when audio has been locked on the browser.
  31501. */
  31502. onAudioLockedObservable: Observable<AudioEngine>;
  31503. /**
  31504. * Flags the audio engine in Locked state.
  31505. * This happens due to new browser policies preventing audio to autoplay.
  31506. */
  31507. lock(): void;
  31508. /**
  31509. * Unlocks the audio engine once a user action has been done on the dom.
  31510. * This is helpful to resume play once browser policies have been satisfied.
  31511. */
  31512. unlock(): void;
  31513. }
  31514. /**
  31515. * This represents the default audio engine used in babylon.
  31516. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31518. */
  31519. export class AudioEngine implements IAudioEngine {
  31520. private _audioContext;
  31521. private _audioContextInitialized;
  31522. private _muteButton;
  31523. private _hostElement;
  31524. /**
  31525. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31526. */
  31527. canUseWebAudio: boolean;
  31528. /**
  31529. * The master gain node defines the global audio volume of your audio engine.
  31530. */
  31531. masterGain: GainNode;
  31532. /**
  31533. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31534. * @ignoreNaming
  31535. */
  31536. WarnedWebAudioUnsupported: boolean;
  31537. /**
  31538. * Gets whether or not mp3 are supported by your browser.
  31539. */
  31540. isMP3supported: boolean;
  31541. /**
  31542. * Gets whether or not ogg are supported by your browser.
  31543. */
  31544. isOGGsupported: boolean;
  31545. /**
  31546. * Gets whether audio has been unlocked on the device.
  31547. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31548. * a user interaction has happened.
  31549. */
  31550. unlocked: boolean;
  31551. /**
  31552. * Defines if the audio engine relies on a custom unlocked button.
  31553. * In this case, the embedded button will not be displayed.
  31554. */
  31555. useCustomUnlockedButton: boolean;
  31556. /**
  31557. * Event raised when audio has been unlocked on the browser.
  31558. */
  31559. onAudioUnlockedObservable: Observable<AudioEngine>;
  31560. /**
  31561. * Event raised when audio has been locked on the browser.
  31562. */
  31563. onAudioLockedObservable: Observable<AudioEngine>;
  31564. /**
  31565. * Gets the current AudioContext if available.
  31566. */
  31567. readonly audioContext: Nullable<AudioContext>;
  31568. private _connectedAnalyser;
  31569. /**
  31570. * Instantiates a new audio engine.
  31571. *
  31572. * There should be only one per page as some browsers restrict the number
  31573. * of audio contexts you can create.
  31574. * @param hostElement defines the host element where to display the mute icon if necessary
  31575. */
  31576. constructor(hostElement?: Nullable<HTMLElement>);
  31577. /**
  31578. * Flags the audio engine in Locked state.
  31579. * This happens due to new browser policies preventing audio to autoplay.
  31580. */
  31581. lock(): void;
  31582. /**
  31583. * Unlocks the audio engine once a user action has been done on the dom.
  31584. * This is helpful to resume play once browser policies have been satisfied.
  31585. */
  31586. unlock(): void;
  31587. private _resumeAudioContext;
  31588. private _initializeAudioContext;
  31589. private _tryToRun;
  31590. private _triggerRunningState;
  31591. private _triggerSuspendedState;
  31592. private _displayMuteButton;
  31593. private _moveButtonToTopLeft;
  31594. private _onResize;
  31595. private _hideMuteButton;
  31596. /**
  31597. * Destroy and release the resources associated with the audio ccontext.
  31598. */
  31599. dispose(): void;
  31600. /**
  31601. * Gets the global volume sets on the master gain.
  31602. * @returns the global volume if set or -1 otherwise
  31603. */
  31604. getGlobalVolume(): number;
  31605. /**
  31606. * Sets the global volume of your experience (sets on the master gain).
  31607. * @param newVolume Defines the new global volume of the application
  31608. */
  31609. setGlobalVolume(newVolume: number): void;
  31610. /**
  31611. * Connect the audio engine to an audio analyser allowing some amazing
  31612. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31614. * @param analyser The analyser to connect to the engine
  31615. */
  31616. connectToAnalyser(analyser: Analyser): void;
  31617. }
  31618. }
  31619. declare module "babylonjs/Loading/loadingScreen" {
  31620. /**
  31621. * Interface used to present a loading screen while loading a scene
  31622. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31623. */
  31624. export interface ILoadingScreen {
  31625. /**
  31626. * Function called to display the loading screen
  31627. */
  31628. displayLoadingUI: () => void;
  31629. /**
  31630. * Function called to hide the loading screen
  31631. */
  31632. hideLoadingUI: () => void;
  31633. /**
  31634. * Gets or sets the color to use for the background
  31635. */
  31636. loadingUIBackgroundColor: string;
  31637. /**
  31638. * Gets or sets the text to display while loading
  31639. */
  31640. loadingUIText: string;
  31641. }
  31642. /**
  31643. * Class used for the default loading screen
  31644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31645. */
  31646. export class DefaultLoadingScreen implements ILoadingScreen {
  31647. private _renderingCanvas;
  31648. private _loadingText;
  31649. private _loadingDivBackgroundColor;
  31650. private _loadingDiv;
  31651. private _loadingTextDiv;
  31652. /** Gets or sets the logo url to use for the default loading screen */
  31653. static DefaultLogoUrl: string;
  31654. /** Gets or sets the spinner url to use for the default loading screen */
  31655. static DefaultSpinnerUrl: string;
  31656. /**
  31657. * Creates a new default loading screen
  31658. * @param _renderingCanvas defines the canvas used to render the scene
  31659. * @param _loadingText defines the default text to display
  31660. * @param _loadingDivBackgroundColor defines the default background color
  31661. */
  31662. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31663. /**
  31664. * Function called to display the loading screen
  31665. */
  31666. displayLoadingUI(): void;
  31667. /**
  31668. * Function called to hide the loading screen
  31669. */
  31670. hideLoadingUI(): void;
  31671. /**
  31672. * Gets or sets the text to display while loading
  31673. */
  31674. loadingUIText: string;
  31675. /**
  31676. * Gets or sets the color to use for the background
  31677. */
  31678. loadingUIBackgroundColor: string;
  31679. private _resizeLoadingUI;
  31680. }
  31681. }
  31682. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31683. /**
  31684. * Interface for any object that can request an animation frame
  31685. */
  31686. export interface ICustomAnimationFrameRequester {
  31687. /**
  31688. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31689. */
  31690. renderFunction?: Function;
  31691. /**
  31692. * Called to request the next frame to render to
  31693. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31694. */
  31695. requestAnimationFrame: Function;
  31696. /**
  31697. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31698. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31699. */
  31700. requestID?: number;
  31701. }
  31702. }
  31703. declare module "babylonjs/Misc/performanceMonitor" {
  31704. /**
  31705. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31706. */
  31707. export class PerformanceMonitor {
  31708. private _enabled;
  31709. private _rollingFrameTime;
  31710. private _lastFrameTimeMs;
  31711. /**
  31712. * constructor
  31713. * @param frameSampleSize The number of samples required to saturate the sliding window
  31714. */
  31715. constructor(frameSampleSize?: number);
  31716. /**
  31717. * Samples current frame
  31718. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31719. */
  31720. sampleFrame(timeMs?: number): void;
  31721. /**
  31722. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31723. */
  31724. readonly averageFrameTime: number;
  31725. /**
  31726. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31727. */
  31728. readonly averageFrameTimeVariance: number;
  31729. /**
  31730. * Returns the frame time of the most recent frame
  31731. */
  31732. readonly instantaneousFrameTime: number;
  31733. /**
  31734. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31735. */
  31736. readonly averageFPS: number;
  31737. /**
  31738. * Returns the average framerate in frames per second using the most recent frame time
  31739. */
  31740. readonly instantaneousFPS: number;
  31741. /**
  31742. * Returns true if enough samples have been taken to completely fill the sliding window
  31743. */
  31744. readonly isSaturated: boolean;
  31745. /**
  31746. * Enables contributions to the sliding window sample set
  31747. */
  31748. enable(): void;
  31749. /**
  31750. * Disables contributions to the sliding window sample set
  31751. * Samples will not be interpolated over the disabled period
  31752. */
  31753. disable(): void;
  31754. /**
  31755. * Returns true if sampling is enabled
  31756. */
  31757. readonly isEnabled: boolean;
  31758. /**
  31759. * Resets performance monitor
  31760. */
  31761. reset(): void;
  31762. }
  31763. /**
  31764. * RollingAverage
  31765. *
  31766. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31767. */
  31768. export class RollingAverage {
  31769. /**
  31770. * Current average
  31771. */
  31772. average: number;
  31773. /**
  31774. * Current variance
  31775. */
  31776. variance: number;
  31777. protected _samples: Array<number>;
  31778. protected _sampleCount: number;
  31779. protected _pos: number;
  31780. protected _m2: number;
  31781. /**
  31782. * constructor
  31783. * @param length The number of samples required to saturate the sliding window
  31784. */
  31785. constructor(length: number);
  31786. /**
  31787. * Adds a sample to the sample set
  31788. * @param v The sample value
  31789. */
  31790. add(v: number): void;
  31791. /**
  31792. * Returns previously added values or null if outside of history or outside the sliding window domain
  31793. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31794. * @return Value previously recorded with add() or null if outside of range
  31795. */
  31796. history(i: number): number;
  31797. /**
  31798. * Returns true if enough samples have been taken to completely fill the sliding window
  31799. * @return true if sample-set saturated
  31800. */
  31801. isSaturated(): boolean;
  31802. /**
  31803. * Resets the rolling average (equivalent to 0 samples taken so far)
  31804. */
  31805. reset(): void;
  31806. /**
  31807. * Wraps a value around the sample range boundaries
  31808. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31809. * @return Wrapped position in sample range
  31810. */
  31811. protected _wrapPosition(i: number): number;
  31812. }
  31813. }
  31814. declare module "babylonjs/Misc/perfCounter" {
  31815. /**
  31816. * This class is used to track a performance counter which is number based.
  31817. * The user has access to many properties which give statistics of different nature.
  31818. *
  31819. * The implementer can track two kinds of Performance Counter: time and count.
  31820. * 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.
  31821. * 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.
  31822. */
  31823. export class PerfCounter {
  31824. /**
  31825. * Gets or sets a global boolean to turn on and off all the counters
  31826. */
  31827. static Enabled: boolean;
  31828. /**
  31829. * Returns the smallest value ever
  31830. */
  31831. readonly min: number;
  31832. /**
  31833. * Returns the biggest value ever
  31834. */
  31835. readonly max: number;
  31836. /**
  31837. * Returns the average value since the performance counter is running
  31838. */
  31839. readonly average: number;
  31840. /**
  31841. * Returns the average value of the last second the counter was monitored
  31842. */
  31843. readonly lastSecAverage: number;
  31844. /**
  31845. * Returns the current value
  31846. */
  31847. readonly current: number;
  31848. /**
  31849. * Gets the accumulated total
  31850. */
  31851. readonly total: number;
  31852. /**
  31853. * Gets the total value count
  31854. */
  31855. readonly count: number;
  31856. /**
  31857. * Creates a new counter
  31858. */
  31859. constructor();
  31860. /**
  31861. * Call this method to start monitoring a new frame.
  31862. * 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.
  31863. */
  31864. fetchNewFrame(): void;
  31865. /**
  31866. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31867. * @param newCount the count value to add to the monitored count
  31868. * @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.
  31869. */
  31870. addCount(newCount: number, fetchResult: boolean): void;
  31871. /**
  31872. * Start monitoring this performance counter
  31873. */
  31874. beginMonitoring(): void;
  31875. /**
  31876. * Compute the time lapsed since the previous beginMonitoring() call.
  31877. * @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
  31878. */
  31879. endMonitoring(newFrame?: boolean): void;
  31880. private _fetchResult;
  31881. private _startMonitoringTime;
  31882. private _min;
  31883. private _max;
  31884. private _average;
  31885. private _current;
  31886. private _totalValueCount;
  31887. private _totalAccumulated;
  31888. private _lastSecAverage;
  31889. private _lastSecAccumulated;
  31890. private _lastSecTime;
  31891. private _lastSecValueCount;
  31892. }
  31893. }
  31894. declare module "babylonjs/Engines/engine" {
  31895. import { Observable } from "babylonjs/Misc/observable";
  31896. import { Nullable, IndicesArray } from "babylonjs/types";
  31897. import { Scene } from "babylonjs/scene";
  31898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31899. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31900. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31901. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31902. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31903. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31904. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31905. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31906. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31908. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31909. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31910. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31911. import { Material } from "babylonjs/Materials/material";
  31912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31913. /**
  31914. * Defines the interface used by display changed events
  31915. */
  31916. export interface IDisplayChangedEventArgs {
  31917. /** Gets the vrDisplay object (if any) */
  31918. vrDisplay: Nullable<any>;
  31919. /** Gets a boolean indicating if webVR is supported */
  31920. vrSupported: boolean;
  31921. }
  31922. /**
  31923. * Defines the interface used by objects containing a viewport (like a camera)
  31924. */
  31925. interface IViewportOwnerLike {
  31926. /**
  31927. * Gets or sets the viewport
  31928. */
  31929. viewport: IViewportLike;
  31930. }
  31931. /**
  31932. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31933. */
  31934. export class Engine extends ThinEngine {
  31935. /** Defines that alpha blending is disabled */
  31936. static readonly ALPHA_DISABLE: number;
  31937. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31938. static readonly ALPHA_ADD: number;
  31939. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31940. static readonly ALPHA_COMBINE: number;
  31941. /** Defines that alpha blending to DEST - SRC * DEST */
  31942. static readonly ALPHA_SUBTRACT: number;
  31943. /** Defines that alpha blending to SRC * DEST */
  31944. static readonly ALPHA_MULTIPLY: number;
  31945. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31946. static readonly ALPHA_MAXIMIZED: number;
  31947. /** Defines that alpha blending to SRC + DEST */
  31948. static readonly ALPHA_ONEONE: number;
  31949. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31950. static readonly ALPHA_PREMULTIPLIED: number;
  31951. /**
  31952. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31953. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31954. */
  31955. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31956. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31957. static readonly ALPHA_INTERPOLATE: number;
  31958. /**
  31959. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31960. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31961. */
  31962. static readonly ALPHA_SCREENMODE: number;
  31963. /** Defines that the ressource is not delayed*/
  31964. static readonly DELAYLOADSTATE_NONE: number;
  31965. /** Defines that the ressource was successfully delay loaded */
  31966. static readonly DELAYLOADSTATE_LOADED: number;
  31967. /** Defines that the ressource is currently delay loading */
  31968. static readonly DELAYLOADSTATE_LOADING: number;
  31969. /** Defines that the ressource is delayed and has not started loading */
  31970. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31972. static readonly NEVER: number;
  31973. /** 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 */
  31974. static readonly ALWAYS: number;
  31975. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31976. static readonly LESS: number;
  31977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31978. static readonly EQUAL: number;
  31979. /** 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 */
  31980. static readonly LEQUAL: number;
  31981. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31982. static readonly GREATER: number;
  31983. /** 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 */
  31984. static readonly GEQUAL: number;
  31985. /** 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 */
  31986. static readonly NOTEQUAL: number;
  31987. /** Passed to stencilOperation to specify that stencil value must be kept */
  31988. static readonly KEEP: number;
  31989. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31990. static readonly REPLACE: number;
  31991. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31992. static readonly INCR: number;
  31993. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31994. static readonly DECR: number;
  31995. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31996. static readonly INVERT: number;
  31997. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31998. static readonly INCR_WRAP: number;
  31999. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32000. static readonly DECR_WRAP: number;
  32001. /** Texture is not repeating outside of 0..1 UVs */
  32002. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32003. /** Texture is repeating outside of 0..1 UVs */
  32004. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32005. /** Texture is repeating and mirrored */
  32006. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32007. /** ALPHA */
  32008. static readonly TEXTUREFORMAT_ALPHA: number;
  32009. /** LUMINANCE */
  32010. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32011. /** LUMINANCE_ALPHA */
  32012. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32013. /** RGB */
  32014. static readonly TEXTUREFORMAT_RGB: number;
  32015. /** RGBA */
  32016. static readonly TEXTUREFORMAT_RGBA: number;
  32017. /** RED */
  32018. static readonly TEXTUREFORMAT_RED: number;
  32019. /** RED (2nd reference) */
  32020. static readonly TEXTUREFORMAT_R: number;
  32021. /** RG */
  32022. static readonly TEXTUREFORMAT_RG: number;
  32023. /** RED_INTEGER */
  32024. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32025. /** RED_INTEGER (2nd reference) */
  32026. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32027. /** RG_INTEGER */
  32028. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32029. /** RGB_INTEGER */
  32030. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32031. /** RGBA_INTEGER */
  32032. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32033. /** UNSIGNED_BYTE */
  32034. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32035. /** UNSIGNED_BYTE (2nd reference) */
  32036. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32037. /** FLOAT */
  32038. static readonly TEXTURETYPE_FLOAT: number;
  32039. /** HALF_FLOAT */
  32040. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32041. /** BYTE */
  32042. static readonly TEXTURETYPE_BYTE: number;
  32043. /** SHORT */
  32044. static readonly TEXTURETYPE_SHORT: number;
  32045. /** UNSIGNED_SHORT */
  32046. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32047. /** INT */
  32048. static readonly TEXTURETYPE_INT: number;
  32049. /** UNSIGNED_INT */
  32050. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32051. /** UNSIGNED_SHORT_4_4_4_4 */
  32052. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32053. /** UNSIGNED_SHORT_5_5_5_1 */
  32054. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32055. /** UNSIGNED_SHORT_5_6_5 */
  32056. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32057. /** UNSIGNED_INT_2_10_10_10_REV */
  32058. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32059. /** UNSIGNED_INT_24_8 */
  32060. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32061. /** UNSIGNED_INT_10F_11F_11F_REV */
  32062. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32063. /** UNSIGNED_INT_5_9_9_9_REV */
  32064. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32065. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32066. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32067. /** nearest is mag = nearest and min = nearest and mip = linear */
  32068. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32069. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32070. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32071. /** Trilinear is mag = linear and min = linear and mip = linear */
  32072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32073. /** nearest is mag = nearest and min = nearest and mip = linear */
  32074. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32076. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32077. /** Trilinear is mag = linear and min = linear and mip = linear */
  32078. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32079. /** mag = nearest and min = nearest and mip = nearest */
  32080. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32081. /** mag = nearest and min = linear and mip = nearest */
  32082. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32083. /** mag = nearest and min = linear and mip = linear */
  32084. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32085. /** mag = nearest and min = linear and mip = none */
  32086. static readonly TEXTURE_NEAREST_LINEAR: number;
  32087. /** mag = nearest and min = nearest and mip = none */
  32088. static readonly TEXTURE_NEAREST_NEAREST: number;
  32089. /** mag = linear and min = nearest and mip = nearest */
  32090. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32091. /** mag = linear and min = nearest and mip = linear */
  32092. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32093. /** mag = linear and min = linear and mip = none */
  32094. static readonly TEXTURE_LINEAR_LINEAR: number;
  32095. /** mag = linear and min = nearest and mip = none */
  32096. static readonly TEXTURE_LINEAR_NEAREST: number;
  32097. /** Explicit coordinates mode */
  32098. static readonly TEXTURE_EXPLICIT_MODE: number;
  32099. /** Spherical coordinates mode */
  32100. static readonly TEXTURE_SPHERICAL_MODE: number;
  32101. /** Planar coordinates mode */
  32102. static readonly TEXTURE_PLANAR_MODE: number;
  32103. /** Cubic coordinates mode */
  32104. static readonly TEXTURE_CUBIC_MODE: number;
  32105. /** Projection coordinates mode */
  32106. static readonly TEXTURE_PROJECTION_MODE: number;
  32107. /** Skybox coordinates mode */
  32108. static readonly TEXTURE_SKYBOX_MODE: number;
  32109. /** Inverse Cubic coordinates mode */
  32110. static readonly TEXTURE_INVCUBIC_MODE: number;
  32111. /** Equirectangular coordinates mode */
  32112. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32113. /** Equirectangular Fixed coordinates mode */
  32114. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32115. /** Equirectangular Fixed Mirrored coordinates mode */
  32116. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32117. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32118. static readonly SCALEMODE_FLOOR: number;
  32119. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32120. static readonly SCALEMODE_NEAREST: number;
  32121. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32122. static readonly SCALEMODE_CEILING: number;
  32123. /**
  32124. * Returns the current npm package of the sdk
  32125. */
  32126. static readonly NpmPackage: string;
  32127. /**
  32128. * Returns the current version of the framework
  32129. */
  32130. static readonly Version: string;
  32131. /** Gets the list of created engines */
  32132. static readonly Instances: Engine[];
  32133. /**
  32134. * Gets the latest created engine
  32135. */
  32136. static readonly LastCreatedEngine: Nullable<Engine>;
  32137. /**
  32138. * Gets the latest created scene
  32139. */
  32140. static readonly LastCreatedScene: Nullable<Scene>;
  32141. /**
  32142. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32143. * @param flag defines which part of the materials must be marked as dirty
  32144. * @param predicate defines a predicate used to filter which materials should be affected
  32145. */
  32146. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32147. /**
  32148. * Method called to create the default loading screen.
  32149. * This can be overriden in your own app.
  32150. * @param canvas The rendering canvas element
  32151. * @returns The loading screen
  32152. */
  32153. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32154. /**
  32155. * Method called to create the default rescale post process on each engine.
  32156. */
  32157. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32158. /**
  32159. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32160. **/
  32161. enableOfflineSupport: boolean;
  32162. /**
  32163. * 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)
  32164. **/
  32165. disableManifestCheck: boolean;
  32166. /**
  32167. * Gets the list of created scenes
  32168. */
  32169. scenes: Scene[];
  32170. /**
  32171. * Event raised when a new scene is created
  32172. */
  32173. onNewSceneAddedObservable: Observable<Scene>;
  32174. /**
  32175. * Gets the list of created postprocesses
  32176. */
  32177. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32178. /**
  32179. * Gets a boolean indicating if the pointer is currently locked
  32180. */
  32181. isPointerLock: boolean;
  32182. /**
  32183. * Observable event triggered each time the rendering canvas is resized
  32184. */
  32185. onResizeObservable: Observable<Engine>;
  32186. /**
  32187. * Observable event triggered each time the canvas loses focus
  32188. */
  32189. onCanvasBlurObservable: Observable<Engine>;
  32190. /**
  32191. * Observable event triggered each time the canvas gains focus
  32192. */
  32193. onCanvasFocusObservable: Observable<Engine>;
  32194. /**
  32195. * Observable event triggered each time the canvas receives pointerout event
  32196. */
  32197. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32198. /**
  32199. * Observable raised when the engine begins a new frame
  32200. */
  32201. onBeginFrameObservable: Observable<Engine>;
  32202. /**
  32203. * If set, will be used to request the next animation frame for the render loop
  32204. */
  32205. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32206. /**
  32207. * Observable raised when the engine ends the current frame
  32208. */
  32209. onEndFrameObservable: Observable<Engine>;
  32210. /**
  32211. * Observable raised when the engine is about to compile a shader
  32212. */
  32213. onBeforeShaderCompilationObservable: Observable<Engine>;
  32214. /**
  32215. * Observable raised when the engine has jsut compiled a shader
  32216. */
  32217. onAfterShaderCompilationObservable: Observable<Engine>;
  32218. /**
  32219. * Gets the audio engine
  32220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32221. * @ignorenaming
  32222. */
  32223. static audioEngine: IAudioEngine;
  32224. /**
  32225. * Default AudioEngine factory responsible of creating the Audio Engine.
  32226. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32227. */
  32228. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32229. /**
  32230. * Default offline support factory responsible of creating a tool used to store data locally.
  32231. * By default, this will create a Database object if the workload has been embedded.
  32232. */
  32233. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32234. private _loadingScreen;
  32235. private _pointerLockRequested;
  32236. private _dummyFramebuffer;
  32237. private _rescalePostProcess;
  32238. /** @hidden */
  32239. protected _alphaMode: number;
  32240. /** @hidden */
  32241. protected _alphaEquation: number;
  32242. private _deterministicLockstep;
  32243. private _lockstepMaxSteps;
  32244. protected readonly _supportsHardwareTextureRescaling: boolean;
  32245. private _fps;
  32246. private _deltaTime;
  32247. /** @hidden */
  32248. _drawCalls: PerfCounter;
  32249. /**
  32250. * Turn this value on if you want to pause FPS computation when in background
  32251. */
  32252. disablePerformanceMonitorInBackground: boolean;
  32253. private _performanceMonitor;
  32254. /**
  32255. * Gets the performance monitor attached to this engine
  32256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32257. */
  32258. readonly performanceMonitor: PerformanceMonitor;
  32259. private _onFocus;
  32260. private _onBlur;
  32261. private _onCanvasPointerOut;
  32262. private _onCanvasBlur;
  32263. private _onCanvasFocus;
  32264. private _onFullscreenChange;
  32265. private _onPointerLockChange;
  32266. /**
  32267. * Creates a new engine
  32268. * @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
  32269. * @param antialias defines enable antialiasing (default: false)
  32270. * @param options defines further options to be sent to the getContext() function
  32271. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32272. */
  32273. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32274. /**
  32275. * Gets current aspect ratio
  32276. * @param viewportOwner defines the camera to use to get the aspect ratio
  32277. * @param useScreen defines if screen size must be used (or the current render target if any)
  32278. * @returns a number defining the aspect ratio
  32279. */
  32280. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32281. /**
  32282. * Gets current screen aspect ratio
  32283. * @returns a number defining the aspect ratio
  32284. */
  32285. getScreenAspectRatio(): number;
  32286. /**
  32287. * Gets host document
  32288. * @returns the host document object
  32289. */
  32290. getHostDocument(): Document;
  32291. /**
  32292. * Gets the client rect of the HTML canvas attached with the current webGL context
  32293. * @returns a client rectanglee
  32294. */
  32295. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32296. /**
  32297. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32299. * @returns true if engine is in deterministic lock step mode
  32300. */
  32301. isDeterministicLockStep(): boolean;
  32302. /**
  32303. * Gets the max steps when engine is running in deterministic lock step
  32304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32305. * @returns the max steps
  32306. */
  32307. getLockstepMaxSteps(): number;
  32308. /**
  32309. * Force the mipmap generation for the given render target texture
  32310. * @param texture defines the render target texture to use
  32311. */
  32312. generateMipMapsForCubemap(texture: InternalTexture): void;
  32313. /** States */
  32314. /**
  32315. * Set various states to the webGL context
  32316. * @param culling defines backface culling state
  32317. * @param zOffset defines the value to apply to zOffset (0 by default)
  32318. * @param force defines if states must be applied even if cache is up to date
  32319. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32320. */
  32321. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32322. /**
  32323. * Set the z offset to apply to current rendering
  32324. * @param value defines the offset to apply
  32325. */
  32326. setZOffset(value: number): void;
  32327. /**
  32328. * Gets the current value of the zOffset
  32329. * @returns the current zOffset state
  32330. */
  32331. getZOffset(): number;
  32332. /**
  32333. * Enable or disable depth buffering
  32334. * @param enable defines the state to set
  32335. */
  32336. setDepthBuffer(enable: boolean): void;
  32337. /**
  32338. * Gets a boolean indicating if depth writing is enabled
  32339. * @returns the current depth writing state
  32340. */
  32341. getDepthWrite(): boolean;
  32342. /**
  32343. * Enable or disable depth writing
  32344. * @param enable defines the state to set
  32345. */
  32346. setDepthWrite(enable: boolean): void;
  32347. /**
  32348. * Enable or disable color writing
  32349. * @param enable defines the state to set
  32350. */
  32351. setColorWrite(enable: boolean): void;
  32352. /**
  32353. * Gets a boolean indicating if color writing is enabled
  32354. * @returns the current color writing state
  32355. */
  32356. getColorWrite(): boolean;
  32357. /**
  32358. * Sets alpha constants used by some alpha blending modes
  32359. * @param r defines the red component
  32360. * @param g defines the green component
  32361. * @param b defines the blue component
  32362. * @param a defines the alpha component
  32363. */
  32364. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32365. /**
  32366. * Sets the current alpha mode
  32367. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32368. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32369. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32370. */
  32371. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32372. /**
  32373. * Gets the current alpha mode
  32374. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32375. * @returns the current alpha mode
  32376. */
  32377. getAlphaMode(): number;
  32378. /**
  32379. * Sets the current alpha equation
  32380. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32381. */
  32382. setAlphaEquation(equation: number): void;
  32383. /**
  32384. * Gets the current alpha equation.
  32385. * @returns the current alpha equation
  32386. */
  32387. getAlphaEquation(): number;
  32388. /**
  32389. * Gets a boolean indicating if stencil buffer is enabled
  32390. * @returns the current stencil buffer state
  32391. */
  32392. getStencilBuffer(): boolean;
  32393. /**
  32394. * Enable or disable the stencil buffer
  32395. * @param enable defines if the stencil buffer must be enabled or disabled
  32396. */
  32397. setStencilBuffer(enable: boolean): void;
  32398. /**
  32399. * Gets the current stencil mask
  32400. * @returns a number defining the new stencil mask to use
  32401. */
  32402. getStencilMask(): number;
  32403. /**
  32404. * Sets the current stencil mask
  32405. * @param mask defines the new stencil mask to use
  32406. */
  32407. setStencilMask(mask: number): void;
  32408. /**
  32409. * Gets the current stencil function
  32410. * @returns a number defining the stencil function to use
  32411. */
  32412. getStencilFunction(): number;
  32413. /**
  32414. * Gets the current stencil reference value
  32415. * @returns a number defining the stencil reference value to use
  32416. */
  32417. getStencilFunctionReference(): number;
  32418. /**
  32419. * Gets the current stencil mask
  32420. * @returns a number defining the stencil mask to use
  32421. */
  32422. getStencilFunctionMask(): number;
  32423. /**
  32424. * Sets the current stencil function
  32425. * @param stencilFunc defines the new stencil function to use
  32426. */
  32427. setStencilFunction(stencilFunc: number): void;
  32428. /**
  32429. * Sets the current stencil reference
  32430. * @param reference defines the new stencil reference to use
  32431. */
  32432. setStencilFunctionReference(reference: number): void;
  32433. /**
  32434. * Sets the current stencil mask
  32435. * @param mask defines the new stencil mask to use
  32436. */
  32437. setStencilFunctionMask(mask: number): void;
  32438. /**
  32439. * Gets the current stencil operation when stencil fails
  32440. * @returns a number defining stencil operation to use when stencil fails
  32441. */
  32442. getStencilOperationFail(): number;
  32443. /**
  32444. * Gets the current stencil operation when depth fails
  32445. * @returns a number defining stencil operation to use when depth fails
  32446. */
  32447. getStencilOperationDepthFail(): number;
  32448. /**
  32449. * Gets the current stencil operation when stencil passes
  32450. * @returns a number defining stencil operation to use when stencil passes
  32451. */
  32452. getStencilOperationPass(): number;
  32453. /**
  32454. * Sets the stencil operation to use when stencil fails
  32455. * @param operation defines the stencil operation to use when stencil fails
  32456. */
  32457. setStencilOperationFail(operation: number): void;
  32458. /**
  32459. * Sets the stencil operation to use when depth fails
  32460. * @param operation defines the stencil operation to use when depth fails
  32461. */
  32462. setStencilOperationDepthFail(operation: number): void;
  32463. /**
  32464. * Sets the stencil operation to use when stencil passes
  32465. * @param operation defines the stencil operation to use when stencil passes
  32466. */
  32467. setStencilOperationPass(operation: number): void;
  32468. /**
  32469. * Sets a boolean indicating if the dithering state is enabled or disabled
  32470. * @param value defines the dithering state
  32471. */
  32472. setDitheringState(value: boolean): void;
  32473. /**
  32474. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32475. * @param value defines the rasterizer state
  32476. */
  32477. setRasterizerState(value: boolean): void;
  32478. /**
  32479. * Gets the current depth function
  32480. * @returns a number defining the depth function
  32481. */
  32482. getDepthFunction(): Nullable<number>;
  32483. /**
  32484. * Sets the current depth function
  32485. * @param depthFunc defines the function to use
  32486. */
  32487. setDepthFunction(depthFunc: number): void;
  32488. /**
  32489. * Sets the current depth function to GREATER
  32490. */
  32491. setDepthFunctionToGreater(): void;
  32492. /**
  32493. * Sets the current depth function to GEQUAL
  32494. */
  32495. setDepthFunctionToGreaterOrEqual(): void;
  32496. /**
  32497. * Sets the current depth function to LESS
  32498. */
  32499. setDepthFunctionToLess(): void;
  32500. /**
  32501. * Sets the current depth function to LEQUAL
  32502. */
  32503. setDepthFunctionToLessOrEqual(): void;
  32504. private _cachedStencilBuffer;
  32505. private _cachedStencilFunction;
  32506. private _cachedStencilMask;
  32507. private _cachedStencilOperationPass;
  32508. private _cachedStencilOperationFail;
  32509. private _cachedStencilOperationDepthFail;
  32510. private _cachedStencilReference;
  32511. /**
  32512. * Caches the the state of the stencil buffer
  32513. */
  32514. cacheStencilState(): void;
  32515. /**
  32516. * Restores the state of the stencil buffer
  32517. */
  32518. restoreStencilState(): void;
  32519. /**
  32520. * Directly set the WebGL Viewport
  32521. * @param x defines the x coordinate of the viewport (in screen space)
  32522. * @param y defines the y coordinate of the viewport (in screen space)
  32523. * @param width defines the width of the viewport (in screen space)
  32524. * @param height defines the height of the viewport (in screen space)
  32525. * @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
  32526. */
  32527. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32528. /**
  32529. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32530. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32531. * @param y defines the y-coordinate of the corner of the clear rectangle
  32532. * @param width defines the width of the clear rectangle
  32533. * @param height defines the height of the clear rectangle
  32534. * @param clearColor defines the clear color
  32535. */
  32536. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32537. /**
  32538. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32539. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32540. * @param y defines the y-coordinate of the corner of the clear rectangle
  32541. * @param width defines the width of the clear rectangle
  32542. * @param height defines the height of the clear rectangle
  32543. */
  32544. enableScissor(x: number, y: number, width: number, height: number): void;
  32545. /**
  32546. * Disable previously set scissor test rectangle
  32547. */
  32548. disableScissor(): void;
  32549. protected _reportDrawCall(): void;
  32550. /**
  32551. * Initializes a webVR display and starts listening to display change events
  32552. * The onVRDisplayChangedObservable will be notified upon these changes
  32553. * @returns The onVRDisplayChangedObservable
  32554. */
  32555. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32556. /** @hidden */
  32557. _prepareVRComponent(): void;
  32558. /** @hidden */
  32559. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32560. /** @hidden */
  32561. _submitVRFrame(): void;
  32562. /**
  32563. * Call this function to leave webVR mode
  32564. * Will do nothing if webVR is not supported or if there is no webVR device
  32565. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32566. */
  32567. disableVR(): void;
  32568. /**
  32569. * Gets a boolean indicating that the system is in VR mode and is presenting
  32570. * @returns true if VR mode is engaged
  32571. */
  32572. isVRPresenting(): boolean;
  32573. /** @hidden */
  32574. _requestVRFrame(): void;
  32575. /** @hidden */
  32576. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32577. /**
  32578. * Gets the source code of the vertex shader associated with a specific webGL program
  32579. * @param program defines the program to use
  32580. * @returns a string containing the source code of the vertex shader associated with the program
  32581. */
  32582. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32583. /**
  32584. * Gets the source code of the fragment shader associated with a specific webGL program
  32585. * @param program defines the program to use
  32586. * @returns a string containing the source code of the fragment shader associated with the program
  32587. */
  32588. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32589. /**
  32590. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32591. * @param x defines the x coordinate of the rectangle where pixels must be read
  32592. * @param y defines the y coordinate of the rectangle where pixels must be read
  32593. * @param width defines the width of the rectangle where pixels must be read
  32594. * @param height defines the height of the rectangle where pixels must be read
  32595. * @returns a Uint8Array containing RGBA colors
  32596. */
  32597. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32598. /**
  32599. * Sets a depth stencil texture from a render target to the according uniform.
  32600. * @param channel The texture channel
  32601. * @param uniform The uniform to set
  32602. * @param texture The render target texture containing the depth stencil texture to apply
  32603. */
  32604. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32605. /**
  32606. * Sets a texture to the webGL context from a postprocess
  32607. * @param channel defines the channel to use
  32608. * @param postProcess defines the source postprocess
  32609. */
  32610. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32611. /**
  32612. * Binds the output of the passed in post process to the texture channel specified
  32613. * @param channel The channel the texture should be bound to
  32614. * @param postProcess The post process which's output should be bound
  32615. */
  32616. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32617. /** @hidden */
  32618. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32619. protected _rebuildBuffers(): void;
  32620. _renderLoop(): void;
  32621. /**
  32622. * Toggle full screen mode
  32623. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32624. */
  32625. switchFullscreen(requestPointerLock: boolean): void;
  32626. /**
  32627. * Enters full screen mode
  32628. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32629. */
  32630. enterFullscreen(requestPointerLock: boolean): void;
  32631. /**
  32632. * Exits full screen mode
  32633. */
  32634. exitFullscreen(): void;
  32635. /**
  32636. * Enters Pointerlock mode
  32637. */
  32638. enterPointerlock(): void;
  32639. /**
  32640. * Exits Pointerlock mode
  32641. */
  32642. exitPointerlock(): void;
  32643. /**
  32644. * Begin a new frame
  32645. */
  32646. beginFrame(): void;
  32647. /**
  32648. * Enf the current frame
  32649. */
  32650. endFrame(): void;
  32651. resize(): void;
  32652. /**
  32653. * Set the compressed texture format to use, based on the formats you have, and the formats
  32654. * supported by the hardware / browser.
  32655. *
  32656. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32657. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32658. * to API arguments needed to compressed textures. This puts the burden on the container
  32659. * generator to house the arcane code for determining these for current & future formats.
  32660. *
  32661. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32662. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32663. *
  32664. * Note: The result of this call is not taken into account when a texture is base64.
  32665. *
  32666. * @param formatsAvailable defines the list of those format families you have created
  32667. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32668. *
  32669. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32670. * @returns The extension selected.
  32671. */
  32672. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32673. /**
  32674. * Force a specific size of the canvas
  32675. * @param width defines the new canvas' width
  32676. * @param height defines the new canvas' height
  32677. */
  32678. setSize(width: number, height: number): void;
  32679. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32680. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32682. _releaseTexture(texture: InternalTexture): void;
  32683. /**
  32684. * @hidden
  32685. * Rescales a texture
  32686. * @param source input texutre
  32687. * @param destination destination texture
  32688. * @param scene scene to use to render the resize
  32689. * @param internalFormat format to use when resizing
  32690. * @param onComplete callback to be called when resize has completed
  32691. */
  32692. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32693. /**
  32694. * Gets the current framerate
  32695. * @returns a number representing the framerate
  32696. */
  32697. getFps(): number;
  32698. /**
  32699. * Gets the time spent between current and previous frame
  32700. * @returns a number representing the delta time in ms
  32701. */
  32702. getDeltaTime(): number;
  32703. private _measureFps;
  32704. /**
  32705. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32706. * @param renderTarget The render target to set the frame buffer for
  32707. */
  32708. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32709. /**
  32710. * Update a dynamic index buffer
  32711. * @param indexBuffer defines the target index buffer
  32712. * @param indices defines the data to update
  32713. * @param offset defines the offset in the target index buffer where update should start
  32714. */
  32715. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32716. /**
  32717. * Updates the sample count of a render target texture
  32718. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32719. * @param texture defines the texture to update
  32720. * @param samples defines the sample count to set
  32721. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32722. */
  32723. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32724. /** @hidden */
  32725. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32726. dispose(): void;
  32727. private _disableTouchAction;
  32728. /**
  32729. * Display the loading screen
  32730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32731. */
  32732. displayLoadingUI(): void;
  32733. /**
  32734. * Hide the loading screen
  32735. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32736. */
  32737. hideLoadingUI(): void;
  32738. /**
  32739. * Gets the current loading screen object
  32740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32741. */
  32742. /**
  32743. * Sets the current loading screen object
  32744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32745. */
  32746. loadingScreen: ILoadingScreen;
  32747. /**
  32748. * Sets the current loading screen text
  32749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32750. */
  32751. loadingUIText: string;
  32752. /**
  32753. * Sets the current loading screen background color
  32754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32755. */
  32756. loadingUIBackgroundColor: string;
  32757. /** Pointerlock and fullscreen */
  32758. /**
  32759. * Ask the browser to promote the current element to pointerlock mode
  32760. * @param element defines the DOM element to promote
  32761. */
  32762. static _RequestPointerlock(element: HTMLElement): void;
  32763. /**
  32764. * Asks the browser to exit pointerlock mode
  32765. */
  32766. static _ExitPointerlock(): void;
  32767. /**
  32768. * Ask the browser to promote the current element to fullscreen rendering mode
  32769. * @param element defines the DOM element to promote
  32770. */
  32771. static _RequestFullscreen(element: HTMLElement): void;
  32772. /**
  32773. * Asks the browser to exit fullscreen mode
  32774. */
  32775. static _ExitFullscreen(): void;
  32776. }
  32777. }
  32778. declare module "babylonjs/Engines/engineStore" {
  32779. import { Nullable } from "babylonjs/types";
  32780. import { Engine } from "babylonjs/Engines/engine";
  32781. import { Scene } from "babylonjs/scene";
  32782. /**
  32783. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32784. * during the life time of the application.
  32785. */
  32786. export class EngineStore {
  32787. /** Gets the list of created engines */
  32788. static Instances: import("babylonjs/Engines/engine").Engine[];
  32789. /** @hidden */
  32790. static _LastCreatedScene: Nullable<Scene>;
  32791. /**
  32792. * Gets the latest created engine
  32793. */
  32794. static readonly LastCreatedEngine: Nullable<Engine>;
  32795. /**
  32796. * Gets the latest created scene
  32797. */
  32798. static readonly LastCreatedScene: Nullable<Scene>;
  32799. /**
  32800. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32801. * @ignorenaming
  32802. */
  32803. static UseFallbackTexture: boolean;
  32804. /**
  32805. * Texture content used if a texture cannot loaded
  32806. * @ignorenaming
  32807. */
  32808. static FallbackTexture: string;
  32809. }
  32810. }
  32811. declare module "babylonjs/Misc/promise" {
  32812. /**
  32813. * Helper class that provides a small promise polyfill
  32814. */
  32815. export class PromisePolyfill {
  32816. /**
  32817. * Static function used to check if the polyfill is required
  32818. * If this is the case then the function will inject the polyfill to window.Promise
  32819. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32820. */
  32821. static Apply(force?: boolean): void;
  32822. }
  32823. }
  32824. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32825. /**
  32826. * Interface for screenshot methods with describe argument called `size` as object with options
  32827. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32828. */
  32829. export interface IScreenshotSize {
  32830. /**
  32831. * number in pixels for canvas height
  32832. */
  32833. height?: number;
  32834. /**
  32835. * multiplier allowing render at a higher or lower resolution
  32836. * If value is defined then height and width will be ignored and taken from camera
  32837. */
  32838. precision?: number;
  32839. /**
  32840. * number in pixels for canvas width
  32841. */
  32842. width?: number;
  32843. }
  32844. }
  32845. declare module "babylonjs/Misc/tools" {
  32846. import { Nullable, float } from "babylonjs/types";
  32847. import { DomManagement } from "babylonjs/Misc/domManagement";
  32848. import { WebRequest } from "babylonjs/Misc/webRequest";
  32849. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32851. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32852. import { Camera } from "babylonjs/Cameras/camera";
  32853. import { Engine } from "babylonjs/Engines/engine";
  32854. interface IColor4Like {
  32855. r: float;
  32856. g: float;
  32857. b: float;
  32858. a: float;
  32859. }
  32860. /**
  32861. * Class containing a set of static utilities functions
  32862. */
  32863. export class Tools {
  32864. /**
  32865. * Gets or sets the base URL to use to load assets
  32866. */
  32867. static BaseUrl: string;
  32868. /**
  32869. * Enable/Disable Custom HTTP Request Headers globally.
  32870. * default = false
  32871. * @see CustomRequestHeaders
  32872. */
  32873. static UseCustomRequestHeaders: boolean;
  32874. /**
  32875. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32876. * i.e. when loading files, where the server/service expects an Authorization header
  32877. */
  32878. static CustomRequestHeaders: {
  32879. [key: string]: string;
  32880. };
  32881. /**
  32882. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32883. */
  32884. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32885. /**
  32886. * Default behaviour for cors in the application.
  32887. * It can be a string if the expected behavior is identical in the entire app.
  32888. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32889. */
  32890. static CorsBehavior: string | ((url: string | string[]) => string);
  32891. /**
  32892. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32893. * @ignorenaming
  32894. */
  32895. static UseFallbackTexture: boolean;
  32896. /**
  32897. * Use this object to register external classes like custom textures or material
  32898. * to allow the laoders to instantiate them
  32899. */
  32900. static RegisteredExternalClasses: {
  32901. [key: string]: Object;
  32902. };
  32903. /**
  32904. * Texture content used if a texture cannot loaded
  32905. * @ignorenaming
  32906. */
  32907. static fallbackTexture: string;
  32908. /**
  32909. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32910. * @param u defines the coordinate on X axis
  32911. * @param v defines the coordinate on Y axis
  32912. * @param width defines the width of the source data
  32913. * @param height defines the height of the source data
  32914. * @param pixels defines the source byte array
  32915. * @param color defines the output color
  32916. */
  32917. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32918. /**
  32919. * Interpolates between a and b via alpha
  32920. * @param a The lower value (returned when alpha = 0)
  32921. * @param b The upper value (returned when alpha = 1)
  32922. * @param alpha The interpolation-factor
  32923. * @return The mixed value
  32924. */
  32925. static Mix(a: number, b: number, alpha: number): number;
  32926. /**
  32927. * Tries to instantiate a new object from a given class name
  32928. * @param className defines the class name to instantiate
  32929. * @returns the new object or null if the system was not able to do the instantiation
  32930. */
  32931. static Instantiate(className: string): any;
  32932. /**
  32933. * Provides a slice function that will work even on IE
  32934. * @param data defines the array to slice
  32935. * @param start defines the start of the data (optional)
  32936. * @param end defines the end of the data (optional)
  32937. * @returns the new sliced array
  32938. */
  32939. static Slice<T>(data: T, start?: number, end?: number): T;
  32940. /**
  32941. * Polyfill for setImmediate
  32942. * @param action defines the action to execute after the current execution block
  32943. */
  32944. static SetImmediate(action: () => void): void;
  32945. /**
  32946. * Function indicating if a number is an exponent of 2
  32947. * @param value defines the value to test
  32948. * @returns true if the value is an exponent of 2
  32949. */
  32950. static IsExponentOfTwo(value: number): boolean;
  32951. private static _tmpFloatArray;
  32952. /**
  32953. * Returns the nearest 32-bit single precision float representation of a Number
  32954. * @param value A Number. If the parameter is of a different type, it will get converted
  32955. * to a number or to NaN if it cannot be converted
  32956. * @returns number
  32957. */
  32958. static FloatRound(value: number): number;
  32959. /**
  32960. * Extracts the filename from a path
  32961. * @param path defines the path to use
  32962. * @returns the filename
  32963. */
  32964. static GetFilename(path: string): string;
  32965. /**
  32966. * Extracts the "folder" part of a path (everything before the filename).
  32967. * @param uri The URI to extract the info from
  32968. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32969. * @returns The "folder" part of the path
  32970. */
  32971. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32972. /**
  32973. * Extracts text content from a DOM element hierarchy
  32974. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32975. */
  32976. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32977. /**
  32978. * Convert an angle in radians to degrees
  32979. * @param angle defines the angle to convert
  32980. * @returns the angle in degrees
  32981. */
  32982. static ToDegrees(angle: number): number;
  32983. /**
  32984. * Convert an angle in degrees to radians
  32985. * @param angle defines the angle to convert
  32986. * @returns the angle in radians
  32987. */
  32988. static ToRadians(angle: number): number;
  32989. /**
  32990. * Encode a buffer to a base64 string
  32991. * @param buffer defines the buffer to encode
  32992. * @returns the encoded string
  32993. */
  32994. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32995. /**
  32996. * Returns an array if obj is not an array
  32997. * @param obj defines the object to evaluate as an array
  32998. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32999. * @returns either obj directly if obj is an array or a new array containing obj
  33000. */
  33001. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33002. /**
  33003. * Gets the pointer prefix to use
  33004. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33005. */
  33006. static GetPointerPrefix(): string;
  33007. /**
  33008. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33009. * @param url define the url we are trying
  33010. * @param element define the dom element where to configure the cors policy
  33011. */
  33012. static SetCorsBehavior(url: string | string[], element: {
  33013. crossOrigin: string | null;
  33014. }): void;
  33015. /**
  33016. * Removes unwanted characters from an url
  33017. * @param url defines the url to clean
  33018. * @returns the cleaned url
  33019. */
  33020. static CleanUrl(url: string): string;
  33021. /**
  33022. * Gets or sets a function used to pre-process url before using them to load assets
  33023. */
  33024. static PreprocessUrl: (url: string) => string;
  33025. /**
  33026. * Loads an image as an HTMLImageElement.
  33027. * @param input url string, ArrayBuffer, or Blob to load
  33028. * @param onLoad callback called when the image successfully loads
  33029. * @param onError callback called when the image fails to load
  33030. * @param offlineProvider offline provider for caching
  33031. * @param mimeType optional mime type
  33032. * @returns the HTMLImageElement of the loaded image
  33033. */
  33034. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33035. /**
  33036. * Loads a file
  33037. * @param url url string, ArrayBuffer, or Blob to load
  33038. * @param onSuccess callback called when the file successfully loads
  33039. * @param onProgress callback called while file is loading (if the server supports this mode)
  33040. * @param offlineProvider defines the offline provider for caching
  33041. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33042. * @param onError callback called when the file fails to load
  33043. * @returns a file request object
  33044. */
  33045. 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;
  33046. /**
  33047. * Loads a file from a url
  33048. * @param url the file url to load
  33049. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33050. */
  33051. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33052. /**
  33053. * Load a script (identified by an url). When the url returns, the
  33054. * content of this file is added into a new script element, attached to the DOM (body element)
  33055. * @param scriptUrl defines the url of the script to laod
  33056. * @param onSuccess defines the callback called when the script is loaded
  33057. * @param onError defines the callback to call if an error occurs
  33058. * @param scriptId defines the id of the script element
  33059. */
  33060. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33061. /**
  33062. * Load an asynchronous script (identified by an url). When the url returns, the
  33063. * content of this file is added into a new script element, attached to the DOM (body element)
  33064. * @param scriptUrl defines the url of the script to laod
  33065. * @param scriptId defines the id of the script element
  33066. * @returns a promise request object
  33067. */
  33068. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33069. /**
  33070. * Loads a file from a blob
  33071. * @param fileToLoad defines the blob to use
  33072. * @param callback defines the callback to call when data is loaded
  33073. * @param progressCallback defines the callback to call during loading process
  33074. * @returns a file request object
  33075. */
  33076. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33077. /**
  33078. * Loads a file
  33079. * @param fileToLoad defines the file to load
  33080. * @param callback defines the callback to call when data is loaded
  33081. * @param progressCallBack defines the callback to call during loading process
  33082. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33083. * @returns a file request object
  33084. */
  33085. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33086. /**
  33087. * Creates a data url from a given string content
  33088. * @param content defines the content to convert
  33089. * @returns the new data url link
  33090. */
  33091. static FileAsURL(content: string): string;
  33092. /**
  33093. * Format the given number to a specific decimal format
  33094. * @param value defines the number to format
  33095. * @param decimals defines the number of decimals to use
  33096. * @returns the formatted string
  33097. */
  33098. static Format(value: number, decimals?: number): string;
  33099. /**
  33100. * Tries to copy an object by duplicating every property
  33101. * @param source defines the source object
  33102. * @param destination defines the target object
  33103. * @param doNotCopyList defines a list of properties to avoid
  33104. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33105. */
  33106. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33107. /**
  33108. * Gets a boolean indicating if the given object has no own property
  33109. * @param obj defines the object to test
  33110. * @returns true if object has no own property
  33111. */
  33112. static IsEmpty(obj: any): boolean;
  33113. /**
  33114. * Function used to register events at window level
  33115. * @param windowElement defines the Window object to use
  33116. * @param events defines the events to register
  33117. */
  33118. static RegisterTopRootEvents(windowElement: Window, events: {
  33119. name: string;
  33120. handler: Nullable<(e: FocusEvent) => any>;
  33121. }[]): void;
  33122. /**
  33123. * Function used to unregister events from window level
  33124. * @param windowElement defines the Window object to use
  33125. * @param events defines the events to unregister
  33126. */
  33127. static UnregisterTopRootEvents(windowElement: Window, events: {
  33128. name: string;
  33129. handler: Nullable<(e: FocusEvent) => any>;
  33130. }[]): void;
  33131. /**
  33132. * @ignore
  33133. */
  33134. static _ScreenshotCanvas: HTMLCanvasElement;
  33135. /**
  33136. * Dumps the current bound framebuffer
  33137. * @param width defines the rendering width
  33138. * @param height defines the rendering height
  33139. * @param engine defines the hosting engine
  33140. * @param successCallback defines the callback triggered once the data are available
  33141. * @param mimeType defines the mime type of the result
  33142. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33143. */
  33144. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33145. /**
  33146. * Converts the canvas data to blob.
  33147. * This acts as a polyfill for browsers not supporting the to blob function.
  33148. * @param canvas Defines the canvas to extract the data from
  33149. * @param successCallback Defines the callback triggered once the data are available
  33150. * @param mimeType Defines the mime type of the result
  33151. */
  33152. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33153. /**
  33154. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33155. * @param successCallback defines the callback triggered once the data are available
  33156. * @param mimeType defines the mime type of the result
  33157. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33158. */
  33159. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33160. /**
  33161. * Downloads a blob in the browser
  33162. * @param blob defines the blob to download
  33163. * @param fileName defines the name of the downloaded file
  33164. */
  33165. static Download(blob: Blob, fileName: string): void;
  33166. /**
  33167. * Captures a screenshot of the current rendering
  33168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33169. * @param engine defines the rendering engine
  33170. * @param camera defines the source camera
  33171. * @param size This parameter can be set to a single number or to an object with the
  33172. * following (optional) properties: precision, width, height. If a single number is passed,
  33173. * it will be used for both width and height. If an object is passed, the screenshot size
  33174. * will be derived from the parameters. The precision property is a multiplier allowing
  33175. * rendering at a higher or lower resolution
  33176. * @param successCallback defines the callback receives a single parameter which contains the
  33177. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33178. * src parameter of an <img> to display it
  33179. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33180. * Check your browser for supported MIME types
  33181. */
  33182. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33183. /**
  33184. * Captures a screenshot of the current rendering
  33185. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33186. * @param engine defines the rendering engine
  33187. * @param camera defines the source camera
  33188. * @param size This parameter can be set to a single number or to an object with the
  33189. * following (optional) properties: precision, width, height. If a single number is passed,
  33190. * it will be used for both width and height. If an object is passed, the screenshot size
  33191. * will be derived from the parameters. The precision property is a multiplier allowing
  33192. * rendering at a higher or lower resolution
  33193. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33194. * Check your browser for supported MIME types
  33195. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33196. * to the src parameter of an <img> to display it
  33197. */
  33198. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33199. /**
  33200. * Generates an image screenshot from the specified camera.
  33201. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33202. * @param engine The engine to use for rendering
  33203. * @param camera The camera to use for rendering
  33204. * @param size This parameter can be set to a single number or to an object with the
  33205. * following (optional) properties: precision, width, height. If a single number is passed,
  33206. * it will be used for both width and height. If an object is passed, the screenshot size
  33207. * will be derived from the parameters. The precision property is a multiplier allowing
  33208. * rendering at a higher or lower resolution
  33209. * @param successCallback The callback receives a single parameter which contains the
  33210. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33211. * src parameter of an <img> to display it
  33212. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33213. * Check your browser for supported MIME types
  33214. * @param samples Texture samples (default: 1)
  33215. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33216. * @param fileName A name for for the downloaded file.
  33217. */
  33218. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33219. /**
  33220. * Generates an image screenshot from the specified camera.
  33221. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33222. * @param engine The engine to use for rendering
  33223. * @param camera The camera to use for rendering
  33224. * @param size This parameter can be set to a single number or to an object with the
  33225. * following (optional) properties: precision, width, height. If a single number is passed,
  33226. * it will be used for both width and height. If an object is passed, the screenshot size
  33227. * will be derived from the parameters. The precision property is a multiplier allowing
  33228. * rendering at a higher or lower resolution
  33229. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33230. * Check your browser for supported MIME types
  33231. * @param samples Texture samples (default: 1)
  33232. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33233. * @param fileName A name for for the downloaded file.
  33234. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33235. * to the src parameter of an <img> to display it
  33236. */
  33237. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33238. /**
  33239. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33240. * Be aware Math.random() could cause collisions, but:
  33241. * "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"
  33242. * @returns a pseudo random id
  33243. */
  33244. static RandomId(): string;
  33245. /**
  33246. * Test if the given uri is a base64 string
  33247. * @param uri The uri to test
  33248. * @return True if the uri is a base64 string or false otherwise
  33249. */
  33250. static IsBase64(uri: string): boolean;
  33251. /**
  33252. * Decode the given base64 uri.
  33253. * @param uri The uri to decode
  33254. * @return The decoded base64 data.
  33255. */
  33256. static DecodeBase64(uri: string): ArrayBuffer;
  33257. /**
  33258. * Gets the absolute url.
  33259. * @param url the input url
  33260. * @return the absolute url
  33261. */
  33262. static GetAbsoluteUrl(url: string): string;
  33263. /**
  33264. * No log
  33265. */
  33266. static readonly NoneLogLevel: number;
  33267. /**
  33268. * Only message logs
  33269. */
  33270. static readonly MessageLogLevel: number;
  33271. /**
  33272. * Only warning logs
  33273. */
  33274. static readonly WarningLogLevel: number;
  33275. /**
  33276. * Only error logs
  33277. */
  33278. static readonly ErrorLogLevel: number;
  33279. /**
  33280. * All logs
  33281. */
  33282. static readonly AllLogLevel: number;
  33283. /**
  33284. * Gets a value indicating the number of loading errors
  33285. * @ignorenaming
  33286. */
  33287. static readonly errorsCount: number;
  33288. /**
  33289. * Callback called when a new log is added
  33290. */
  33291. static OnNewCacheEntry: (entry: string) => void;
  33292. /**
  33293. * Log a message to the console
  33294. * @param message defines the message to log
  33295. */
  33296. static Log(message: string): void;
  33297. /**
  33298. * Write a warning message to the console
  33299. * @param message defines the message to log
  33300. */
  33301. static Warn(message: string): void;
  33302. /**
  33303. * Write an error message to the console
  33304. * @param message defines the message to log
  33305. */
  33306. static Error(message: string): void;
  33307. /**
  33308. * Gets current log cache (list of logs)
  33309. */
  33310. static readonly LogCache: string;
  33311. /**
  33312. * Clears the log cache
  33313. */
  33314. static ClearLogCache(): void;
  33315. /**
  33316. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33317. */
  33318. static LogLevels: number;
  33319. /**
  33320. * Checks if the window object exists
  33321. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33322. */
  33323. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33324. /**
  33325. * No performance log
  33326. */
  33327. static readonly PerformanceNoneLogLevel: number;
  33328. /**
  33329. * Use user marks to log performance
  33330. */
  33331. static readonly PerformanceUserMarkLogLevel: number;
  33332. /**
  33333. * Log performance to the console
  33334. */
  33335. static readonly PerformanceConsoleLogLevel: number;
  33336. private static _performance;
  33337. /**
  33338. * Sets the current performance log level
  33339. */
  33340. static PerformanceLogLevel: number;
  33341. private static _StartPerformanceCounterDisabled;
  33342. private static _EndPerformanceCounterDisabled;
  33343. private static _StartUserMark;
  33344. private static _EndUserMark;
  33345. private static _StartPerformanceConsole;
  33346. private static _EndPerformanceConsole;
  33347. /**
  33348. * Starts a performance counter
  33349. */
  33350. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33351. /**
  33352. * Ends a specific performance coutner
  33353. */
  33354. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33355. /**
  33356. * Gets either window.performance.now() if supported or Date.now() else
  33357. */
  33358. static readonly Now: number;
  33359. /**
  33360. * This method will return the name of the class used to create the instance of the given object.
  33361. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33362. * @param object the object to get the class name from
  33363. * @param isType defines if the object is actually a type
  33364. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33365. */
  33366. static GetClassName(object: any, isType?: boolean): string;
  33367. /**
  33368. * Gets the first element of an array satisfying a given predicate
  33369. * @param array defines the array to browse
  33370. * @param predicate defines the predicate to use
  33371. * @returns null if not found or the element
  33372. */
  33373. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33374. /**
  33375. * This method will return the name of the full name of the class, including its owning module (if any).
  33376. * 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).
  33377. * @param object the object to get the class name from
  33378. * @param isType defines if the object is actually a type
  33379. * @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.
  33380. * @ignorenaming
  33381. */
  33382. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33383. /**
  33384. * Returns a promise that resolves after the given amount of time.
  33385. * @param delay Number of milliseconds to delay
  33386. * @returns Promise that resolves after the given amount of time
  33387. */
  33388. static DelayAsync(delay: number): Promise<void>;
  33389. }
  33390. /**
  33391. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33392. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33393. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33394. * @param name The name of the class, case should be preserved
  33395. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33396. */
  33397. export function className(name: string, module?: string): (target: Object) => void;
  33398. /**
  33399. * An implementation of a loop for asynchronous functions.
  33400. */
  33401. export class AsyncLoop {
  33402. /**
  33403. * Defines the number of iterations for the loop
  33404. */
  33405. iterations: number;
  33406. /**
  33407. * Defines the current index of the loop.
  33408. */
  33409. index: number;
  33410. private _done;
  33411. private _fn;
  33412. private _successCallback;
  33413. /**
  33414. * Constructor.
  33415. * @param iterations the number of iterations.
  33416. * @param func the function to run each iteration
  33417. * @param successCallback the callback that will be called upon succesful execution
  33418. * @param offset starting offset.
  33419. */
  33420. constructor(
  33421. /**
  33422. * Defines the number of iterations for the loop
  33423. */
  33424. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33425. /**
  33426. * Execute the next iteration. Must be called after the last iteration was finished.
  33427. */
  33428. executeNext(): void;
  33429. /**
  33430. * Break the loop and run the success callback.
  33431. */
  33432. breakLoop(): void;
  33433. /**
  33434. * Create and run an async loop.
  33435. * @param iterations the number of iterations.
  33436. * @param fn the function to run each iteration
  33437. * @param successCallback the callback that will be called upon succesful execution
  33438. * @param offset starting offset.
  33439. * @returns the created async loop object
  33440. */
  33441. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33442. /**
  33443. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33444. * @param iterations total number of iterations
  33445. * @param syncedIterations number of synchronous iterations in each async iteration.
  33446. * @param fn the function to call each iteration.
  33447. * @param callback a success call back that will be called when iterating stops.
  33448. * @param breakFunction a break condition (optional)
  33449. * @param timeout timeout settings for the setTimeout function. default - 0.
  33450. * @returns the created async loop object
  33451. */
  33452. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33453. }
  33454. }
  33455. declare module "babylonjs/Misc/stringDictionary" {
  33456. import { Nullable } from "babylonjs/types";
  33457. /**
  33458. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33459. * The underlying implementation relies on an associative array to ensure the best performances.
  33460. * The value can be anything including 'null' but except 'undefined'
  33461. */
  33462. export class StringDictionary<T> {
  33463. /**
  33464. * This will clear this dictionary and copy the content from the 'source' one.
  33465. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33466. * @param source the dictionary to take the content from and copy to this dictionary
  33467. */
  33468. copyFrom(source: StringDictionary<T>): void;
  33469. /**
  33470. * Get a value based from its key
  33471. * @param key the given key to get the matching value from
  33472. * @return the value if found, otherwise undefined is returned
  33473. */
  33474. get(key: string): T | undefined;
  33475. /**
  33476. * Get a value from its key or add it if it doesn't exist.
  33477. * This method will ensure you that a given key/data will be present in the dictionary.
  33478. * @param key the given key to get the matching value from
  33479. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33480. * The factory will only be invoked if there's no data for the given key.
  33481. * @return the value corresponding to the key.
  33482. */
  33483. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33484. /**
  33485. * Get a value from its key if present in the dictionary otherwise add it
  33486. * @param key the key to get the value from
  33487. * @param val if there's no such key/value pair in the dictionary add it with this value
  33488. * @return the value corresponding to the key
  33489. */
  33490. getOrAdd(key: string, val: T): T;
  33491. /**
  33492. * Check if there's a given key in the dictionary
  33493. * @param key the key to check for
  33494. * @return true if the key is present, false otherwise
  33495. */
  33496. contains(key: string): boolean;
  33497. /**
  33498. * Add a new key and its corresponding value
  33499. * @param key the key to add
  33500. * @param value the value corresponding to the key
  33501. * @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
  33502. */
  33503. add(key: string, value: T): boolean;
  33504. /**
  33505. * Update a specific value associated to a key
  33506. * @param key defines the key to use
  33507. * @param value defines the value to store
  33508. * @returns true if the value was updated (or false if the key was not found)
  33509. */
  33510. set(key: string, value: T): boolean;
  33511. /**
  33512. * Get the element of the given key and remove it from the dictionary
  33513. * @param key defines the key to search
  33514. * @returns the value associated with the key or null if not found
  33515. */
  33516. getAndRemove(key: string): Nullable<T>;
  33517. /**
  33518. * Remove a key/value from the dictionary.
  33519. * @param key the key to remove
  33520. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33521. */
  33522. remove(key: string): boolean;
  33523. /**
  33524. * Clear the whole content of the dictionary
  33525. */
  33526. clear(): void;
  33527. /**
  33528. * Gets the current count
  33529. */
  33530. readonly count: number;
  33531. /**
  33532. * Execute a callback on each key/val of the dictionary.
  33533. * Note that you can remove any element in this dictionary in the callback implementation
  33534. * @param callback the callback to execute on a given key/value pair
  33535. */
  33536. forEach(callback: (key: string, val: T) => void): void;
  33537. /**
  33538. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33539. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33540. * Note that you can remove any element in this dictionary in the callback implementation
  33541. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33542. * @returns the first item
  33543. */
  33544. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33545. private _count;
  33546. private _data;
  33547. }
  33548. }
  33549. declare module "babylonjs/Collisions/collisionCoordinator" {
  33550. import { Nullable } from "babylonjs/types";
  33551. import { Scene } from "babylonjs/scene";
  33552. import { Vector3 } from "babylonjs/Maths/math.vector";
  33553. import { Collider } from "babylonjs/Collisions/collider";
  33554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33555. /** @hidden */
  33556. export interface ICollisionCoordinator {
  33557. createCollider(): Collider;
  33558. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33559. init(scene: Scene): void;
  33560. }
  33561. /** @hidden */
  33562. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33563. private _scene;
  33564. private _scaledPosition;
  33565. private _scaledVelocity;
  33566. private _finalPosition;
  33567. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33568. createCollider(): Collider;
  33569. init(scene: Scene): void;
  33570. private _collideWithWorld;
  33571. }
  33572. }
  33573. declare module "babylonjs/Inputs/scene.inputManager" {
  33574. import { Nullable } from "babylonjs/types";
  33575. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33576. import { Vector2 } from "babylonjs/Maths/math.vector";
  33577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33578. import { Scene } from "babylonjs/scene";
  33579. /**
  33580. * Class used to manage all inputs for the scene.
  33581. */
  33582. export class InputManager {
  33583. /** The distance in pixel that you have to move to prevent some events */
  33584. static DragMovementThreshold: number;
  33585. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33586. static LongPressDelay: number;
  33587. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33588. static DoubleClickDelay: number;
  33589. /** If you need to check double click without raising a single click at first click, enable this flag */
  33590. static ExclusiveDoubleClickMode: boolean;
  33591. private _wheelEventName;
  33592. private _onPointerMove;
  33593. private _onPointerDown;
  33594. private _onPointerUp;
  33595. private _initClickEvent;
  33596. private _initActionManager;
  33597. private _delayedSimpleClick;
  33598. private _delayedSimpleClickTimeout;
  33599. private _previousDelayedSimpleClickTimeout;
  33600. private _meshPickProceed;
  33601. private _previousButtonPressed;
  33602. private _currentPickResult;
  33603. private _previousPickResult;
  33604. private _totalPointersPressed;
  33605. private _doubleClickOccured;
  33606. private _pointerOverMesh;
  33607. private _pickedDownMesh;
  33608. private _pickedUpMesh;
  33609. private _pointerX;
  33610. private _pointerY;
  33611. private _unTranslatedPointerX;
  33612. private _unTranslatedPointerY;
  33613. private _startingPointerPosition;
  33614. private _previousStartingPointerPosition;
  33615. private _startingPointerTime;
  33616. private _previousStartingPointerTime;
  33617. private _pointerCaptures;
  33618. private _onKeyDown;
  33619. private _onKeyUp;
  33620. private _onCanvasFocusObserver;
  33621. private _onCanvasBlurObserver;
  33622. private _scene;
  33623. /**
  33624. * Creates a new InputManager
  33625. * @param scene defines the hosting scene
  33626. */
  33627. constructor(scene: Scene);
  33628. /**
  33629. * Gets the mesh that is currently under the pointer
  33630. */
  33631. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33632. /**
  33633. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33634. */
  33635. readonly unTranslatedPointer: Vector2;
  33636. /**
  33637. * Gets or sets the current on-screen X position of the pointer
  33638. */
  33639. pointerX: number;
  33640. /**
  33641. * Gets or sets the current on-screen Y position of the pointer
  33642. */
  33643. pointerY: number;
  33644. private _updatePointerPosition;
  33645. private _processPointerMove;
  33646. private _setRayOnPointerInfo;
  33647. private _checkPrePointerObservable;
  33648. /**
  33649. * Use this method to simulate a pointer move on a mesh
  33650. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33651. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33652. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33653. */
  33654. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33655. /**
  33656. * Use this method to simulate a pointer down on a mesh
  33657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33660. */
  33661. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33662. private _processPointerDown;
  33663. /** @hidden */
  33664. _isPointerSwiping(): boolean;
  33665. /**
  33666. * Use this method to simulate a pointer up on a mesh
  33667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33670. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33671. */
  33672. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33673. private _processPointerUp;
  33674. /**
  33675. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33676. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33677. * @returns true if the pointer was captured
  33678. */
  33679. isPointerCaptured(pointerId?: number): boolean;
  33680. /**
  33681. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33682. * @param attachUp defines if you want to attach events to pointerup
  33683. * @param attachDown defines if you want to attach events to pointerdown
  33684. * @param attachMove defines if you want to attach events to pointermove
  33685. */
  33686. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33687. /**
  33688. * Detaches all event handlers
  33689. */
  33690. detachControl(): void;
  33691. /**
  33692. * Force the value of meshUnderPointer
  33693. * @param mesh defines the mesh to use
  33694. */
  33695. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33696. /**
  33697. * Gets the mesh under the pointer
  33698. * @returns a Mesh or null if no mesh is under the pointer
  33699. */
  33700. getPointerOverMesh(): Nullable<AbstractMesh>;
  33701. }
  33702. }
  33703. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33704. /**
  33705. * Helper class used to generate session unique ID
  33706. */
  33707. export class UniqueIdGenerator {
  33708. private static _UniqueIdCounter;
  33709. /**
  33710. * Gets an unique (relatively to the current scene) Id
  33711. */
  33712. static readonly UniqueId: number;
  33713. }
  33714. }
  33715. declare module "babylonjs/Animations/animationGroup" {
  33716. import { Animatable } from "babylonjs/Animations/animatable";
  33717. import { Animation } from "babylonjs/Animations/animation";
  33718. import { Scene, IDisposable } from "babylonjs/scene";
  33719. import { Observable } from "babylonjs/Misc/observable";
  33720. import { Nullable } from "babylonjs/types";
  33721. import "babylonjs/Animations/animatable";
  33722. /**
  33723. * This class defines the direct association between an animation and a target
  33724. */
  33725. export class TargetedAnimation {
  33726. /**
  33727. * Animation to perform
  33728. */
  33729. animation: Animation;
  33730. /**
  33731. * Target to animate
  33732. */
  33733. target: any;
  33734. /**
  33735. * Serialize the object
  33736. * @returns the JSON object representing the current entity
  33737. */
  33738. serialize(): any;
  33739. }
  33740. /**
  33741. * Use this class to create coordinated animations on multiple targets
  33742. */
  33743. export class AnimationGroup implements IDisposable {
  33744. /** The name of the animation group */
  33745. name: string;
  33746. private _scene;
  33747. private _targetedAnimations;
  33748. private _animatables;
  33749. private _from;
  33750. private _to;
  33751. private _isStarted;
  33752. private _isPaused;
  33753. private _speedRatio;
  33754. private _loopAnimation;
  33755. /**
  33756. * Gets or sets the unique id of the node
  33757. */
  33758. uniqueId: number;
  33759. /**
  33760. * This observable will notify when one animation have ended
  33761. */
  33762. onAnimationEndObservable: Observable<TargetedAnimation>;
  33763. /**
  33764. * Observer raised when one animation loops
  33765. */
  33766. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33767. /**
  33768. * This observable will notify when all animations have ended.
  33769. */
  33770. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33771. /**
  33772. * This observable will notify when all animations have paused.
  33773. */
  33774. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33775. /**
  33776. * This observable will notify when all animations are playing.
  33777. */
  33778. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33779. /**
  33780. * Gets the first frame
  33781. */
  33782. readonly from: number;
  33783. /**
  33784. * Gets the last frame
  33785. */
  33786. readonly to: number;
  33787. /**
  33788. * Define if the animations are started
  33789. */
  33790. readonly isStarted: boolean;
  33791. /**
  33792. * Gets a value indicating that the current group is playing
  33793. */
  33794. readonly isPlaying: boolean;
  33795. /**
  33796. * Gets or sets the speed ratio to use for all animations
  33797. */
  33798. /**
  33799. * Gets or sets the speed ratio to use for all animations
  33800. */
  33801. speedRatio: number;
  33802. /**
  33803. * Gets or sets if all animations should loop or not
  33804. */
  33805. loopAnimation: boolean;
  33806. /**
  33807. * Gets the targeted animations for this animation group
  33808. */
  33809. readonly targetedAnimations: Array<TargetedAnimation>;
  33810. /**
  33811. * returning the list of animatables controlled by this animation group.
  33812. */
  33813. readonly animatables: Array<Animatable>;
  33814. /**
  33815. * Instantiates a new Animation Group.
  33816. * This helps managing several animations at once.
  33817. * @see http://doc.babylonjs.com/how_to/group
  33818. * @param name Defines the name of the group
  33819. * @param scene Defines the scene the group belongs to
  33820. */
  33821. constructor(
  33822. /** The name of the animation group */
  33823. name: string, scene?: Nullable<Scene>);
  33824. /**
  33825. * Add an animation (with its target) in the group
  33826. * @param animation defines the animation we want to add
  33827. * @param target defines the target of the animation
  33828. * @returns the TargetedAnimation object
  33829. */
  33830. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33831. /**
  33832. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33833. * It can add constant keys at begin or end
  33834. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33835. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33836. * @returns the animation group
  33837. */
  33838. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33839. /**
  33840. * Start all animations on given targets
  33841. * @param loop defines if animations must loop
  33842. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33843. * @param from defines the from key (optional)
  33844. * @param to defines the to key (optional)
  33845. * @returns the current animation group
  33846. */
  33847. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33848. /**
  33849. * Pause all animations
  33850. * @returns the animation group
  33851. */
  33852. pause(): AnimationGroup;
  33853. /**
  33854. * Play all animations to initial state
  33855. * This function will start() the animations if they were not started or will restart() them if they were paused
  33856. * @param loop defines if animations must loop
  33857. * @returns the animation group
  33858. */
  33859. play(loop?: boolean): AnimationGroup;
  33860. /**
  33861. * Reset all animations to initial state
  33862. * @returns the animation group
  33863. */
  33864. reset(): AnimationGroup;
  33865. /**
  33866. * Restart animations from key 0
  33867. * @returns the animation group
  33868. */
  33869. restart(): AnimationGroup;
  33870. /**
  33871. * Stop all animations
  33872. * @returns the animation group
  33873. */
  33874. stop(): AnimationGroup;
  33875. /**
  33876. * Set animation weight for all animatables
  33877. * @param weight defines the weight to use
  33878. * @return the animationGroup
  33879. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33880. */
  33881. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33882. /**
  33883. * Synchronize and normalize all animatables with a source animatable
  33884. * @param root defines the root animatable to synchronize with
  33885. * @return the animationGroup
  33886. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33887. */
  33888. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33889. /**
  33890. * Goes to a specific frame in this animation group
  33891. * @param frame the frame number to go to
  33892. * @return the animationGroup
  33893. */
  33894. goToFrame(frame: number): AnimationGroup;
  33895. /**
  33896. * Dispose all associated resources
  33897. */
  33898. dispose(): void;
  33899. private _checkAnimationGroupEnded;
  33900. /**
  33901. * Clone the current animation group and returns a copy
  33902. * @param newName defines the name of the new group
  33903. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33904. * @returns the new aniamtion group
  33905. */
  33906. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33907. /**
  33908. * Serializes the animationGroup to an object
  33909. * @returns Serialized object
  33910. */
  33911. serialize(): any;
  33912. /**
  33913. * Returns a new AnimationGroup object parsed from the source provided.
  33914. * @param parsedAnimationGroup defines the source
  33915. * @param scene defines the scene that will receive the animationGroup
  33916. * @returns a new AnimationGroup
  33917. */
  33918. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33919. /**
  33920. * Returns the string "AnimationGroup"
  33921. * @returns "AnimationGroup"
  33922. */
  33923. getClassName(): string;
  33924. /**
  33925. * Creates a detailled string about the object
  33926. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33927. * @returns a string representing the object
  33928. */
  33929. toString(fullDetails?: boolean): string;
  33930. }
  33931. }
  33932. declare module "babylonjs/scene" {
  33933. import { Nullable } from "babylonjs/types";
  33934. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33935. import { Observable } from "babylonjs/Misc/observable";
  33936. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33937. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33938. import { Geometry } from "babylonjs/Meshes/geometry";
  33939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33942. import { Mesh } from "babylonjs/Meshes/mesh";
  33943. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33944. import { Bone } from "babylonjs/Bones/bone";
  33945. import { Skeleton } from "babylonjs/Bones/skeleton";
  33946. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33947. import { Camera } from "babylonjs/Cameras/camera";
  33948. import { AbstractScene } from "babylonjs/abstractScene";
  33949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33950. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33951. import { Material } from "babylonjs/Materials/material";
  33952. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33953. import { Effect } from "babylonjs/Materials/effect";
  33954. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33955. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33956. import { Light } from "babylonjs/Lights/light";
  33957. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33958. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33959. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33960. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33961. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33962. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33963. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33964. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33965. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33966. import { Engine } from "babylonjs/Engines/engine";
  33967. import { Node } from "babylonjs/node";
  33968. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33969. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33970. import { WebRequest } from "babylonjs/Misc/webRequest";
  33971. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33972. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33973. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33974. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33975. import { Plane } from "babylonjs/Maths/math.plane";
  33976. import { Ray } from "babylonjs/Culling/ray";
  33977. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33978. import { Animation } from "babylonjs/Animations/animation";
  33979. import { Animatable } from "babylonjs/Animations/animatable";
  33980. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33981. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33982. import { Collider } from "babylonjs/Collisions/collider";
  33983. /**
  33984. * Define an interface for all classes that will hold resources
  33985. */
  33986. export interface IDisposable {
  33987. /**
  33988. * Releases all held resources
  33989. */
  33990. dispose(): void;
  33991. }
  33992. /** Interface defining initialization parameters for Scene class */
  33993. export interface SceneOptions {
  33994. /**
  33995. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33996. * It will improve performance when the number of geometries becomes important.
  33997. */
  33998. useGeometryUniqueIdsMap?: boolean;
  33999. /**
  34000. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34001. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34002. */
  34003. useMaterialMeshMap?: boolean;
  34004. /**
  34005. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34006. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34007. */
  34008. useClonedMeshhMap?: boolean;
  34009. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34010. virtual?: boolean;
  34011. }
  34012. /**
  34013. * Represents a scene to be rendered by the engine.
  34014. * @see http://doc.babylonjs.com/features/scene
  34015. */
  34016. export class Scene extends AbstractScene implements IAnimatable {
  34017. /** The fog is deactivated */
  34018. static readonly FOGMODE_NONE: number;
  34019. /** The fog density is following an exponential function */
  34020. static readonly FOGMODE_EXP: number;
  34021. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34022. static readonly FOGMODE_EXP2: number;
  34023. /** The fog density is following a linear function. */
  34024. static readonly FOGMODE_LINEAR: number;
  34025. /**
  34026. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34028. */
  34029. static MinDeltaTime: number;
  34030. /**
  34031. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34033. */
  34034. static MaxDeltaTime: number;
  34035. /**
  34036. * Factory used to create the default material.
  34037. * @param name The name of the material to create
  34038. * @param scene The scene to create the material for
  34039. * @returns The default material
  34040. */
  34041. static DefaultMaterialFactory(scene: Scene): Material;
  34042. /**
  34043. * Factory used to create the a collision coordinator.
  34044. * @returns The collision coordinator
  34045. */
  34046. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34047. /** @hidden */
  34048. _inputManager: InputManager;
  34049. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34050. cameraToUseForPointers: Nullable<Camera>;
  34051. /** @hidden */
  34052. readonly _isScene: boolean;
  34053. /**
  34054. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34055. */
  34056. autoClear: boolean;
  34057. /**
  34058. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34059. */
  34060. autoClearDepthAndStencil: boolean;
  34061. /**
  34062. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34063. */
  34064. clearColor: Color4;
  34065. /**
  34066. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34067. */
  34068. ambientColor: Color3;
  34069. /**
  34070. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34071. * It should only be one of the following (if not the default embedded one):
  34072. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34073. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34074. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34075. * The material properties need to be setup according to the type of texture in use.
  34076. */
  34077. environmentBRDFTexture: BaseTexture;
  34078. /** @hidden */
  34079. protected _environmentTexture: Nullable<BaseTexture>;
  34080. /**
  34081. * Texture used in all pbr material as the reflection texture.
  34082. * As in the majority of the scene they are the same (exception for multi room and so on),
  34083. * this is easier to reference from here than from all the materials.
  34084. */
  34085. /**
  34086. * Texture used in all pbr material as the reflection texture.
  34087. * As in the majority of the scene they are the same (exception for multi room and so on),
  34088. * this is easier to set here than in all the materials.
  34089. */
  34090. environmentTexture: Nullable<BaseTexture>;
  34091. /** @hidden */
  34092. protected _environmentIntensity: number;
  34093. /**
  34094. * Intensity of the environment in all pbr material.
  34095. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34096. * As in the majority of the scene they are the same (exception for multi room and so on),
  34097. * this is easier to reference from here than from all the materials.
  34098. */
  34099. /**
  34100. * Intensity of the environment in all pbr material.
  34101. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34102. * As in the majority of the scene they are the same (exception for multi room and so on),
  34103. * this is easier to set here than in all the materials.
  34104. */
  34105. environmentIntensity: number;
  34106. /** @hidden */
  34107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34108. /**
  34109. * Default image processing configuration used either in the rendering
  34110. * Forward main pass or through the imageProcessingPostProcess if present.
  34111. * As in the majority of the scene they are the same (exception for multi camera),
  34112. * this is easier to reference from here than from all the materials and post process.
  34113. *
  34114. * No setter as we it is a shared configuration, you can set the values instead.
  34115. */
  34116. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34117. private _forceWireframe;
  34118. /**
  34119. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34120. */
  34121. forceWireframe: boolean;
  34122. private _forcePointsCloud;
  34123. /**
  34124. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34125. */
  34126. forcePointsCloud: boolean;
  34127. /**
  34128. * Gets or sets the active clipplane 1
  34129. */
  34130. clipPlane: Nullable<Plane>;
  34131. /**
  34132. * Gets or sets the active clipplane 2
  34133. */
  34134. clipPlane2: Nullable<Plane>;
  34135. /**
  34136. * Gets or sets the active clipplane 3
  34137. */
  34138. clipPlane3: Nullable<Plane>;
  34139. /**
  34140. * Gets or sets the active clipplane 4
  34141. */
  34142. clipPlane4: Nullable<Plane>;
  34143. /**
  34144. * Gets or sets a boolean indicating if animations are enabled
  34145. */
  34146. animationsEnabled: boolean;
  34147. private _animationPropertiesOverride;
  34148. /**
  34149. * Gets or sets the animation properties override
  34150. */
  34151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34152. /**
  34153. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34154. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34155. */
  34156. useConstantAnimationDeltaTime: boolean;
  34157. /**
  34158. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34159. * Please note that it requires to run a ray cast through the scene on every frame
  34160. */
  34161. constantlyUpdateMeshUnderPointer: boolean;
  34162. /**
  34163. * Defines the HTML cursor to use when hovering over interactive elements
  34164. */
  34165. hoverCursor: string;
  34166. /**
  34167. * Defines the HTML default cursor to use (empty by default)
  34168. */
  34169. defaultCursor: string;
  34170. /**
  34171. * Defines wether cursors are handled by the scene.
  34172. */
  34173. doNotHandleCursors: boolean;
  34174. /**
  34175. * This is used to call preventDefault() on pointer down
  34176. * in order to block unwanted artifacts like system double clicks
  34177. */
  34178. preventDefaultOnPointerDown: boolean;
  34179. /**
  34180. * This is used to call preventDefault() on pointer up
  34181. * in order to block unwanted artifacts like system double clicks
  34182. */
  34183. preventDefaultOnPointerUp: boolean;
  34184. /**
  34185. * Gets or sets user defined metadata
  34186. */
  34187. metadata: any;
  34188. /**
  34189. * For internal use only. Please do not use.
  34190. */
  34191. reservedDataStore: any;
  34192. /**
  34193. * Gets the name of the plugin used to load this scene (null by default)
  34194. */
  34195. loadingPluginName: string;
  34196. /**
  34197. * Use this array to add regular expressions used to disable offline support for specific urls
  34198. */
  34199. disableOfflineSupportExceptionRules: RegExp[];
  34200. /**
  34201. * An event triggered when the scene is disposed.
  34202. */
  34203. onDisposeObservable: Observable<Scene>;
  34204. private _onDisposeObserver;
  34205. /** Sets a function to be executed when this scene is disposed. */
  34206. onDispose: () => void;
  34207. /**
  34208. * An event triggered before rendering the scene (right after animations and physics)
  34209. */
  34210. onBeforeRenderObservable: Observable<Scene>;
  34211. private _onBeforeRenderObserver;
  34212. /** Sets a function to be executed before rendering this scene */
  34213. beforeRender: Nullable<() => void>;
  34214. /**
  34215. * An event triggered after rendering the scene
  34216. */
  34217. onAfterRenderObservable: Observable<Scene>;
  34218. /**
  34219. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34220. */
  34221. onAfterRenderCameraObservable: Observable<Camera>;
  34222. private _onAfterRenderObserver;
  34223. /** Sets a function to be executed after rendering this scene */
  34224. afterRender: Nullable<() => void>;
  34225. /**
  34226. * An event triggered before animating the scene
  34227. */
  34228. onBeforeAnimationsObservable: Observable<Scene>;
  34229. /**
  34230. * An event triggered after animations processing
  34231. */
  34232. onAfterAnimationsObservable: Observable<Scene>;
  34233. /**
  34234. * An event triggered before draw calls are ready to be sent
  34235. */
  34236. onBeforeDrawPhaseObservable: Observable<Scene>;
  34237. /**
  34238. * An event triggered after draw calls have been sent
  34239. */
  34240. onAfterDrawPhaseObservable: Observable<Scene>;
  34241. /**
  34242. * An event triggered when the scene is ready
  34243. */
  34244. onReadyObservable: Observable<Scene>;
  34245. /**
  34246. * An event triggered before rendering a camera
  34247. */
  34248. onBeforeCameraRenderObservable: Observable<Camera>;
  34249. private _onBeforeCameraRenderObserver;
  34250. /** Sets a function to be executed before rendering a camera*/
  34251. beforeCameraRender: () => void;
  34252. /**
  34253. * An event triggered after rendering a camera
  34254. */
  34255. onAfterCameraRenderObservable: Observable<Camera>;
  34256. private _onAfterCameraRenderObserver;
  34257. /** Sets a function to be executed after rendering a camera*/
  34258. afterCameraRender: () => void;
  34259. /**
  34260. * An event triggered when active meshes evaluation is about to start
  34261. */
  34262. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34263. /**
  34264. * An event triggered when active meshes evaluation is done
  34265. */
  34266. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34267. /**
  34268. * An event triggered when particles rendering is about to start
  34269. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34270. */
  34271. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34272. /**
  34273. * An event triggered when particles rendering is done
  34274. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34275. */
  34276. onAfterParticlesRenderingObservable: Observable<Scene>;
  34277. /**
  34278. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34279. */
  34280. onDataLoadedObservable: Observable<Scene>;
  34281. /**
  34282. * An event triggered when a camera is created
  34283. */
  34284. onNewCameraAddedObservable: Observable<Camera>;
  34285. /**
  34286. * An event triggered when a camera is removed
  34287. */
  34288. onCameraRemovedObservable: Observable<Camera>;
  34289. /**
  34290. * An event triggered when a light is created
  34291. */
  34292. onNewLightAddedObservable: Observable<Light>;
  34293. /**
  34294. * An event triggered when a light is removed
  34295. */
  34296. onLightRemovedObservable: Observable<Light>;
  34297. /**
  34298. * An event triggered when a geometry is created
  34299. */
  34300. onNewGeometryAddedObservable: Observable<Geometry>;
  34301. /**
  34302. * An event triggered when a geometry is removed
  34303. */
  34304. onGeometryRemovedObservable: Observable<Geometry>;
  34305. /**
  34306. * An event triggered when a transform node is created
  34307. */
  34308. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34309. /**
  34310. * An event triggered when a transform node is removed
  34311. */
  34312. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34313. /**
  34314. * An event triggered when a mesh is created
  34315. */
  34316. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34317. /**
  34318. * An event triggered when a mesh is removed
  34319. */
  34320. onMeshRemovedObservable: Observable<AbstractMesh>;
  34321. /**
  34322. * An event triggered when a skeleton is created
  34323. */
  34324. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34325. /**
  34326. * An event triggered when a skeleton is removed
  34327. */
  34328. onSkeletonRemovedObservable: Observable<Skeleton>;
  34329. /**
  34330. * An event triggered when a material is created
  34331. */
  34332. onNewMaterialAddedObservable: Observable<Material>;
  34333. /**
  34334. * An event triggered when a material is removed
  34335. */
  34336. onMaterialRemovedObservable: Observable<Material>;
  34337. /**
  34338. * An event triggered when a texture is created
  34339. */
  34340. onNewTextureAddedObservable: Observable<BaseTexture>;
  34341. /**
  34342. * An event triggered when a texture is removed
  34343. */
  34344. onTextureRemovedObservable: Observable<BaseTexture>;
  34345. /**
  34346. * An event triggered when render targets are about to be rendered
  34347. * Can happen multiple times per frame.
  34348. */
  34349. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34350. /**
  34351. * An event triggered when render targets were rendered.
  34352. * Can happen multiple times per frame.
  34353. */
  34354. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34355. /**
  34356. * An event triggered before calculating deterministic simulation step
  34357. */
  34358. onBeforeStepObservable: Observable<Scene>;
  34359. /**
  34360. * An event triggered after calculating deterministic simulation step
  34361. */
  34362. onAfterStepObservable: Observable<Scene>;
  34363. /**
  34364. * An event triggered when the activeCamera property is updated
  34365. */
  34366. onActiveCameraChanged: Observable<Scene>;
  34367. /**
  34368. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34369. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34370. * 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)
  34371. */
  34372. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34373. /**
  34374. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34375. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34376. * 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)
  34377. */
  34378. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34379. /**
  34380. * This Observable will when a mesh has been imported into the scene.
  34381. */
  34382. onMeshImportedObservable: Observable<AbstractMesh>;
  34383. /**
  34384. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34385. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34386. */
  34387. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34388. /** @hidden */
  34389. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34390. /**
  34391. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34392. */
  34393. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34394. /**
  34395. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34396. */
  34397. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34398. /**
  34399. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34400. */
  34401. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34402. /** Callback called when a pointer move is detected */
  34403. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34404. /** Callback called when a pointer down is detected */
  34405. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34406. /** Callback called when a pointer up is detected */
  34407. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34408. /** Callback called when a pointer pick is detected */
  34409. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34410. /**
  34411. * 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).
  34412. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34413. */
  34414. onPrePointerObservable: Observable<PointerInfoPre>;
  34415. /**
  34416. * Observable event triggered each time an input event is received from the rendering canvas
  34417. */
  34418. onPointerObservable: Observable<PointerInfo>;
  34419. /**
  34420. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34421. */
  34422. readonly unTranslatedPointer: Vector2;
  34423. /**
  34424. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34425. */
  34426. static DragMovementThreshold: number;
  34427. /**
  34428. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34429. */
  34430. static LongPressDelay: number;
  34431. /**
  34432. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34433. */
  34434. static DoubleClickDelay: number;
  34435. /** If you need to check double click without raising a single click at first click, enable this flag */
  34436. static ExclusiveDoubleClickMode: boolean;
  34437. /** @hidden */
  34438. _mirroredCameraPosition: Nullable<Vector3>;
  34439. /**
  34440. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34441. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34442. */
  34443. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34444. /**
  34445. * Observable event triggered each time an keyboard event is received from the hosting window
  34446. */
  34447. onKeyboardObservable: Observable<KeyboardInfo>;
  34448. private _useRightHandedSystem;
  34449. /**
  34450. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34451. */
  34452. useRightHandedSystem: boolean;
  34453. private _timeAccumulator;
  34454. private _currentStepId;
  34455. private _currentInternalStep;
  34456. /**
  34457. * Sets the step Id used by deterministic lock step
  34458. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34459. * @param newStepId defines the step Id
  34460. */
  34461. setStepId(newStepId: number): void;
  34462. /**
  34463. * Gets the step Id used by deterministic lock step
  34464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34465. * @returns the step Id
  34466. */
  34467. getStepId(): number;
  34468. /**
  34469. * Gets the internal step used by deterministic lock step
  34470. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34471. * @returns the internal step
  34472. */
  34473. getInternalStep(): number;
  34474. private _fogEnabled;
  34475. /**
  34476. * Gets or sets a boolean indicating if fog is enabled on this scene
  34477. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34478. * (Default is true)
  34479. */
  34480. fogEnabled: boolean;
  34481. private _fogMode;
  34482. /**
  34483. * Gets or sets the fog mode to use
  34484. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34485. * | mode | value |
  34486. * | --- | --- |
  34487. * | FOGMODE_NONE | 0 |
  34488. * | FOGMODE_EXP | 1 |
  34489. * | FOGMODE_EXP2 | 2 |
  34490. * | FOGMODE_LINEAR | 3 |
  34491. */
  34492. fogMode: number;
  34493. /**
  34494. * Gets or sets the fog color to use
  34495. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34496. * (Default is Color3(0.2, 0.2, 0.3))
  34497. */
  34498. fogColor: Color3;
  34499. /**
  34500. * Gets or sets the fog density to use
  34501. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34502. * (Default is 0.1)
  34503. */
  34504. fogDensity: number;
  34505. /**
  34506. * Gets or sets the fog start distance to use
  34507. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34508. * (Default is 0)
  34509. */
  34510. fogStart: number;
  34511. /**
  34512. * Gets or sets the fog end distance to use
  34513. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34514. * (Default is 1000)
  34515. */
  34516. fogEnd: number;
  34517. private _shadowsEnabled;
  34518. /**
  34519. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34520. */
  34521. shadowsEnabled: boolean;
  34522. private _lightsEnabled;
  34523. /**
  34524. * Gets or sets a boolean indicating if lights are enabled on this scene
  34525. */
  34526. lightsEnabled: boolean;
  34527. /** All of the active cameras added to this scene. */
  34528. activeCameras: Camera[];
  34529. /** @hidden */
  34530. _activeCamera: Nullable<Camera>;
  34531. /** Gets or sets the current active camera */
  34532. activeCamera: Nullable<Camera>;
  34533. private _defaultMaterial;
  34534. /** The default material used on meshes when no material is affected */
  34535. /** The default material used on meshes when no material is affected */
  34536. defaultMaterial: Material;
  34537. private _texturesEnabled;
  34538. /**
  34539. * Gets or sets a boolean indicating if textures are enabled on this scene
  34540. */
  34541. texturesEnabled: boolean;
  34542. /**
  34543. * Gets or sets a boolean indicating if particles are enabled on this scene
  34544. */
  34545. particlesEnabled: boolean;
  34546. /**
  34547. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34548. */
  34549. spritesEnabled: boolean;
  34550. private _skeletonsEnabled;
  34551. /**
  34552. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34553. */
  34554. skeletonsEnabled: boolean;
  34555. /**
  34556. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34557. */
  34558. lensFlaresEnabled: boolean;
  34559. /**
  34560. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34562. */
  34563. collisionsEnabled: boolean;
  34564. private _collisionCoordinator;
  34565. /** @hidden */
  34566. readonly collisionCoordinator: ICollisionCoordinator;
  34567. /**
  34568. * Defines the gravity applied to this scene (used only for collisions)
  34569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34570. */
  34571. gravity: Vector3;
  34572. /**
  34573. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34574. */
  34575. postProcessesEnabled: boolean;
  34576. /**
  34577. * The list of postprocesses added to the scene
  34578. */
  34579. postProcesses: PostProcess[];
  34580. /**
  34581. * Gets the current postprocess manager
  34582. */
  34583. postProcessManager: PostProcessManager;
  34584. /**
  34585. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34586. */
  34587. renderTargetsEnabled: boolean;
  34588. /**
  34589. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34590. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34591. */
  34592. dumpNextRenderTargets: boolean;
  34593. /**
  34594. * The list of user defined render targets added to the scene
  34595. */
  34596. customRenderTargets: RenderTargetTexture[];
  34597. /**
  34598. * Defines if texture loading must be delayed
  34599. * If true, textures will only be loaded when they need to be rendered
  34600. */
  34601. useDelayedTextureLoading: boolean;
  34602. /**
  34603. * Gets the list of meshes imported to the scene through SceneLoader
  34604. */
  34605. importedMeshesFiles: String[];
  34606. /**
  34607. * Gets or sets a boolean indicating if probes are enabled on this scene
  34608. */
  34609. probesEnabled: boolean;
  34610. /**
  34611. * Gets or sets the current offline provider to use to store scene data
  34612. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34613. */
  34614. offlineProvider: IOfflineProvider;
  34615. /**
  34616. * Gets or sets the action manager associated with the scene
  34617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34618. */
  34619. actionManager: AbstractActionManager;
  34620. private _meshesForIntersections;
  34621. /**
  34622. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34623. */
  34624. proceduralTexturesEnabled: boolean;
  34625. private _engine;
  34626. private _totalVertices;
  34627. /** @hidden */
  34628. _activeIndices: PerfCounter;
  34629. /** @hidden */
  34630. _activeParticles: PerfCounter;
  34631. /** @hidden */
  34632. _activeBones: PerfCounter;
  34633. private _animationRatio;
  34634. /** @hidden */
  34635. _animationTimeLast: number;
  34636. /** @hidden */
  34637. _animationTime: number;
  34638. /**
  34639. * Gets or sets a general scale for animation speed
  34640. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34641. */
  34642. animationTimeScale: number;
  34643. /** @hidden */
  34644. _cachedMaterial: Nullable<Material>;
  34645. /** @hidden */
  34646. _cachedEffect: Nullable<Effect>;
  34647. /** @hidden */
  34648. _cachedVisibility: Nullable<number>;
  34649. private _renderId;
  34650. private _frameId;
  34651. private _executeWhenReadyTimeoutId;
  34652. private _intermediateRendering;
  34653. private _viewUpdateFlag;
  34654. private _projectionUpdateFlag;
  34655. /** @hidden */
  34656. _toBeDisposed: Nullable<IDisposable>[];
  34657. private _activeRequests;
  34658. /** @hidden */
  34659. _pendingData: any[];
  34660. private _isDisposed;
  34661. /**
  34662. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34663. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34664. */
  34665. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34666. private _activeMeshes;
  34667. private _processedMaterials;
  34668. private _renderTargets;
  34669. /** @hidden */
  34670. _activeParticleSystems: SmartArray<IParticleSystem>;
  34671. private _activeSkeletons;
  34672. private _softwareSkinnedMeshes;
  34673. private _renderingManager;
  34674. /** @hidden */
  34675. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34676. private _transformMatrix;
  34677. private _sceneUbo;
  34678. /** @hidden */
  34679. _viewMatrix: Matrix;
  34680. private _projectionMatrix;
  34681. /** @hidden */
  34682. _forcedViewPosition: Nullable<Vector3>;
  34683. /** @hidden */
  34684. _frustumPlanes: Plane[];
  34685. /**
  34686. * Gets the list of frustum planes (built from the active camera)
  34687. */
  34688. readonly frustumPlanes: Plane[];
  34689. /**
  34690. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34691. * This is useful if there are more lights that the maximum simulteanous authorized
  34692. */
  34693. requireLightSorting: boolean;
  34694. /** @hidden */
  34695. readonly useMaterialMeshMap: boolean;
  34696. /** @hidden */
  34697. readonly useClonedMeshhMap: boolean;
  34698. private _externalData;
  34699. private _uid;
  34700. /**
  34701. * @hidden
  34702. * Backing store of defined scene components.
  34703. */
  34704. _components: ISceneComponent[];
  34705. /**
  34706. * @hidden
  34707. * Backing store of defined scene components.
  34708. */
  34709. _serializableComponents: ISceneSerializableComponent[];
  34710. /**
  34711. * List of components to register on the next registration step.
  34712. */
  34713. private _transientComponents;
  34714. /**
  34715. * Registers the transient components if needed.
  34716. */
  34717. private _registerTransientComponents;
  34718. /**
  34719. * @hidden
  34720. * Add a component to the scene.
  34721. * Note that the ccomponent could be registered on th next frame if this is called after
  34722. * the register component stage.
  34723. * @param component Defines the component to add to the scene
  34724. */
  34725. _addComponent(component: ISceneComponent): void;
  34726. /**
  34727. * @hidden
  34728. * Gets a component from the scene.
  34729. * @param name defines the name of the component to retrieve
  34730. * @returns the component or null if not present
  34731. */
  34732. _getComponent(name: string): Nullable<ISceneComponent>;
  34733. /**
  34734. * @hidden
  34735. * Defines the actions happening before camera updates.
  34736. */
  34737. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34738. /**
  34739. * @hidden
  34740. * Defines the actions happening before clear the canvas.
  34741. */
  34742. _beforeClearStage: Stage<SimpleStageAction>;
  34743. /**
  34744. * @hidden
  34745. * Defines the actions when collecting render targets for the frame.
  34746. */
  34747. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34748. /**
  34749. * @hidden
  34750. * Defines the actions happening for one camera in the frame.
  34751. */
  34752. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34753. /**
  34754. * @hidden
  34755. * Defines the actions happening during the per mesh ready checks.
  34756. */
  34757. _isReadyForMeshStage: Stage<MeshStageAction>;
  34758. /**
  34759. * @hidden
  34760. * Defines the actions happening before evaluate active mesh checks.
  34761. */
  34762. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34763. /**
  34764. * @hidden
  34765. * Defines the actions happening during the evaluate sub mesh checks.
  34766. */
  34767. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34768. /**
  34769. * @hidden
  34770. * Defines the actions happening during the active mesh stage.
  34771. */
  34772. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34773. /**
  34774. * @hidden
  34775. * Defines the actions happening during the per camera render target step.
  34776. */
  34777. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34778. /**
  34779. * @hidden
  34780. * Defines the actions happening just before the active camera is drawing.
  34781. */
  34782. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34783. /**
  34784. * @hidden
  34785. * Defines the actions happening just before a render target is drawing.
  34786. */
  34787. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34788. /**
  34789. * @hidden
  34790. * Defines the actions happening just before a rendering group is drawing.
  34791. */
  34792. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34793. /**
  34794. * @hidden
  34795. * Defines the actions happening just before a mesh is drawing.
  34796. */
  34797. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34798. /**
  34799. * @hidden
  34800. * Defines the actions happening just after a mesh has been drawn.
  34801. */
  34802. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34803. /**
  34804. * @hidden
  34805. * Defines the actions happening just after a rendering group has been drawn.
  34806. */
  34807. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34808. /**
  34809. * @hidden
  34810. * Defines the actions happening just after the active camera has been drawn.
  34811. */
  34812. _afterCameraDrawStage: Stage<CameraStageAction>;
  34813. /**
  34814. * @hidden
  34815. * Defines the actions happening just after a render target has been drawn.
  34816. */
  34817. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34818. /**
  34819. * @hidden
  34820. * Defines the actions happening just after rendering all cameras and computing intersections.
  34821. */
  34822. _afterRenderStage: Stage<SimpleStageAction>;
  34823. /**
  34824. * @hidden
  34825. * Defines the actions happening when a pointer move event happens.
  34826. */
  34827. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34828. /**
  34829. * @hidden
  34830. * Defines the actions happening when a pointer down event happens.
  34831. */
  34832. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34833. /**
  34834. * @hidden
  34835. * Defines the actions happening when a pointer up event happens.
  34836. */
  34837. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34838. /**
  34839. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34840. */
  34841. private geometriesByUniqueId;
  34842. /**
  34843. * Creates a new Scene
  34844. * @param engine defines the engine to use to render this scene
  34845. * @param options defines the scene options
  34846. */
  34847. constructor(engine: Engine, options?: SceneOptions);
  34848. /**
  34849. * Gets a string idenfifying the name of the class
  34850. * @returns "Scene" string
  34851. */
  34852. getClassName(): string;
  34853. private _defaultMeshCandidates;
  34854. /**
  34855. * @hidden
  34856. */
  34857. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34858. private _defaultSubMeshCandidates;
  34859. /**
  34860. * @hidden
  34861. */
  34862. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34863. /**
  34864. * Sets the default candidate providers for the scene.
  34865. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34866. * and getCollidingSubMeshCandidates to their default function
  34867. */
  34868. setDefaultCandidateProviders(): void;
  34869. /**
  34870. * Gets the mesh that is currently under the pointer
  34871. */
  34872. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34873. /**
  34874. * Gets or sets the current on-screen X position of the pointer
  34875. */
  34876. pointerX: number;
  34877. /**
  34878. * Gets or sets the current on-screen Y position of the pointer
  34879. */
  34880. pointerY: number;
  34881. /**
  34882. * Gets the cached material (ie. the latest rendered one)
  34883. * @returns the cached material
  34884. */
  34885. getCachedMaterial(): Nullable<Material>;
  34886. /**
  34887. * Gets the cached effect (ie. the latest rendered one)
  34888. * @returns the cached effect
  34889. */
  34890. getCachedEffect(): Nullable<Effect>;
  34891. /**
  34892. * Gets the cached visibility state (ie. the latest rendered one)
  34893. * @returns the cached visibility state
  34894. */
  34895. getCachedVisibility(): Nullable<number>;
  34896. /**
  34897. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34898. * @param material defines the current material
  34899. * @param effect defines the current effect
  34900. * @param visibility defines the current visibility state
  34901. * @returns true if one parameter is not cached
  34902. */
  34903. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34904. /**
  34905. * Gets the engine associated with the scene
  34906. * @returns an Engine
  34907. */
  34908. getEngine(): Engine;
  34909. /**
  34910. * Gets the total number of vertices rendered per frame
  34911. * @returns the total number of vertices rendered per frame
  34912. */
  34913. getTotalVertices(): number;
  34914. /**
  34915. * Gets the performance counter for total vertices
  34916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34917. */
  34918. readonly totalVerticesPerfCounter: PerfCounter;
  34919. /**
  34920. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34921. * @returns the total number of active indices rendered per frame
  34922. */
  34923. getActiveIndices(): number;
  34924. /**
  34925. * Gets the performance counter for active indices
  34926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34927. */
  34928. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34929. /**
  34930. * Gets the total number of active particles rendered per frame
  34931. * @returns the total number of active particles rendered per frame
  34932. */
  34933. getActiveParticles(): number;
  34934. /**
  34935. * Gets the performance counter for active particles
  34936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34937. */
  34938. readonly activeParticlesPerfCounter: PerfCounter;
  34939. /**
  34940. * Gets the total number of active bones rendered per frame
  34941. * @returns the total number of active bones rendered per frame
  34942. */
  34943. getActiveBones(): number;
  34944. /**
  34945. * Gets the performance counter for active bones
  34946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34947. */
  34948. readonly activeBonesPerfCounter: PerfCounter;
  34949. /**
  34950. * Gets the array of active meshes
  34951. * @returns an array of AbstractMesh
  34952. */
  34953. getActiveMeshes(): SmartArray<AbstractMesh>;
  34954. /**
  34955. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34956. * @returns a number
  34957. */
  34958. getAnimationRatio(): number;
  34959. /**
  34960. * Gets an unique Id for the current render phase
  34961. * @returns a number
  34962. */
  34963. getRenderId(): number;
  34964. /**
  34965. * Gets an unique Id for the current frame
  34966. * @returns a number
  34967. */
  34968. getFrameId(): number;
  34969. /** Call this function if you want to manually increment the render Id*/
  34970. incrementRenderId(): void;
  34971. private _createUbo;
  34972. /**
  34973. * Use this method to simulate a pointer move on a mesh
  34974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34977. * @returns the current scene
  34978. */
  34979. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34980. /**
  34981. * Use this method to simulate a pointer down on a mesh
  34982. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34983. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34984. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34985. * @returns the current scene
  34986. */
  34987. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34988. /**
  34989. * Use this method to simulate a pointer up on a mesh
  34990. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34991. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34992. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34993. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34994. * @returns the current scene
  34995. */
  34996. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34997. /**
  34998. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34999. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35000. * @returns true if the pointer was captured
  35001. */
  35002. isPointerCaptured(pointerId?: number): boolean;
  35003. /**
  35004. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35005. * @param attachUp defines if you want to attach events to pointerup
  35006. * @param attachDown defines if you want to attach events to pointerdown
  35007. * @param attachMove defines if you want to attach events to pointermove
  35008. */
  35009. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35010. /** Detaches all event handlers*/
  35011. detachControl(): void;
  35012. /**
  35013. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35014. * Delay loaded resources are not taking in account
  35015. * @return true if all required resources are ready
  35016. */
  35017. isReady(): boolean;
  35018. /** Resets all cached information relative to material (including effect and visibility) */
  35019. resetCachedMaterial(): void;
  35020. /**
  35021. * Registers a function to be called before every frame render
  35022. * @param func defines the function to register
  35023. */
  35024. registerBeforeRender(func: () => void): void;
  35025. /**
  35026. * Unregisters a function called before every frame render
  35027. * @param func defines the function to unregister
  35028. */
  35029. unregisterBeforeRender(func: () => void): void;
  35030. /**
  35031. * Registers a function to be called after every frame render
  35032. * @param func defines the function to register
  35033. */
  35034. registerAfterRender(func: () => void): void;
  35035. /**
  35036. * Unregisters a function called after every frame render
  35037. * @param func defines the function to unregister
  35038. */
  35039. unregisterAfterRender(func: () => void): void;
  35040. private _executeOnceBeforeRender;
  35041. /**
  35042. * The provided function will run before render once and will be disposed afterwards.
  35043. * A timeout delay can be provided so that the function will be executed in N ms.
  35044. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35045. * @param func The function to be executed.
  35046. * @param timeout optional delay in ms
  35047. */
  35048. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35049. /** @hidden */
  35050. _addPendingData(data: any): void;
  35051. /** @hidden */
  35052. _removePendingData(data: any): void;
  35053. /**
  35054. * Returns the number of items waiting to be loaded
  35055. * @returns the number of items waiting to be loaded
  35056. */
  35057. getWaitingItemsCount(): number;
  35058. /**
  35059. * Returns a boolean indicating if the scene is still loading data
  35060. */
  35061. readonly isLoading: boolean;
  35062. /**
  35063. * Registers a function to be executed when the scene is ready
  35064. * @param {Function} func - the function to be executed
  35065. */
  35066. executeWhenReady(func: () => void): void;
  35067. /**
  35068. * Returns a promise that resolves when the scene is ready
  35069. * @returns A promise that resolves when the scene is ready
  35070. */
  35071. whenReadyAsync(): Promise<void>;
  35072. /** @hidden */
  35073. _checkIsReady(): void;
  35074. /**
  35075. * Gets all animatable attached to the scene
  35076. */
  35077. readonly animatables: Animatable[];
  35078. /**
  35079. * Resets the last animation time frame.
  35080. * Useful to override when animations start running when loading a scene for the first time.
  35081. */
  35082. resetLastAnimationTimeFrame(): void;
  35083. /**
  35084. * Gets the current view matrix
  35085. * @returns a Matrix
  35086. */
  35087. getViewMatrix(): Matrix;
  35088. /**
  35089. * Gets the current projection matrix
  35090. * @returns a Matrix
  35091. */
  35092. getProjectionMatrix(): Matrix;
  35093. /**
  35094. * Gets the current transform matrix
  35095. * @returns a Matrix made of View * Projection
  35096. */
  35097. getTransformMatrix(): Matrix;
  35098. /**
  35099. * Sets the current transform matrix
  35100. * @param viewL defines the View matrix to use
  35101. * @param projectionL defines the Projection matrix to use
  35102. * @param viewR defines the right View matrix to use (if provided)
  35103. * @param projectionR defines the right Projection matrix to use (if provided)
  35104. */
  35105. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35106. /**
  35107. * Gets the uniform buffer used to store scene data
  35108. * @returns a UniformBuffer
  35109. */
  35110. getSceneUniformBuffer(): UniformBuffer;
  35111. /**
  35112. * Gets an unique (relatively to the current scene) Id
  35113. * @returns an unique number for the scene
  35114. */
  35115. getUniqueId(): number;
  35116. /**
  35117. * Add a mesh to the list of scene's meshes
  35118. * @param newMesh defines the mesh to add
  35119. * @param recursive if all child meshes should also be added to the scene
  35120. */
  35121. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35122. /**
  35123. * Remove a mesh for the list of scene's meshes
  35124. * @param toRemove defines the mesh to remove
  35125. * @param recursive if all child meshes should also be removed from the scene
  35126. * @returns the index where the mesh was in the mesh list
  35127. */
  35128. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35129. /**
  35130. * Add a transform node to the list of scene's transform nodes
  35131. * @param newTransformNode defines the transform node to add
  35132. */
  35133. addTransformNode(newTransformNode: TransformNode): void;
  35134. /**
  35135. * Remove a transform node for the list of scene's transform nodes
  35136. * @param toRemove defines the transform node to remove
  35137. * @returns the index where the transform node was in the transform node list
  35138. */
  35139. removeTransformNode(toRemove: TransformNode): number;
  35140. /**
  35141. * Remove a skeleton for the list of scene's skeletons
  35142. * @param toRemove defines the skeleton to remove
  35143. * @returns the index where the skeleton was in the skeleton list
  35144. */
  35145. removeSkeleton(toRemove: Skeleton): number;
  35146. /**
  35147. * Remove a morph target for the list of scene's morph targets
  35148. * @param toRemove defines the morph target to remove
  35149. * @returns the index where the morph target was in the morph target list
  35150. */
  35151. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35152. /**
  35153. * Remove a light for the list of scene's lights
  35154. * @param toRemove defines the light to remove
  35155. * @returns the index where the light was in the light list
  35156. */
  35157. removeLight(toRemove: Light): number;
  35158. /**
  35159. * Remove a camera for the list of scene's cameras
  35160. * @param toRemove defines the camera to remove
  35161. * @returns the index where the camera was in the camera list
  35162. */
  35163. removeCamera(toRemove: Camera): number;
  35164. /**
  35165. * Remove a particle system for the list of scene's particle systems
  35166. * @param toRemove defines the particle system to remove
  35167. * @returns the index where the particle system was in the particle system list
  35168. */
  35169. removeParticleSystem(toRemove: IParticleSystem): number;
  35170. /**
  35171. * Remove a animation for the list of scene's animations
  35172. * @param toRemove defines the animation to remove
  35173. * @returns the index where the animation was in the animation list
  35174. */
  35175. removeAnimation(toRemove: Animation): number;
  35176. /**
  35177. * Will stop the animation of the given target
  35178. * @param target - the target
  35179. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35180. * @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)
  35181. */
  35182. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35183. /**
  35184. * Removes the given animation group from this scene.
  35185. * @param toRemove The animation group to remove
  35186. * @returns The index of the removed animation group
  35187. */
  35188. removeAnimationGroup(toRemove: AnimationGroup): number;
  35189. /**
  35190. * Removes the given multi-material from this scene.
  35191. * @param toRemove The multi-material to remove
  35192. * @returns The index of the removed multi-material
  35193. */
  35194. removeMultiMaterial(toRemove: MultiMaterial): number;
  35195. /**
  35196. * Removes the given material from this scene.
  35197. * @param toRemove The material to remove
  35198. * @returns The index of the removed material
  35199. */
  35200. removeMaterial(toRemove: Material): number;
  35201. /**
  35202. * Removes the given action manager from this scene.
  35203. * @param toRemove The action manager to remove
  35204. * @returns The index of the removed action manager
  35205. */
  35206. removeActionManager(toRemove: AbstractActionManager): number;
  35207. /**
  35208. * Removes the given texture from this scene.
  35209. * @param toRemove The texture to remove
  35210. * @returns The index of the removed texture
  35211. */
  35212. removeTexture(toRemove: BaseTexture): number;
  35213. /**
  35214. * Adds the given light to this scene
  35215. * @param newLight The light to add
  35216. */
  35217. addLight(newLight: Light): void;
  35218. /**
  35219. * Sorts the list list based on light priorities
  35220. */
  35221. sortLightsByPriority(): void;
  35222. /**
  35223. * Adds the given camera to this scene
  35224. * @param newCamera The camera to add
  35225. */
  35226. addCamera(newCamera: Camera): void;
  35227. /**
  35228. * Adds the given skeleton to this scene
  35229. * @param newSkeleton The skeleton to add
  35230. */
  35231. addSkeleton(newSkeleton: Skeleton): void;
  35232. /**
  35233. * Adds the given particle system to this scene
  35234. * @param newParticleSystem The particle system to add
  35235. */
  35236. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35237. /**
  35238. * Adds the given animation to this scene
  35239. * @param newAnimation The animation to add
  35240. */
  35241. addAnimation(newAnimation: Animation): void;
  35242. /**
  35243. * Adds the given animation group to this scene.
  35244. * @param newAnimationGroup The animation group to add
  35245. */
  35246. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35247. /**
  35248. * Adds the given multi-material to this scene
  35249. * @param newMultiMaterial The multi-material to add
  35250. */
  35251. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35252. /**
  35253. * Adds the given material to this scene
  35254. * @param newMaterial The material to add
  35255. */
  35256. addMaterial(newMaterial: Material): void;
  35257. /**
  35258. * Adds the given morph target to this scene
  35259. * @param newMorphTargetManager The morph target to add
  35260. */
  35261. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35262. /**
  35263. * Adds the given geometry to this scene
  35264. * @param newGeometry The geometry to add
  35265. */
  35266. addGeometry(newGeometry: Geometry): void;
  35267. /**
  35268. * Adds the given action manager to this scene
  35269. * @param newActionManager The action manager to add
  35270. */
  35271. addActionManager(newActionManager: AbstractActionManager): void;
  35272. /**
  35273. * Adds the given texture to this scene.
  35274. * @param newTexture The texture to add
  35275. */
  35276. addTexture(newTexture: BaseTexture): void;
  35277. /**
  35278. * Switch active camera
  35279. * @param newCamera defines the new active camera
  35280. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35281. */
  35282. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35283. /**
  35284. * sets the active camera of the scene using its ID
  35285. * @param id defines the camera's ID
  35286. * @return the new active camera or null if none found.
  35287. */
  35288. setActiveCameraByID(id: string): Nullable<Camera>;
  35289. /**
  35290. * sets the active camera of the scene using its name
  35291. * @param name defines the camera's name
  35292. * @returns the new active camera or null if none found.
  35293. */
  35294. setActiveCameraByName(name: string): Nullable<Camera>;
  35295. /**
  35296. * get an animation group using its name
  35297. * @param name defines the material's name
  35298. * @return the animation group or null if none found.
  35299. */
  35300. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35301. /**
  35302. * Get a material using its unique id
  35303. * @param uniqueId defines the material's unique id
  35304. * @return the material or null if none found.
  35305. */
  35306. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35307. /**
  35308. * get a material using its id
  35309. * @param id defines the material's ID
  35310. * @return the material or null if none found.
  35311. */
  35312. getMaterialByID(id: string): Nullable<Material>;
  35313. /**
  35314. * Gets a the last added material using a given id
  35315. * @param id defines the material's ID
  35316. * @return the last material with the given id or null if none found.
  35317. */
  35318. getLastMaterialByID(id: string): Nullable<Material>;
  35319. /**
  35320. * Gets a material using its name
  35321. * @param name defines the material's name
  35322. * @return the material or null if none found.
  35323. */
  35324. getMaterialByName(name: string): Nullable<Material>;
  35325. /**
  35326. * Get a texture using its unique id
  35327. * @param uniqueId defines the texture's unique id
  35328. * @return the texture or null if none found.
  35329. */
  35330. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35331. /**
  35332. * Gets a camera using its id
  35333. * @param id defines the id to look for
  35334. * @returns the camera or null if not found
  35335. */
  35336. getCameraByID(id: string): Nullable<Camera>;
  35337. /**
  35338. * Gets a camera using its unique id
  35339. * @param uniqueId defines the unique id to look for
  35340. * @returns the camera or null if not found
  35341. */
  35342. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35343. /**
  35344. * Gets a camera using its name
  35345. * @param name defines the camera's name
  35346. * @return the camera or null if none found.
  35347. */
  35348. getCameraByName(name: string): Nullable<Camera>;
  35349. /**
  35350. * Gets a bone using its id
  35351. * @param id defines the bone's id
  35352. * @return the bone or null if not found
  35353. */
  35354. getBoneByID(id: string): Nullable<Bone>;
  35355. /**
  35356. * Gets a bone using its id
  35357. * @param name defines the bone's name
  35358. * @return the bone or null if not found
  35359. */
  35360. getBoneByName(name: string): Nullable<Bone>;
  35361. /**
  35362. * Gets a light node using its name
  35363. * @param name defines the the light's name
  35364. * @return the light or null if none found.
  35365. */
  35366. getLightByName(name: string): Nullable<Light>;
  35367. /**
  35368. * Gets a light node using its id
  35369. * @param id defines the light's id
  35370. * @return the light or null if none found.
  35371. */
  35372. getLightByID(id: string): Nullable<Light>;
  35373. /**
  35374. * Gets a light node using its scene-generated unique ID
  35375. * @param uniqueId defines the light's unique id
  35376. * @return the light or null if none found.
  35377. */
  35378. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35379. /**
  35380. * Gets a particle system by id
  35381. * @param id defines the particle system id
  35382. * @return the corresponding system or null if none found
  35383. */
  35384. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35385. /**
  35386. * Gets a geometry using its ID
  35387. * @param id defines the geometry's id
  35388. * @return the geometry or null if none found.
  35389. */
  35390. getGeometryByID(id: string): Nullable<Geometry>;
  35391. private _getGeometryByUniqueID;
  35392. /**
  35393. * Add a new geometry to this scene
  35394. * @param geometry defines the geometry to be added to the scene.
  35395. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35396. * @return a boolean defining if the geometry was added or not
  35397. */
  35398. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35399. /**
  35400. * Removes an existing geometry
  35401. * @param geometry defines the geometry to be removed from the scene
  35402. * @return a boolean defining if the geometry was removed or not
  35403. */
  35404. removeGeometry(geometry: Geometry): boolean;
  35405. /**
  35406. * Gets the list of geometries attached to the scene
  35407. * @returns an array of Geometry
  35408. */
  35409. getGeometries(): Geometry[];
  35410. /**
  35411. * Gets the first added mesh found of a given ID
  35412. * @param id defines the id to search for
  35413. * @return the mesh found or null if not found at all
  35414. */
  35415. getMeshByID(id: string): Nullable<AbstractMesh>;
  35416. /**
  35417. * Gets a list of meshes using their id
  35418. * @param id defines the id to search for
  35419. * @returns a list of meshes
  35420. */
  35421. getMeshesByID(id: string): Array<AbstractMesh>;
  35422. /**
  35423. * Gets the first added transform node found of a given ID
  35424. * @param id defines the id to search for
  35425. * @return the found transform node or null if not found at all.
  35426. */
  35427. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35428. /**
  35429. * Gets a transform node with its auto-generated unique id
  35430. * @param uniqueId efines the unique id to search for
  35431. * @return the found transform node or null if not found at all.
  35432. */
  35433. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35434. /**
  35435. * Gets a list of transform nodes using their id
  35436. * @param id defines the id to search for
  35437. * @returns a list of transform nodes
  35438. */
  35439. getTransformNodesByID(id: string): Array<TransformNode>;
  35440. /**
  35441. * Gets a mesh with its auto-generated unique id
  35442. * @param uniqueId defines the unique id to search for
  35443. * @return the found mesh or null if not found at all.
  35444. */
  35445. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35446. /**
  35447. * Gets a the last added mesh using a given id
  35448. * @param id defines the id to search for
  35449. * @return the found mesh or null if not found at all.
  35450. */
  35451. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35452. /**
  35453. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35454. * @param id defines the id to search for
  35455. * @return the found node or null if not found at all
  35456. */
  35457. getLastEntryByID(id: string): Nullable<Node>;
  35458. /**
  35459. * Gets a node (Mesh, Camera, Light) using a given id
  35460. * @param id defines the id to search for
  35461. * @return the found node or null if not found at all
  35462. */
  35463. getNodeByID(id: string): Nullable<Node>;
  35464. /**
  35465. * Gets a node (Mesh, Camera, Light) using a given name
  35466. * @param name defines the name to search for
  35467. * @return the found node or null if not found at all.
  35468. */
  35469. getNodeByName(name: string): Nullable<Node>;
  35470. /**
  35471. * Gets a mesh using a given name
  35472. * @param name defines the name to search for
  35473. * @return the found mesh or null if not found at all.
  35474. */
  35475. getMeshByName(name: string): Nullable<AbstractMesh>;
  35476. /**
  35477. * Gets a transform node using a given name
  35478. * @param name defines the name to search for
  35479. * @return the found transform node or null if not found at all.
  35480. */
  35481. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35482. /**
  35483. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35484. * @param id defines the id to search for
  35485. * @return the found skeleton or null if not found at all.
  35486. */
  35487. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35488. /**
  35489. * Gets a skeleton using a given auto generated unique id
  35490. * @param uniqueId defines the unique id to search for
  35491. * @return the found skeleton or null if not found at all.
  35492. */
  35493. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35494. /**
  35495. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35496. * @param id defines the id to search for
  35497. * @return the found skeleton or null if not found at all.
  35498. */
  35499. getSkeletonById(id: string): Nullable<Skeleton>;
  35500. /**
  35501. * Gets a skeleton using a given name
  35502. * @param name defines the name to search for
  35503. * @return the found skeleton or null if not found at all.
  35504. */
  35505. getSkeletonByName(name: string): Nullable<Skeleton>;
  35506. /**
  35507. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35508. * @param id defines the id to search for
  35509. * @return the found morph target manager or null if not found at all.
  35510. */
  35511. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35512. /**
  35513. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35514. * @param id defines the id to search for
  35515. * @return the found morph target or null if not found at all.
  35516. */
  35517. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35518. /**
  35519. * Gets a boolean indicating if the given mesh is active
  35520. * @param mesh defines the mesh to look for
  35521. * @returns true if the mesh is in the active list
  35522. */
  35523. isActiveMesh(mesh: AbstractMesh): boolean;
  35524. /**
  35525. * Return a unique id as a string which can serve as an identifier for the scene
  35526. */
  35527. readonly uid: string;
  35528. /**
  35529. * Add an externaly attached data from its key.
  35530. * This method call will fail and return false, if such key already exists.
  35531. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35532. * @param key the unique key that identifies the data
  35533. * @param data the data object to associate to the key for this Engine instance
  35534. * @return true if no such key were already present and the data was added successfully, false otherwise
  35535. */
  35536. addExternalData<T>(key: string, data: T): boolean;
  35537. /**
  35538. * Get an externaly attached data from its key
  35539. * @param key the unique key that identifies the data
  35540. * @return the associated data, if present (can be null), or undefined if not present
  35541. */
  35542. getExternalData<T>(key: string): Nullable<T>;
  35543. /**
  35544. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35545. * @param key the unique key that identifies the data
  35546. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35547. * @return the associated data, can be null if the factory returned null.
  35548. */
  35549. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35550. /**
  35551. * Remove an externaly attached data from the Engine instance
  35552. * @param key the unique key that identifies the data
  35553. * @return true if the data was successfully removed, false if it doesn't exist
  35554. */
  35555. removeExternalData(key: string): boolean;
  35556. private _evaluateSubMesh;
  35557. /**
  35558. * Clear the processed materials smart array preventing retention point in material dispose.
  35559. */
  35560. freeProcessedMaterials(): void;
  35561. private _preventFreeActiveMeshesAndRenderingGroups;
  35562. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35563. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35564. * when disposing several meshes in a row or a hierarchy of meshes.
  35565. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35566. */
  35567. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35568. /**
  35569. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35570. */
  35571. freeActiveMeshes(): void;
  35572. /**
  35573. * Clear the info related to rendering groups preventing retention points during dispose.
  35574. */
  35575. freeRenderingGroups(): void;
  35576. /** @hidden */
  35577. _isInIntermediateRendering(): boolean;
  35578. /**
  35579. * Lambda returning the list of potentially active meshes.
  35580. */
  35581. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35582. /**
  35583. * Lambda returning the list of potentially active sub meshes.
  35584. */
  35585. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35586. /**
  35587. * Lambda returning the list of potentially intersecting sub meshes.
  35588. */
  35589. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35590. /**
  35591. * Lambda returning the list of potentially colliding sub meshes.
  35592. */
  35593. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35594. private _activeMeshesFrozen;
  35595. /**
  35596. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35597. * @returns the current scene
  35598. */
  35599. freezeActiveMeshes(): Scene;
  35600. /**
  35601. * Use this function to restart evaluating active meshes on every frame
  35602. * @returns the current scene
  35603. */
  35604. unfreezeActiveMeshes(): Scene;
  35605. private _evaluateActiveMeshes;
  35606. private _activeMesh;
  35607. /**
  35608. * Update the transform matrix to update from the current active camera
  35609. * @param force defines a boolean used to force the update even if cache is up to date
  35610. */
  35611. updateTransformMatrix(force?: boolean): void;
  35612. private _bindFrameBuffer;
  35613. /** @hidden */
  35614. _allowPostProcessClearColor: boolean;
  35615. /** @hidden */
  35616. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35617. private _processSubCameras;
  35618. private _checkIntersections;
  35619. /** @hidden */
  35620. _advancePhysicsEngineStep(step: number): void;
  35621. /**
  35622. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35623. */
  35624. getDeterministicFrameTime: () => number;
  35625. /** @hidden */
  35626. _animate(): void;
  35627. /** Execute all animations (for a frame) */
  35628. animate(): void;
  35629. /**
  35630. * Render the scene
  35631. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35632. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35633. */
  35634. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35635. /**
  35636. * Freeze all materials
  35637. * A frozen material will not be updatable but should be faster to render
  35638. */
  35639. freezeMaterials(): void;
  35640. /**
  35641. * Unfreeze all materials
  35642. * A frozen material will not be updatable but should be faster to render
  35643. */
  35644. unfreezeMaterials(): void;
  35645. /**
  35646. * Releases all held ressources
  35647. */
  35648. dispose(): void;
  35649. /**
  35650. * Gets if the scene is already disposed
  35651. */
  35652. readonly isDisposed: boolean;
  35653. /**
  35654. * Call this function to reduce memory footprint of the scene.
  35655. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35656. */
  35657. clearCachedVertexData(): void;
  35658. /**
  35659. * This function will remove the local cached buffer data from texture.
  35660. * It will save memory but will prevent the texture from being rebuilt
  35661. */
  35662. cleanCachedTextureBuffer(): void;
  35663. /**
  35664. * Get the world extend vectors with an optional filter
  35665. *
  35666. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35667. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35668. */
  35669. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35670. min: Vector3;
  35671. max: Vector3;
  35672. };
  35673. /**
  35674. * Creates a ray that can be used to pick in the scene
  35675. * @param x defines the x coordinate of the origin (on-screen)
  35676. * @param y defines the y coordinate of the origin (on-screen)
  35677. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35678. * @param camera defines the camera to use for the picking
  35679. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35680. * @returns a Ray
  35681. */
  35682. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35683. /**
  35684. * Creates a ray that can be used to pick in the scene
  35685. * @param x defines the x coordinate of the origin (on-screen)
  35686. * @param y defines the y coordinate of the origin (on-screen)
  35687. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35688. * @param result defines the ray where to store the picking ray
  35689. * @param camera defines the camera to use for the picking
  35690. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35691. * @returns the current scene
  35692. */
  35693. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35694. /**
  35695. * Creates a ray that can be used to pick in the scene
  35696. * @param x defines the x coordinate of the origin (on-screen)
  35697. * @param y defines the y coordinate of the origin (on-screen)
  35698. * @param camera defines the camera to use for the picking
  35699. * @returns a Ray
  35700. */
  35701. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35702. /**
  35703. * Creates a ray that can be used to pick in the scene
  35704. * @param x defines the x coordinate of the origin (on-screen)
  35705. * @param y defines the y coordinate of the origin (on-screen)
  35706. * @param result defines the ray where to store the picking ray
  35707. * @param camera defines the camera to use for the picking
  35708. * @returns the current scene
  35709. */
  35710. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35711. /** Launch a ray to try to pick a mesh in the scene
  35712. * @param x position on screen
  35713. * @param y position on screen
  35714. * @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
  35715. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35716. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35717. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35718. * @returns a PickingInfo
  35719. */
  35720. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35721. /** Use the given ray to pick a mesh in the scene
  35722. * @param ray The ray to use to pick meshes
  35723. * @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
  35724. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35725. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35726. * @returns a PickingInfo
  35727. */
  35728. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35729. /**
  35730. * Launch a ray to try to pick a mesh in the scene
  35731. * @param x X position on screen
  35732. * @param y Y position on screen
  35733. * @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
  35734. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35736. * @returns an array of PickingInfo
  35737. */
  35738. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35739. /**
  35740. * Launch a ray to try to pick a mesh in the scene
  35741. * @param ray Ray to use
  35742. * @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
  35743. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35744. * @returns an array of PickingInfo
  35745. */
  35746. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35747. /**
  35748. * Force the value of meshUnderPointer
  35749. * @param mesh defines the mesh to use
  35750. */
  35751. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35752. /**
  35753. * Gets the mesh under the pointer
  35754. * @returns a Mesh or null if no mesh is under the pointer
  35755. */
  35756. getPointerOverMesh(): Nullable<AbstractMesh>;
  35757. /** @hidden */
  35758. _rebuildGeometries(): void;
  35759. /** @hidden */
  35760. _rebuildTextures(): void;
  35761. private _getByTags;
  35762. /**
  35763. * Get a list of meshes by tags
  35764. * @param tagsQuery defines the tags query to use
  35765. * @param forEach defines a predicate used to filter results
  35766. * @returns an array of Mesh
  35767. */
  35768. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35769. /**
  35770. * Get a list of cameras by tags
  35771. * @param tagsQuery defines the tags query to use
  35772. * @param forEach defines a predicate used to filter results
  35773. * @returns an array of Camera
  35774. */
  35775. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35776. /**
  35777. * Get a list of lights by tags
  35778. * @param tagsQuery defines the tags query to use
  35779. * @param forEach defines a predicate used to filter results
  35780. * @returns an array of Light
  35781. */
  35782. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35783. /**
  35784. * Get a list of materials by tags
  35785. * @param tagsQuery defines the tags query to use
  35786. * @param forEach defines a predicate used to filter results
  35787. * @returns an array of Material
  35788. */
  35789. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35790. /**
  35791. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35792. * This allowed control for front to back rendering or reversly depending of the special needs.
  35793. *
  35794. * @param renderingGroupId The rendering group id corresponding to its index
  35795. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35796. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35797. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35798. */
  35799. 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;
  35800. /**
  35801. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35802. *
  35803. * @param renderingGroupId The rendering group id corresponding to its index
  35804. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35805. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35806. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35807. */
  35808. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35809. /**
  35810. * Gets the current auto clear configuration for one rendering group of the rendering
  35811. * manager.
  35812. * @param index the rendering group index to get the information for
  35813. * @returns The auto clear setup for the requested rendering group
  35814. */
  35815. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35816. private _blockMaterialDirtyMechanism;
  35817. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35818. blockMaterialDirtyMechanism: boolean;
  35819. /**
  35820. * Will flag all materials as dirty to trigger new shader compilation
  35821. * @param flag defines the flag used to specify which material part must be marked as dirty
  35822. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35823. */
  35824. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35825. /** @hidden */
  35826. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35827. /** @hidden */
  35828. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35829. }
  35830. }
  35831. declare module "babylonjs/assetContainer" {
  35832. import { AbstractScene } from "babylonjs/abstractScene";
  35833. import { Scene } from "babylonjs/scene";
  35834. import { Mesh } from "babylonjs/Meshes/mesh";
  35835. /**
  35836. * Set of assets to keep when moving a scene into an asset container.
  35837. */
  35838. export class KeepAssets extends AbstractScene {
  35839. }
  35840. /**
  35841. * Container with a set of assets that can be added or removed from a scene.
  35842. */
  35843. export class AssetContainer extends AbstractScene {
  35844. /**
  35845. * The scene the AssetContainer belongs to.
  35846. */
  35847. scene: Scene;
  35848. /**
  35849. * Instantiates an AssetContainer.
  35850. * @param scene The scene the AssetContainer belongs to.
  35851. */
  35852. constructor(scene: Scene);
  35853. /**
  35854. * Adds all the assets from the container to the scene.
  35855. */
  35856. addAllToScene(): void;
  35857. /**
  35858. * Removes all the assets in the container from the scene
  35859. */
  35860. removeAllFromScene(): void;
  35861. /**
  35862. * Disposes all the assets in the container
  35863. */
  35864. dispose(): void;
  35865. private _moveAssets;
  35866. /**
  35867. * Removes all the assets contained in the scene and adds them to the container.
  35868. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35869. */
  35870. moveAllFromScene(keepAssets?: KeepAssets): void;
  35871. /**
  35872. * 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.
  35873. * @returns the root mesh
  35874. */
  35875. createRootMesh(): Mesh;
  35876. }
  35877. }
  35878. declare module "babylonjs/abstractScene" {
  35879. import { Scene } from "babylonjs/scene";
  35880. import { Nullable } from "babylonjs/types";
  35881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35883. import { Geometry } from "babylonjs/Meshes/geometry";
  35884. import { Skeleton } from "babylonjs/Bones/skeleton";
  35885. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35886. import { AssetContainer } from "babylonjs/assetContainer";
  35887. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35888. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35890. import { Material } from "babylonjs/Materials/material";
  35891. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35893. import { Camera } from "babylonjs/Cameras/camera";
  35894. import { Light } from "babylonjs/Lights/light";
  35895. import { Node } from "babylonjs/node";
  35896. import { Animation } from "babylonjs/Animations/animation";
  35897. /**
  35898. * Defines how the parser contract is defined.
  35899. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35900. */
  35901. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35902. /**
  35903. * Defines how the individual parser contract is defined.
  35904. * These parser can parse an individual asset
  35905. */
  35906. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35907. /**
  35908. * Base class of the scene acting as a container for the different elements composing a scene.
  35909. * This class is dynamically extended by the different components of the scene increasing
  35910. * flexibility and reducing coupling
  35911. */
  35912. export abstract class AbstractScene {
  35913. /**
  35914. * Stores the list of available parsers in the application.
  35915. */
  35916. private static _BabylonFileParsers;
  35917. /**
  35918. * Stores the list of available individual parsers in the application.
  35919. */
  35920. private static _IndividualBabylonFileParsers;
  35921. /**
  35922. * Adds a parser in the list of available ones
  35923. * @param name Defines the name of the parser
  35924. * @param parser Defines the parser to add
  35925. */
  35926. static AddParser(name: string, parser: BabylonFileParser): void;
  35927. /**
  35928. * Gets a general parser from the list of avaialble ones
  35929. * @param name Defines the name of the parser
  35930. * @returns the requested parser or null
  35931. */
  35932. static GetParser(name: string): Nullable<BabylonFileParser>;
  35933. /**
  35934. * Adds n individual parser in the list of available ones
  35935. * @param name Defines the name of the parser
  35936. * @param parser Defines the parser to add
  35937. */
  35938. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35939. /**
  35940. * Gets an individual parser from the list of avaialble ones
  35941. * @param name Defines the name of the parser
  35942. * @returns the requested parser or null
  35943. */
  35944. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35945. /**
  35946. * Parser json data and populate both a scene and its associated container object
  35947. * @param jsonData Defines the data to parse
  35948. * @param scene Defines the scene to parse the data for
  35949. * @param container Defines the container attached to the parsing sequence
  35950. * @param rootUrl Defines the root url of the data
  35951. */
  35952. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35953. /**
  35954. * Gets the list of root nodes (ie. nodes with no parent)
  35955. */
  35956. rootNodes: Node[];
  35957. /** All of the cameras added to this scene
  35958. * @see http://doc.babylonjs.com/babylon101/cameras
  35959. */
  35960. cameras: Camera[];
  35961. /**
  35962. * All of the lights added to this scene
  35963. * @see http://doc.babylonjs.com/babylon101/lights
  35964. */
  35965. lights: Light[];
  35966. /**
  35967. * All of the (abstract) meshes added to this scene
  35968. */
  35969. meshes: AbstractMesh[];
  35970. /**
  35971. * The list of skeletons added to the scene
  35972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35973. */
  35974. skeletons: Skeleton[];
  35975. /**
  35976. * All of the particle systems added to this scene
  35977. * @see http://doc.babylonjs.com/babylon101/particles
  35978. */
  35979. particleSystems: IParticleSystem[];
  35980. /**
  35981. * Gets a list of Animations associated with the scene
  35982. */
  35983. animations: Animation[];
  35984. /**
  35985. * All of the animation groups added to this scene
  35986. * @see http://doc.babylonjs.com/how_to/group
  35987. */
  35988. animationGroups: AnimationGroup[];
  35989. /**
  35990. * All of the multi-materials added to this scene
  35991. * @see http://doc.babylonjs.com/how_to/multi_materials
  35992. */
  35993. multiMaterials: MultiMaterial[];
  35994. /**
  35995. * All of the materials added to this scene
  35996. * In the context of a Scene, it is not supposed to be modified manually.
  35997. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35998. * Note also that the order of the Material wihin the array is not significant and might change.
  35999. * @see http://doc.babylonjs.com/babylon101/materials
  36000. */
  36001. materials: Material[];
  36002. /**
  36003. * The list of morph target managers added to the scene
  36004. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36005. */
  36006. morphTargetManagers: MorphTargetManager[];
  36007. /**
  36008. * The list of geometries used in the scene.
  36009. */
  36010. geometries: Geometry[];
  36011. /**
  36012. * All of the tranform nodes added to this scene
  36013. * In the context of a Scene, it is not supposed to be modified manually.
  36014. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36015. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36016. * @see http://doc.babylonjs.com/how_to/transformnode
  36017. */
  36018. transformNodes: TransformNode[];
  36019. /**
  36020. * ActionManagers available on the scene.
  36021. */
  36022. actionManagers: AbstractActionManager[];
  36023. /**
  36024. * Textures to keep.
  36025. */
  36026. textures: BaseTexture[];
  36027. /**
  36028. * Environment texture for the scene
  36029. */
  36030. environmentTexture: Nullable<BaseTexture>;
  36031. }
  36032. }
  36033. declare module "babylonjs/Audio/sound" {
  36034. import { Observable } from "babylonjs/Misc/observable";
  36035. import { Vector3 } from "babylonjs/Maths/math.vector";
  36036. import { Nullable } from "babylonjs/types";
  36037. import { Scene } from "babylonjs/scene";
  36038. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36039. /**
  36040. * Interface used to define options for Sound class
  36041. */
  36042. export interface ISoundOptions {
  36043. /**
  36044. * Does the sound autoplay once loaded.
  36045. */
  36046. autoplay?: boolean;
  36047. /**
  36048. * Does the sound loop after it finishes playing once.
  36049. */
  36050. loop?: boolean;
  36051. /**
  36052. * Sound's volume
  36053. */
  36054. volume?: number;
  36055. /**
  36056. * Is it a spatial sound?
  36057. */
  36058. spatialSound?: boolean;
  36059. /**
  36060. * Maximum distance to hear that sound
  36061. */
  36062. maxDistance?: number;
  36063. /**
  36064. * Uses user defined attenuation function
  36065. */
  36066. useCustomAttenuation?: boolean;
  36067. /**
  36068. * Define the roll off factor of spatial sounds.
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36070. */
  36071. rolloffFactor?: number;
  36072. /**
  36073. * Define the reference distance the sound should be heard perfectly.
  36074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36075. */
  36076. refDistance?: number;
  36077. /**
  36078. * Define the distance attenuation model the sound will follow.
  36079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36080. */
  36081. distanceModel?: string;
  36082. /**
  36083. * Defines the playback speed (1 by default)
  36084. */
  36085. playbackRate?: number;
  36086. /**
  36087. * Defines if the sound is from a streaming source
  36088. */
  36089. streaming?: boolean;
  36090. /**
  36091. * Defines an optional length (in seconds) inside the sound file
  36092. */
  36093. length?: number;
  36094. /**
  36095. * Defines an optional offset (in seconds) inside the sound file
  36096. */
  36097. offset?: number;
  36098. /**
  36099. * If true, URLs will not be required to state the audio file codec to use.
  36100. */
  36101. skipCodecCheck?: boolean;
  36102. }
  36103. /**
  36104. * Defines a sound that can be played in the application.
  36105. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36107. */
  36108. export class Sound {
  36109. /**
  36110. * The name of the sound in the scene.
  36111. */
  36112. name: string;
  36113. /**
  36114. * Does the sound autoplay once loaded.
  36115. */
  36116. autoplay: boolean;
  36117. /**
  36118. * Does the sound loop after it finishes playing once.
  36119. */
  36120. loop: boolean;
  36121. /**
  36122. * Does the sound use a custom attenuation curve to simulate the falloff
  36123. * happening when the source gets further away from the camera.
  36124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36125. */
  36126. useCustomAttenuation: boolean;
  36127. /**
  36128. * The sound track id this sound belongs to.
  36129. */
  36130. soundTrackId: number;
  36131. /**
  36132. * Is this sound currently played.
  36133. */
  36134. isPlaying: boolean;
  36135. /**
  36136. * Is this sound currently paused.
  36137. */
  36138. isPaused: boolean;
  36139. /**
  36140. * Does this sound enables spatial sound.
  36141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36142. */
  36143. spatialSound: boolean;
  36144. /**
  36145. * Define the reference distance the sound should be heard perfectly.
  36146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36147. */
  36148. refDistance: number;
  36149. /**
  36150. * Define the roll off factor of spatial sounds.
  36151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36152. */
  36153. rolloffFactor: number;
  36154. /**
  36155. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36157. */
  36158. maxDistance: number;
  36159. /**
  36160. * Define the distance attenuation model the sound will follow.
  36161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36162. */
  36163. distanceModel: string;
  36164. /**
  36165. * @hidden
  36166. * Back Compat
  36167. **/
  36168. onended: () => any;
  36169. /**
  36170. * Observable event when the current playing sound finishes.
  36171. */
  36172. onEndedObservable: Observable<Sound>;
  36173. private _panningModel;
  36174. private _playbackRate;
  36175. private _streaming;
  36176. private _startTime;
  36177. private _startOffset;
  36178. private _position;
  36179. /** @hidden */
  36180. _positionInEmitterSpace: boolean;
  36181. private _localDirection;
  36182. private _volume;
  36183. private _isReadyToPlay;
  36184. private _isDirectional;
  36185. private _readyToPlayCallback;
  36186. private _audioBuffer;
  36187. private _soundSource;
  36188. private _streamingSource;
  36189. private _soundPanner;
  36190. private _soundGain;
  36191. private _inputAudioNode;
  36192. private _outputAudioNode;
  36193. private _coneInnerAngle;
  36194. private _coneOuterAngle;
  36195. private _coneOuterGain;
  36196. private _scene;
  36197. private _connectedTransformNode;
  36198. private _customAttenuationFunction;
  36199. private _registerFunc;
  36200. private _isOutputConnected;
  36201. private _htmlAudioElement;
  36202. private _urlType;
  36203. private _length?;
  36204. private _offset?;
  36205. /** @hidden */
  36206. static _SceneComponentInitialization: (scene: Scene) => void;
  36207. /**
  36208. * Create a sound and attach it to a scene
  36209. * @param name Name of your sound
  36210. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36211. * @param scene defines the scene the sound belongs to
  36212. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36213. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36214. */
  36215. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36216. /**
  36217. * Release the sound and its associated resources
  36218. */
  36219. dispose(): void;
  36220. /**
  36221. * Gets if the sounds is ready to be played or not.
  36222. * @returns true if ready, otherwise false
  36223. */
  36224. isReady(): boolean;
  36225. private _soundLoaded;
  36226. /**
  36227. * Sets the data of the sound from an audiobuffer
  36228. * @param audioBuffer The audioBuffer containing the data
  36229. */
  36230. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36231. /**
  36232. * Updates the current sounds options such as maxdistance, loop...
  36233. * @param options A JSON object containing values named as the object properties
  36234. */
  36235. updateOptions(options: ISoundOptions): void;
  36236. private _createSpatialParameters;
  36237. private _updateSpatialParameters;
  36238. /**
  36239. * Switch the panning model to HRTF:
  36240. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36242. */
  36243. switchPanningModelToHRTF(): void;
  36244. /**
  36245. * Switch the panning model to Equal Power:
  36246. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36248. */
  36249. switchPanningModelToEqualPower(): void;
  36250. private _switchPanningModel;
  36251. /**
  36252. * Connect this sound to a sound track audio node like gain...
  36253. * @param soundTrackAudioNode the sound track audio node to connect to
  36254. */
  36255. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36256. /**
  36257. * Transform this sound into a directional source
  36258. * @param coneInnerAngle Size of the inner cone in degree
  36259. * @param coneOuterAngle Size of the outer cone in degree
  36260. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36261. */
  36262. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36263. /**
  36264. * Gets or sets the inner angle for the directional cone.
  36265. */
  36266. /**
  36267. * Gets or sets the inner angle for the directional cone.
  36268. */
  36269. directionalConeInnerAngle: number;
  36270. /**
  36271. * Gets or sets the outer angle for the directional cone.
  36272. */
  36273. /**
  36274. * Gets or sets the outer angle for the directional cone.
  36275. */
  36276. directionalConeOuterAngle: number;
  36277. /**
  36278. * Sets the position of the emitter if spatial sound is enabled
  36279. * @param newPosition Defines the new posisiton
  36280. */
  36281. setPosition(newPosition: Vector3): void;
  36282. /**
  36283. * Sets the local direction of the emitter if spatial sound is enabled
  36284. * @param newLocalDirection Defines the new local direction
  36285. */
  36286. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36287. private _updateDirection;
  36288. /** @hidden */
  36289. updateDistanceFromListener(): void;
  36290. /**
  36291. * Sets a new custom attenuation function for the sound.
  36292. * @param callback Defines the function used for the attenuation
  36293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36294. */
  36295. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36296. /**
  36297. * Play the sound
  36298. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36299. * @param offset (optional) Start the sound at a specific time in seconds
  36300. * @param length (optional) Sound duration (in seconds)
  36301. */
  36302. play(time?: number, offset?: number, length?: number): void;
  36303. private _onended;
  36304. /**
  36305. * Stop the sound
  36306. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36307. */
  36308. stop(time?: number): void;
  36309. /**
  36310. * Put the sound in pause
  36311. */
  36312. pause(): void;
  36313. /**
  36314. * Sets a dedicated volume for this sounds
  36315. * @param newVolume Define the new volume of the sound
  36316. * @param time Define time for gradual change to new volume
  36317. */
  36318. setVolume(newVolume: number, time?: number): void;
  36319. /**
  36320. * Set the sound play back rate
  36321. * @param newPlaybackRate Define the playback rate the sound should be played at
  36322. */
  36323. setPlaybackRate(newPlaybackRate: number): void;
  36324. /**
  36325. * Gets the volume of the sound.
  36326. * @returns the volume of the sound
  36327. */
  36328. getVolume(): number;
  36329. /**
  36330. * Attach the sound to a dedicated mesh
  36331. * @param transformNode The transform node to connect the sound with
  36332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36333. */
  36334. attachToMesh(transformNode: TransformNode): void;
  36335. /**
  36336. * Detach the sound from the previously attached mesh
  36337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36338. */
  36339. detachFromMesh(): void;
  36340. private _onRegisterAfterWorldMatrixUpdate;
  36341. /**
  36342. * Clone the current sound in the scene.
  36343. * @returns the new sound clone
  36344. */
  36345. clone(): Nullable<Sound>;
  36346. /**
  36347. * Gets the current underlying audio buffer containing the data
  36348. * @returns the audio buffer
  36349. */
  36350. getAudioBuffer(): Nullable<AudioBuffer>;
  36351. /**
  36352. * Serializes the Sound in a JSON representation
  36353. * @returns the JSON representation of the sound
  36354. */
  36355. serialize(): any;
  36356. /**
  36357. * Parse a JSON representation of a sound to innstantiate in a given scene
  36358. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36359. * @param scene Define the scene the new parsed sound should be created in
  36360. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36361. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36362. * @returns the newly parsed sound
  36363. */
  36364. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36365. }
  36366. }
  36367. declare module "babylonjs/Actions/directAudioActions" {
  36368. import { Action } from "babylonjs/Actions/action";
  36369. import { Condition } from "babylonjs/Actions/condition";
  36370. import { Sound } from "babylonjs/Audio/sound";
  36371. /**
  36372. * This defines an action helpful to play a defined sound on a triggered action.
  36373. */
  36374. export class PlaySoundAction extends Action {
  36375. private _sound;
  36376. /**
  36377. * Instantiate the action
  36378. * @param triggerOptions defines the trigger options
  36379. * @param sound defines the sound to play
  36380. * @param condition defines the trigger related conditions
  36381. */
  36382. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36383. /** @hidden */
  36384. _prepare(): void;
  36385. /**
  36386. * Execute the action and play the sound.
  36387. */
  36388. execute(): void;
  36389. /**
  36390. * Serializes the actions and its related information.
  36391. * @param parent defines the object to serialize in
  36392. * @returns the serialized object
  36393. */
  36394. serialize(parent: any): any;
  36395. }
  36396. /**
  36397. * This defines an action helpful to stop a defined sound on a triggered action.
  36398. */
  36399. export class StopSoundAction extends Action {
  36400. private _sound;
  36401. /**
  36402. * Instantiate the action
  36403. * @param triggerOptions defines the trigger options
  36404. * @param sound defines the sound to stop
  36405. * @param condition defines the trigger related conditions
  36406. */
  36407. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36408. /** @hidden */
  36409. _prepare(): void;
  36410. /**
  36411. * Execute the action and stop the sound.
  36412. */
  36413. execute(): void;
  36414. /**
  36415. * Serializes the actions and its related information.
  36416. * @param parent defines the object to serialize in
  36417. * @returns the serialized object
  36418. */
  36419. serialize(parent: any): any;
  36420. }
  36421. }
  36422. declare module "babylonjs/Actions/interpolateValueAction" {
  36423. import { Action } from "babylonjs/Actions/action";
  36424. import { Condition } from "babylonjs/Actions/condition";
  36425. import { Observable } from "babylonjs/Misc/observable";
  36426. /**
  36427. * This defines an action responsible to change the value of a property
  36428. * by interpolating between its current value and the newly set one once triggered.
  36429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36430. */
  36431. export class InterpolateValueAction extends Action {
  36432. /**
  36433. * Defines the path of the property where the value should be interpolated
  36434. */
  36435. propertyPath: string;
  36436. /**
  36437. * Defines the target value at the end of the interpolation.
  36438. */
  36439. value: any;
  36440. /**
  36441. * Defines the time it will take for the property to interpolate to the value.
  36442. */
  36443. duration: number;
  36444. /**
  36445. * Defines if the other scene animations should be stopped when the action has been triggered
  36446. */
  36447. stopOtherAnimations?: boolean;
  36448. /**
  36449. * Defines a callback raised once the interpolation animation has been done.
  36450. */
  36451. onInterpolationDone?: () => void;
  36452. /**
  36453. * Observable triggered once the interpolation animation has been done.
  36454. */
  36455. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36456. private _target;
  36457. private _effectiveTarget;
  36458. private _property;
  36459. /**
  36460. * Instantiate the action
  36461. * @param triggerOptions defines the trigger options
  36462. * @param target defines the object containing the value to interpolate
  36463. * @param propertyPath defines the path to the property in the target object
  36464. * @param value defines the target value at the end of the interpolation
  36465. * @param duration deines the time it will take for the property to interpolate to the value.
  36466. * @param condition defines the trigger related conditions
  36467. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36468. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36469. */
  36470. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36471. /** @hidden */
  36472. _prepare(): void;
  36473. /**
  36474. * Execute the action starts the value interpolation.
  36475. */
  36476. execute(): void;
  36477. /**
  36478. * Serializes the actions and its related information.
  36479. * @param parent defines the object to serialize in
  36480. * @returns the serialized object
  36481. */
  36482. serialize(parent: any): any;
  36483. }
  36484. }
  36485. declare module "babylonjs/Actions/index" {
  36486. export * from "babylonjs/Actions/abstractActionManager";
  36487. export * from "babylonjs/Actions/action";
  36488. export * from "babylonjs/Actions/actionEvent";
  36489. export * from "babylonjs/Actions/actionManager";
  36490. export * from "babylonjs/Actions/condition";
  36491. export * from "babylonjs/Actions/directActions";
  36492. export * from "babylonjs/Actions/directAudioActions";
  36493. export * from "babylonjs/Actions/interpolateValueAction";
  36494. }
  36495. declare module "babylonjs/Animations/index" {
  36496. export * from "babylonjs/Animations/animatable";
  36497. export * from "babylonjs/Animations/animation";
  36498. export * from "babylonjs/Animations/animationGroup";
  36499. export * from "babylonjs/Animations/animationPropertiesOverride";
  36500. export * from "babylonjs/Animations/easing";
  36501. export * from "babylonjs/Animations/runtimeAnimation";
  36502. export * from "babylonjs/Animations/animationEvent";
  36503. export * from "babylonjs/Animations/animationGroup";
  36504. export * from "babylonjs/Animations/animationKey";
  36505. export * from "babylonjs/Animations/animationRange";
  36506. export * from "babylonjs/Animations/animatable.interface";
  36507. }
  36508. declare module "babylonjs/Audio/soundTrack" {
  36509. import { Sound } from "babylonjs/Audio/sound";
  36510. import { Analyser } from "babylonjs/Audio/analyser";
  36511. import { Scene } from "babylonjs/scene";
  36512. /**
  36513. * Options allowed during the creation of a sound track.
  36514. */
  36515. export interface ISoundTrackOptions {
  36516. /**
  36517. * The volume the sound track should take during creation
  36518. */
  36519. volume?: number;
  36520. /**
  36521. * Define if the sound track is the main sound track of the scene
  36522. */
  36523. mainTrack?: boolean;
  36524. }
  36525. /**
  36526. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36527. * It will be also used in a future release to apply effects on a specific track.
  36528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36529. */
  36530. export class SoundTrack {
  36531. /**
  36532. * The unique identifier of the sound track in the scene.
  36533. */
  36534. id: number;
  36535. /**
  36536. * The list of sounds included in the sound track.
  36537. */
  36538. soundCollection: Array<Sound>;
  36539. private _outputAudioNode;
  36540. private _scene;
  36541. private _isMainTrack;
  36542. private _connectedAnalyser;
  36543. private _options;
  36544. private _isInitialized;
  36545. /**
  36546. * Creates a new sound track.
  36547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36548. * @param scene Define the scene the sound track belongs to
  36549. * @param options
  36550. */
  36551. constructor(scene: Scene, options?: ISoundTrackOptions);
  36552. private _initializeSoundTrackAudioGraph;
  36553. /**
  36554. * Release the sound track and its associated resources
  36555. */
  36556. dispose(): void;
  36557. /**
  36558. * Adds a sound to this sound track
  36559. * @param sound define the cound to add
  36560. * @ignoreNaming
  36561. */
  36562. AddSound(sound: Sound): void;
  36563. /**
  36564. * Removes a sound to this sound track
  36565. * @param sound define the cound to remove
  36566. * @ignoreNaming
  36567. */
  36568. RemoveSound(sound: Sound): void;
  36569. /**
  36570. * Set a global volume for the full sound track.
  36571. * @param newVolume Define the new volume of the sound track
  36572. */
  36573. setVolume(newVolume: number): void;
  36574. /**
  36575. * Switch the panning model to HRTF:
  36576. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36578. */
  36579. switchPanningModelToHRTF(): void;
  36580. /**
  36581. * Switch the panning model to Equal Power:
  36582. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36584. */
  36585. switchPanningModelToEqualPower(): void;
  36586. /**
  36587. * Connect the sound track to an audio analyser allowing some amazing
  36588. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36590. * @param analyser The analyser to connect to the engine
  36591. */
  36592. connectToAnalyser(analyser: Analyser): void;
  36593. }
  36594. }
  36595. declare module "babylonjs/Audio/audioSceneComponent" {
  36596. import { Sound } from "babylonjs/Audio/sound";
  36597. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36598. import { Nullable } from "babylonjs/types";
  36599. import { Vector3 } from "babylonjs/Maths/math.vector";
  36600. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36601. import { Scene } from "babylonjs/scene";
  36602. import { AbstractScene } from "babylonjs/abstractScene";
  36603. import "babylonjs/Audio/audioEngine";
  36604. module "babylonjs/abstractScene" {
  36605. interface AbstractScene {
  36606. /**
  36607. * The list of sounds used in the scene.
  36608. */
  36609. sounds: Nullable<Array<Sound>>;
  36610. }
  36611. }
  36612. module "babylonjs/scene" {
  36613. interface Scene {
  36614. /**
  36615. * @hidden
  36616. * Backing field
  36617. */
  36618. _mainSoundTrack: SoundTrack;
  36619. /**
  36620. * The main sound track played by the scene.
  36621. * It cotains your primary collection of sounds.
  36622. */
  36623. mainSoundTrack: SoundTrack;
  36624. /**
  36625. * The list of sound tracks added to the scene
  36626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36627. */
  36628. soundTracks: Nullable<Array<SoundTrack>>;
  36629. /**
  36630. * Gets a sound using a given name
  36631. * @param name defines the name to search for
  36632. * @return the found sound or null if not found at all.
  36633. */
  36634. getSoundByName(name: string): Nullable<Sound>;
  36635. /**
  36636. * Gets or sets if audio support is enabled
  36637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36638. */
  36639. audioEnabled: boolean;
  36640. /**
  36641. * Gets or sets if audio will be output to headphones
  36642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36643. */
  36644. headphone: boolean;
  36645. /**
  36646. * Gets or sets custom audio listener position provider
  36647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36648. */
  36649. audioListenerPositionProvider: Nullable<() => Vector3>;
  36650. }
  36651. }
  36652. /**
  36653. * Defines the sound scene component responsible to manage any sounds
  36654. * in a given scene.
  36655. */
  36656. export class AudioSceneComponent implements ISceneSerializableComponent {
  36657. /**
  36658. * The component name helpfull to identify the component in the list of scene components.
  36659. */
  36660. readonly name: string;
  36661. /**
  36662. * The scene the component belongs to.
  36663. */
  36664. scene: Scene;
  36665. private _audioEnabled;
  36666. /**
  36667. * Gets whether audio is enabled or not.
  36668. * Please use related enable/disable method to switch state.
  36669. */
  36670. readonly audioEnabled: boolean;
  36671. private _headphone;
  36672. /**
  36673. * Gets whether audio is outputing to headphone or not.
  36674. * Please use the according Switch methods to change output.
  36675. */
  36676. readonly headphone: boolean;
  36677. private _audioListenerPositionProvider;
  36678. /**
  36679. * Gets the current audio listener position provider
  36680. */
  36681. /**
  36682. * Sets a custom listener position for all sounds in the scene
  36683. * By default, this is the position of the first active camera
  36684. */
  36685. audioListenerPositionProvider: Nullable<() => Vector3>;
  36686. /**
  36687. * Creates a new instance of the component for the given scene
  36688. * @param scene Defines the scene to register the component in
  36689. */
  36690. constructor(scene: Scene);
  36691. /**
  36692. * Registers the component in a given scene
  36693. */
  36694. register(): void;
  36695. /**
  36696. * Rebuilds the elements related to this component in case of
  36697. * context lost for instance.
  36698. */
  36699. rebuild(): void;
  36700. /**
  36701. * Serializes the component data to the specified json object
  36702. * @param serializationObject The object to serialize to
  36703. */
  36704. serialize(serializationObject: any): void;
  36705. /**
  36706. * Adds all the elements from the container to the scene
  36707. * @param container the container holding the elements
  36708. */
  36709. addFromContainer(container: AbstractScene): void;
  36710. /**
  36711. * Removes all the elements in the container from the scene
  36712. * @param container contains the elements to remove
  36713. * @param dispose if the removed element should be disposed (default: false)
  36714. */
  36715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36716. /**
  36717. * Disposes the component and the associated ressources.
  36718. */
  36719. dispose(): void;
  36720. /**
  36721. * Disables audio in the associated scene.
  36722. */
  36723. disableAudio(): void;
  36724. /**
  36725. * Enables audio in the associated scene.
  36726. */
  36727. enableAudio(): void;
  36728. /**
  36729. * Switch audio to headphone output.
  36730. */
  36731. switchAudioModeForHeadphones(): void;
  36732. /**
  36733. * Switch audio to normal speakers.
  36734. */
  36735. switchAudioModeForNormalSpeakers(): void;
  36736. private _afterRender;
  36737. }
  36738. }
  36739. declare module "babylonjs/Audio/weightedsound" {
  36740. import { Sound } from "babylonjs/Audio/sound";
  36741. /**
  36742. * Wraps one or more Sound objects and selects one with random weight for playback.
  36743. */
  36744. export class WeightedSound {
  36745. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36746. loop: boolean;
  36747. private _coneInnerAngle;
  36748. private _coneOuterAngle;
  36749. private _volume;
  36750. /** A Sound is currently playing. */
  36751. isPlaying: boolean;
  36752. /** A Sound is currently paused. */
  36753. isPaused: boolean;
  36754. private _sounds;
  36755. private _weights;
  36756. private _currentIndex?;
  36757. /**
  36758. * Creates a new WeightedSound from the list of sounds given.
  36759. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36760. * @param sounds Array of Sounds that will be selected from.
  36761. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36762. */
  36763. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36764. /**
  36765. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36766. */
  36767. /**
  36768. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36769. */
  36770. directionalConeInnerAngle: number;
  36771. /**
  36772. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36773. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36774. */
  36775. /**
  36776. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36777. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36778. */
  36779. directionalConeOuterAngle: number;
  36780. /**
  36781. * Playback volume.
  36782. */
  36783. /**
  36784. * Playback volume.
  36785. */
  36786. volume: number;
  36787. private _onended;
  36788. /**
  36789. * Suspend playback
  36790. */
  36791. pause(): void;
  36792. /**
  36793. * Stop playback
  36794. */
  36795. stop(): void;
  36796. /**
  36797. * Start playback.
  36798. * @param startOffset Position the clip head at a specific time in seconds.
  36799. */
  36800. play(startOffset?: number): void;
  36801. }
  36802. }
  36803. declare module "babylonjs/Audio/index" {
  36804. export * from "babylonjs/Audio/analyser";
  36805. export * from "babylonjs/Audio/audioEngine";
  36806. export * from "babylonjs/Audio/audioSceneComponent";
  36807. export * from "babylonjs/Audio/sound";
  36808. export * from "babylonjs/Audio/soundTrack";
  36809. export * from "babylonjs/Audio/weightedsound";
  36810. }
  36811. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36812. import { Behavior } from "babylonjs/Behaviors/behavior";
  36813. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36814. import { BackEase } from "babylonjs/Animations/easing";
  36815. /**
  36816. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36817. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36818. */
  36819. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36820. /**
  36821. * Gets the name of the behavior.
  36822. */
  36823. readonly name: string;
  36824. /**
  36825. * The easing function used by animations
  36826. */
  36827. static EasingFunction: BackEase;
  36828. /**
  36829. * The easing mode used by animations
  36830. */
  36831. static EasingMode: number;
  36832. /**
  36833. * The duration of the animation, in milliseconds
  36834. */
  36835. transitionDuration: number;
  36836. /**
  36837. * Length of the distance animated by the transition when lower radius is reached
  36838. */
  36839. lowerRadiusTransitionRange: number;
  36840. /**
  36841. * Length of the distance animated by the transition when upper radius is reached
  36842. */
  36843. upperRadiusTransitionRange: number;
  36844. private _autoTransitionRange;
  36845. /**
  36846. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36847. */
  36848. /**
  36849. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36850. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36851. */
  36852. autoTransitionRange: boolean;
  36853. private _attachedCamera;
  36854. private _onAfterCheckInputsObserver;
  36855. private _onMeshTargetChangedObserver;
  36856. /**
  36857. * Initializes the behavior.
  36858. */
  36859. init(): void;
  36860. /**
  36861. * Attaches the behavior to its arc rotate camera.
  36862. * @param camera Defines the camera to attach the behavior to
  36863. */
  36864. attach(camera: ArcRotateCamera): void;
  36865. /**
  36866. * Detaches the behavior from its current arc rotate camera.
  36867. */
  36868. detach(): void;
  36869. private _radiusIsAnimating;
  36870. private _radiusBounceTransition;
  36871. private _animatables;
  36872. private _cachedWheelPrecision;
  36873. /**
  36874. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36875. * @param radiusLimit The limit to check against.
  36876. * @return Bool to indicate if at limit.
  36877. */
  36878. private _isRadiusAtLimit;
  36879. /**
  36880. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36881. * @param radiusDelta The delta by which to animate to. Can be negative.
  36882. */
  36883. private _applyBoundRadiusAnimation;
  36884. /**
  36885. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36886. */
  36887. protected _clearAnimationLocks(): void;
  36888. /**
  36889. * Stops and removes all animations that have been applied to the camera
  36890. */
  36891. stopAllAnimations(): void;
  36892. }
  36893. }
  36894. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36895. import { Behavior } from "babylonjs/Behaviors/behavior";
  36896. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36897. import { ExponentialEase } from "babylonjs/Animations/easing";
  36898. import { Nullable } from "babylonjs/types";
  36899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36900. import { Vector3 } from "babylonjs/Maths/math.vector";
  36901. /**
  36902. * 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.
  36903. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36904. */
  36905. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36906. /**
  36907. * Gets the name of the behavior.
  36908. */
  36909. readonly name: string;
  36910. private _mode;
  36911. private _radiusScale;
  36912. private _positionScale;
  36913. private _defaultElevation;
  36914. private _elevationReturnTime;
  36915. private _elevationReturnWaitTime;
  36916. private _zoomStopsAnimation;
  36917. private _framingTime;
  36918. /**
  36919. * The easing function used by animations
  36920. */
  36921. static EasingFunction: ExponentialEase;
  36922. /**
  36923. * The easing mode used by animations
  36924. */
  36925. static EasingMode: number;
  36926. /**
  36927. * Sets the current mode used by the behavior
  36928. */
  36929. /**
  36930. * Gets current mode used by the behavior.
  36931. */
  36932. mode: number;
  36933. /**
  36934. * Sets the scale applied to the radius (1 by default)
  36935. */
  36936. /**
  36937. * Gets the scale applied to the radius
  36938. */
  36939. radiusScale: number;
  36940. /**
  36941. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36942. */
  36943. /**
  36944. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36945. */
  36946. positionScale: number;
  36947. /**
  36948. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36949. * behaviour is triggered, in radians.
  36950. */
  36951. /**
  36952. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36953. * behaviour is triggered, in radians.
  36954. */
  36955. defaultElevation: number;
  36956. /**
  36957. * Sets the time (in milliseconds) taken to return to the default beta position.
  36958. * Negative value indicates camera should not return to default.
  36959. */
  36960. /**
  36961. * Gets the time (in milliseconds) taken to return to the default beta position.
  36962. * Negative value indicates camera should not return to default.
  36963. */
  36964. elevationReturnTime: number;
  36965. /**
  36966. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36967. */
  36968. /**
  36969. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36970. */
  36971. elevationReturnWaitTime: number;
  36972. /**
  36973. * Sets the flag that indicates if user zooming should stop animation.
  36974. */
  36975. /**
  36976. * Gets the flag that indicates if user zooming should stop animation.
  36977. */
  36978. zoomStopsAnimation: boolean;
  36979. /**
  36980. * Sets the transition time when framing the mesh, in milliseconds
  36981. */
  36982. /**
  36983. * Gets the transition time when framing the mesh, in milliseconds
  36984. */
  36985. framingTime: number;
  36986. /**
  36987. * Define if the behavior should automatically change the configured
  36988. * camera limits and sensibilities.
  36989. */
  36990. autoCorrectCameraLimitsAndSensibility: boolean;
  36991. private _onPrePointerObservableObserver;
  36992. private _onAfterCheckInputsObserver;
  36993. private _onMeshTargetChangedObserver;
  36994. private _attachedCamera;
  36995. private _isPointerDown;
  36996. private _lastInteractionTime;
  36997. /**
  36998. * Initializes the behavior.
  36999. */
  37000. init(): void;
  37001. /**
  37002. * Attaches the behavior to its arc rotate camera.
  37003. * @param camera Defines the camera to attach the behavior to
  37004. */
  37005. attach(camera: ArcRotateCamera): void;
  37006. /**
  37007. * Detaches the behavior from its current arc rotate camera.
  37008. */
  37009. detach(): void;
  37010. private _animatables;
  37011. private _betaIsAnimating;
  37012. private _betaTransition;
  37013. private _radiusTransition;
  37014. private _vectorTransition;
  37015. /**
  37016. * Targets the given mesh and updates zoom level accordingly.
  37017. * @param mesh The mesh to target.
  37018. * @param radius Optional. If a cached radius position already exists, overrides default.
  37019. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37020. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37021. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37022. */
  37023. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37024. /**
  37025. * Targets the given mesh with its children and updates zoom level accordingly.
  37026. * @param mesh The mesh to target.
  37027. * @param radius Optional. If a cached radius position already exists, overrides default.
  37028. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37031. */
  37032. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37033. /**
  37034. * Targets the given meshes with their children and updates zoom level accordingly.
  37035. * @param meshes The mesh to target.
  37036. * @param radius Optional. If a cached radius position already exists, overrides default.
  37037. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37038. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37039. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37040. */
  37041. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37042. /**
  37043. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37044. * @param minimumWorld Determines the smaller position of the bounding box extend
  37045. * @param maximumWorld Determines the bigger position of the bounding box extend
  37046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37048. */
  37049. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37050. /**
  37051. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37052. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37053. * frustum width.
  37054. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37055. * to fully enclose the mesh in the viewing frustum.
  37056. */
  37057. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37058. /**
  37059. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37060. * is automatically returned to its default position (expected to be above ground plane).
  37061. */
  37062. private _maintainCameraAboveGround;
  37063. /**
  37064. * Returns the frustum slope based on the canvas ratio and camera FOV
  37065. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37066. */
  37067. private _getFrustumSlope;
  37068. /**
  37069. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37070. */
  37071. private _clearAnimationLocks;
  37072. /**
  37073. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37074. */
  37075. private _applyUserInteraction;
  37076. /**
  37077. * Stops and removes all animations that have been applied to the camera
  37078. */
  37079. stopAllAnimations(): void;
  37080. /**
  37081. * Gets a value indicating if the user is moving the camera
  37082. */
  37083. readonly isUserIsMoving: boolean;
  37084. /**
  37085. * The camera can move all the way towards the mesh.
  37086. */
  37087. static IgnoreBoundsSizeMode: number;
  37088. /**
  37089. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37090. */
  37091. static FitFrustumSidesMode: number;
  37092. }
  37093. }
  37094. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37095. import { Nullable } from "babylonjs/types";
  37096. import { Camera } from "babylonjs/Cameras/camera";
  37097. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37098. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37099. /**
  37100. * Base class for Camera Pointer Inputs.
  37101. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37102. * for example usage.
  37103. */
  37104. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37105. /**
  37106. * Defines the camera the input is attached to.
  37107. */
  37108. abstract camera: Camera;
  37109. /**
  37110. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37111. */
  37112. protected _altKey: boolean;
  37113. protected _ctrlKey: boolean;
  37114. protected _metaKey: boolean;
  37115. protected _shiftKey: boolean;
  37116. /**
  37117. * Which mouse buttons were pressed at time of last mouse event.
  37118. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37119. */
  37120. protected _buttonsPressed: number;
  37121. /**
  37122. * Defines the buttons associated with the input to handle camera move.
  37123. */
  37124. buttons: number[];
  37125. /**
  37126. * Attach the input controls to a specific dom element to get the input from.
  37127. * @param element Defines the element the controls should be listened from
  37128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37129. */
  37130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37131. /**
  37132. * Detach the current controls from the specified dom element.
  37133. * @param element Defines the element to stop listening the inputs from
  37134. */
  37135. detachControl(element: Nullable<HTMLElement>): void;
  37136. /**
  37137. * Gets the class name of the current input.
  37138. * @returns the class name
  37139. */
  37140. getClassName(): string;
  37141. /**
  37142. * Get the friendly name associated with the input class.
  37143. * @returns the input friendly name
  37144. */
  37145. getSimpleName(): string;
  37146. /**
  37147. * Called on pointer POINTERDOUBLETAP event.
  37148. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37149. */
  37150. protected onDoubleTap(type: string): void;
  37151. /**
  37152. * Called on pointer POINTERMOVE event if only a single touch is active.
  37153. * Override this method to provide functionality.
  37154. */
  37155. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37156. /**
  37157. * Called on pointer POINTERMOVE event if multiple touches are active.
  37158. * Override this method to provide functionality.
  37159. */
  37160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37161. /**
  37162. * Called on JS contextmenu event.
  37163. * Override this method to provide functionality.
  37164. */
  37165. protected onContextMenu(evt: PointerEvent): void;
  37166. /**
  37167. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37168. * press.
  37169. * Override this method to provide functionality.
  37170. */
  37171. protected onButtonDown(evt: PointerEvent): void;
  37172. /**
  37173. * Called each time a new POINTERUP event occurs. Ie, for each button
  37174. * release.
  37175. * Override this method to provide functionality.
  37176. */
  37177. protected onButtonUp(evt: PointerEvent): void;
  37178. /**
  37179. * Called when window becomes inactive.
  37180. * Override this method to provide functionality.
  37181. */
  37182. protected onLostFocus(): void;
  37183. private _pointerInput;
  37184. private _observer;
  37185. private _onLostFocus;
  37186. private pointA;
  37187. private pointB;
  37188. }
  37189. }
  37190. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37191. import { Nullable } from "babylonjs/types";
  37192. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37193. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37194. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37195. /**
  37196. * Manage the pointers inputs to control an arc rotate camera.
  37197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37198. */
  37199. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37200. /**
  37201. * Defines the camera the input is attached to.
  37202. */
  37203. camera: ArcRotateCamera;
  37204. /**
  37205. * Gets the class name of the current input.
  37206. * @returns the class name
  37207. */
  37208. getClassName(): string;
  37209. /**
  37210. * Defines the buttons associated with the input to handle camera move.
  37211. */
  37212. buttons: number[];
  37213. /**
  37214. * Defines the pointer angular sensibility along the X axis or how fast is
  37215. * the camera rotating.
  37216. */
  37217. angularSensibilityX: number;
  37218. /**
  37219. * Defines the pointer angular sensibility along the Y axis or how fast is
  37220. * the camera rotating.
  37221. */
  37222. angularSensibilityY: number;
  37223. /**
  37224. * Defines the pointer pinch precision or how fast is the camera zooming.
  37225. */
  37226. pinchPrecision: number;
  37227. /**
  37228. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37229. * from 0.
  37230. * It defines the percentage of current camera.radius to use as delta when
  37231. * pinch zoom is used.
  37232. */
  37233. pinchDeltaPercentage: number;
  37234. /**
  37235. * Defines the pointer panning sensibility or how fast is the camera moving.
  37236. */
  37237. panningSensibility: number;
  37238. /**
  37239. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37240. */
  37241. multiTouchPanning: boolean;
  37242. /**
  37243. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37244. * zoom (pinch) through multitouch.
  37245. */
  37246. multiTouchPanAndZoom: boolean;
  37247. /**
  37248. * Revers pinch action direction.
  37249. */
  37250. pinchInwards: boolean;
  37251. private _isPanClick;
  37252. private _twoFingerActivityCount;
  37253. private _isPinching;
  37254. /**
  37255. * Called on pointer POINTERMOVE event if only a single touch is active.
  37256. */
  37257. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37258. /**
  37259. * Called on pointer POINTERDOUBLETAP event.
  37260. */
  37261. protected onDoubleTap(type: string): void;
  37262. /**
  37263. * Called on pointer POINTERMOVE event if multiple touches are active.
  37264. */
  37265. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37266. /**
  37267. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37268. * press.
  37269. */
  37270. protected onButtonDown(evt: PointerEvent): void;
  37271. /**
  37272. * Called each time a new POINTERUP event occurs. Ie, for each button
  37273. * release.
  37274. */
  37275. protected onButtonUp(evt: PointerEvent): void;
  37276. /**
  37277. * Called when window becomes inactive.
  37278. */
  37279. protected onLostFocus(): void;
  37280. }
  37281. }
  37282. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37283. import { Nullable } from "babylonjs/types";
  37284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37285. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37286. /**
  37287. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37289. */
  37290. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37291. /**
  37292. * Defines the camera the input is attached to.
  37293. */
  37294. camera: ArcRotateCamera;
  37295. /**
  37296. * Defines the list of key codes associated with the up action (increase alpha)
  37297. */
  37298. keysUp: number[];
  37299. /**
  37300. * Defines the list of key codes associated with the down action (decrease alpha)
  37301. */
  37302. keysDown: number[];
  37303. /**
  37304. * Defines the list of key codes associated with the left action (increase beta)
  37305. */
  37306. keysLeft: number[];
  37307. /**
  37308. * Defines the list of key codes associated with the right action (decrease beta)
  37309. */
  37310. keysRight: number[];
  37311. /**
  37312. * Defines the list of key codes associated with the reset action.
  37313. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37314. */
  37315. keysReset: number[];
  37316. /**
  37317. * Defines the panning sensibility of the inputs.
  37318. * (How fast is the camera paning)
  37319. */
  37320. panningSensibility: number;
  37321. /**
  37322. * Defines the zooming sensibility of the inputs.
  37323. * (How fast is the camera zooming)
  37324. */
  37325. zoomingSensibility: number;
  37326. /**
  37327. * Defines wether maintaining the alt key down switch the movement mode from
  37328. * orientation to zoom.
  37329. */
  37330. useAltToZoom: boolean;
  37331. /**
  37332. * Rotation speed of the camera
  37333. */
  37334. angularSpeed: number;
  37335. private _keys;
  37336. private _ctrlPressed;
  37337. private _altPressed;
  37338. private _onCanvasBlurObserver;
  37339. private _onKeyboardObserver;
  37340. private _engine;
  37341. private _scene;
  37342. /**
  37343. * Attach the input controls to a specific dom element to get the input from.
  37344. * @param element Defines the element the controls should be listened from
  37345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37346. */
  37347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37348. /**
  37349. * Detach the current controls from the specified dom element.
  37350. * @param element Defines the element to stop listening the inputs from
  37351. */
  37352. detachControl(element: Nullable<HTMLElement>): void;
  37353. /**
  37354. * Update the current camera state depending on the inputs that have been used this frame.
  37355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37356. */
  37357. checkInputs(): void;
  37358. /**
  37359. * Gets the class name of the current intput.
  37360. * @returns the class name
  37361. */
  37362. getClassName(): string;
  37363. /**
  37364. * Get the friendly name associated with the input class.
  37365. * @returns the input friendly name
  37366. */
  37367. getSimpleName(): string;
  37368. }
  37369. }
  37370. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37371. import { Nullable } from "babylonjs/types";
  37372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37374. /**
  37375. * Manage the mouse wheel inputs to control an arc rotate camera.
  37376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37377. */
  37378. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37379. /**
  37380. * Defines the camera the input is attached to.
  37381. */
  37382. camera: ArcRotateCamera;
  37383. /**
  37384. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37385. */
  37386. wheelPrecision: number;
  37387. /**
  37388. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37389. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37390. */
  37391. wheelDeltaPercentage: number;
  37392. private _wheel;
  37393. private _observer;
  37394. private computeDeltaFromMouseWheelLegacyEvent;
  37395. /**
  37396. * Attach the input controls to a specific dom element to get the input from.
  37397. * @param element Defines the element the controls should be listened from
  37398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37399. */
  37400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37401. /**
  37402. * Detach the current controls from the specified dom element.
  37403. * @param element Defines the element to stop listening the inputs from
  37404. */
  37405. detachControl(element: Nullable<HTMLElement>): void;
  37406. /**
  37407. * Gets the class name of the current intput.
  37408. * @returns the class name
  37409. */
  37410. getClassName(): string;
  37411. /**
  37412. * Get the friendly name associated with the input class.
  37413. * @returns the input friendly name
  37414. */
  37415. getSimpleName(): string;
  37416. }
  37417. }
  37418. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37419. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37420. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37421. /**
  37422. * Default Inputs manager for the ArcRotateCamera.
  37423. * It groups all the default supported inputs for ease of use.
  37424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37425. */
  37426. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37427. /**
  37428. * Instantiates a new ArcRotateCameraInputsManager.
  37429. * @param camera Defines the camera the inputs belong to
  37430. */
  37431. constructor(camera: ArcRotateCamera);
  37432. /**
  37433. * Add mouse wheel input support to the input manager.
  37434. * @returns the current input manager
  37435. */
  37436. addMouseWheel(): ArcRotateCameraInputsManager;
  37437. /**
  37438. * Add pointers input support to the input manager.
  37439. * @returns the current input manager
  37440. */
  37441. addPointers(): ArcRotateCameraInputsManager;
  37442. /**
  37443. * Add keyboard input support to the input manager.
  37444. * @returns the current input manager
  37445. */
  37446. addKeyboard(): ArcRotateCameraInputsManager;
  37447. }
  37448. }
  37449. declare module "babylonjs/Cameras/arcRotateCamera" {
  37450. import { Observable } from "babylonjs/Misc/observable";
  37451. import { Nullable } from "babylonjs/types";
  37452. import { Scene } from "babylonjs/scene";
  37453. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37455. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37456. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37457. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37458. import { Camera } from "babylonjs/Cameras/camera";
  37459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37460. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37461. import { Collider } from "babylonjs/Collisions/collider";
  37462. /**
  37463. * This represents an orbital type of camera.
  37464. *
  37465. * 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.
  37466. * 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.
  37467. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37468. */
  37469. export class ArcRotateCamera extends TargetCamera {
  37470. /**
  37471. * Defines the rotation angle of the camera along the longitudinal axis.
  37472. */
  37473. alpha: number;
  37474. /**
  37475. * Defines the rotation angle of the camera along the latitudinal axis.
  37476. */
  37477. beta: number;
  37478. /**
  37479. * Defines the radius of the camera from it s target point.
  37480. */
  37481. radius: number;
  37482. protected _target: Vector3;
  37483. protected _targetHost: Nullable<AbstractMesh>;
  37484. /**
  37485. * Defines the target point of the camera.
  37486. * The camera looks towards it form the radius distance.
  37487. */
  37488. target: Vector3;
  37489. /**
  37490. * Define the current local position of the camera in the scene
  37491. */
  37492. position: Vector3;
  37493. protected _upVector: Vector3;
  37494. protected _upToYMatrix: Matrix;
  37495. protected _YToUpMatrix: Matrix;
  37496. /**
  37497. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37498. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37499. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37500. */
  37501. upVector: Vector3;
  37502. /**
  37503. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37504. */
  37505. setMatUp(): void;
  37506. /**
  37507. * Current inertia value on the longitudinal axis.
  37508. * The bigger this number the longer it will take for the camera to stop.
  37509. */
  37510. inertialAlphaOffset: number;
  37511. /**
  37512. * Current inertia value on the latitudinal axis.
  37513. * The bigger this number the longer it will take for the camera to stop.
  37514. */
  37515. inertialBetaOffset: number;
  37516. /**
  37517. * Current inertia value on the radius axis.
  37518. * The bigger this number the longer it will take for the camera to stop.
  37519. */
  37520. inertialRadiusOffset: number;
  37521. /**
  37522. * Minimum allowed angle on the longitudinal axis.
  37523. * This can help limiting how the Camera is able to move in the scene.
  37524. */
  37525. lowerAlphaLimit: Nullable<number>;
  37526. /**
  37527. * Maximum allowed angle on the longitudinal axis.
  37528. * This can help limiting how the Camera is able to move in the scene.
  37529. */
  37530. upperAlphaLimit: Nullable<number>;
  37531. /**
  37532. * Minimum allowed angle on the latitudinal axis.
  37533. * This can help limiting how the Camera is able to move in the scene.
  37534. */
  37535. lowerBetaLimit: number;
  37536. /**
  37537. * Maximum allowed angle on the latitudinal axis.
  37538. * This can help limiting how the Camera is able to move in the scene.
  37539. */
  37540. upperBetaLimit: number;
  37541. /**
  37542. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37543. * This can help limiting how the Camera is able to move in the scene.
  37544. */
  37545. lowerRadiusLimit: Nullable<number>;
  37546. /**
  37547. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37548. * This can help limiting how the Camera is able to move in the scene.
  37549. */
  37550. upperRadiusLimit: Nullable<number>;
  37551. /**
  37552. * Defines the current inertia value used during panning of the camera along the X axis.
  37553. */
  37554. inertialPanningX: number;
  37555. /**
  37556. * Defines the current inertia value used during panning of the camera along the Y axis.
  37557. */
  37558. inertialPanningY: number;
  37559. /**
  37560. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37561. * Basically if your fingers moves away from more than this distance you will be considered
  37562. * in pinch mode.
  37563. */
  37564. pinchToPanMaxDistance: number;
  37565. /**
  37566. * Defines the maximum distance the camera can pan.
  37567. * This could help keeping the cammera always in your scene.
  37568. */
  37569. panningDistanceLimit: Nullable<number>;
  37570. /**
  37571. * Defines the target of the camera before paning.
  37572. */
  37573. panningOriginTarget: Vector3;
  37574. /**
  37575. * Defines the value of the inertia used during panning.
  37576. * 0 would mean stop inertia and one would mean no decelleration at all.
  37577. */
  37578. panningInertia: number;
  37579. /**
  37580. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37581. */
  37582. angularSensibilityX: number;
  37583. /**
  37584. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37585. */
  37586. angularSensibilityY: number;
  37587. /**
  37588. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37589. */
  37590. pinchPrecision: number;
  37591. /**
  37592. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37593. * It will be used instead of pinchDeltaPrecision if different from 0.
  37594. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37595. */
  37596. pinchDeltaPercentage: number;
  37597. /**
  37598. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37599. */
  37600. panningSensibility: number;
  37601. /**
  37602. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37603. */
  37604. keysUp: number[];
  37605. /**
  37606. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37607. */
  37608. keysDown: number[];
  37609. /**
  37610. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37611. */
  37612. keysLeft: number[];
  37613. /**
  37614. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37615. */
  37616. keysRight: number[];
  37617. /**
  37618. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37619. */
  37620. wheelPrecision: number;
  37621. /**
  37622. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37623. * It will be used instead of pinchDeltaPrecision if different from 0.
  37624. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37625. */
  37626. wheelDeltaPercentage: number;
  37627. /**
  37628. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37629. */
  37630. zoomOnFactor: number;
  37631. /**
  37632. * Defines a screen offset for the camera position.
  37633. */
  37634. targetScreenOffset: Vector2;
  37635. /**
  37636. * Allows the camera to be completely reversed.
  37637. * If false the camera can not arrive upside down.
  37638. */
  37639. allowUpsideDown: boolean;
  37640. /**
  37641. * Define if double tap/click is used to restore the previously saved state of the camera.
  37642. */
  37643. useInputToRestoreState: boolean;
  37644. /** @hidden */
  37645. _viewMatrix: Matrix;
  37646. /** @hidden */
  37647. _useCtrlForPanning: boolean;
  37648. /** @hidden */
  37649. _panningMouseButton: number;
  37650. /**
  37651. * Defines the input associated to the camera.
  37652. */
  37653. inputs: ArcRotateCameraInputsManager;
  37654. /** @hidden */
  37655. _reset: () => void;
  37656. /**
  37657. * Defines the allowed panning axis.
  37658. */
  37659. panningAxis: Vector3;
  37660. protected _localDirection: Vector3;
  37661. protected _transformedDirection: Vector3;
  37662. private _bouncingBehavior;
  37663. /**
  37664. * Gets the bouncing behavior of the camera if it has been enabled.
  37665. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37666. */
  37667. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37668. /**
  37669. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37670. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37671. */
  37672. useBouncingBehavior: boolean;
  37673. private _framingBehavior;
  37674. /**
  37675. * Gets the framing behavior of the camera if it has been enabled.
  37676. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37677. */
  37678. readonly framingBehavior: Nullable<FramingBehavior>;
  37679. /**
  37680. * Defines if the framing behavior of the camera is enabled on the camera.
  37681. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37682. */
  37683. useFramingBehavior: boolean;
  37684. private _autoRotationBehavior;
  37685. /**
  37686. * Gets the auto rotation behavior of the camera if it has been enabled.
  37687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37688. */
  37689. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37690. /**
  37691. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37692. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37693. */
  37694. useAutoRotationBehavior: boolean;
  37695. /**
  37696. * Observable triggered when the mesh target has been changed on the camera.
  37697. */
  37698. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37699. /**
  37700. * Event raised when the camera is colliding with a mesh.
  37701. */
  37702. onCollide: (collidedMesh: AbstractMesh) => void;
  37703. /**
  37704. * Defines whether the camera should check collision with the objects oh the scene.
  37705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37706. */
  37707. checkCollisions: boolean;
  37708. /**
  37709. * Defines the collision radius of the camera.
  37710. * This simulates a sphere around the camera.
  37711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37712. */
  37713. collisionRadius: Vector3;
  37714. protected _collider: Collider;
  37715. protected _previousPosition: Vector3;
  37716. protected _collisionVelocity: Vector3;
  37717. protected _newPosition: Vector3;
  37718. protected _previousAlpha: number;
  37719. protected _previousBeta: number;
  37720. protected _previousRadius: number;
  37721. protected _collisionTriggered: boolean;
  37722. protected _targetBoundingCenter: Nullable<Vector3>;
  37723. private _computationVector;
  37724. /**
  37725. * Instantiates a new ArcRotateCamera in a given scene
  37726. * @param name Defines the name of the camera
  37727. * @param alpha Defines the camera rotation along the logitudinal axis
  37728. * @param beta Defines the camera rotation along the latitudinal axis
  37729. * @param radius Defines the camera distance from its target
  37730. * @param target Defines the camera target
  37731. * @param scene Defines the scene the camera belongs to
  37732. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37733. */
  37734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37735. /** @hidden */
  37736. _initCache(): void;
  37737. /** @hidden */
  37738. _updateCache(ignoreParentClass?: boolean): void;
  37739. protected _getTargetPosition(): Vector3;
  37740. private _storedAlpha;
  37741. private _storedBeta;
  37742. private _storedRadius;
  37743. private _storedTarget;
  37744. private _storedTargetScreenOffset;
  37745. /**
  37746. * Stores the current state of the camera (alpha, beta, radius and target)
  37747. * @returns the camera itself
  37748. */
  37749. storeState(): Camera;
  37750. /**
  37751. * @hidden
  37752. * Restored camera state. You must call storeState() first
  37753. */
  37754. _restoreStateValues(): boolean;
  37755. /** @hidden */
  37756. _isSynchronizedViewMatrix(): boolean;
  37757. /**
  37758. * Attached controls to the current camera.
  37759. * @param element Defines the element the controls should be listened from
  37760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37761. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37762. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37763. */
  37764. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37765. /**
  37766. * Detach the current controls from the camera.
  37767. * The camera will stop reacting to inputs.
  37768. * @param element Defines the element to stop listening the inputs from
  37769. */
  37770. detachControl(element: HTMLElement): void;
  37771. /** @hidden */
  37772. _checkInputs(): void;
  37773. protected _checkLimits(): void;
  37774. /**
  37775. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37776. */
  37777. rebuildAnglesAndRadius(): void;
  37778. /**
  37779. * Use a position to define the current camera related information like alpha, beta and radius
  37780. * @param position Defines the position to set the camera at
  37781. */
  37782. setPosition(position: Vector3): void;
  37783. /**
  37784. * Defines the target the camera should look at.
  37785. * This will automatically adapt alpha beta and radius to fit within the new target.
  37786. * @param target Defines the new target as a Vector or a mesh
  37787. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37788. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37789. */
  37790. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37791. /** @hidden */
  37792. _getViewMatrix(): Matrix;
  37793. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37794. /**
  37795. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37796. * @param meshes Defines the mesh to zoom on
  37797. * @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)
  37798. */
  37799. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37800. /**
  37801. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37802. * The target will be changed but the radius
  37803. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37804. * @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)
  37805. */
  37806. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37807. min: Vector3;
  37808. max: Vector3;
  37809. distance: number;
  37810. }, doNotUpdateMaxZ?: boolean): void;
  37811. /**
  37812. * @override
  37813. * Override Camera.createRigCamera
  37814. */
  37815. createRigCamera(name: string, cameraIndex: number): Camera;
  37816. /**
  37817. * @hidden
  37818. * @override
  37819. * Override Camera._updateRigCameras
  37820. */
  37821. _updateRigCameras(): void;
  37822. /**
  37823. * Destroy the camera and release the current resources hold by it.
  37824. */
  37825. dispose(): void;
  37826. /**
  37827. * Gets the current object class name.
  37828. * @return the class name
  37829. */
  37830. getClassName(): string;
  37831. }
  37832. }
  37833. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37834. import { Behavior } from "babylonjs/Behaviors/behavior";
  37835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37836. /**
  37837. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37839. */
  37840. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37841. /**
  37842. * Gets the name of the behavior.
  37843. */
  37844. readonly name: string;
  37845. private _zoomStopsAnimation;
  37846. private _idleRotationSpeed;
  37847. private _idleRotationWaitTime;
  37848. private _idleRotationSpinupTime;
  37849. /**
  37850. * Sets the flag that indicates if user zooming should stop animation.
  37851. */
  37852. /**
  37853. * Gets the flag that indicates if user zooming should stop animation.
  37854. */
  37855. zoomStopsAnimation: boolean;
  37856. /**
  37857. * Sets the default speed at which the camera rotates around the model.
  37858. */
  37859. /**
  37860. * Gets the default speed at which the camera rotates around the model.
  37861. */
  37862. idleRotationSpeed: number;
  37863. /**
  37864. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37865. */
  37866. /**
  37867. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37868. */
  37869. idleRotationWaitTime: number;
  37870. /**
  37871. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37872. */
  37873. /**
  37874. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37875. */
  37876. idleRotationSpinupTime: number;
  37877. /**
  37878. * Gets a value indicating if the camera is currently rotating because of this behavior
  37879. */
  37880. readonly rotationInProgress: boolean;
  37881. private _onPrePointerObservableObserver;
  37882. private _onAfterCheckInputsObserver;
  37883. private _attachedCamera;
  37884. private _isPointerDown;
  37885. private _lastFrameTime;
  37886. private _lastInteractionTime;
  37887. private _cameraRotationSpeed;
  37888. /**
  37889. * Initializes the behavior.
  37890. */
  37891. init(): void;
  37892. /**
  37893. * Attaches the behavior to its arc rotate camera.
  37894. * @param camera Defines the camera to attach the behavior to
  37895. */
  37896. attach(camera: ArcRotateCamera): void;
  37897. /**
  37898. * Detaches the behavior from its current arc rotate camera.
  37899. */
  37900. detach(): void;
  37901. /**
  37902. * Returns true if user is scrolling.
  37903. * @return true if user is scrolling.
  37904. */
  37905. private _userIsZooming;
  37906. private _lastFrameRadius;
  37907. private _shouldAnimationStopForInteraction;
  37908. /**
  37909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37910. */
  37911. private _applyUserInteraction;
  37912. private _userIsMoving;
  37913. }
  37914. }
  37915. declare module "babylonjs/Behaviors/Cameras/index" {
  37916. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37917. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37918. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37919. }
  37920. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37921. import { Mesh } from "babylonjs/Meshes/mesh";
  37922. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37923. import { Behavior } from "babylonjs/Behaviors/behavior";
  37924. /**
  37925. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37926. */
  37927. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37928. private ui;
  37929. /**
  37930. * The name of the behavior
  37931. */
  37932. name: string;
  37933. /**
  37934. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37935. */
  37936. distanceAwayFromFace: number;
  37937. /**
  37938. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37939. */
  37940. distanceAwayFromBottomOfFace: number;
  37941. private _faceVectors;
  37942. private _target;
  37943. private _scene;
  37944. private _onRenderObserver;
  37945. private _tmpMatrix;
  37946. private _tmpVector;
  37947. /**
  37948. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37949. * @param ui The transform node that should be attched to the mesh
  37950. */
  37951. constructor(ui: TransformNode);
  37952. /**
  37953. * Initializes the behavior
  37954. */
  37955. init(): void;
  37956. private _closestFace;
  37957. private _zeroVector;
  37958. private _lookAtTmpMatrix;
  37959. private _lookAtToRef;
  37960. /**
  37961. * Attaches the AttachToBoxBehavior to the passed in mesh
  37962. * @param target The mesh that the specified node will be attached to
  37963. */
  37964. attach(target: Mesh): void;
  37965. /**
  37966. * Detaches the behavior from the mesh
  37967. */
  37968. detach(): void;
  37969. }
  37970. }
  37971. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37972. import { Behavior } from "babylonjs/Behaviors/behavior";
  37973. import { Mesh } from "babylonjs/Meshes/mesh";
  37974. /**
  37975. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37976. */
  37977. export class FadeInOutBehavior implements Behavior<Mesh> {
  37978. /**
  37979. * Time in milliseconds to delay before fading in (Default: 0)
  37980. */
  37981. delay: number;
  37982. /**
  37983. * Time in milliseconds for the mesh to fade in (Default: 300)
  37984. */
  37985. fadeInTime: number;
  37986. private _millisecondsPerFrame;
  37987. private _hovered;
  37988. private _hoverValue;
  37989. private _ownerNode;
  37990. /**
  37991. * Instatiates the FadeInOutBehavior
  37992. */
  37993. constructor();
  37994. /**
  37995. * The name of the behavior
  37996. */
  37997. readonly name: string;
  37998. /**
  37999. * Initializes the behavior
  38000. */
  38001. init(): void;
  38002. /**
  38003. * Attaches the fade behavior on the passed in mesh
  38004. * @param ownerNode The mesh that will be faded in/out once attached
  38005. */
  38006. attach(ownerNode: Mesh): void;
  38007. /**
  38008. * Detaches the behavior from the mesh
  38009. */
  38010. detach(): void;
  38011. /**
  38012. * Triggers the mesh to begin fading in or out
  38013. * @param value if the object should fade in or out (true to fade in)
  38014. */
  38015. fadeIn(value: boolean): void;
  38016. private _update;
  38017. private _setAllVisibility;
  38018. }
  38019. }
  38020. declare module "babylonjs/Misc/pivotTools" {
  38021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38022. /**
  38023. * Class containing a set of static utilities functions for managing Pivots
  38024. * @hidden
  38025. */
  38026. export class PivotTools {
  38027. private static _PivotCached;
  38028. private static _OldPivotPoint;
  38029. private static _PivotTranslation;
  38030. private static _PivotTmpVector;
  38031. /** @hidden */
  38032. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38033. /** @hidden */
  38034. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38035. }
  38036. }
  38037. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38038. import { Scene } from "babylonjs/scene";
  38039. import { Vector4 } from "babylonjs/Maths/math.vector";
  38040. import { Mesh } from "babylonjs/Meshes/mesh";
  38041. import { Nullable } from "babylonjs/types";
  38042. import { Plane } from "babylonjs/Maths/math.plane";
  38043. /**
  38044. * Class containing static functions to help procedurally build meshes
  38045. */
  38046. export class PlaneBuilder {
  38047. /**
  38048. * Creates a plane mesh
  38049. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38050. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38051. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38055. * @param name defines the name of the mesh
  38056. * @param options defines the options used to create the mesh
  38057. * @param scene defines the hosting scene
  38058. * @returns the plane mesh
  38059. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38060. */
  38061. static CreatePlane(name: string, options: {
  38062. size?: number;
  38063. width?: number;
  38064. height?: number;
  38065. sideOrientation?: number;
  38066. frontUVs?: Vector4;
  38067. backUVs?: Vector4;
  38068. updatable?: boolean;
  38069. sourcePlane?: Plane;
  38070. }, scene?: Nullable<Scene>): Mesh;
  38071. }
  38072. }
  38073. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38074. import { Behavior } from "babylonjs/Behaviors/behavior";
  38075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38076. import { Observable } from "babylonjs/Misc/observable";
  38077. import { Vector3 } from "babylonjs/Maths/math.vector";
  38078. import { Ray } from "babylonjs/Culling/ray";
  38079. import "babylonjs/Meshes/Builders/planeBuilder";
  38080. /**
  38081. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38082. */
  38083. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38084. private static _AnyMouseID;
  38085. /**
  38086. * Abstract mesh the behavior is set on
  38087. */
  38088. attachedNode: AbstractMesh;
  38089. private _dragPlane;
  38090. private _scene;
  38091. private _pointerObserver;
  38092. private _beforeRenderObserver;
  38093. private static _planeScene;
  38094. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38095. /**
  38096. * 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)
  38097. */
  38098. maxDragAngle: number;
  38099. /**
  38100. * @hidden
  38101. */
  38102. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38103. /**
  38104. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38105. */
  38106. currentDraggingPointerID: number;
  38107. /**
  38108. * The last position where the pointer hit the drag plane in world space
  38109. */
  38110. lastDragPosition: Vector3;
  38111. /**
  38112. * If the behavior is currently in a dragging state
  38113. */
  38114. dragging: boolean;
  38115. /**
  38116. * 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)
  38117. */
  38118. dragDeltaRatio: number;
  38119. /**
  38120. * If the drag plane orientation should be updated during the dragging (Default: true)
  38121. */
  38122. updateDragPlane: boolean;
  38123. private _debugMode;
  38124. private _moving;
  38125. /**
  38126. * Fires each time the attached mesh is dragged with the pointer
  38127. * * delta between last drag position and current drag position in world space
  38128. * * dragDistance along the drag axis
  38129. * * dragPlaneNormal normal of the current drag plane used during the drag
  38130. * * dragPlanePoint in world space where the drag intersects the drag plane
  38131. */
  38132. onDragObservable: Observable<{
  38133. delta: Vector3;
  38134. dragPlanePoint: Vector3;
  38135. dragPlaneNormal: Vector3;
  38136. dragDistance: number;
  38137. pointerId: number;
  38138. }>;
  38139. /**
  38140. * Fires each time a drag begins (eg. mouse down on mesh)
  38141. */
  38142. onDragStartObservable: Observable<{
  38143. dragPlanePoint: Vector3;
  38144. pointerId: number;
  38145. }>;
  38146. /**
  38147. * Fires each time a drag ends (eg. mouse release after drag)
  38148. */
  38149. onDragEndObservable: Observable<{
  38150. dragPlanePoint: Vector3;
  38151. pointerId: number;
  38152. }>;
  38153. /**
  38154. * If the attached mesh should be moved when dragged
  38155. */
  38156. moveAttached: boolean;
  38157. /**
  38158. * If the drag behavior will react to drag events (Default: true)
  38159. */
  38160. enabled: boolean;
  38161. /**
  38162. * If pointer events should start and release the drag (Default: true)
  38163. */
  38164. startAndReleaseDragOnPointerEvents: boolean;
  38165. /**
  38166. * If camera controls should be detached during the drag
  38167. */
  38168. detachCameraControls: boolean;
  38169. /**
  38170. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38171. */
  38172. useObjectOrienationForDragging: boolean;
  38173. private _options;
  38174. /**
  38175. * Creates a pointer drag behavior that can be attached to a mesh
  38176. * @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)
  38177. */
  38178. constructor(options?: {
  38179. dragAxis?: Vector3;
  38180. dragPlaneNormal?: Vector3;
  38181. });
  38182. /**
  38183. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38184. */
  38185. validateDrag: (targetPosition: Vector3) => boolean;
  38186. /**
  38187. * The name of the behavior
  38188. */
  38189. readonly name: string;
  38190. /**
  38191. * Initializes the behavior
  38192. */
  38193. init(): void;
  38194. private _tmpVector;
  38195. private _alternatePickedPoint;
  38196. private _worldDragAxis;
  38197. private _targetPosition;
  38198. private _attachedElement;
  38199. /**
  38200. * Attaches the drag behavior the passed in mesh
  38201. * @param ownerNode The mesh that will be dragged around once attached
  38202. * @param predicate Predicate to use for pick filtering
  38203. */
  38204. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38205. /**
  38206. * Force relase the drag action by code.
  38207. */
  38208. releaseDrag(): void;
  38209. private _startDragRay;
  38210. private _lastPointerRay;
  38211. /**
  38212. * Simulates the start of a pointer drag event on the behavior
  38213. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38214. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38215. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38216. */
  38217. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38218. private _startDrag;
  38219. private _dragDelta;
  38220. private _moveDrag;
  38221. private _pickWithRayOnDragPlane;
  38222. private _pointA;
  38223. private _pointB;
  38224. private _pointC;
  38225. private _lineA;
  38226. private _lineB;
  38227. private _localAxis;
  38228. private _lookAt;
  38229. private _updateDragPlanePosition;
  38230. /**
  38231. * Detaches the behavior from the mesh
  38232. */
  38233. detach(): void;
  38234. }
  38235. }
  38236. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38237. import { Mesh } from "babylonjs/Meshes/mesh";
  38238. import { Behavior } from "babylonjs/Behaviors/behavior";
  38239. /**
  38240. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38241. */
  38242. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38243. private _dragBehaviorA;
  38244. private _dragBehaviorB;
  38245. private _startDistance;
  38246. private _initialScale;
  38247. private _targetScale;
  38248. private _ownerNode;
  38249. private _sceneRenderObserver;
  38250. /**
  38251. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38252. */
  38253. constructor();
  38254. /**
  38255. * The name of the behavior
  38256. */
  38257. readonly name: string;
  38258. /**
  38259. * Initializes the behavior
  38260. */
  38261. init(): void;
  38262. private _getCurrentDistance;
  38263. /**
  38264. * Attaches the scale behavior the passed in mesh
  38265. * @param ownerNode The mesh that will be scaled around once attached
  38266. */
  38267. attach(ownerNode: Mesh): void;
  38268. /**
  38269. * Detaches the behavior from the mesh
  38270. */
  38271. detach(): void;
  38272. }
  38273. }
  38274. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38275. import { Behavior } from "babylonjs/Behaviors/behavior";
  38276. import { Mesh } from "babylonjs/Meshes/mesh";
  38277. import { Observable } from "babylonjs/Misc/observable";
  38278. /**
  38279. * 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
  38280. */
  38281. export class SixDofDragBehavior implements Behavior<Mesh> {
  38282. private static _virtualScene;
  38283. private _ownerNode;
  38284. private _sceneRenderObserver;
  38285. private _scene;
  38286. private _targetPosition;
  38287. private _virtualOriginMesh;
  38288. private _virtualDragMesh;
  38289. private _pointerObserver;
  38290. private _moving;
  38291. private _startingOrientation;
  38292. /**
  38293. * 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)
  38294. */
  38295. private zDragFactor;
  38296. /**
  38297. * If the object should rotate to face the drag origin
  38298. */
  38299. rotateDraggedObject: boolean;
  38300. /**
  38301. * If the behavior is currently in a dragging state
  38302. */
  38303. dragging: boolean;
  38304. /**
  38305. * 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)
  38306. */
  38307. dragDeltaRatio: number;
  38308. /**
  38309. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38310. */
  38311. currentDraggingPointerID: number;
  38312. /**
  38313. * If camera controls should be detached during the drag
  38314. */
  38315. detachCameraControls: boolean;
  38316. /**
  38317. * Fires each time a drag starts
  38318. */
  38319. onDragStartObservable: Observable<{}>;
  38320. /**
  38321. * Fires each time a drag ends (eg. mouse release after drag)
  38322. */
  38323. onDragEndObservable: Observable<{}>;
  38324. /**
  38325. * 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
  38326. */
  38327. constructor();
  38328. /**
  38329. * The name of the behavior
  38330. */
  38331. readonly name: string;
  38332. /**
  38333. * Initializes the behavior
  38334. */
  38335. init(): void;
  38336. /**
  38337. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38338. */
  38339. private readonly _pointerCamera;
  38340. /**
  38341. * Attaches the scale behavior the passed in mesh
  38342. * @param ownerNode The mesh that will be scaled around once attached
  38343. */
  38344. attach(ownerNode: Mesh): void;
  38345. /**
  38346. * Detaches the behavior from the mesh
  38347. */
  38348. detach(): void;
  38349. }
  38350. }
  38351. declare module "babylonjs/Behaviors/Meshes/index" {
  38352. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38353. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38354. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38355. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38356. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38357. }
  38358. declare module "babylonjs/Behaviors/index" {
  38359. export * from "babylonjs/Behaviors/behavior";
  38360. export * from "babylonjs/Behaviors/Cameras/index";
  38361. export * from "babylonjs/Behaviors/Meshes/index";
  38362. }
  38363. declare module "babylonjs/Bones/boneIKController" {
  38364. import { Bone } from "babylonjs/Bones/bone";
  38365. import { Vector3 } from "babylonjs/Maths/math.vector";
  38366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38367. import { Nullable } from "babylonjs/types";
  38368. /**
  38369. * Class used to apply inverse kinematics to bones
  38370. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38371. */
  38372. export class BoneIKController {
  38373. private static _tmpVecs;
  38374. private static _tmpQuat;
  38375. private static _tmpMats;
  38376. /**
  38377. * Gets or sets the target mesh
  38378. */
  38379. targetMesh: AbstractMesh;
  38380. /** Gets or sets the mesh used as pole */
  38381. poleTargetMesh: AbstractMesh;
  38382. /**
  38383. * Gets or sets the bone used as pole
  38384. */
  38385. poleTargetBone: Nullable<Bone>;
  38386. /**
  38387. * Gets or sets the target position
  38388. */
  38389. targetPosition: Vector3;
  38390. /**
  38391. * Gets or sets the pole target position
  38392. */
  38393. poleTargetPosition: Vector3;
  38394. /**
  38395. * Gets or sets the pole target local offset
  38396. */
  38397. poleTargetLocalOffset: Vector3;
  38398. /**
  38399. * Gets or sets the pole angle
  38400. */
  38401. poleAngle: number;
  38402. /**
  38403. * Gets or sets the mesh associated with the controller
  38404. */
  38405. mesh: AbstractMesh;
  38406. /**
  38407. * 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)
  38408. */
  38409. slerpAmount: number;
  38410. private _bone1Quat;
  38411. private _bone1Mat;
  38412. private _bone2Ang;
  38413. private _bone1;
  38414. private _bone2;
  38415. private _bone1Length;
  38416. private _bone2Length;
  38417. private _maxAngle;
  38418. private _maxReach;
  38419. private _rightHandedSystem;
  38420. private _bendAxis;
  38421. private _slerping;
  38422. private _adjustRoll;
  38423. /**
  38424. * Gets or sets maximum allowed angle
  38425. */
  38426. maxAngle: number;
  38427. /**
  38428. * Creates a new BoneIKController
  38429. * @param mesh defines the mesh to control
  38430. * @param bone defines the bone to control
  38431. * @param options defines options to set up the controller
  38432. */
  38433. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38434. targetMesh?: AbstractMesh;
  38435. poleTargetMesh?: AbstractMesh;
  38436. poleTargetBone?: Bone;
  38437. poleTargetLocalOffset?: Vector3;
  38438. poleAngle?: number;
  38439. bendAxis?: Vector3;
  38440. maxAngle?: number;
  38441. slerpAmount?: number;
  38442. });
  38443. private _setMaxAngle;
  38444. /**
  38445. * Force the controller to update the bones
  38446. */
  38447. update(): void;
  38448. }
  38449. }
  38450. declare module "babylonjs/Bones/boneLookController" {
  38451. import { Vector3 } from "babylonjs/Maths/math.vector";
  38452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38453. import { Bone } from "babylonjs/Bones/bone";
  38454. import { Space } from "babylonjs/Maths/math.axis";
  38455. /**
  38456. * Class used to make a bone look toward a point in space
  38457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38458. */
  38459. export class BoneLookController {
  38460. private static _tmpVecs;
  38461. private static _tmpQuat;
  38462. private static _tmpMats;
  38463. /**
  38464. * The target Vector3 that the bone will look at
  38465. */
  38466. target: Vector3;
  38467. /**
  38468. * The mesh that the bone is attached to
  38469. */
  38470. mesh: AbstractMesh;
  38471. /**
  38472. * The bone that will be looking to the target
  38473. */
  38474. bone: Bone;
  38475. /**
  38476. * The up axis of the coordinate system that is used when the bone is rotated
  38477. */
  38478. upAxis: Vector3;
  38479. /**
  38480. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38481. */
  38482. upAxisSpace: Space;
  38483. /**
  38484. * Used to make an adjustment to the yaw of the bone
  38485. */
  38486. adjustYaw: number;
  38487. /**
  38488. * Used to make an adjustment to the pitch of the bone
  38489. */
  38490. adjustPitch: number;
  38491. /**
  38492. * Used to make an adjustment to the roll of the bone
  38493. */
  38494. adjustRoll: number;
  38495. /**
  38496. * 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)
  38497. */
  38498. slerpAmount: number;
  38499. private _minYaw;
  38500. private _maxYaw;
  38501. private _minPitch;
  38502. private _maxPitch;
  38503. private _minYawSin;
  38504. private _minYawCos;
  38505. private _maxYawSin;
  38506. private _maxYawCos;
  38507. private _midYawConstraint;
  38508. private _minPitchTan;
  38509. private _maxPitchTan;
  38510. private _boneQuat;
  38511. private _slerping;
  38512. private _transformYawPitch;
  38513. private _transformYawPitchInv;
  38514. private _firstFrameSkipped;
  38515. private _yawRange;
  38516. private _fowardAxis;
  38517. /**
  38518. * Gets or sets the minimum yaw angle that the bone can look to
  38519. */
  38520. minYaw: number;
  38521. /**
  38522. * Gets or sets the maximum yaw angle that the bone can look to
  38523. */
  38524. maxYaw: number;
  38525. /**
  38526. * Gets or sets the minimum pitch angle that the bone can look to
  38527. */
  38528. minPitch: number;
  38529. /**
  38530. * Gets or sets the maximum pitch angle that the bone can look to
  38531. */
  38532. maxPitch: number;
  38533. /**
  38534. * Create a BoneLookController
  38535. * @param mesh the mesh that the bone belongs to
  38536. * @param bone the bone that will be looking to the target
  38537. * @param target the target Vector3 to look at
  38538. * @param options optional settings:
  38539. * * maxYaw: the maximum angle the bone will yaw to
  38540. * * minYaw: the minimum angle the bone will yaw to
  38541. * * maxPitch: the maximum angle the bone will pitch to
  38542. * * minPitch: the minimum angle the bone will yaw to
  38543. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38544. * * upAxis: the up axis of the coordinate system
  38545. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38546. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38547. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38548. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38549. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38550. * * adjustRoll: used to make an adjustment to the roll of the bone
  38551. **/
  38552. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38553. maxYaw?: number;
  38554. minYaw?: number;
  38555. maxPitch?: number;
  38556. minPitch?: number;
  38557. slerpAmount?: number;
  38558. upAxis?: Vector3;
  38559. upAxisSpace?: Space;
  38560. yawAxis?: Vector3;
  38561. pitchAxis?: Vector3;
  38562. adjustYaw?: number;
  38563. adjustPitch?: number;
  38564. adjustRoll?: number;
  38565. });
  38566. /**
  38567. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38568. */
  38569. update(): void;
  38570. private _getAngleDiff;
  38571. private _getAngleBetween;
  38572. private _isAngleBetween;
  38573. }
  38574. }
  38575. declare module "babylonjs/Bones/index" {
  38576. export * from "babylonjs/Bones/bone";
  38577. export * from "babylonjs/Bones/boneIKController";
  38578. export * from "babylonjs/Bones/boneLookController";
  38579. export * from "babylonjs/Bones/skeleton";
  38580. }
  38581. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38582. import { Nullable } from "babylonjs/types";
  38583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38585. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38586. /**
  38587. * Manage the gamepad inputs to control an arc rotate camera.
  38588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38589. */
  38590. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38591. /**
  38592. * Defines the camera the input is attached to.
  38593. */
  38594. camera: ArcRotateCamera;
  38595. /**
  38596. * Defines the gamepad the input is gathering event from.
  38597. */
  38598. gamepad: Nullable<Gamepad>;
  38599. /**
  38600. * Defines the gamepad rotation sensiblity.
  38601. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38602. */
  38603. gamepadRotationSensibility: number;
  38604. /**
  38605. * Defines the gamepad move sensiblity.
  38606. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38607. */
  38608. gamepadMoveSensibility: number;
  38609. private _yAxisScale;
  38610. /**
  38611. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38612. */
  38613. invertYAxis: boolean;
  38614. private _onGamepadConnectedObserver;
  38615. private _onGamepadDisconnectedObserver;
  38616. /**
  38617. * Attach the input controls to a specific dom element to get the input from.
  38618. * @param element Defines the element the controls should be listened from
  38619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38620. */
  38621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38622. /**
  38623. * Detach the current controls from the specified dom element.
  38624. * @param element Defines the element to stop listening the inputs from
  38625. */
  38626. detachControl(element: Nullable<HTMLElement>): void;
  38627. /**
  38628. * Update the current camera state depending on the inputs that have been used this frame.
  38629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38630. */
  38631. checkInputs(): void;
  38632. /**
  38633. * Gets the class name of the current intput.
  38634. * @returns the class name
  38635. */
  38636. getClassName(): string;
  38637. /**
  38638. * Get the friendly name associated with the input class.
  38639. * @returns the input friendly name
  38640. */
  38641. getSimpleName(): string;
  38642. }
  38643. }
  38644. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38645. import { Nullable } from "babylonjs/types";
  38646. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38647. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38648. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38649. interface ArcRotateCameraInputsManager {
  38650. /**
  38651. * Add orientation input support to the input manager.
  38652. * @returns the current input manager
  38653. */
  38654. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38655. }
  38656. }
  38657. /**
  38658. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38660. */
  38661. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38662. /**
  38663. * Defines the camera the input is attached to.
  38664. */
  38665. camera: ArcRotateCamera;
  38666. /**
  38667. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38668. */
  38669. alphaCorrection: number;
  38670. /**
  38671. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38672. */
  38673. gammaCorrection: number;
  38674. private _alpha;
  38675. private _gamma;
  38676. private _dirty;
  38677. private _deviceOrientationHandler;
  38678. /**
  38679. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38680. */
  38681. constructor();
  38682. /**
  38683. * Attach the input controls to a specific dom element to get the input from.
  38684. * @param element Defines the element the controls should be listened from
  38685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38686. */
  38687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38688. /** @hidden */
  38689. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38690. /**
  38691. * Update the current camera state depending on the inputs that have been used this frame.
  38692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38693. */
  38694. checkInputs(): void;
  38695. /**
  38696. * Detach the current controls from the specified dom element.
  38697. * @param element Defines the element to stop listening the inputs from
  38698. */
  38699. detachControl(element: Nullable<HTMLElement>): void;
  38700. /**
  38701. * Gets the class name of the current intput.
  38702. * @returns the class name
  38703. */
  38704. getClassName(): string;
  38705. /**
  38706. * Get the friendly name associated with the input class.
  38707. * @returns the input friendly name
  38708. */
  38709. getSimpleName(): string;
  38710. }
  38711. }
  38712. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38713. import { Nullable } from "babylonjs/types";
  38714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38715. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38716. /**
  38717. * Listen to mouse events to control the camera.
  38718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38719. */
  38720. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38721. /**
  38722. * Defines the camera the input is attached to.
  38723. */
  38724. camera: FlyCamera;
  38725. /**
  38726. * Defines if touch is enabled. (Default is true.)
  38727. */
  38728. touchEnabled: boolean;
  38729. /**
  38730. * Defines the buttons associated with the input to handle camera rotation.
  38731. */
  38732. buttons: number[];
  38733. /**
  38734. * Assign buttons for Yaw control.
  38735. */
  38736. buttonsYaw: number[];
  38737. /**
  38738. * Assign buttons for Pitch control.
  38739. */
  38740. buttonsPitch: number[];
  38741. /**
  38742. * Assign buttons for Roll control.
  38743. */
  38744. buttonsRoll: number[];
  38745. /**
  38746. * Detect if any button is being pressed while mouse is moved.
  38747. * -1 = Mouse locked.
  38748. * 0 = Left button.
  38749. * 1 = Middle Button.
  38750. * 2 = Right Button.
  38751. */
  38752. activeButton: number;
  38753. /**
  38754. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38755. * Higher values reduce its sensitivity.
  38756. */
  38757. angularSensibility: number;
  38758. private _mousemoveCallback;
  38759. private _observer;
  38760. private _rollObserver;
  38761. private previousPosition;
  38762. private noPreventDefault;
  38763. private element;
  38764. /**
  38765. * Listen to mouse events to control the camera.
  38766. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38768. */
  38769. constructor(touchEnabled?: boolean);
  38770. /**
  38771. * Attach the mouse control to the HTML DOM element.
  38772. * @param element Defines the element that listens to the input events.
  38773. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38774. */
  38775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38776. /**
  38777. * Detach the current controls from the specified dom element.
  38778. * @param element Defines the element to stop listening the inputs from
  38779. */
  38780. detachControl(element: Nullable<HTMLElement>): void;
  38781. /**
  38782. * Gets the class name of the current input.
  38783. * @returns the class name.
  38784. */
  38785. getClassName(): string;
  38786. /**
  38787. * Get the friendly name associated with the input class.
  38788. * @returns the input's friendly name.
  38789. */
  38790. getSimpleName(): string;
  38791. private _pointerInput;
  38792. private _onMouseMove;
  38793. /**
  38794. * Rotate camera by mouse offset.
  38795. */
  38796. private rotateCamera;
  38797. }
  38798. }
  38799. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38800. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38801. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38802. /**
  38803. * Default Inputs manager for the FlyCamera.
  38804. * It groups all the default supported inputs for ease of use.
  38805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38806. */
  38807. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38808. /**
  38809. * Instantiates a new FlyCameraInputsManager.
  38810. * @param camera Defines the camera the inputs belong to.
  38811. */
  38812. constructor(camera: FlyCamera);
  38813. /**
  38814. * Add keyboard input support to the input manager.
  38815. * @returns the new FlyCameraKeyboardMoveInput().
  38816. */
  38817. addKeyboard(): FlyCameraInputsManager;
  38818. /**
  38819. * Add mouse input support to the input manager.
  38820. * @param touchEnabled Enable touch screen support.
  38821. * @returns the new FlyCameraMouseInput().
  38822. */
  38823. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38824. }
  38825. }
  38826. declare module "babylonjs/Cameras/flyCamera" {
  38827. import { Scene } from "babylonjs/scene";
  38828. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38830. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38831. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38832. /**
  38833. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38834. * such as in a 3D Space Shooter or a Flight Simulator.
  38835. */
  38836. export class FlyCamera extends TargetCamera {
  38837. /**
  38838. * Define the collision ellipsoid of the camera.
  38839. * This is helpful for simulating a camera body, like a player's body.
  38840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38841. */
  38842. ellipsoid: Vector3;
  38843. /**
  38844. * Define an offset for the position of the ellipsoid around the camera.
  38845. * This can be helpful if the camera is attached away from the player's body center,
  38846. * such as at its head.
  38847. */
  38848. ellipsoidOffset: Vector3;
  38849. /**
  38850. * Enable or disable collisions of the camera with the rest of the scene objects.
  38851. */
  38852. checkCollisions: boolean;
  38853. /**
  38854. * Enable or disable gravity on the camera.
  38855. */
  38856. applyGravity: boolean;
  38857. /**
  38858. * Define the current direction the camera is moving to.
  38859. */
  38860. cameraDirection: Vector3;
  38861. /**
  38862. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38863. * This overrides and empties cameraRotation.
  38864. */
  38865. rotationQuaternion: Quaternion;
  38866. /**
  38867. * Track Roll to maintain the wanted Rolling when looking around.
  38868. */
  38869. _trackRoll: number;
  38870. /**
  38871. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38872. */
  38873. rollCorrect: number;
  38874. /**
  38875. * Mimic a banked turn, Rolling the camera when Yawing.
  38876. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38877. */
  38878. bankedTurn: boolean;
  38879. /**
  38880. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38881. */
  38882. bankedTurnLimit: number;
  38883. /**
  38884. * Value of 0 disables the banked Roll.
  38885. * Value of 1 is equal to the Yaw angle in radians.
  38886. */
  38887. bankedTurnMultiplier: number;
  38888. /**
  38889. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38890. */
  38891. inputs: FlyCameraInputsManager;
  38892. /**
  38893. * Gets the input sensibility for mouse input.
  38894. * Higher values reduce sensitivity.
  38895. */
  38896. /**
  38897. * Sets the input sensibility for a mouse input.
  38898. * Higher values reduce sensitivity.
  38899. */
  38900. angularSensibility: number;
  38901. /**
  38902. * Get the keys for camera movement forward.
  38903. */
  38904. /**
  38905. * Set the keys for camera movement forward.
  38906. */
  38907. keysForward: number[];
  38908. /**
  38909. * Get the keys for camera movement backward.
  38910. */
  38911. keysBackward: number[];
  38912. /**
  38913. * Get the keys for camera movement up.
  38914. */
  38915. /**
  38916. * Set the keys for camera movement up.
  38917. */
  38918. keysUp: number[];
  38919. /**
  38920. * Get the keys for camera movement down.
  38921. */
  38922. /**
  38923. * Set the keys for camera movement down.
  38924. */
  38925. keysDown: number[];
  38926. /**
  38927. * Get the keys for camera movement left.
  38928. */
  38929. /**
  38930. * Set the keys for camera movement left.
  38931. */
  38932. keysLeft: number[];
  38933. /**
  38934. * Set the keys for camera movement right.
  38935. */
  38936. /**
  38937. * Set the keys for camera movement right.
  38938. */
  38939. keysRight: number[];
  38940. /**
  38941. * Event raised when the camera collides with a mesh in the scene.
  38942. */
  38943. onCollide: (collidedMesh: AbstractMesh) => void;
  38944. private _collider;
  38945. private _needMoveForGravity;
  38946. private _oldPosition;
  38947. private _diffPosition;
  38948. private _newPosition;
  38949. /** @hidden */
  38950. _localDirection: Vector3;
  38951. /** @hidden */
  38952. _transformedDirection: Vector3;
  38953. /**
  38954. * Instantiates a FlyCamera.
  38955. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38956. * such as in a 3D Space Shooter or a Flight Simulator.
  38957. * @param name Define the name of the camera in the scene.
  38958. * @param position Define the starting position of the camera in the scene.
  38959. * @param scene Define the scene the camera belongs to.
  38960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38961. */
  38962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38963. /**
  38964. * Attach a control to the HTML DOM element.
  38965. * @param element Defines the element that listens to the input events.
  38966. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38967. */
  38968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38969. /**
  38970. * Detach a control from the HTML DOM element.
  38971. * The camera will stop reacting to that input.
  38972. * @param element Defines the element that listens to the input events.
  38973. */
  38974. detachControl(element: HTMLElement): void;
  38975. private _collisionMask;
  38976. /**
  38977. * Get the mask that the camera ignores in collision events.
  38978. */
  38979. /**
  38980. * Set the mask that the camera ignores in collision events.
  38981. */
  38982. collisionMask: number;
  38983. /** @hidden */
  38984. _collideWithWorld(displacement: Vector3): void;
  38985. /** @hidden */
  38986. private _onCollisionPositionChange;
  38987. /** @hidden */
  38988. _checkInputs(): void;
  38989. /** @hidden */
  38990. _decideIfNeedsToMove(): boolean;
  38991. /** @hidden */
  38992. _updatePosition(): void;
  38993. /**
  38994. * Restore the Roll to its target value at the rate specified.
  38995. * @param rate - Higher means slower restoring.
  38996. * @hidden
  38997. */
  38998. restoreRoll(rate: number): void;
  38999. /**
  39000. * Destroy the camera and release the current resources held by it.
  39001. */
  39002. dispose(): void;
  39003. /**
  39004. * Get the current object class name.
  39005. * @returns the class name.
  39006. */
  39007. getClassName(): string;
  39008. }
  39009. }
  39010. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39011. import { Nullable } from "babylonjs/types";
  39012. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39013. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39014. /**
  39015. * Listen to keyboard events to control the camera.
  39016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39017. */
  39018. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39019. /**
  39020. * Defines the camera the input is attached to.
  39021. */
  39022. camera: FlyCamera;
  39023. /**
  39024. * The list of keyboard keys used to control the forward move of the camera.
  39025. */
  39026. keysForward: number[];
  39027. /**
  39028. * The list of keyboard keys used to control the backward move of the camera.
  39029. */
  39030. keysBackward: number[];
  39031. /**
  39032. * The list of keyboard keys used to control the forward move of the camera.
  39033. */
  39034. keysUp: number[];
  39035. /**
  39036. * The list of keyboard keys used to control the backward move of the camera.
  39037. */
  39038. keysDown: number[];
  39039. /**
  39040. * The list of keyboard keys used to control the right strafe move of the camera.
  39041. */
  39042. keysRight: number[];
  39043. /**
  39044. * The list of keyboard keys used to control the left strafe move of the camera.
  39045. */
  39046. keysLeft: number[];
  39047. private _keys;
  39048. private _onCanvasBlurObserver;
  39049. private _onKeyboardObserver;
  39050. private _engine;
  39051. private _scene;
  39052. /**
  39053. * Attach the input controls to a specific dom element to get the input from.
  39054. * @param element Defines the element the controls should be listened from
  39055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39056. */
  39057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39058. /**
  39059. * Detach the current controls from the specified dom element.
  39060. * @param element Defines the element to stop listening the inputs from
  39061. */
  39062. detachControl(element: Nullable<HTMLElement>): void;
  39063. /**
  39064. * Gets the class name of the current intput.
  39065. * @returns the class name
  39066. */
  39067. getClassName(): string;
  39068. /** @hidden */
  39069. _onLostFocus(e: FocusEvent): void;
  39070. /**
  39071. * Get the friendly name associated with the input class.
  39072. * @returns the input friendly name
  39073. */
  39074. getSimpleName(): string;
  39075. /**
  39076. * Update the current camera state depending on the inputs that have been used this frame.
  39077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39078. */
  39079. checkInputs(): void;
  39080. }
  39081. }
  39082. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39083. import { Nullable } from "babylonjs/types";
  39084. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39085. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39086. /**
  39087. * Manage the mouse wheel inputs to control a follow camera.
  39088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39089. */
  39090. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39091. /**
  39092. * Defines the camera the input is attached to.
  39093. */
  39094. camera: FollowCamera;
  39095. /**
  39096. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39097. */
  39098. axisControlRadius: boolean;
  39099. /**
  39100. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39101. */
  39102. axisControlHeight: boolean;
  39103. /**
  39104. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39105. */
  39106. axisControlRotation: boolean;
  39107. /**
  39108. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39109. * relation to mouseWheel events.
  39110. */
  39111. wheelPrecision: number;
  39112. /**
  39113. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39114. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39115. */
  39116. wheelDeltaPercentage: number;
  39117. private _wheel;
  39118. private _observer;
  39119. /**
  39120. * Attach the input controls to a specific dom element to get the input from.
  39121. * @param element Defines the element the controls should be listened from
  39122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39123. */
  39124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39125. /**
  39126. * Detach the current controls from the specified dom element.
  39127. * @param element Defines the element to stop listening the inputs from
  39128. */
  39129. detachControl(element: Nullable<HTMLElement>): void;
  39130. /**
  39131. * Gets the class name of the current intput.
  39132. * @returns the class name
  39133. */
  39134. getClassName(): string;
  39135. /**
  39136. * Get the friendly name associated with the input class.
  39137. * @returns the input friendly name
  39138. */
  39139. getSimpleName(): string;
  39140. }
  39141. }
  39142. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39143. import { Nullable } from "babylonjs/types";
  39144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39145. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39146. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39147. /**
  39148. * Manage the pointers inputs to control an follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Gets the class name of the current input.
  39158. * @returns the class name
  39159. */
  39160. getClassName(): string;
  39161. /**
  39162. * Defines the pointer angular sensibility along the X axis or how fast is
  39163. * the camera rotating.
  39164. * A negative number will reverse the axis direction.
  39165. */
  39166. angularSensibilityX: number;
  39167. /**
  39168. * Defines the pointer angular sensibility along the Y axis or how fast is
  39169. * the camera rotating.
  39170. * A negative number will reverse the axis direction.
  39171. */
  39172. angularSensibilityY: number;
  39173. /**
  39174. * Defines the pointer pinch precision or how fast is the camera zooming.
  39175. * A negative number will reverse the axis direction.
  39176. */
  39177. pinchPrecision: number;
  39178. /**
  39179. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39180. * from 0.
  39181. * It defines the percentage of current camera.radius to use as delta when
  39182. * pinch zoom is used.
  39183. */
  39184. pinchDeltaPercentage: number;
  39185. /**
  39186. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39187. */
  39188. axisXControlRadius: boolean;
  39189. /**
  39190. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39191. */
  39192. axisXControlHeight: boolean;
  39193. /**
  39194. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39195. */
  39196. axisXControlRotation: boolean;
  39197. /**
  39198. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39199. */
  39200. axisYControlRadius: boolean;
  39201. /**
  39202. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39203. */
  39204. axisYControlHeight: boolean;
  39205. /**
  39206. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39207. */
  39208. axisYControlRotation: boolean;
  39209. /**
  39210. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39211. */
  39212. axisPinchControlRadius: boolean;
  39213. /**
  39214. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39215. */
  39216. axisPinchControlHeight: boolean;
  39217. /**
  39218. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39219. */
  39220. axisPinchControlRotation: boolean;
  39221. /**
  39222. * Log error messages if basic misconfiguration has occurred.
  39223. */
  39224. warningEnable: boolean;
  39225. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39226. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39227. private _warningCounter;
  39228. private _warning;
  39229. }
  39230. }
  39231. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39232. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39233. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39234. /**
  39235. * Default Inputs manager for the FollowCamera.
  39236. * It groups all the default supported inputs for ease of use.
  39237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39238. */
  39239. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39240. /**
  39241. * Instantiates a new FollowCameraInputsManager.
  39242. * @param camera Defines the camera the inputs belong to
  39243. */
  39244. constructor(camera: FollowCamera);
  39245. /**
  39246. * Add keyboard input support to the input manager.
  39247. * @returns the current input manager
  39248. */
  39249. addKeyboard(): FollowCameraInputsManager;
  39250. /**
  39251. * Add mouse wheel input support to the input manager.
  39252. * @returns the current input manager
  39253. */
  39254. addMouseWheel(): FollowCameraInputsManager;
  39255. /**
  39256. * Add pointers input support to the input manager.
  39257. * @returns the current input manager
  39258. */
  39259. addPointers(): FollowCameraInputsManager;
  39260. /**
  39261. * Add orientation input support to the input manager.
  39262. * @returns the current input manager
  39263. */
  39264. addVRDeviceOrientation(): FollowCameraInputsManager;
  39265. }
  39266. }
  39267. declare module "babylonjs/Cameras/followCamera" {
  39268. import { Nullable } from "babylonjs/types";
  39269. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39270. import { Scene } from "babylonjs/scene";
  39271. import { Vector3 } from "babylonjs/Maths/math.vector";
  39272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39273. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39274. /**
  39275. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39276. * an arc rotate version arcFollowCamera are available.
  39277. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39278. */
  39279. export class FollowCamera extends TargetCamera {
  39280. /**
  39281. * Distance the follow camera should follow an object at
  39282. */
  39283. radius: number;
  39284. /**
  39285. * Minimum allowed distance of the camera to the axis of rotation
  39286. * (The camera can not get closer).
  39287. * This can help limiting how the Camera is able to move in the scene.
  39288. */
  39289. lowerRadiusLimit: Nullable<number>;
  39290. /**
  39291. * Maximum allowed distance of the camera to the axis of rotation
  39292. * (The camera can not get further).
  39293. * This can help limiting how the Camera is able to move in the scene.
  39294. */
  39295. upperRadiusLimit: Nullable<number>;
  39296. /**
  39297. * Define a rotation offset between the camera and the object it follows
  39298. */
  39299. rotationOffset: number;
  39300. /**
  39301. * Minimum allowed angle to camera position relative to target object.
  39302. * This can help limiting how the Camera is able to move in the scene.
  39303. */
  39304. lowerRotationOffsetLimit: Nullable<number>;
  39305. /**
  39306. * Maximum allowed angle to camera position relative to target object.
  39307. * This can help limiting how the Camera is able to move in the scene.
  39308. */
  39309. upperRotationOffsetLimit: Nullable<number>;
  39310. /**
  39311. * Define a height offset between the camera and the object it follows.
  39312. * It can help following an object from the top (like a car chaing a plane)
  39313. */
  39314. heightOffset: number;
  39315. /**
  39316. * Minimum allowed height of camera position relative to target object.
  39317. * This can help limiting how the Camera is able to move in the scene.
  39318. */
  39319. lowerHeightOffsetLimit: Nullable<number>;
  39320. /**
  39321. * Maximum allowed height of camera position relative to target object.
  39322. * This can help limiting how the Camera is able to move in the scene.
  39323. */
  39324. upperHeightOffsetLimit: Nullable<number>;
  39325. /**
  39326. * Define how fast the camera can accelerate to follow it s target.
  39327. */
  39328. cameraAcceleration: number;
  39329. /**
  39330. * Define the speed limit of the camera following an object.
  39331. */
  39332. maxCameraSpeed: number;
  39333. /**
  39334. * Define the target of the camera.
  39335. */
  39336. lockedTarget: Nullable<AbstractMesh>;
  39337. /**
  39338. * Defines the input associated with the camera.
  39339. */
  39340. inputs: FollowCameraInputsManager;
  39341. /**
  39342. * Instantiates the follow camera.
  39343. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39344. * @param name Define the name of the camera in the scene
  39345. * @param position Define the position of the camera
  39346. * @param scene Define the scene the camera belong to
  39347. * @param lockedTarget Define the target of the camera
  39348. */
  39349. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39350. private _follow;
  39351. /**
  39352. * Attached controls to the current camera.
  39353. * @param element Defines the element the controls should be listened from
  39354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39355. */
  39356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39357. /**
  39358. * Detach the current controls from the camera.
  39359. * The camera will stop reacting to inputs.
  39360. * @param element Defines the element to stop listening the inputs from
  39361. */
  39362. detachControl(element: HTMLElement): void;
  39363. /** @hidden */
  39364. _checkInputs(): void;
  39365. private _checkLimits;
  39366. /**
  39367. * Gets the camera class name.
  39368. * @returns the class name
  39369. */
  39370. getClassName(): string;
  39371. }
  39372. /**
  39373. * Arc Rotate version of the follow camera.
  39374. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39375. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39376. */
  39377. export class ArcFollowCamera extends TargetCamera {
  39378. /** The longitudinal angle of the camera */
  39379. alpha: number;
  39380. /** The latitudinal angle of the camera */
  39381. beta: number;
  39382. /** The radius of the camera from its target */
  39383. radius: number;
  39384. /** Define the camera target (the messh it should follow) */
  39385. target: Nullable<AbstractMesh>;
  39386. private _cartesianCoordinates;
  39387. /**
  39388. * Instantiates a new ArcFollowCamera
  39389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39390. * @param name Define the name of the camera
  39391. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39392. * @param beta Define the rotation angle of the camera around the elevation axis
  39393. * @param radius Define the radius of the camera from its target point
  39394. * @param target Define the target of the camera
  39395. * @param scene Define the scene the camera belongs to
  39396. */
  39397. constructor(name: string,
  39398. /** The longitudinal angle of the camera */
  39399. alpha: number,
  39400. /** The latitudinal angle of the camera */
  39401. beta: number,
  39402. /** The radius of the camera from its target */
  39403. radius: number,
  39404. /** Define the camera target (the messh it should follow) */
  39405. target: Nullable<AbstractMesh>, scene: Scene);
  39406. private _follow;
  39407. /** @hidden */
  39408. _checkInputs(): void;
  39409. /**
  39410. * Returns the class name of the object.
  39411. * It is mostly used internally for serialization purposes.
  39412. */
  39413. getClassName(): string;
  39414. }
  39415. }
  39416. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39417. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39418. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39419. import { Nullable } from "babylonjs/types";
  39420. /**
  39421. * Manage the keyboard inputs to control the movement of a follow camera.
  39422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39423. */
  39424. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39425. /**
  39426. * Defines the camera the input is attached to.
  39427. */
  39428. camera: FollowCamera;
  39429. /**
  39430. * Defines the list of key codes associated with the up action (increase heightOffset)
  39431. */
  39432. keysHeightOffsetIncr: number[];
  39433. /**
  39434. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39435. */
  39436. keysHeightOffsetDecr: number[];
  39437. /**
  39438. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39439. */
  39440. keysHeightOffsetModifierAlt: boolean;
  39441. /**
  39442. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39443. */
  39444. keysHeightOffsetModifierCtrl: boolean;
  39445. /**
  39446. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39447. */
  39448. keysHeightOffsetModifierShift: boolean;
  39449. /**
  39450. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39451. */
  39452. keysRotationOffsetIncr: number[];
  39453. /**
  39454. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39455. */
  39456. keysRotationOffsetDecr: number[];
  39457. /**
  39458. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39459. */
  39460. keysRotationOffsetModifierAlt: boolean;
  39461. /**
  39462. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39463. */
  39464. keysRotationOffsetModifierCtrl: boolean;
  39465. /**
  39466. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39467. */
  39468. keysRotationOffsetModifierShift: boolean;
  39469. /**
  39470. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39471. */
  39472. keysRadiusIncr: number[];
  39473. /**
  39474. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39475. */
  39476. keysRadiusDecr: number[];
  39477. /**
  39478. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39479. */
  39480. keysRadiusModifierAlt: boolean;
  39481. /**
  39482. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39483. */
  39484. keysRadiusModifierCtrl: boolean;
  39485. /**
  39486. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39487. */
  39488. keysRadiusModifierShift: boolean;
  39489. /**
  39490. * Defines the rate of change of heightOffset.
  39491. */
  39492. heightSensibility: number;
  39493. /**
  39494. * Defines the rate of change of rotationOffset.
  39495. */
  39496. rotationSensibility: number;
  39497. /**
  39498. * Defines the rate of change of radius.
  39499. */
  39500. radiusSensibility: number;
  39501. private _keys;
  39502. private _ctrlPressed;
  39503. private _altPressed;
  39504. private _shiftPressed;
  39505. private _onCanvasBlurObserver;
  39506. private _onKeyboardObserver;
  39507. private _engine;
  39508. private _scene;
  39509. /**
  39510. * Attach the input controls to a specific dom element to get the input from.
  39511. * @param element Defines the element the controls should be listened from
  39512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39513. */
  39514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39515. /**
  39516. * Detach the current controls from the specified dom element.
  39517. * @param element Defines the element to stop listening the inputs from
  39518. */
  39519. detachControl(element: Nullable<HTMLElement>): void;
  39520. /**
  39521. * Update the current camera state depending on the inputs that have been used this frame.
  39522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39523. */
  39524. checkInputs(): void;
  39525. /**
  39526. * Gets the class name of the current input.
  39527. * @returns the class name
  39528. */
  39529. getClassName(): string;
  39530. /**
  39531. * Get the friendly name associated with the input class.
  39532. * @returns the input friendly name
  39533. */
  39534. getSimpleName(): string;
  39535. /**
  39536. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39537. * allow modification of the heightOffset value.
  39538. */
  39539. private _modifierHeightOffset;
  39540. /**
  39541. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39542. * allow modification of the rotationOffset value.
  39543. */
  39544. private _modifierRotationOffset;
  39545. /**
  39546. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39547. * allow modification of the radius value.
  39548. */
  39549. private _modifierRadius;
  39550. }
  39551. }
  39552. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39553. import { Nullable } from "babylonjs/types";
  39554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39556. import { Observable } from "babylonjs/Misc/observable";
  39557. module "babylonjs/Cameras/freeCameraInputsManager" {
  39558. interface FreeCameraInputsManager {
  39559. /**
  39560. * @hidden
  39561. */
  39562. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39563. /**
  39564. * Add orientation input support to the input manager.
  39565. * @returns the current input manager
  39566. */
  39567. addDeviceOrientation(): FreeCameraInputsManager;
  39568. }
  39569. }
  39570. /**
  39571. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39572. * Screen rotation is taken into account.
  39573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39574. */
  39575. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39576. private _camera;
  39577. private _screenOrientationAngle;
  39578. private _constantTranform;
  39579. private _screenQuaternion;
  39580. private _alpha;
  39581. private _beta;
  39582. private _gamma;
  39583. /**
  39584. * Can be used to detect if a device orientation sensor is availible on a device
  39585. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39586. * @returns a promise that will resolve on orientation change
  39587. */
  39588. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39589. /**
  39590. * @hidden
  39591. */
  39592. _onDeviceOrientationChangedObservable: Observable<void>;
  39593. /**
  39594. * Instantiates a new input
  39595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39596. */
  39597. constructor();
  39598. /**
  39599. * Define the camera controlled by the input.
  39600. */
  39601. camera: FreeCamera;
  39602. /**
  39603. * Attach the input controls to a specific dom element to get the input from.
  39604. * @param element Defines the element the controls should be listened from
  39605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39606. */
  39607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39608. private _orientationChanged;
  39609. private _deviceOrientation;
  39610. /**
  39611. * Detach the current controls from the specified dom element.
  39612. * @param element Defines the element to stop listening the inputs from
  39613. */
  39614. detachControl(element: Nullable<HTMLElement>): void;
  39615. /**
  39616. * Update the current camera state depending on the inputs that have been used this frame.
  39617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39618. */
  39619. checkInputs(): void;
  39620. /**
  39621. * Gets the class name of the current intput.
  39622. * @returns the class name
  39623. */
  39624. getClassName(): string;
  39625. /**
  39626. * Get the friendly name associated with the input class.
  39627. * @returns the input friendly name
  39628. */
  39629. getSimpleName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39633. import { Nullable } from "babylonjs/types";
  39634. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39635. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39636. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39637. /**
  39638. * Manage the gamepad inputs to control a free camera.
  39639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39640. */
  39641. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39642. /**
  39643. * Define the camera the input is attached to.
  39644. */
  39645. camera: FreeCamera;
  39646. /**
  39647. * Define the Gamepad controlling the input
  39648. */
  39649. gamepad: Nullable<Gamepad>;
  39650. /**
  39651. * Defines the gamepad rotation sensiblity.
  39652. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39653. */
  39654. gamepadAngularSensibility: number;
  39655. /**
  39656. * Defines the gamepad move sensiblity.
  39657. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39658. */
  39659. gamepadMoveSensibility: number;
  39660. private _yAxisScale;
  39661. /**
  39662. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39663. */
  39664. invertYAxis: boolean;
  39665. private _onGamepadConnectedObserver;
  39666. private _onGamepadDisconnectedObserver;
  39667. private _cameraTransform;
  39668. private _deltaTransform;
  39669. private _vector3;
  39670. private _vector2;
  39671. /**
  39672. * Attach the input controls to a specific dom element to get the input from.
  39673. * @param element Defines the element the controls should be listened from
  39674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39675. */
  39676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39677. /**
  39678. * Detach the current controls from the specified dom element.
  39679. * @param element Defines the element to stop listening the inputs from
  39680. */
  39681. detachControl(element: Nullable<HTMLElement>): void;
  39682. /**
  39683. * Update the current camera state depending on the inputs that have been used this frame.
  39684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39685. */
  39686. checkInputs(): void;
  39687. /**
  39688. * Gets the class name of the current intput.
  39689. * @returns the class name
  39690. */
  39691. getClassName(): string;
  39692. /**
  39693. * Get the friendly name associated with the input class.
  39694. * @returns the input friendly name
  39695. */
  39696. getSimpleName(): string;
  39697. }
  39698. }
  39699. declare module "babylonjs/Misc/virtualJoystick" {
  39700. import { Nullable } from "babylonjs/types";
  39701. import { Vector3 } from "babylonjs/Maths/math.vector";
  39702. /**
  39703. * Defines the potential axis of a Joystick
  39704. */
  39705. export enum JoystickAxis {
  39706. /** X axis */
  39707. X = 0,
  39708. /** Y axis */
  39709. Y = 1,
  39710. /** Z axis */
  39711. Z = 2
  39712. }
  39713. /**
  39714. * Class used to define virtual joystick (used in touch mode)
  39715. */
  39716. export class VirtualJoystick {
  39717. /**
  39718. * Gets or sets a boolean indicating that left and right values must be inverted
  39719. */
  39720. reverseLeftRight: boolean;
  39721. /**
  39722. * Gets or sets a boolean indicating that up and down values must be inverted
  39723. */
  39724. reverseUpDown: boolean;
  39725. /**
  39726. * Gets the offset value for the position (ie. the change of the position value)
  39727. */
  39728. deltaPosition: Vector3;
  39729. /**
  39730. * Gets a boolean indicating if the virtual joystick was pressed
  39731. */
  39732. pressed: boolean;
  39733. /**
  39734. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39735. */
  39736. static Canvas: Nullable<HTMLCanvasElement>;
  39737. private static _globalJoystickIndex;
  39738. private static vjCanvasContext;
  39739. private static vjCanvasWidth;
  39740. private static vjCanvasHeight;
  39741. private static halfWidth;
  39742. private _action;
  39743. private _axisTargetedByLeftAndRight;
  39744. private _axisTargetedByUpAndDown;
  39745. private _joystickSensibility;
  39746. private _inversedSensibility;
  39747. private _joystickPointerID;
  39748. private _joystickColor;
  39749. private _joystickPointerPos;
  39750. private _joystickPreviousPointerPos;
  39751. private _joystickPointerStartPos;
  39752. private _deltaJoystickVector;
  39753. private _leftJoystick;
  39754. private _touches;
  39755. private _onPointerDownHandlerRef;
  39756. private _onPointerMoveHandlerRef;
  39757. private _onPointerUpHandlerRef;
  39758. private _onResize;
  39759. /**
  39760. * Creates a new virtual joystick
  39761. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39762. */
  39763. constructor(leftJoystick?: boolean);
  39764. /**
  39765. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39766. * @param newJoystickSensibility defines the new sensibility
  39767. */
  39768. setJoystickSensibility(newJoystickSensibility: number): void;
  39769. private _onPointerDown;
  39770. private _onPointerMove;
  39771. private _onPointerUp;
  39772. /**
  39773. * Change the color of the virtual joystick
  39774. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39775. */
  39776. setJoystickColor(newColor: string): void;
  39777. /**
  39778. * Defines a callback to call when the joystick is touched
  39779. * @param action defines the callback
  39780. */
  39781. setActionOnTouch(action: () => any): void;
  39782. /**
  39783. * Defines which axis you'd like to control for left & right
  39784. * @param axis defines the axis to use
  39785. */
  39786. setAxisForLeftRight(axis: JoystickAxis): void;
  39787. /**
  39788. * Defines which axis you'd like to control for up & down
  39789. * @param axis defines the axis to use
  39790. */
  39791. setAxisForUpDown(axis: JoystickAxis): void;
  39792. private _drawVirtualJoystick;
  39793. /**
  39794. * Release internal HTML canvas
  39795. */
  39796. releaseCanvas(): void;
  39797. }
  39798. }
  39799. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39800. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39801. import { Nullable } from "babylonjs/types";
  39802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39803. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39804. module "babylonjs/Cameras/freeCameraInputsManager" {
  39805. interface FreeCameraInputsManager {
  39806. /**
  39807. * Add virtual joystick input support to the input manager.
  39808. * @returns the current input manager
  39809. */
  39810. addVirtualJoystick(): FreeCameraInputsManager;
  39811. }
  39812. }
  39813. /**
  39814. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39816. */
  39817. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39818. /**
  39819. * Defines the camera the input is attached to.
  39820. */
  39821. camera: FreeCamera;
  39822. private _leftjoystick;
  39823. private _rightjoystick;
  39824. /**
  39825. * Gets the left stick of the virtual joystick.
  39826. * @returns The virtual Joystick
  39827. */
  39828. getLeftJoystick(): VirtualJoystick;
  39829. /**
  39830. * Gets the right stick of the virtual joystick.
  39831. * @returns The virtual Joystick
  39832. */
  39833. getRightJoystick(): VirtualJoystick;
  39834. /**
  39835. * Update the current camera state depending on the inputs that have been used this frame.
  39836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39837. */
  39838. checkInputs(): void;
  39839. /**
  39840. * Attach the input controls to a specific dom element to get the input from.
  39841. * @param element Defines the element the controls should be listened from
  39842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39843. */
  39844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39845. /**
  39846. * Detach the current controls from the specified dom element.
  39847. * @param element Defines the element to stop listening the inputs from
  39848. */
  39849. detachControl(element: Nullable<HTMLElement>): void;
  39850. /**
  39851. * Gets the class name of the current intput.
  39852. * @returns the class name
  39853. */
  39854. getClassName(): string;
  39855. /**
  39856. * Get the friendly name associated with the input class.
  39857. * @returns the input friendly name
  39858. */
  39859. getSimpleName(): string;
  39860. }
  39861. }
  39862. declare module "babylonjs/Cameras/Inputs/index" {
  39863. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39864. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39865. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39866. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39867. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39868. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39869. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39870. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39871. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39872. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39873. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39874. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39875. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39876. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39877. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39878. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39879. }
  39880. declare module "babylonjs/Cameras/touchCamera" {
  39881. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39882. import { Scene } from "babylonjs/scene";
  39883. import { Vector3 } from "babylonjs/Maths/math.vector";
  39884. /**
  39885. * This represents a FPS type of camera controlled by touch.
  39886. * This is like a universal camera minus the Gamepad controls.
  39887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39888. */
  39889. export class TouchCamera extends FreeCamera {
  39890. /**
  39891. * Defines the touch sensibility for rotation.
  39892. * The higher the faster.
  39893. */
  39894. touchAngularSensibility: number;
  39895. /**
  39896. * Defines the touch sensibility for move.
  39897. * The higher the faster.
  39898. */
  39899. touchMoveSensibility: number;
  39900. /**
  39901. * Instantiates a new touch camera.
  39902. * This represents a FPS type of camera controlled by touch.
  39903. * This is like a universal camera minus the Gamepad controls.
  39904. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39905. * @param name Define the name of the camera in the scene
  39906. * @param position Define the start position of the camera in the scene
  39907. * @param scene Define the scene the camera belongs to
  39908. */
  39909. constructor(name: string, position: Vector3, scene: Scene);
  39910. /**
  39911. * Gets the current object class name.
  39912. * @return the class name
  39913. */
  39914. getClassName(): string;
  39915. /** @hidden */
  39916. _setupInputs(): void;
  39917. }
  39918. }
  39919. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39920. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39921. import { Scene } from "babylonjs/scene";
  39922. import { Vector3 } from "babylonjs/Maths/math.vector";
  39923. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39924. import { Axis } from "babylonjs/Maths/math.axis";
  39925. /**
  39926. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39927. * being tilted forward or back and left or right.
  39928. */
  39929. export class DeviceOrientationCamera extends FreeCamera {
  39930. private _initialQuaternion;
  39931. private _quaternionCache;
  39932. private _tmpDragQuaternion;
  39933. private _disablePointerInputWhenUsingDeviceOrientation;
  39934. /**
  39935. * Creates a new device orientation camera
  39936. * @param name The name of the camera
  39937. * @param position The start position camera
  39938. * @param scene The scene the camera belongs to
  39939. */
  39940. constructor(name: string, position: Vector3, scene: Scene);
  39941. /**
  39942. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39943. */
  39944. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39945. private _dragFactor;
  39946. /**
  39947. * Enabled turning on the y axis when the orientation sensor is active
  39948. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39949. */
  39950. enableHorizontalDragging(dragFactor?: number): void;
  39951. /**
  39952. * Gets the current instance class name ("DeviceOrientationCamera").
  39953. * This helps avoiding instanceof at run time.
  39954. * @returns the class name
  39955. */
  39956. getClassName(): string;
  39957. /**
  39958. * @hidden
  39959. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39960. */
  39961. _checkInputs(): void;
  39962. /**
  39963. * Reset the camera to its default orientation on the specified axis only.
  39964. * @param axis The axis to reset
  39965. */
  39966. resetToCurrentRotation(axis?: Axis): void;
  39967. }
  39968. }
  39969. declare module "babylonjs/Gamepads/xboxGamepad" {
  39970. import { Observable } from "babylonjs/Misc/observable";
  39971. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39972. /**
  39973. * Defines supported buttons for XBox360 compatible gamepads
  39974. */
  39975. export enum Xbox360Button {
  39976. /** A */
  39977. A = 0,
  39978. /** B */
  39979. B = 1,
  39980. /** X */
  39981. X = 2,
  39982. /** Y */
  39983. Y = 3,
  39984. /** Start */
  39985. Start = 4,
  39986. /** Back */
  39987. Back = 5,
  39988. /** Left button */
  39989. LB = 6,
  39990. /** Right button */
  39991. RB = 7,
  39992. /** Left stick */
  39993. LeftStick = 8,
  39994. /** Right stick */
  39995. RightStick = 9
  39996. }
  39997. /** Defines values for XBox360 DPad */
  39998. export enum Xbox360Dpad {
  39999. /** Up */
  40000. Up = 0,
  40001. /** Down */
  40002. Down = 1,
  40003. /** Left */
  40004. Left = 2,
  40005. /** Right */
  40006. Right = 3
  40007. }
  40008. /**
  40009. * Defines a XBox360 gamepad
  40010. */
  40011. export class Xbox360Pad extends Gamepad {
  40012. private _leftTrigger;
  40013. private _rightTrigger;
  40014. private _onlefttriggerchanged;
  40015. private _onrighttriggerchanged;
  40016. private _onbuttondown;
  40017. private _onbuttonup;
  40018. private _ondpaddown;
  40019. private _ondpadup;
  40020. /** Observable raised when a button is pressed */
  40021. onButtonDownObservable: Observable<Xbox360Button>;
  40022. /** Observable raised when a button is released */
  40023. onButtonUpObservable: Observable<Xbox360Button>;
  40024. /** Observable raised when a pad is pressed */
  40025. onPadDownObservable: Observable<Xbox360Dpad>;
  40026. /** Observable raised when a pad is released */
  40027. onPadUpObservable: Observable<Xbox360Dpad>;
  40028. private _buttonA;
  40029. private _buttonB;
  40030. private _buttonX;
  40031. private _buttonY;
  40032. private _buttonBack;
  40033. private _buttonStart;
  40034. private _buttonLB;
  40035. private _buttonRB;
  40036. private _buttonLeftStick;
  40037. private _buttonRightStick;
  40038. private _dPadUp;
  40039. private _dPadDown;
  40040. private _dPadLeft;
  40041. private _dPadRight;
  40042. private _isXboxOnePad;
  40043. /**
  40044. * Creates a new XBox360 gamepad object
  40045. * @param id defines the id of this gamepad
  40046. * @param index defines its index
  40047. * @param gamepad defines the internal HTML gamepad object
  40048. * @param xboxOne defines if it is a XBox One gamepad
  40049. */
  40050. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40051. /**
  40052. * Defines the callback to call when left trigger is pressed
  40053. * @param callback defines the callback to use
  40054. */
  40055. onlefttriggerchanged(callback: (value: number) => void): void;
  40056. /**
  40057. * Defines the callback to call when right trigger is pressed
  40058. * @param callback defines the callback to use
  40059. */
  40060. onrighttriggerchanged(callback: (value: number) => void): void;
  40061. /**
  40062. * Gets the left trigger value
  40063. */
  40064. /**
  40065. * Sets the left trigger value
  40066. */
  40067. leftTrigger: number;
  40068. /**
  40069. * Gets the right trigger value
  40070. */
  40071. /**
  40072. * Sets the right trigger value
  40073. */
  40074. rightTrigger: number;
  40075. /**
  40076. * Defines the callback to call when a button is pressed
  40077. * @param callback defines the callback to use
  40078. */
  40079. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40080. /**
  40081. * Defines the callback to call when a button is released
  40082. * @param callback defines the callback to use
  40083. */
  40084. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40085. /**
  40086. * Defines the callback to call when a pad is pressed
  40087. * @param callback defines the callback to use
  40088. */
  40089. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40090. /**
  40091. * Defines the callback to call when a pad is released
  40092. * @param callback defines the callback to use
  40093. */
  40094. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40095. private _setButtonValue;
  40096. private _setDPadValue;
  40097. /**
  40098. * Gets the value of the `A` button
  40099. */
  40100. /**
  40101. * Sets the value of the `A` button
  40102. */
  40103. buttonA: number;
  40104. /**
  40105. * Gets the value of the `B` button
  40106. */
  40107. /**
  40108. * Sets the value of the `B` button
  40109. */
  40110. buttonB: number;
  40111. /**
  40112. * Gets the value of the `X` button
  40113. */
  40114. /**
  40115. * Sets the value of the `X` button
  40116. */
  40117. buttonX: number;
  40118. /**
  40119. * Gets the value of the `Y` button
  40120. */
  40121. /**
  40122. * Sets the value of the `Y` button
  40123. */
  40124. buttonY: number;
  40125. /**
  40126. * Gets the value of the `Start` button
  40127. */
  40128. /**
  40129. * Sets the value of the `Start` button
  40130. */
  40131. buttonStart: number;
  40132. /**
  40133. * Gets the value of the `Back` button
  40134. */
  40135. /**
  40136. * Sets the value of the `Back` button
  40137. */
  40138. buttonBack: number;
  40139. /**
  40140. * Gets the value of the `Left` button
  40141. */
  40142. /**
  40143. * Sets the value of the `Left` button
  40144. */
  40145. buttonLB: number;
  40146. /**
  40147. * Gets the value of the `Right` button
  40148. */
  40149. /**
  40150. * Sets the value of the `Right` button
  40151. */
  40152. buttonRB: number;
  40153. /**
  40154. * Gets the value of the Left joystick
  40155. */
  40156. /**
  40157. * Sets the value of the Left joystick
  40158. */
  40159. buttonLeftStick: number;
  40160. /**
  40161. * Gets the value of the Right joystick
  40162. */
  40163. /**
  40164. * Sets the value of the Right joystick
  40165. */
  40166. buttonRightStick: number;
  40167. /**
  40168. * Gets the value of D-pad up
  40169. */
  40170. /**
  40171. * Sets the value of D-pad up
  40172. */
  40173. dPadUp: number;
  40174. /**
  40175. * Gets the value of D-pad down
  40176. */
  40177. /**
  40178. * Sets the value of D-pad down
  40179. */
  40180. dPadDown: number;
  40181. /**
  40182. * Gets the value of D-pad left
  40183. */
  40184. /**
  40185. * Sets the value of D-pad left
  40186. */
  40187. dPadLeft: number;
  40188. /**
  40189. * Gets the value of D-pad right
  40190. */
  40191. /**
  40192. * Sets the value of D-pad right
  40193. */
  40194. dPadRight: number;
  40195. /**
  40196. * Force the gamepad to synchronize with device values
  40197. */
  40198. update(): void;
  40199. /**
  40200. * Disposes the gamepad
  40201. */
  40202. dispose(): void;
  40203. }
  40204. }
  40205. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40206. import { Observable } from "babylonjs/Misc/observable";
  40207. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40208. /**
  40209. * Defines supported buttons for DualShock compatible gamepads
  40210. */
  40211. export enum DualShockButton {
  40212. /** Cross */
  40213. Cross = 0,
  40214. /** Circle */
  40215. Circle = 1,
  40216. /** Square */
  40217. Square = 2,
  40218. /** Triangle */
  40219. Triangle = 3,
  40220. /** Options */
  40221. Options = 4,
  40222. /** Share */
  40223. Share = 5,
  40224. /** L1 */
  40225. L1 = 6,
  40226. /** R1 */
  40227. R1 = 7,
  40228. /** Left stick */
  40229. LeftStick = 8,
  40230. /** Right stick */
  40231. RightStick = 9
  40232. }
  40233. /** Defines values for DualShock DPad */
  40234. export enum DualShockDpad {
  40235. /** Up */
  40236. Up = 0,
  40237. /** Down */
  40238. Down = 1,
  40239. /** Left */
  40240. Left = 2,
  40241. /** Right */
  40242. Right = 3
  40243. }
  40244. /**
  40245. * Defines a DualShock gamepad
  40246. */
  40247. export class DualShockPad extends Gamepad {
  40248. private _leftTrigger;
  40249. private _rightTrigger;
  40250. private _onlefttriggerchanged;
  40251. private _onrighttriggerchanged;
  40252. private _onbuttondown;
  40253. private _onbuttonup;
  40254. private _ondpaddown;
  40255. private _ondpadup;
  40256. /** Observable raised when a button is pressed */
  40257. onButtonDownObservable: Observable<DualShockButton>;
  40258. /** Observable raised when a button is released */
  40259. onButtonUpObservable: Observable<DualShockButton>;
  40260. /** Observable raised when a pad is pressed */
  40261. onPadDownObservable: Observable<DualShockDpad>;
  40262. /** Observable raised when a pad is released */
  40263. onPadUpObservable: Observable<DualShockDpad>;
  40264. private _buttonCross;
  40265. private _buttonCircle;
  40266. private _buttonSquare;
  40267. private _buttonTriangle;
  40268. private _buttonShare;
  40269. private _buttonOptions;
  40270. private _buttonL1;
  40271. private _buttonR1;
  40272. private _buttonLeftStick;
  40273. private _buttonRightStick;
  40274. private _dPadUp;
  40275. private _dPadDown;
  40276. private _dPadLeft;
  40277. private _dPadRight;
  40278. /**
  40279. * Creates a new DualShock gamepad object
  40280. * @param id defines the id of this gamepad
  40281. * @param index defines its index
  40282. * @param gamepad defines the internal HTML gamepad object
  40283. */
  40284. constructor(id: string, index: number, gamepad: any);
  40285. /**
  40286. * Defines the callback to call when left trigger is pressed
  40287. * @param callback defines the callback to use
  40288. */
  40289. onlefttriggerchanged(callback: (value: number) => void): void;
  40290. /**
  40291. * Defines the callback to call when right trigger is pressed
  40292. * @param callback defines the callback to use
  40293. */
  40294. onrighttriggerchanged(callback: (value: number) => void): void;
  40295. /**
  40296. * Gets the left trigger value
  40297. */
  40298. /**
  40299. * Sets the left trigger value
  40300. */
  40301. leftTrigger: number;
  40302. /**
  40303. * Gets the right trigger value
  40304. */
  40305. /**
  40306. * Sets the right trigger value
  40307. */
  40308. rightTrigger: number;
  40309. /**
  40310. * Defines the callback to call when a button is pressed
  40311. * @param callback defines the callback to use
  40312. */
  40313. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40314. /**
  40315. * Defines the callback to call when a button is released
  40316. * @param callback defines the callback to use
  40317. */
  40318. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40319. /**
  40320. * Defines the callback to call when a pad is pressed
  40321. * @param callback defines the callback to use
  40322. */
  40323. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40324. /**
  40325. * Defines the callback to call when a pad is released
  40326. * @param callback defines the callback to use
  40327. */
  40328. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40329. private _setButtonValue;
  40330. private _setDPadValue;
  40331. /**
  40332. * Gets the value of the `Cross` button
  40333. */
  40334. /**
  40335. * Sets the value of the `Cross` button
  40336. */
  40337. buttonCross: number;
  40338. /**
  40339. * Gets the value of the `Circle` button
  40340. */
  40341. /**
  40342. * Sets the value of the `Circle` button
  40343. */
  40344. buttonCircle: number;
  40345. /**
  40346. * Gets the value of the `Square` button
  40347. */
  40348. /**
  40349. * Sets the value of the `Square` button
  40350. */
  40351. buttonSquare: number;
  40352. /**
  40353. * Gets the value of the `Triangle` button
  40354. */
  40355. /**
  40356. * Sets the value of the `Triangle` button
  40357. */
  40358. buttonTriangle: number;
  40359. /**
  40360. * Gets the value of the `Options` button
  40361. */
  40362. /**
  40363. * Sets the value of the `Options` button
  40364. */
  40365. buttonOptions: number;
  40366. /**
  40367. * Gets the value of the `Share` button
  40368. */
  40369. /**
  40370. * Sets the value of the `Share` button
  40371. */
  40372. buttonShare: number;
  40373. /**
  40374. * Gets the value of the `L1` button
  40375. */
  40376. /**
  40377. * Sets the value of the `L1` button
  40378. */
  40379. buttonL1: number;
  40380. /**
  40381. * Gets the value of the `R1` button
  40382. */
  40383. /**
  40384. * Sets the value of the `R1` button
  40385. */
  40386. buttonR1: number;
  40387. /**
  40388. * Gets the value of the Left joystick
  40389. */
  40390. /**
  40391. * Sets the value of the Left joystick
  40392. */
  40393. buttonLeftStick: number;
  40394. /**
  40395. * Gets the value of the Right joystick
  40396. */
  40397. /**
  40398. * Sets the value of the Right joystick
  40399. */
  40400. buttonRightStick: number;
  40401. /**
  40402. * Gets the value of D-pad up
  40403. */
  40404. /**
  40405. * Sets the value of D-pad up
  40406. */
  40407. dPadUp: number;
  40408. /**
  40409. * Gets the value of D-pad down
  40410. */
  40411. /**
  40412. * Sets the value of D-pad down
  40413. */
  40414. dPadDown: number;
  40415. /**
  40416. * Gets the value of D-pad left
  40417. */
  40418. /**
  40419. * Sets the value of D-pad left
  40420. */
  40421. dPadLeft: number;
  40422. /**
  40423. * Gets the value of D-pad right
  40424. */
  40425. /**
  40426. * Sets the value of D-pad right
  40427. */
  40428. dPadRight: number;
  40429. /**
  40430. * Force the gamepad to synchronize with device values
  40431. */
  40432. update(): void;
  40433. /**
  40434. * Disposes the gamepad
  40435. */
  40436. dispose(): void;
  40437. }
  40438. }
  40439. declare module "babylonjs/Gamepads/gamepadManager" {
  40440. import { Observable } from "babylonjs/Misc/observable";
  40441. import { Nullable } from "babylonjs/types";
  40442. import { Scene } from "babylonjs/scene";
  40443. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40444. /**
  40445. * Manager for handling gamepads
  40446. */
  40447. export class GamepadManager {
  40448. private _scene?;
  40449. private _babylonGamepads;
  40450. private _oneGamepadConnected;
  40451. /** @hidden */
  40452. _isMonitoring: boolean;
  40453. private _gamepadEventSupported;
  40454. private _gamepadSupport;
  40455. /**
  40456. * observable to be triggered when the gamepad controller has been connected
  40457. */
  40458. onGamepadConnectedObservable: Observable<Gamepad>;
  40459. /**
  40460. * observable to be triggered when the gamepad controller has been disconnected
  40461. */
  40462. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40463. private _onGamepadConnectedEvent;
  40464. private _onGamepadDisconnectedEvent;
  40465. /**
  40466. * Initializes the gamepad manager
  40467. * @param _scene BabylonJS scene
  40468. */
  40469. constructor(_scene?: Scene | undefined);
  40470. /**
  40471. * The gamepads in the game pad manager
  40472. */
  40473. readonly gamepads: Gamepad[];
  40474. /**
  40475. * Get the gamepad controllers based on type
  40476. * @param type The type of gamepad controller
  40477. * @returns Nullable gamepad
  40478. */
  40479. getGamepadByType(type?: number): Nullable<Gamepad>;
  40480. /**
  40481. * Disposes the gamepad manager
  40482. */
  40483. dispose(): void;
  40484. private _addNewGamepad;
  40485. private _startMonitoringGamepads;
  40486. private _stopMonitoringGamepads;
  40487. /** @hidden */
  40488. _checkGamepadsStatus(): void;
  40489. private _updateGamepadObjects;
  40490. }
  40491. }
  40492. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40493. import { Nullable } from "babylonjs/types";
  40494. import { Scene } from "babylonjs/scene";
  40495. import { ISceneComponent } from "babylonjs/sceneComponent";
  40496. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40497. module "babylonjs/scene" {
  40498. interface Scene {
  40499. /** @hidden */
  40500. _gamepadManager: Nullable<GamepadManager>;
  40501. /**
  40502. * Gets the gamepad manager associated with the scene
  40503. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40504. */
  40505. gamepadManager: GamepadManager;
  40506. }
  40507. }
  40508. module "babylonjs/Cameras/freeCameraInputsManager" {
  40509. /**
  40510. * Interface representing a free camera inputs manager
  40511. */
  40512. interface FreeCameraInputsManager {
  40513. /**
  40514. * Adds gamepad input support to the FreeCameraInputsManager.
  40515. * @returns the FreeCameraInputsManager
  40516. */
  40517. addGamepad(): FreeCameraInputsManager;
  40518. }
  40519. }
  40520. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40521. /**
  40522. * Interface representing an arc rotate camera inputs manager
  40523. */
  40524. interface ArcRotateCameraInputsManager {
  40525. /**
  40526. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40527. * @returns the camera inputs manager
  40528. */
  40529. addGamepad(): ArcRotateCameraInputsManager;
  40530. }
  40531. }
  40532. /**
  40533. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40534. */
  40535. export class GamepadSystemSceneComponent implements ISceneComponent {
  40536. /**
  40537. * The component name helpfull to identify the component in the list of scene components.
  40538. */
  40539. readonly name: string;
  40540. /**
  40541. * The scene the component belongs to.
  40542. */
  40543. scene: Scene;
  40544. /**
  40545. * Creates a new instance of the component for the given scene
  40546. * @param scene Defines the scene to register the component in
  40547. */
  40548. constructor(scene: Scene);
  40549. /**
  40550. * Registers the component in a given scene
  40551. */
  40552. register(): void;
  40553. /**
  40554. * Rebuilds the elements related to this component in case of
  40555. * context lost for instance.
  40556. */
  40557. rebuild(): void;
  40558. /**
  40559. * Disposes the component and the associated ressources
  40560. */
  40561. dispose(): void;
  40562. private _beforeCameraUpdate;
  40563. }
  40564. }
  40565. declare module "babylonjs/Cameras/universalCamera" {
  40566. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40567. import { Scene } from "babylonjs/scene";
  40568. import { Vector3 } from "babylonjs/Maths/math.vector";
  40569. import "babylonjs/Gamepads/gamepadSceneComponent";
  40570. /**
  40571. * 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,
  40572. * which still works and will still be found in many Playgrounds.
  40573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40574. */
  40575. export class UniversalCamera extends TouchCamera {
  40576. /**
  40577. * Defines the gamepad rotation sensiblity.
  40578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40579. */
  40580. gamepadAngularSensibility: number;
  40581. /**
  40582. * Defines the gamepad move sensiblity.
  40583. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40584. */
  40585. gamepadMoveSensibility: number;
  40586. /**
  40587. * 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,
  40588. * which still works and will still be found in many Playgrounds.
  40589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40590. * @param name Define the name of the camera in the scene
  40591. * @param position Define the start position of the camera in the scene
  40592. * @param scene Define the scene the camera belongs to
  40593. */
  40594. constructor(name: string, position: Vector3, scene: Scene);
  40595. /**
  40596. * Gets the current object class name.
  40597. * @return the class name
  40598. */
  40599. getClassName(): string;
  40600. }
  40601. }
  40602. declare module "babylonjs/Cameras/gamepadCamera" {
  40603. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40604. import { Scene } from "babylonjs/scene";
  40605. import { Vector3 } from "babylonjs/Maths/math.vector";
  40606. /**
  40607. * This represents a FPS type of camera. This is only here for back compat purpose.
  40608. * Please use the UniversalCamera instead as both are identical.
  40609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40610. */
  40611. export class GamepadCamera extends UniversalCamera {
  40612. /**
  40613. * Instantiates a new Gamepad Camera
  40614. * This represents a FPS type of camera. This is only here for back compat purpose.
  40615. * Please use the UniversalCamera instead as both are identical.
  40616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40617. * @param name Define the name of the camera in the scene
  40618. * @param position Define the start position of the camera in the scene
  40619. * @param scene Define the scene the camera belongs to
  40620. */
  40621. constructor(name: string, position: Vector3, scene: Scene);
  40622. /**
  40623. * Gets the current object class name.
  40624. * @return the class name
  40625. */
  40626. getClassName(): string;
  40627. }
  40628. }
  40629. declare module "babylonjs/Shaders/pass.fragment" {
  40630. /** @hidden */
  40631. export var passPixelShader: {
  40632. name: string;
  40633. shader: string;
  40634. };
  40635. }
  40636. declare module "babylonjs/Shaders/passCube.fragment" {
  40637. /** @hidden */
  40638. export var passCubePixelShader: {
  40639. name: string;
  40640. shader: string;
  40641. };
  40642. }
  40643. declare module "babylonjs/PostProcesses/passPostProcess" {
  40644. import { Nullable } from "babylonjs/types";
  40645. import { Camera } from "babylonjs/Cameras/camera";
  40646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40647. import { Engine } from "babylonjs/Engines/engine";
  40648. import "babylonjs/Shaders/pass.fragment";
  40649. import "babylonjs/Shaders/passCube.fragment";
  40650. /**
  40651. * PassPostProcess which produces an output the same as it's input
  40652. */
  40653. export class PassPostProcess extends PostProcess {
  40654. /**
  40655. * Creates the PassPostProcess
  40656. * @param name The name of the effect.
  40657. * @param options The required width/height ratio to downsize to before computing the render pass.
  40658. * @param camera The camera to apply the render pass to.
  40659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40660. * @param engine The engine which the post process will be applied. (default: current engine)
  40661. * @param reusable If the post process can be reused on the same frame. (default: false)
  40662. * @param textureType The type of texture to be used when performing the post processing.
  40663. * @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)
  40664. */
  40665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40666. }
  40667. /**
  40668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40669. */
  40670. export class PassCubePostProcess extends PostProcess {
  40671. private _face;
  40672. /**
  40673. * Gets or sets the cube face to display.
  40674. * * 0 is +X
  40675. * * 1 is -X
  40676. * * 2 is +Y
  40677. * * 3 is -Y
  40678. * * 4 is +Z
  40679. * * 5 is -Z
  40680. */
  40681. face: number;
  40682. /**
  40683. * Creates the PassCubePostProcess
  40684. * @param name The name of the effect.
  40685. * @param options The required width/height ratio to downsize to before computing the render pass.
  40686. * @param camera The camera to apply the render pass to.
  40687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40688. * @param engine The engine which the post process will be applied. (default: current engine)
  40689. * @param reusable If the post process can be reused on the same frame. (default: false)
  40690. * @param textureType The type of texture to be used when performing the post processing.
  40691. * @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)
  40692. */
  40693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40694. }
  40695. }
  40696. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40697. /** @hidden */
  40698. export var anaglyphPixelShader: {
  40699. name: string;
  40700. shader: string;
  40701. };
  40702. }
  40703. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40704. import { Engine } from "babylonjs/Engines/engine";
  40705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40706. import { Camera } from "babylonjs/Cameras/camera";
  40707. import "babylonjs/Shaders/anaglyph.fragment";
  40708. /**
  40709. * Postprocess used to generate anaglyphic rendering
  40710. */
  40711. export class AnaglyphPostProcess extends PostProcess {
  40712. private _passedProcess;
  40713. /**
  40714. * Creates a new AnaglyphPostProcess
  40715. * @param name defines postprocess name
  40716. * @param options defines creation options or target ratio scale
  40717. * @param rigCameras defines cameras using this postprocess
  40718. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40719. * @param engine defines hosting engine
  40720. * @param reusable defines if the postprocess will be reused multiple times per frame
  40721. */
  40722. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40723. }
  40724. }
  40725. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40726. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40728. import { Scene } from "babylonjs/scene";
  40729. import { Vector3 } from "babylonjs/Maths/math.vector";
  40730. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40731. /**
  40732. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40733. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40734. */
  40735. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40736. /**
  40737. * Creates a new AnaglyphArcRotateCamera
  40738. * @param name defines camera name
  40739. * @param alpha defines alpha angle (in radians)
  40740. * @param beta defines beta angle (in radians)
  40741. * @param radius defines radius
  40742. * @param target defines camera target
  40743. * @param interaxialDistance defines distance between each color axis
  40744. * @param scene defines the hosting scene
  40745. */
  40746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40747. /**
  40748. * Gets camera class name
  40749. * @returns AnaglyphArcRotateCamera
  40750. */
  40751. getClassName(): string;
  40752. }
  40753. }
  40754. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40755. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40756. import { Scene } from "babylonjs/scene";
  40757. import { Vector3 } from "babylonjs/Maths/math.vector";
  40758. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40759. /**
  40760. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40762. */
  40763. export class AnaglyphFreeCamera extends FreeCamera {
  40764. /**
  40765. * Creates a new AnaglyphFreeCamera
  40766. * @param name defines camera name
  40767. * @param position defines initial position
  40768. * @param interaxialDistance defines distance between each color axis
  40769. * @param scene defines the hosting scene
  40770. */
  40771. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40772. /**
  40773. * Gets camera class name
  40774. * @returns AnaglyphFreeCamera
  40775. */
  40776. getClassName(): string;
  40777. }
  40778. }
  40779. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40780. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40781. import { Scene } from "babylonjs/scene";
  40782. import { Vector3 } from "babylonjs/Maths/math.vector";
  40783. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40784. /**
  40785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40787. */
  40788. export class AnaglyphGamepadCamera extends GamepadCamera {
  40789. /**
  40790. * Creates a new AnaglyphGamepadCamera
  40791. * @param name defines camera name
  40792. * @param position defines initial position
  40793. * @param interaxialDistance defines distance between each color axis
  40794. * @param scene defines the hosting scene
  40795. */
  40796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40797. /**
  40798. * Gets camera class name
  40799. * @returns AnaglyphGamepadCamera
  40800. */
  40801. getClassName(): string;
  40802. }
  40803. }
  40804. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40805. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40806. import { Scene } from "babylonjs/scene";
  40807. import { Vector3 } from "babylonjs/Maths/math.vector";
  40808. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40809. /**
  40810. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40812. */
  40813. export class AnaglyphUniversalCamera extends UniversalCamera {
  40814. /**
  40815. * Creates a new AnaglyphUniversalCamera
  40816. * @param name defines camera name
  40817. * @param position defines initial position
  40818. * @param interaxialDistance defines distance between each color axis
  40819. * @param scene defines the hosting scene
  40820. */
  40821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40822. /**
  40823. * Gets camera class name
  40824. * @returns AnaglyphUniversalCamera
  40825. */
  40826. getClassName(): string;
  40827. }
  40828. }
  40829. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40830. /** @hidden */
  40831. export var stereoscopicInterlacePixelShader: {
  40832. name: string;
  40833. shader: string;
  40834. };
  40835. }
  40836. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40837. import { Camera } from "babylonjs/Cameras/camera";
  40838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40839. import { Engine } from "babylonjs/Engines/engine";
  40840. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40841. /**
  40842. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40843. */
  40844. export class StereoscopicInterlacePostProcess extends PostProcess {
  40845. private _stepSize;
  40846. private _passedProcess;
  40847. /**
  40848. * Initializes a StereoscopicInterlacePostProcess
  40849. * @param name The name of the effect.
  40850. * @param rigCameras The rig cameras to be appled to the post process
  40851. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40853. * @param engine The engine which the post process will be applied. (default: current engine)
  40854. * @param reusable If the post process can be reused on the same frame. (default: false)
  40855. */
  40856. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40857. }
  40858. }
  40859. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40862. import { Scene } from "babylonjs/scene";
  40863. import { Vector3 } from "babylonjs/Maths/math.vector";
  40864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40865. /**
  40866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/features/cameras
  40868. */
  40869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new StereoscopicArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines alpha angle (in radians)
  40874. * @param beta defines beta angle (in radians)
  40875. * @param radius defines radius
  40876. * @param target defines camera target
  40877. * @param interaxialDistance defines distance between each color axis
  40878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40879. * @param scene defines the hosting scene
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns StereoscopicArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40891. import { Scene } from "babylonjs/scene";
  40892. import { Vector3 } from "babylonjs/Maths/math.vector";
  40893. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40894. /**
  40895. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40896. * @see http://doc.babylonjs.com/features/cameras
  40897. */
  40898. export class StereoscopicFreeCamera extends FreeCamera {
  40899. /**
  40900. * Creates a new StereoscopicFreeCamera
  40901. * @param name defines camera name
  40902. * @param position defines initial position
  40903. * @param interaxialDistance defines distance between each color axis
  40904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40905. * @param scene defines the hosting scene
  40906. */
  40907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40908. /**
  40909. * Gets camera class name
  40910. * @returns StereoscopicFreeCamera
  40911. */
  40912. getClassName(): string;
  40913. }
  40914. }
  40915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40916. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40917. import { Scene } from "babylonjs/scene";
  40918. import { Vector3 } from "babylonjs/Maths/math.vector";
  40919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40920. /**
  40921. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40922. * @see http://doc.babylonjs.com/features/cameras
  40923. */
  40924. export class StereoscopicGamepadCamera extends GamepadCamera {
  40925. /**
  40926. * Creates a new StereoscopicGamepadCamera
  40927. * @param name defines camera name
  40928. * @param position defines initial position
  40929. * @param interaxialDistance defines distance between each color axis
  40930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40931. * @param scene defines the hosting scene
  40932. */
  40933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40934. /**
  40935. * Gets camera class name
  40936. * @returns StereoscopicGamepadCamera
  40937. */
  40938. getClassName(): string;
  40939. }
  40940. }
  40941. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40943. import { Scene } from "babylonjs/scene";
  40944. import { Vector3 } from "babylonjs/Maths/math.vector";
  40945. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40946. /**
  40947. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40948. * @see http://doc.babylonjs.com/features/cameras
  40949. */
  40950. export class StereoscopicUniversalCamera extends UniversalCamera {
  40951. /**
  40952. * Creates a new StereoscopicUniversalCamera
  40953. * @param name defines camera name
  40954. * @param position defines initial position
  40955. * @param interaxialDistance defines distance between each color axis
  40956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40957. * @param scene defines the hosting scene
  40958. */
  40959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40960. /**
  40961. * Gets camera class name
  40962. * @returns StereoscopicUniversalCamera
  40963. */
  40964. getClassName(): string;
  40965. }
  40966. }
  40967. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40971. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40975. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40976. }
  40977. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40979. import { Scene } from "babylonjs/scene";
  40980. import { Vector3 } from "babylonjs/Maths/math.vector";
  40981. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40982. /**
  40983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40984. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40985. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40986. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40987. */
  40988. export class VirtualJoysticksCamera extends FreeCamera {
  40989. /**
  40990. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40993. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40994. * @param name Define the name of the camera in the scene
  40995. * @param position Define the start position of the camera in the scene
  40996. * @param scene Define the scene the camera belongs to
  40997. */
  40998. constructor(name: string, position: Vector3, scene: Scene);
  40999. /**
  41000. * Gets the current object class name.
  41001. * @return the class name
  41002. */
  41003. getClassName(): string;
  41004. }
  41005. }
  41006. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41007. import { Matrix } from "babylonjs/Maths/math.vector";
  41008. /**
  41009. * This represents all the required metrics to create a VR camera.
  41010. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41011. */
  41012. export class VRCameraMetrics {
  41013. /**
  41014. * Define the horizontal resolution off the screen.
  41015. */
  41016. hResolution: number;
  41017. /**
  41018. * Define the vertical resolution off the screen.
  41019. */
  41020. vResolution: number;
  41021. /**
  41022. * Define the horizontal screen size.
  41023. */
  41024. hScreenSize: number;
  41025. /**
  41026. * Define the vertical screen size.
  41027. */
  41028. vScreenSize: number;
  41029. /**
  41030. * Define the vertical screen center position.
  41031. */
  41032. vScreenCenter: number;
  41033. /**
  41034. * Define the distance of the eyes to the screen.
  41035. */
  41036. eyeToScreenDistance: number;
  41037. /**
  41038. * Define the distance between both lenses
  41039. */
  41040. lensSeparationDistance: number;
  41041. /**
  41042. * Define the distance between both viewer's eyes.
  41043. */
  41044. interpupillaryDistance: number;
  41045. /**
  41046. * Define the distortion factor of the VR postprocess.
  41047. * Please, touch with care.
  41048. */
  41049. distortionK: number[];
  41050. /**
  41051. * Define the chromatic aberration correction factors for the VR post process.
  41052. */
  41053. chromaAbCorrection: number[];
  41054. /**
  41055. * Define the scale factor of the post process.
  41056. * The smaller the better but the slower.
  41057. */
  41058. postProcessScaleFactor: number;
  41059. /**
  41060. * Define an offset for the lens center.
  41061. */
  41062. lensCenterOffset: number;
  41063. /**
  41064. * Define if the current vr camera should compensate the distortion of the lense or not.
  41065. */
  41066. compensateDistortion: boolean;
  41067. /**
  41068. * Defines if multiview should be enabled when rendering (Default: false)
  41069. */
  41070. multiviewEnabled: boolean;
  41071. /**
  41072. * Gets the rendering aspect ratio based on the provided resolutions.
  41073. */
  41074. readonly aspectRatio: number;
  41075. /**
  41076. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41077. */
  41078. readonly aspectRatioFov: number;
  41079. /**
  41080. * @hidden
  41081. */
  41082. readonly leftHMatrix: Matrix;
  41083. /**
  41084. * @hidden
  41085. */
  41086. readonly rightHMatrix: Matrix;
  41087. /**
  41088. * @hidden
  41089. */
  41090. readonly leftPreViewMatrix: Matrix;
  41091. /**
  41092. * @hidden
  41093. */
  41094. readonly rightPreViewMatrix: Matrix;
  41095. /**
  41096. * Get the default VRMetrics based on the most generic setup.
  41097. * @returns the default vr metrics
  41098. */
  41099. static GetDefault(): VRCameraMetrics;
  41100. }
  41101. }
  41102. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41103. /** @hidden */
  41104. export var vrDistortionCorrectionPixelShader: {
  41105. name: string;
  41106. shader: string;
  41107. };
  41108. }
  41109. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41110. import { Camera } from "babylonjs/Cameras/camera";
  41111. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41113. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41114. /**
  41115. * VRDistortionCorrectionPostProcess used for mobile VR
  41116. */
  41117. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41118. private _isRightEye;
  41119. private _distortionFactors;
  41120. private _postProcessScaleFactor;
  41121. private _lensCenterOffset;
  41122. private _scaleIn;
  41123. private _scaleFactor;
  41124. private _lensCenter;
  41125. /**
  41126. * Initializes the VRDistortionCorrectionPostProcess
  41127. * @param name The name of the effect.
  41128. * @param camera The camera to apply the render pass to.
  41129. * @param isRightEye If this is for the right eye distortion
  41130. * @param vrMetrics All the required metrics for the VR camera
  41131. */
  41132. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41133. }
  41134. }
  41135. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41136. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41138. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41139. import { Scene } from "babylonjs/scene";
  41140. import { Vector3 } from "babylonjs/Maths/math.vector";
  41141. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41142. import "babylonjs/Cameras/RigModes/vrRigMode";
  41143. /**
  41144. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41146. */
  41147. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41148. /**
  41149. * Creates a new VRDeviceOrientationArcRotateCamera
  41150. * @param name defines camera name
  41151. * @param alpha defines the camera rotation along the logitudinal axis
  41152. * @param beta defines the camera rotation along the latitudinal axis
  41153. * @param radius defines the camera distance from its target
  41154. * @param target defines the camera target
  41155. * @param scene defines the scene the camera belongs to
  41156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41158. */
  41159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41160. /**
  41161. * Gets camera class name
  41162. * @returns VRDeviceOrientationArcRotateCamera
  41163. */
  41164. getClassName(): string;
  41165. }
  41166. }
  41167. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41168. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41169. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41170. import { Scene } from "babylonjs/scene";
  41171. import { Vector3 } from "babylonjs/Maths/math.vector";
  41172. import "babylonjs/Cameras/RigModes/vrRigMode";
  41173. /**
  41174. * Camera used to simulate VR rendering (based on FreeCamera)
  41175. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41176. */
  41177. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41178. /**
  41179. * Creates a new VRDeviceOrientationFreeCamera
  41180. * @param name defines camera name
  41181. * @param position defines the start position of the camera
  41182. * @param scene defines the scene the camera belongs to
  41183. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41184. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41185. */
  41186. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41187. /**
  41188. * Gets camera class name
  41189. * @returns VRDeviceOrientationFreeCamera
  41190. */
  41191. getClassName(): string;
  41192. }
  41193. }
  41194. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41195. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41196. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41197. import { Scene } from "babylonjs/scene";
  41198. import { Vector3 } from "babylonjs/Maths/math.vector";
  41199. import "babylonjs/Gamepads/gamepadSceneComponent";
  41200. /**
  41201. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41203. */
  41204. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41205. /**
  41206. * Creates a new VRDeviceOrientationGamepadCamera
  41207. * @param name defines camera name
  41208. * @param position defines the start position of the camera
  41209. * @param scene defines the scene the camera belongs to
  41210. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41211. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41212. */
  41213. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41214. /**
  41215. * Gets camera class name
  41216. * @returns VRDeviceOrientationGamepadCamera
  41217. */
  41218. getClassName(): string;
  41219. }
  41220. }
  41221. declare module "babylonjs/Materials/pushMaterial" {
  41222. import { Nullable } from "babylonjs/types";
  41223. import { Scene } from "babylonjs/scene";
  41224. import { Matrix } from "babylonjs/Maths/math.vector";
  41225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41226. import { Mesh } from "babylonjs/Meshes/mesh";
  41227. import { Material } from "babylonjs/Materials/material";
  41228. import { Effect } from "babylonjs/Materials/effect";
  41229. /**
  41230. * Base class of materials working in push mode in babylon JS
  41231. * @hidden
  41232. */
  41233. export class PushMaterial extends Material {
  41234. protected _activeEffect: Effect;
  41235. protected _normalMatrix: Matrix;
  41236. /**
  41237. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41238. * This means that the material can keep using a previous shader while a new one is being compiled.
  41239. * This is mostly used when shader parallel compilation is supported (true by default)
  41240. */
  41241. allowShaderHotSwapping: boolean;
  41242. constructor(name: string, scene: Scene);
  41243. getEffect(): Effect;
  41244. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41245. /**
  41246. * Binds the given world matrix to the active effect
  41247. *
  41248. * @param world the matrix to bind
  41249. */
  41250. bindOnlyWorldMatrix(world: Matrix): void;
  41251. /**
  41252. * Binds the given normal matrix to the active effect
  41253. *
  41254. * @param normalMatrix the matrix to bind
  41255. */
  41256. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41257. bind(world: Matrix, mesh?: Mesh): void;
  41258. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41259. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41260. }
  41261. }
  41262. declare module "babylonjs/Materials/materialFlags" {
  41263. /**
  41264. * This groups all the flags used to control the materials channel.
  41265. */
  41266. export class MaterialFlags {
  41267. private static _DiffuseTextureEnabled;
  41268. /**
  41269. * Are diffuse textures enabled in the application.
  41270. */
  41271. static DiffuseTextureEnabled: boolean;
  41272. private static _AmbientTextureEnabled;
  41273. /**
  41274. * Are ambient textures enabled in the application.
  41275. */
  41276. static AmbientTextureEnabled: boolean;
  41277. private static _OpacityTextureEnabled;
  41278. /**
  41279. * Are opacity textures enabled in the application.
  41280. */
  41281. static OpacityTextureEnabled: boolean;
  41282. private static _ReflectionTextureEnabled;
  41283. /**
  41284. * Are reflection textures enabled in the application.
  41285. */
  41286. static ReflectionTextureEnabled: boolean;
  41287. private static _EmissiveTextureEnabled;
  41288. /**
  41289. * Are emissive textures enabled in the application.
  41290. */
  41291. static EmissiveTextureEnabled: boolean;
  41292. private static _SpecularTextureEnabled;
  41293. /**
  41294. * Are specular textures enabled in the application.
  41295. */
  41296. static SpecularTextureEnabled: boolean;
  41297. private static _BumpTextureEnabled;
  41298. /**
  41299. * Are bump textures enabled in the application.
  41300. */
  41301. static BumpTextureEnabled: boolean;
  41302. private static _LightmapTextureEnabled;
  41303. /**
  41304. * Are lightmap textures enabled in the application.
  41305. */
  41306. static LightmapTextureEnabled: boolean;
  41307. private static _RefractionTextureEnabled;
  41308. /**
  41309. * Are refraction textures enabled in the application.
  41310. */
  41311. static RefractionTextureEnabled: boolean;
  41312. private static _ColorGradingTextureEnabled;
  41313. /**
  41314. * Are color grading textures enabled in the application.
  41315. */
  41316. static ColorGradingTextureEnabled: boolean;
  41317. private static _FresnelEnabled;
  41318. /**
  41319. * Are fresnels enabled in the application.
  41320. */
  41321. static FresnelEnabled: boolean;
  41322. private static _ClearCoatTextureEnabled;
  41323. /**
  41324. * Are clear coat textures enabled in the application.
  41325. */
  41326. static ClearCoatTextureEnabled: boolean;
  41327. private static _ClearCoatBumpTextureEnabled;
  41328. /**
  41329. * Are clear coat bump textures enabled in the application.
  41330. */
  41331. static ClearCoatBumpTextureEnabled: boolean;
  41332. private static _ClearCoatTintTextureEnabled;
  41333. /**
  41334. * Are clear coat tint textures enabled in the application.
  41335. */
  41336. static ClearCoatTintTextureEnabled: boolean;
  41337. private static _SheenTextureEnabled;
  41338. /**
  41339. * Are sheen textures enabled in the application.
  41340. */
  41341. static SheenTextureEnabled: boolean;
  41342. private static _AnisotropicTextureEnabled;
  41343. /**
  41344. * Are anisotropic textures enabled in the application.
  41345. */
  41346. static AnisotropicTextureEnabled: boolean;
  41347. private static _ThicknessTextureEnabled;
  41348. /**
  41349. * Are thickness textures enabled in the application.
  41350. */
  41351. static ThicknessTextureEnabled: boolean;
  41352. }
  41353. }
  41354. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41355. /** @hidden */
  41356. export var defaultFragmentDeclaration: {
  41357. name: string;
  41358. shader: string;
  41359. };
  41360. }
  41361. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41362. /** @hidden */
  41363. export var defaultUboDeclaration: {
  41364. name: string;
  41365. shader: string;
  41366. };
  41367. }
  41368. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41369. /** @hidden */
  41370. export var lightFragmentDeclaration: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41376. /** @hidden */
  41377. export var lightUboDeclaration: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41383. /** @hidden */
  41384. export var lightsFragmentFunctions: {
  41385. name: string;
  41386. shader: string;
  41387. };
  41388. }
  41389. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41390. /** @hidden */
  41391. export var shadowsFragmentFunctions: {
  41392. name: string;
  41393. shader: string;
  41394. };
  41395. }
  41396. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41397. /** @hidden */
  41398. export var fresnelFunction: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41404. /** @hidden */
  41405. export var reflectionFunction: {
  41406. name: string;
  41407. shader: string;
  41408. };
  41409. }
  41410. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41411. /** @hidden */
  41412. export var bumpFragmentFunctions: {
  41413. name: string;
  41414. shader: string;
  41415. };
  41416. }
  41417. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41418. /** @hidden */
  41419. export var logDepthDeclaration: {
  41420. name: string;
  41421. shader: string;
  41422. };
  41423. }
  41424. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41425. /** @hidden */
  41426. export var bumpFragment: {
  41427. name: string;
  41428. shader: string;
  41429. };
  41430. }
  41431. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41432. /** @hidden */
  41433. export var depthPrePass: {
  41434. name: string;
  41435. shader: string;
  41436. };
  41437. }
  41438. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41439. /** @hidden */
  41440. export var lightFragment: {
  41441. name: string;
  41442. shader: string;
  41443. };
  41444. }
  41445. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41446. /** @hidden */
  41447. export var logDepthFragment: {
  41448. name: string;
  41449. shader: string;
  41450. };
  41451. }
  41452. declare module "babylonjs/Shaders/default.fragment" {
  41453. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41454. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41456. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41457. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41458. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41459. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41460. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41461. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41462. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41463. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41464. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41465. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41466. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41468. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41469. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41470. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41471. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41472. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41473. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41474. /** @hidden */
  41475. export var defaultPixelShader: {
  41476. name: string;
  41477. shader: string;
  41478. };
  41479. }
  41480. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41481. /** @hidden */
  41482. export var defaultVertexDeclaration: {
  41483. name: string;
  41484. shader: string;
  41485. };
  41486. }
  41487. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41488. /** @hidden */
  41489. export var bumpVertexDeclaration: {
  41490. name: string;
  41491. shader: string;
  41492. };
  41493. }
  41494. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41495. /** @hidden */
  41496. export var bumpVertex: {
  41497. name: string;
  41498. shader: string;
  41499. };
  41500. }
  41501. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41502. /** @hidden */
  41503. export var fogVertex: {
  41504. name: string;
  41505. shader: string;
  41506. };
  41507. }
  41508. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41509. /** @hidden */
  41510. export var shadowsVertex: {
  41511. name: string;
  41512. shader: string;
  41513. };
  41514. }
  41515. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41516. /** @hidden */
  41517. export var pointCloudVertex: {
  41518. name: string;
  41519. shader: string;
  41520. };
  41521. }
  41522. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41523. /** @hidden */
  41524. export var logDepthVertex: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module "babylonjs/Shaders/default.vertex" {
  41530. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41531. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41533. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41535. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41537. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41538. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41539. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41542. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41544. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41545. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41546. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41547. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41548. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41549. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41550. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41551. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41552. /** @hidden */
  41553. export var defaultVertexShader: {
  41554. name: string;
  41555. shader: string;
  41556. };
  41557. }
  41558. declare module "babylonjs/Materials/standardMaterial" {
  41559. import { SmartArray } from "babylonjs/Misc/smartArray";
  41560. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41561. import { Nullable } from "babylonjs/types";
  41562. import { Scene } from "babylonjs/scene";
  41563. import { Matrix } from "babylonjs/Maths/math.vector";
  41564. import { Color3 } from "babylonjs/Maths/math.color";
  41565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41567. import { Mesh } from "babylonjs/Meshes/mesh";
  41568. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41569. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41570. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41571. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41572. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41575. import "babylonjs/Shaders/default.fragment";
  41576. import "babylonjs/Shaders/default.vertex";
  41577. /** @hidden */
  41578. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41579. MAINUV1: boolean;
  41580. MAINUV2: boolean;
  41581. DIFFUSE: boolean;
  41582. DIFFUSEDIRECTUV: number;
  41583. AMBIENT: boolean;
  41584. AMBIENTDIRECTUV: number;
  41585. OPACITY: boolean;
  41586. OPACITYDIRECTUV: number;
  41587. OPACITYRGB: boolean;
  41588. REFLECTION: boolean;
  41589. EMISSIVE: boolean;
  41590. EMISSIVEDIRECTUV: number;
  41591. SPECULAR: boolean;
  41592. SPECULARDIRECTUV: number;
  41593. BUMP: boolean;
  41594. BUMPDIRECTUV: number;
  41595. PARALLAX: boolean;
  41596. PARALLAXOCCLUSION: boolean;
  41597. SPECULAROVERALPHA: boolean;
  41598. CLIPPLANE: boolean;
  41599. CLIPPLANE2: boolean;
  41600. CLIPPLANE3: boolean;
  41601. CLIPPLANE4: boolean;
  41602. ALPHATEST: boolean;
  41603. DEPTHPREPASS: boolean;
  41604. ALPHAFROMDIFFUSE: boolean;
  41605. POINTSIZE: boolean;
  41606. FOG: boolean;
  41607. SPECULARTERM: boolean;
  41608. DIFFUSEFRESNEL: boolean;
  41609. OPACITYFRESNEL: boolean;
  41610. REFLECTIONFRESNEL: boolean;
  41611. REFRACTIONFRESNEL: boolean;
  41612. EMISSIVEFRESNEL: boolean;
  41613. FRESNEL: boolean;
  41614. NORMAL: boolean;
  41615. UV1: boolean;
  41616. UV2: boolean;
  41617. VERTEXCOLOR: boolean;
  41618. VERTEXALPHA: boolean;
  41619. NUM_BONE_INFLUENCERS: number;
  41620. BonesPerMesh: number;
  41621. BONETEXTURE: boolean;
  41622. INSTANCES: boolean;
  41623. GLOSSINESS: boolean;
  41624. ROUGHNESS: boolean;
  41625. EMISSIVEASILLUMINATION: boolean;
  41626. LINKEMISSIVEWITHDIFFUSE: boolean;
  41627. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41628. LIGHTMAP: boolean;
  41629. LIGHTMAPDIRECTUV: number;
  41630. OBJECTSPACE_NORMALMAP: boolean;
  41631. USELIGHTMAPASSHADOWMAP: boolean;
  41632. REFLECTIONMAP_3D: boolean;
  41633. REFLECTIONMAP_SPHERICAL: boolean;
  41634. REFLECTIONMAP_PLANAR: boolean;
  41635. REFLECTIONMAP_CUBIC: boolean;
  41636. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41637. REFLECTIONMAP_PROJECTION: boolean;
  41638. REFLECTIONMAP_SKYBOX: boolean;
  41639. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41640. REFLECTIONMAP_EXPLICIT: boolean;
  41641. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41642. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41643. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41644. INVERTCUBICMAP: boolean;
  41645. LOGARITHMICDEPTH: boolean;
  41646. REFRACTION: boolean;
  41647. REFRACTIONMAP_3D: boolean;
  41648. REFLECTIONOVERALPHA: boolean;
  41649. TWOSIDEDLIGHTING: boolean;
  41650. SHADOWFLOAT: boolean;
  41651. MORPHTARGETS: boolean;
  41652. MORPHTARGETS_NORMAL: boolean;
  41653. MORPHTARGETS_TANGENT: boolean;
  41654. MORPHTARGETS_UV: boolean;
  41655. NUM_MORPH_INFLUENCERS: number;
  41656. NONUNIFORMSCALING: boolean;
  41657. PREMULTIPLYALPHA: boolean;
  41658. IMAGEPROCESSING: boolean;
  41659. VIGNETTE: boolean;
  41660. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41661. VIGNETTEBLENDMODEOPAQUE: boolean;
  41662. TONEMAPPING: boolean;
  41663. TONEMAPPING_ACES: boolean;
  41664. CONTRAST: boolean;
  41665. COLORCURVES: boolean;
  41666. COLORGRADING: boolean;
  41667. COLORGRADING3D: boolean;
  41668. SAMPLER3DGREENDEPTH: boolean;
  41669. SAMPLER3DBGRMAP: boolean;
  41670. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41671. MULTIVIEW: boolean;
  41672. /**
  41673. * If the reflection texture on this material is in linear color space
  41674. * @hidden
  41675. */
  41676. IS_REFLECTION_LINEAR: boolean;
  41677. /**
  41678. * If the refraction texture on this material is in linear color space
  41679. * @hidden
  41680. */
  41681. IS_REFRACTION_LINEAR: boolean;
  41682. EXPOSURE: boolean;
  41683. constructor();
  41684. setReflectionMode(modeToEnable: string): void;
  41685. }
  41686. /**
  41687. * This is the default material used in Babylon. It is the best trade off between quality
  41688. * and performances.
  41689. * @see http://doc.babylonjs.com/babylon101/materials
  41690. */
  41691. export class StandardMaterial extends PushMaterial {
  41692. private _diffuseTexture;
  41693. /**
  41694. * The basic texture of the material as viewed under a light.
  41695. */
  41696. diffuseTexture: Nullable<BaseTexture>;
  41697. private _ambientTexture;
  41698. /**
  41699. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41700. */
  41701. ambientTexture: Nullable<BaseTexture>;
  41702. private _opacityTexture;
  41703. /**
  41704. * Define the transparency of the material from a texture.
  41705. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41706. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41707. */
  41708. opacityTexture: Nullable<BaseTexture>;
  41709. private _reflectionTexture;
  41710. /**
  41711. * Define the texture used to display the reflection.
  41712. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41713. */
  41714. reflectionTexture: Nullable<BaseTexture>;
  41715. private _emissiveTexture;
  41716. /**
  41717. * Define texture of the material as if self lit.
  41718. * This will be mixed in the final result even in the absence of light.
  41719. */
  41720. emissiveTexture: Nullable<BaseTexture>;
  41721. private _specularTexture;
  41722. /**
  41723. * Define how the color and intensity of the highlight given by the light in the material.
  41724. */
  41725. specularTexture: Nullable<BaseTexture>;
  41726. private _bumpTexture;
  41727. /**
  41728. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41729. * 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.
  41730. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41731. */
  41732. bumpTexture: Nullable<BaseTexture>;
  41733. private _lightmapTexture;
  41734. /**
  41735. * Complex lighting can be computationally expensive to compute at runtime.
  41736. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41737. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41738. */
  41739. lightmapTexture: Nullable<BaseTexture>;
  41740. private _refractionTexture;
  41741. /**
  41742. * Define the texture used to display the refraction.
  41743. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41744. */
  41745. refractionTexture: Nullable<BaseTexture>;
  41746. /**
  41747. * The color of the material lit by the environmental background lighting.
  41748. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41749. */
  41750. ambientColor: Color3;
  41751. /**
  41752. * The basic color of the material as viewed under a light.
  41753. */
  41754. diffuseColor: Color3;
  41755. /**
  41756. * Define how the color and intensity of the highlight given by the light in the material.
  41757. */
  41758. specularColor: Color3;
  41759. /**
  41760. * Define the color of the material as if self lit.
  41761. * This will be mixed in the final result even in the absence of light.
  41762. */
  41763. emissiveColor: Color3;
  41764. /**
  41765. * Defines how sharp are the highlights in the material.
  41766. * The bigger the value the sharper giving a more glossy feeling to the result.
  41767. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41768. */
  41769. specularPower: number;
  41770. private _useAlphaFromDiffuseTexture;
  41771. /**
  41772. * Does the transparency come from the diffuse texture alpha channel.
  41773. */
  41774. useAlphaFromDiffuseTexture: boolean;
  41775. private _useEmissiveAsIllumination;
  41776. /**
  41777. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41778. */
  41779. useEmissiveAsIllumination: boolean;
  41780. private _linkEmissiveWithDiffuse;
  41781. /**
  41782. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41783. * the emissive level when the final color is close to one.
  41784. */
  41785. linkEmissiveWithDiffuse: boolean;
  41786. private _useSpecularOverAlpha;
  41787. /**
  41788. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41789. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41790. */
  41791. useSpecularOverAlpha: boolean;
  41792. private _useReflectionOverAlpha;
  41793. /**
  41794. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41795. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41796. */
  41797. useReflectionOverAlpha: boolean;
  41798. private _disableLighting;
  41799. /**
  41800. * Does lights from the scene impacts this material.
  41801. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41802. */
  41803. disableLighting: boolean;
  41804. private _useObjectSpaceNormalMap;
  41805. /**
  41806. * Allows using an object space normal map (instead of tangent space).
  41807. */
  41808. useObjectSpaceNormalMap: boolean;
  41809. private _useParallax;
  41810. /**
  41811. * Is parallax enabled or not.
  41812. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41813. */
  41814. useParallax: boolean;
  41815. private _useParallaxOcclusion;
  41816. /**
  41817. * Is parallax occlusion enabled or not.
  41818. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41819. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41820. */
  41821. useParallaxOcclusion: boolean;
  41822. /**
  41823. * 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.
  41824. */
  41825. parallaxScaleBias: number;
  41826. private _roughness;
  41827. /**
  41828. * Helps to define how blurry the reflections should appears in the material.
  41829. */
  41830. roughness: number;
  41831. /**
  41832. * In case of refraction, define the value of the index of refraction.
  41833. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41834. */
  41835. indexOfRefraction: number;
  41836. /**
  41837. * Invert the refraction texture alongside the y axis.
  41838. * It can be useful with procedural textures or probe for instance.
  41839. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41840. */
  41841. invertRefractionY: boolean;
  41842. /**
  41843. * Defines the alpha limits in alpha test mode.
  41844. */
  41845. alphaCutOff: number;
  41846. private _useLightmapAsShadowmap;
  41847. /**
  41848. * In case of light mapping, define whether the map contains light or shadow informations.
  41849. */
  41850. useLightmapAsShadowmap: boolean;
  41851. private _diffuseFresnelParameters;
  41852. /**
  41853. * Define the diffuse fresnel parameters of the material.
  41854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41855. */
  41856. diffuseFresnelParameters: FresnelParameters;
  41857. private _opacityFresnelParameters;
  41858. /**
  41859. * Define the opacity fresnel parameters of the material.
  41860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41861. */
  41862. opacityFresnelParameters: FresnelParameters;
  41863. private _reflectionFresnelParameters;
  41864. /**
  41865. * Define the reflection fresnel parameters of the material.
  41866. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41867. */
  41868. reflectionFresnelParameters: FresnelParameters;
  41869. private _refractionFresnelParameters;
  41870. /**
  41871. * Define the refraction fresnel parameters of the material.
  41872. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41873. */
  41874. refractionFresnelParameters: FresnelParameters;
  41875. private _emissiveFresnelParameters;
  41876. /**
  41877. * Define the emissive fresnel parameters of the material.
  41878. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41879. */
  41880. emissiveFresnelParameters: FresnelParameters;
  41881. private _useReflectionFresnelFromSpecular;
  41882. /**
  41883. * If true automatically deducts the fresnels values from the material specularity.
  41884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41885. */
  41886. useReflectionFresnelFromSpecular: boolean;
  41887. private _useGlossinessFromSpecularMapAlpha;
  41888. /**
  41889. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41890. */
  41891. useGlossinessFromSpecularMapAlpha: boolean;
  41892. private _maxSimultaneousLights;
  41893. /**
  41894. * Defines the maximum number of lights that can be used in the material
  41895. */
  41896. maxSimultaneousLights: number;
  41897. private _invertNormalMapX;
  41898. /**
  41899. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41900. */
  41901. invertNormalMapX: boolean;
  41902. private _invertNormalMapY;
  41903. /**
  41904. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41905. */
  41906. invertNormalMapY: boolean;
  41907. private _twoSidedLighting;
  41908. /**
  41909. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41910. */
  41911. twoSidedLighting: boolean;
  41912. /**
  41913. * Default configuration related to image processing available in the standard Material.
  41914. */
  41915. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Gets the image processing configuration used either in this material.
  41918. */
  41919. /**
  41920. * Sets the Default image processing configuration used either in the this material.
  41921. *
  41922. * If sets to null, the scene one is in use.
  41923. */
  41924. imageProcessingConfiguration: ImageProcessingConfiguration;
  41925. /**
  41926. * Keep track of the image processing observer to allow dispose and replace.
  41927. */
  41928. private _imageProcessingObserver;
  41929. /**
  41930. * Attaches a new image processing configuration to the Standard Material.
  41931. * @param configuration
  41932. */
  41933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41934. /**
  41935. * Gets wether the color curves effect is enabled.
  41936. */
  41937. /**
  41938. * Sets wether the color curves effect is enabled.
  41939. */
  41940. cameraColorCurvesEnabled: boolean;
  41941. /**
  41942. * Gets wether the color grading effect is enabled.
  41943. */
  41944. /**
  41945. * Gets wether the color grading effect is enabled.
  41946. */
  41947. cameraColorGradingEnabled: boolean;
  41948. /**
  41949. * Gets wether tonemapping is enabled or not.
  41950. */
  41951. /**
  41952. * Sets wether tonemapping is enabled or not
  41953. */
  41954. cameraToneMappingEnabled: boolean;
  41955. /**
  41956. * The camera exposure used on this material.
  41957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41958. * This corresponds to a photographic exposure.
  41959. */
  41960. /**
  41961. * The camera exposure used on this material.
  41962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41963. * This corresponds to a photographic exposure.
  41964. */
  41965. cameraExposure: number;
  41966. /**
  41967. * Gets The camera contrast used on this material.
  41968. */
  41969. /**
  41970. * Sets The camera contrast used on this material.
  41971. */
  41972. cameraContrast: number;
  41973. /**
  41974. * Gets the Color Grading 2D Lookup Texture.
  41975. */
  41976. /**
  41977. * Sets the Color Grading 2D Lookup Texture.
  41978. */
  41979. cameraColorGradingTexture: Nullable<BaseTexture>;
  41980. /**
  41981. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41982. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41983. * 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;
  41984. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41985. */
  41986. /**
  41987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41989. * 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;
  41990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41991. */
  41992. cameraColorCurves: Nullable<ColorCurves>;
  41993. /**
  41994. * Custom callback helping to override the default shader used in the material.
  41995. */
  41996. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41997. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41998. protected _worldViewProjectionMatrix: Matrix;
  41999. protected _globalAmbientColor: Color3;
  42000. protected _useLogarithmicDepth: boolean;
  42001. protected _rebuildInParallel: boolean;
  42002. /**
  42003. * Instantiates a new standard material.
  42004. * This is the default material used in Babylon. It is the best trade off between quality
  42005. * and performances.
  42006. * @see http://doc.babylonjs.com/babylon101/materials
  42007. * @param name Define the name of the material in the scene
  42008. * @param scene Define the scene the material belong to
  42009. */
  42010. constructor(name: string, scene: Scene);
  42011. /**
  42012. * Gets a boolean indicating that current material needs to register RTT
  42013. */
  42014. readonly hasRenderTargetTextures: boolean;
  42015. /**
  42016. * Gets the current class name of the material e.g. "StandardMaterial"
  42017. * Mainly use in serialization.
  42018. * @returns the class name
  42019. */
  42020. getClassName(): string;
  42021. /**
  42022. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42023. * You can try switching to logarithmic depth.
  42024. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42025. */
  42026. useLogarithmicDepth: boolean;
  42027. /**
  42028. * Specifies if the material will require alpha blending
  42029. * @returns a boolean specifying if alpha blending is needed
  42030. */
  42031. needAlphaBlending(): boolean;
  42032. /**
  42033. * Specifies if this material should be rendered in alpha test mode
  42034. * @returns a boolean specifying if an alpha test is needed.
  42035. */
  42036. needAlphaTesting(): boolean;
  42037. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42038. /**
  42039. * Get the texture used for alpha test purpose.
  42040. * @returns the diffuse texture in case of the standard material.
  42041. */
  42042. getAlphaTestTexture(): Nullable<BaseTexture>;
  42043. /**
  42044. * Get if the submesh is ready to be used and all its information available.
  42045. * Child classes can use it to update shaders
  42046. * @param mesh defines the mesh to check
  42047. * @param subMesh defines which submesh to check
  42048. * @param useInstances specifies that instances should be used
  42049. * @returns a boolean indicating that the submesh is ready or not
  42050. */
  42051. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42052. /**
  42053. * Builds the material UBO layouts.
  42054. * Used internally during the effect preparation.
  42055. */
  42056. buildUniformLayout(): void;
  42057. /**
  42058. * Unbinds the material from the mesh
  42059. */
  42060. unbind(): void;
  42061. /**
  42062. * Binds the submesh to this material by preparing the effect and shader to draw
  42063. * @param world defines the world transformation matrix
  42064. * @param mesh defines the mesh containing the submesh
  42065. * @param subMesh defines the submesh to bind the material to
  42066. */
  42067. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42068. /**
  42069. * Get the list of animatables in the material.
  42070. * @returns the list of animatables object used in the material
  42071. */
  42072. getAnimatables(): IAnimatable[];
  42073. /**
  42074. * Gets the active textures from the material
  42075. * @returns an array of textures
  42076. */
  42077. getActiveTextures(): BaseTexture[];
  42078. /**
  42079. * Specifies if the material uses a texture
  42080. * @param texture defines the texture to check against the material
  42081. * @returns a boolean specifying if the material uses the texture
  42082. */
  42083. hasTexture(texture: BaseTexture): boolean;
  42084. /**
  42085. * Disposes the material
  42086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42087. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42088. */
  42089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42090. /**
  42091. * Makes a duplicate of the material, and gives it a new name
  42092. * @param name defines the new name for the duplicated material
  42093. * @returns the cloned material
  42094. */
  42095. clone(name: string): StandardMaterial;
  42096. /**
  42097. * Serializes this material in a JSON representation
  42098. * @returns the serialized material object
  42099. */
  42100. serialize(): any;
  42101. /**
  42102. * Creates a standard material from parsed material data
  42103. * @param source defines the JSON representation of the material
  42104. * @param scene defines the hosting scene
  42105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42106. * @returns a new standard material
  42107. */
  42108. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42109. /**
  42110. * Are diffuse textures enabled in the application.
  42111. */
  42112. static DiffuseTextureEnabled: boolean;
  42113. /**
  42114. * Are ambient textures enabled in the application.
  42115. */
  42116. static AmbientTextureEnabled: boolean;
  42117. /**
  42118. * Are opacity textures enabled in the application.
  42119. */
  42120. static OpacityTextureEnabled: boolean;
  42121. /**
  42122. * Are reflection textures enabled in the application.
  42123. */
  42124. static ReflectionTextureEnabled: boolean;
  42125. /**
  42126. * Are emissive textures enabled in the application.
  42127. */
  42128. static EmissiveTextureEnabled: boolean;
  42129. /**
  42130. * Are specular textures enabled in the application.
  42131. */
  42132. static SpecularTextureEnabled: boolean;
  42133. /**
  42134. * Are bump textures enabled in the application.
  42135. */
  42136. static BumpTextureEnabled: boolean;
  42137. /**
  42138. * Are lightmap textures enabled in the application.
  42139. */
  42140. static LightmapTextureEnabled: boolean;
  42141. /**
  42142. * Are refraction textures enabled in the application.
  42143. */
  42144. static RefractionTextureEnabled: boolean;
  42145. /**
  42146. * Are color grading textures enabled in the application.
  42147. */
  42148. static ColorGradingTextureEnabled: boolean;
  42149. /**
  42150. * Are fresnels enabled in the application.
  42151. */
  42152. static FresnelEnabled: boolean;
  42153. }
  42154. }
  42155. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42156. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42157. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42158. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42159. /** @hidden */
  42160. export var imageProcessingPixelShader: {
  42161. name: string;
  42162. shader: string;
  42163. };
  42164. }
  42165. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42166. import { Nullable } from "babylonjs/types";
  42167. import { Color4 } from "babylonjs/Maths/math.color";
  42168. import { Camera } from "babylonjs/Cameras/camera";
  42169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42170. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42171. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42172. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42173. import { Engine } from "babylonjs/Engines/engine";
  42174. import "babylonjs/Shaders/imageProcessing.fragment";
  42175. import "babylonjs/Shaders/postprocess.vertex";
  42176. /**
  42177. * ImageProcessingPostProcess
  42178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42179. */
  42180. export class ImageProcessingPostProcess extends PostProcess {
  42181. /**
  42182. * Default configuration related to image processing available in the PBR Material.
  42183. */
  42184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42185. /**
  42186. * Gets the image processing configuration used either in this material.
  42187. */
  42188. /**
  42189. * Sets the Default image processing configuration used either in the this material.
  42190. *
  42191. * If sets to null, the scene one is in use.
  42192. */
  42193. imageProcessingConfiguration: ImageProcessingConfiguration;
  42194. /**
  42195. * Keep track of the image processing observer to allow dispose and replace.
  42196. */
  42197. private _imageProcessingObserver;
  42198. /**
  42199. * Attaches a new image processing configuration to the PBR Material.
  42200. * @param configuration
  42201. */
  42202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42203. /**
  42204. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42205. */
  42206. /**
  42207. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42208. */
  42209. colorCurves: Nullable<ColorCurves>;
  42210. /**
  42211. * Gets wether the color curves effect is enabled.
  42212. */
  42213. /**
  42214. * Sets wether the color curves effect is enabled.
  42215. */
  42216. colorCurvesEnabled: boolean;
  42217. /**
  42218. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42219. */
  42220. /**
  42221. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42222. */
  42223. colorGradingTexture: Nullable<BaseTexture>;
  42224. /**
  42225. * Gets wether the color grading effect is enabled.
  42226. */
  42227. /**
  42228. * Gets wether the color grading effect is enabled.
  42229. */
  42230. colorGradingEnabled: boolean;
  42231. /**
  42232. * Gets exposure used in the effect.
  42233. */
  42234. /**
  42235. * Sets exposure used in the effect.
  42236. */
  42237. exposure: number;
  42238. /**
  42239. * Gets wether tonemapping is enabled or not.
  42240. */
  42241. /**
  42242. * Sets wether tonemapping is enabled or not
  42243. */
  42244. toneMappingEnabled: boolean;
  42245. /**
  42246. * Gets the type of tone mapping effect.
  42247. */
  42248. /**
  42249. * Sets the type of tone mapping effect.
  42250. */
  42251. toneMappingType: number;
  42252. /**
  42253. * Gets contrast used in the effect.
  42254. */
  42255. /**
  42256. * Sets contrast used in the effect.
  42257. */
  42258. contrast: number;
  42259. /**
  42260. * Gets Vignette stretch size.
  42261. */
  42262. /**
  42263. * Sets Vignette stretch size.
  42264. */
  42265. vignetteStretch: number;
  42266. /**
  42267. * Gets Vignette centre X Offset.
  42268. */
  42269. /**
  42270. * Sets Vignette centre X Offset.
  42271. */
  42272. vignetteCentreX: number;
  42273. /**
  42274. * Gets Vignette centre Y Offset.
  42275. */
  42276. /**
  42277. * Sets Vignette centre Y Offset.
  42278. */
  42279. vignetteCentreY: number;
  42280. /**
  42281. * Gets Vignette weight or intensity of the vignette effect.
  42282. */
  42283. /**
  42284. * Sets Vignette weight or intensity of the vignette effect.
  42285. */
  42286. vignetteWeight: number;
  42287. /**
  42288. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42289. * if vignetteEnabled is set to true.
  42290. */
  42291. /**
  42292. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42293. * if vignetteEnabled is set to true.
  42294. */
  42295. vignetteColor: Color4;
  42296. /**
  42297. * Gets Camera field of view used by the Vignette effect.
  42298. */
  42299. /**
  42300. * Sets Camera field of view used by the Vignette effect.
  42301. */
  42302. vignetteCameraFov: number;
  42303. /**
  42304. * Gets the vignette blend mode allowing different kind of effect.
  42305. */
  42306. /**
  42307. * Sets the vignette blend mode allowing different kind of effect.
  42308. */
  42309. vignetteBlendMode: number;
  42310. /**
  42311. * Gets wether the vignette effect is enabled.
  42312. */
  42313. /**
  42314. * Sets wether the vignette effect is enabled.
  42315. */
  42316. vignetteEnabled: boolean;
  42317. private _fromLinearSpace;
  42318. /**
  42319. * Gets wether the input of the processing is in Gamma or Linear Space.
  42320. */
  42321. /**
  42322. * Sets wether the input of the processing is in Gamma or Linear Space.
  42323. */
  42324. fromLinearSpace: boolean;
  42325. /**
  42326. * Defines cache preventing GC.
  42327. */
  42328. private _defines;
  42329. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42330. /**
  42331. * "ImageProcessingPostProcess"
  42332. * @returns "ImageProcessingPostProcess"
  42333. */
  42334. getClassName(): string;
  42335. protected _updateParameters(): void;
  42336. dispose(camera?: Camera): void;
  42337. }
  42338. }
  42339. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42340. import { Scene } from "babylonjs/scene";
  42341. import { Color3 } from "babylonjs/Maths/math.color";
  42342. import { Mesh } from "babylonjs/Meshes/mesh";
  42343. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42344. import { Nullable } from "babylonjs/types";
  42345. /**
  42346. * Class containing static functions to help procedurally build meshes
  42347. */
  42348. export class GroundBuilder {
  42349. /**
  42350. * Creates a ground mesh
  42351. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42352. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42354. * @param name defines the name of the mesh
  42355. * @param options defines the options used to create the mesh
  42356. * @param scene defines the hosting scene
  42357. * @returns the ground mesh
  42358. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42359. */
  42360. static CreateGround(name: string, options: {
  42361. width?: number;
  42362. height?: number;
  42363. subdivisions?: number;
  42364. subdivisionsX?: number;
  42365. subdivisionsY?: number;
  42366. updatable?: boolean;
  42367. }, scene: any): Mesh;
  42368. /**
  42369. * Creates a tiled ground mesh
  42370. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42371. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42372. * * 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
  42373. * * 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
  42374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42375. * @param name defines the name of the mesh
  42376. * @param options defines the options used to create the mesh
  42377. * @param scene defines the hosting scene
  42378. * @returns the tiled ground mesh
  42379. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42380. */
  42381. static CreateTiledGround(name: string, options: {
  42382. xmin: number;
  42383. zmin: number;
  42384. xmax: number;
  42385. zmax: number;
  42386. subdivisions?: {
  42387. w: number;
  42388. h: number;
  42389. };
  42390. precision?: {
  42391. w: number;
  42392. h: number;
  42393. };
  42394. updatable?: boolean;
  42395. }, scene?: Nullable<Scene>): Mesh;
  42396. /**
  42397. * Creates a ground mesh from a height map
  42398. * * The parameter `url` sets the URL of the height map image resource.
  42399. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42400. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42401. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42402. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42403. * * 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.
  42404. * * 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).
  42405. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42407. * @param name defines the name of the mesh
  42408. * @param url defines the url to the height map
  42409. * @param options defines the options used to create the mesh
  42410. * @param scene defines the hosting scene
  42411. * @returns the ground mesh
  42412. * @see https://doc.babylonjs.com/babylon101/height_map
  42413. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42414. */
  42415. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42416. width?: number;
  42417. height?: number;
  42418. subdivisions?: number;
  42419. minHeight?: number;
  42420. maxHeight?: number;
  42421. colorFilter?: Color3;
  42422. alphaFilter?: number;
  42423. updatable?: boolean;
  42424. onReady?: (mesh: GroundMesh) => void;
  42425. }, scene?: Nullable<Scene>): GroundMesh;
  42426. }
  42427. }
  42428. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42429. import { Vector4 } from "babylonjs/Maths/math.vector";
  42430. import { Mesh } from "babylonjs/Meshes/mesh";
  42431. /**
  42432. * Class containing static functions to help procedurally build meshes
  42433. */
  42434. export class TorusBuilder {
  42435. /**
  42436. * Creates a torus mesh
  42437. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42438. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42439. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42443. * @param name defines the name of the mesh
  42444. * @param options defines the options used to create the mesh
  42445. * @param scene defines the hosting scene
  42446. * @returns the torus mesh
  42447. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42448. */
  42449. static CreateTorus(name: string, options: {
  42450. diameter?: number;
  42451. thickness?: number;
  42452. tessellation?: number;
  42453. updatable?: boolean;
  42454. sideOrientation?: number;
  42455. frontUVs?: Vector4;
  42456. backUVs?: Vector4;
  42457. }, scene: any): Mesh;
  42458. }
  42459. }
  42460. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42461. import { Vector4 } from "babylonjs/Maths/math.vector";
  42462. import { Color4 } from "babylonjs/Maths/math.color";
  42463. import { Mesh } from "babylonjs/Meshes/mesh";
  42464. /**
  42465. * Class containing static functions to help procedurally build meshes
  42466. */
  42467. export class CylinderBuilder {
  42468. /**
  42469. * Creates a cylinder or a cone mesh
  42470. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42471. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42472. * * 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.
  42473. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42474. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42475. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42476. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42477. * * 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).
  42478. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42479. * * 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).
  42480. * * 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
  42481. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42482. * * 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
  42483. * * 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.
  42484. * * If `enclose` is false, a ring surface is one element.
  42485. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42486. * * 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
  42487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42490. * @param name defines the name of the mesh
  42491. * @param options defines the options used to create the mesh
  42492. * @param scene defines the hosting scene
  42493. * @returns the cylinder mesh
  42494. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42495. */
  42496. static CreateCylinder(name: string, options: {
  42497. height?: number;
  42498. diameterTop?: number;
  42499. diameterBottom?: number;
  42500. diameter?: number;
  42501. tessellation?: number;
  42502. subdivisions?: number;
  42503. arc?: number;
  42504. faceColors?: Color4[];
  42505. faceUV?: Vector4[];
  42506. updatable?: boolean;
  42507. hasRings?: boolean;
  42508. enclose?: boolean;
  42509. cap?: number;
  42510. sideOrientation?: number;
  42511. frontUVs?: Vector4;
  42512. backUVs?: Vector4;
  42513. }, scene: any): Mesh;
  42514. }
  42515. }
  42516. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42517. import { Observable } from "babylonjs/Misc/observable";
  42518. import { Nullable } from "babylonjs/types";
  42519. import { Camera } from "babylonjs/Cameras/camera";
  42520. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42521. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42522. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42523. import { Scene } from "babylonjs/scene";
  42524. import { Vector3 } from "babylonjs/Maths/math.vector";
  42525. import { Color3 } from "babylonjs/Maths/math.color";
  42526. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42528. import { Mesh } from "babylonjs/Meshes/mesh";
  42529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42530. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42531. import "babylonjs/Meshes/Builders/groundBuilder";
  42532. import "babylonjs/Meshes/Builders/torusBuilder";
  42533. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42534. import "babylonjs/Gamepads/gamepadSceneComponent";
  42535. import "babylonjs/Animations/animatable";
  42536. /**
  42537. * Options to modify the vr teleportation behavior.
  42538. */
  42539. export interface VRTeleportationOptions {
  42540. /**
  42541. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42542. */
  42543. floorMeshName?: string;
  42544. /**
  42545. * A list of meshes to be used as the teleportation floor. (default: empty)
  42546. */
  42547. floorMeshes?: Mesh[];
  42548. }
  42549. /**
  42550. * Options to modify the vr experience helper's behavior.
  42551. */
  42552. export interface VRExperienceHelperOptions extends WebVROptions {
  42553. /**
  42554. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42555. */
  42556. createDeviceOrientationCamera?: boolean;
  42557. /**
  42558. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42559. */
  42560. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42561. /**
  42562. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42563. */
  42564. laserToggle?: boolean;
  42565. /**
  42566. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42567. */
  42568. floorMeshes?: Mesh[];
  42569. /**
  42570. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42571. */
  42572. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42573. }
  42574. /**
  42575. * Event containing information after VR has been entered
  42576. */
  42577. export class OnAfterEnteringVRObservableEvent {
  42578. /**
  42579. * If entering vr was successful
  42580. */
  42581. success: boolean;
  42582. }
  42583. /**
  42584. * Helps to quickly add VR support to an existing scene.
  42585. * See http://doc.babylonjs.com/how_to/webvr_helper
  42586. */
  42587. export class VRExperienceHelper {
  42588. /** Options to modify the vr experience helper's behavior. */
  42589. webVROptions: VRExperienceHelperOptions;
  42590. private _scene;
  42591. private _position;
  42592. private _btnVR;
  42593. private _btnVRDisplayed;
  42594. private _webVRsupported;
  42595. private _webVRready;
  42596. private _webVRrequesting;
  42597. private _webVRpresenting;
  42598. private _hasEnteredVR;
  42599. private _fullscreenVRpresenting;
  42600. private _canvas;
  42601. private _webVRCamera;
  42602. private _vrDeviceOrientationCamera;
  42603. private _deviceOrientationCamera;
  42604. private _existingCamera;
  42605. private _onKeyDown;
  42606. private _onVrDisplayPresentChange;
  42607. private _onVRDisplayChanged;
  42608. private _onVRRequestPresentStart;
  42609. private _onVRRequestPresentComplete;
  42610. /**
  42611. * 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)
  42612. */
  42613. enableGazeEvenWhenNoPointerLock: boolean;
  42614. /**
  42615. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42616. */
  42617. exitVROnDoubleTap: boolean;
  42618. /**
  42619. * Observable raised right before entering VR.
  42620. */
  42621. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42622. /**
  42623. * Observable raised when entering VR has completed.
  42624. */
  42625. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42626. /**
  42627. * Observable raised when exiting VR.
  42628. */
  42629. onExitingVRObservable: Observable<VRExperienceHelper>;
  42630. /**
  42631. * Observable raised when controller mesh is loaded.
  42632. */
  42633. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42634. /** Return this.onEnteringVRObservable
  42635. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42636. */
  42637. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42638. /** Return this.onExitingVRObservable
  42639. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42640. */
  42641. readonly onExitingVR: Observable<VRExperienceHelper>;
  42642. /** Return this.onControllerMeshLoadedObservable
  42643. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42644. */
  42645. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42646. private _rayLength;
  42647. private _useCustomVRButton;
  42648. private _teleportationRequested;
  42649. private _teleportActive;
  42650. private _floorMeshName;
  42651. private _floorMeshesCollection;
  42652. private _rotationAllowed;
  42653. private _teleportBackwardsVector;
  42654. private _teleportationTarget;
  42655. private _isDefaultTeleportationTarget;
  42656. private _postProcessMove;
  42657. private _teleportationFillColor;
  42658. private _teleportationBorderColor;
  42659. private _rotationAngle;
  42660. private _haloCenter;
  42661. private _cameraGazer;
  42662. private _padSensibilityUp;
  42663. private _padSensibilityDown;
  42664. private _leftController;
  42665. private _rightController;
  42666. /**
  42667. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42668. */
  42669. onNewMeshSelected: Observable<AbstractMesh>;
  42670. /**
  42671. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42672. * This observable will provide the mesh and the controller used to select the mesh
  42673. */
  42674. onMeshSelectedWithController: Observable<{
  42675. mesh: AbstractMesh;
  42676. controller: WebVRController;
  42677. }>;
  42678. /**
  42679. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42680. */
  42681. onNewMeshPicked: Observable<PickingInfo>;
  42682. private _circleEase;
  42683. /**
  42684. * Observable raised before camera teleportation
  42685. */
  42686. onBeforeCameraTeleport: Observable<Vector3>;
  42687. /**
  42688. * Observable raised after camera teleportation
  42689. */
  42690. onAfterCameraTeleport: Observable<Vector3>;
  42691. /**
  42692. * Observable raised when current selected mesh gets unselected
  42693. */
  42694. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42695. private _raySelectionPredicate;
  42696. /**
  42697. * To be optionaly changed by user to define custom ray selection
  42698. */
  42699. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42700. /**
  42701. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42702. */
  42703. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42704. /**
  42705. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42706. */
  42707. teleportationEnabled: boolean;
  42708. private _defaultHeight;
  42709. private _teleportationInitialized;
  42710. private _interactionsEnabled;
  42711. private _interactionsRequested;
  42712. private _displayGaze;
  42713. private _displayLaserPointer;
  42714. /**
  42715. * The mesh used to display where the user is going to teleport.
  42716. */
  42717. /**
  42718. * Sets the mesh to be used to display where the user is going to teleport.
  42719. */
  42720. teleportationTarget: Mesh;
  42721. /**
  42722. * 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
  42723. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42724. * See http://doc.babylonjs.com/resources/baking_transformations
  42725. */
  42726. gazeTrackerMesh: Mesh;
  42727. /**
  42728. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42729. */
  42730. updateGazeTrackerScale: boolean;
  42731. /**
  42732. * If the gaze trackers color should be updated when selecting meshes
  42733. */
  42734. updateGazeTrackerColor: boolean;
  42735. /**
  42736. * If the controller laser color should be updated when selecting meshes
  42737. */
  42738. updateControllerLaserColor: boolean;
  42739. /**
  42740. * The gaze tracking mesh corresponding to the left controller
  42741. */
  42742. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42743. /**
  42744. * The gaze tracking mesh corresponding to the right controller
  42745. */
  42746. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42747. /**
  42748. * If the ray of the gaze should be displayed.
  42749. */
  42750. /**
  42751. * Sets if the ray of the gaze should be displayed.
  42752. */
  42753. displayGaze: boolean;
  42754. /**
  42755. * If the ray of the LaserPointer should be displayed.
  42756. */
  42757. /**
  42758. * Sets if the ray of the LaserPointer should be displayed.
  42759. */
  42760. displayLaserPointer: boolean;
  42761. /**
  42762. * The deviceOrientationCamera used as the camera when not in VR.
  42763. */
  42764. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42765. /**
  42766. * Based on the current WebVR support, returns the current VR camera used.
  42767. */
  42768. readonly currentVRCamera: Nullable<Camera>;
  42769. /**
  42770. * The webVRCamera which is used when in VR.
  42771. */
  42772. readonly webVRCamera: WebVRFreeCamera;
  42773. /**
  42774. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42775. */
  42776. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42777. /**
  42778. * The html button that is used to trigger entering into VR.
  42779. */
  42780. readonly vrButton: Nullable<HTMLButtonElement>;
  42781. private readonly _teleportationRequestInitiated;
  42782. /**
  42783. * Defines wether or not Pointer lock should be requested when switching to
  42784. * full screen.
  42785. */
  42786. requestPointerLockOnFullScreen: boolean;
  42787. /**
  42788. * Instantiates a VRExperienceHelper.
  42789. * Helps to quickly add VR support to an existing scene.
  42790. * @param scene The scene the VRExperienceHelper belongs to.
  42791. * @param webVROptions Options to modify the vr experience helper's behavior.
  42792. */
  42793. constructor(scene: Scene,
  42794. /** Options to modify the vr experience helper's behavior. */
  42795. webVROptions?: VRExperienceHelperOptions);
  42796. private _onDefaultMeshLoaded;
  42797. private _onResize;
  42798. private _onFullscreenChange;
  42799. /**
  42800. * Gets a value indicating if we are currently in VR mode.
  42801. */
  42802. readonly isInVRMode: boolean;
  42803. private onVrDisplayPresentChange;
  42804. private onVRDisplayChanged;
  42805. private moveButtonToBottomRight;
  42806. private displayVRButton;
  42807. private updateButtonVisibility;
  42808. private _cachedAngularSensibility;
  42809. /**
  42810. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42811. * Otherwise, will use the fullscreen API.
  42812. */
  42813. enterVR(): void;
  42814. /**
  42815. * Attempt to exit VR, or fullscreen.
  42816. */
  42817. exitVR(): void;
  42818. /**
  42819. * The position of the vr experience helper.
  42820. */
  42821. /**
  42822. * Sets the position of the vr experience helper.
  42823. */
  42824. position: Vector3;
  42825. /**
  42826. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42827. */
  42828. enableInteractions(): void;
  42829. private readonly _noControllerIsActive;
  42830. private beforeRender;
  42831. private _isTeleportationFloor;
  42832. /**
  42833. * Adds a floor mesh to be used for teleportation.
  42834. * @param floorMesh the mesh to be used for teleportation.
  42835. */
  42836. addFloorMesh(floorMesh: Mesh): void;
  42837. /**
  42838. * Removes a floor mesh from being used for teleportation.
  42839. * @param floorMesh the mesh to be removed.
  42840. */
  42841. removeFloorMesh(floorMesh: Mesh): void;
  42842. /**
  42843. * Enables interactions and teleportation using the VR controllers and gaze.
  42844. * @param vrTeleportationOptions options to modify teleportation behavior.
  42845. */
  42846. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42847. private _onNewGamepadConnected;
  42848. private _tryEnableInteractionOnController;
  42849. private _onNewGamepadDisconnected;
  42850. private _enableInteractionOnController;
  42851. private _checkTeleportWithRay;
  42852. private _checkRotate;
  42853. private _checkTeleportBackwards;
  42854. private _enableTeleportationOnController;
  42855. private _createTeleportationCircles;
  42856. private _displayTeleportationTarget;
  42857. private _hideTeleportationTarget;
  42858. private _rotateCamera;
  42859. private _moveTeleportationSelectorTo;
  42860. private _workingVector;
  42861. private _workingQuaternion;
  42862. private _workingMatrix;
  42863. /**
  42864. * Teleports the users feet to the desired location
  42865. * @param location The location where the user's feet should be placed
  42866. */
  42867. teleportCamera(location: Vector3): void;
  42868. private _convertNormalToDirectionOfRay;
  42869. private _castRayAndSelectObject;
  42870. private _notifySelectedMeshUnselected;
  42871. /**
  42872. * Sets the color of the laser ray from the vr controllers.
  42873. * @param color new color for the ray.
  42874. */
  42875. changeLaserColor(color: Color3): void;
  42876. /**
  42877. * Sets the color of the ray from the vr headsets gaze.
  42878. * @param color new color for the ray.
  42879. */
  42880. changeGazeColor(color: Color3): void;
  42881. /**
  42882. * Exits VR and disposes of the vr experience helper
  42883. */
  42884. dispose(): void;
  42885. /**
  42886. * Gets the name of the VRExperienceHelper class
  42887. * @returns "VRExperienceHelper"
  42888. */
  42889. getClassName(): string;
  42890. }
  42891. }
  42892. declare module "babylonjs/Cameras/VR/index" {
  42893. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42894. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42895. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42896. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42897. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42898. export * from "babylonjs/Cameras/VR/webVRCamera";
  42899. }
  42900. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42901. import { Observable } from "babylonjs/Misc/observable";
  42902. import { Nullable } from "babylonjs/types";
  42903. import { IDisposable, Scene } from "babylonjs/scene";
  42904. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42905. /**
  42906. * Manages an XRSession to work with Babylon's engine
  42907. * @see https://doc.babylonjs.com/how_to/webxr
  42908. */
  42909. export class WebXRSessionManager implements IDisposable {
  42910. private scene;
  42911. /**
  42912. * Fires every time a new xrFrame arrives which can be used to update the camera
  42913. */
  42914. onXRFrameObservable: Observable<any>;
  42915. /**
  42916. * Fires when the xr session is ended either by the device or manually done
  42917. */
  42918. onXRSessionEnded: Observable<any>;
  42919. /**
  42920. * Underlying xr session
  42921. */
  42922. session: XRSession;
  42923. /**
  42924. * Type of reference space used when creating the session
  42925. */
  42926. referenceSpace: XRReferenceSpace;
  42927. /** @hidden */
  42928. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42929. /**
  42930. * Current XR frame
  42931. */
  42932. currentFrame: Nullable<XRFrame>;
  42933. private _xrNavigator;
  42934. private baseLayer;
  42935. /**
  42936. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42937. * @param scene The scene which the session should be created for
  42938. */
  42939. constructor(scene: Scene);
  42940. /**
  42941. * Initializes the manager
  42942. * After initialization enterXR can be called to start an XR session
  42943. * @returns Promise which resolves after it is initialized
  42944. */
  42945. initializeAsync(): Promise<void>;
  42946. /**
  42947. * Initializes an xr session
  42948. * @param xrSessionMode mode to initialize
  42949. * @returns a promise which will resolve once the session has been initialized
  42950. */
  42951. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42952. /**
  42953. * Sets the reference space on the xr session
  42954. * @param referenceSpace space to set
  42955. * @returns a promise that will resolve once the reference space has been set
  42956. */
  42957. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42958. /**
  42959. * Updates the render state of the session
  42960. * @param state state to set
  42961. * @returns a promise that resolves once the render state has been updated
  42962. */
  42963. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42964. /**
  42965. * Starts rendering to the xr layer
  42966. * @returns a promise that will resolve once rendering has started
  42967. */
  42968. startRenderingToXRAsync(): Promise<void>;
  42969. /**
  42970. * Stops the xrSession and restores the renderloop
  42971. * @returns Promise which resolves after it exits XR
  42972. */
  42973. exitXRAsync(): Promise<unknown>;
  42974. /**
  42975. * Checks if a session would be supported for the creation options specified
  42976. * @param sessionMode session mode to check if supported eg. immersive-vr
  42977. * @returns true if supported
  42978. */
  42979. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42980. /**
  42981. * @hidden
  42982. * Converts the render layer of xrSession to a render target
  42983. * @param session session to create render target for
  42984. * @param scene scene the new render target should be created for
  42985. */
  42986. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42987. /**
  42988. * Disposes of the session manager
  42989. */
  42990. dispose(): void;
  42991. }
  42992. }
  42993. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42994. import { Scene } from "babylonjs/scene";
  42995. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42996. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42997. /**
  42998. * WebXR Camera which holds the views for the xrSession
  42999. * @see https://doc.babylonjs.com/how_to/webxr
  43000. */
  43001. export class WebXRCamera extends FreeCamera {
  43002. private static _TmpMatrix;
  43003. /**
  43004. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43005. * @param name the name of the camera
  43006. * @param scene the scene to add the camera to
  43007. */
  43008. constructor(name: string, scene: Scene);
  43009. private _updateNumberOfRigCameras;
  43010. /** @hidden */
  43011. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43012. /**
  43013. * Updates the cameras position from the current pose information of the XR session
  43014. * @param xrSessionManager the session containing pose information
  43015. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43016. */
  43017. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43018. }
  43019. }
  43020. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43021. import { Nullable } from "babylonjs/types";
  43022. import { IDisposable } from "babylonjs/scene";
  43023. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43024. /**
  43025. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43026. */
  43027. export class WebXRManagedOutputCanvas implements IDisposable {
  43028. private helper;
  43029. private _canvas;
  43030. /**
  43031. * xrpresent context of the canvas which can be used to display/mirror xr content
  43032. */
  43033. canvasContext: WebGLRenderingContext;
  43034. /**
  43035. * xr layer for the canvas
  43036. */
  43037. xrLayer: Nullable<XRWebGLLayer>;
  43038. /**
  43039. * Initializes the xr layer for the session
  43040. * @param xrSession xr session
  43041. * @returns a promise that will resolve once the XR Layer has been created
  43042. */
  43043. initializeXRLayerAsync(xrSession: any): any;
  43044. /**
  43045. * Initializes the canvas to be added/removed upon entering/exiting xr
  43046. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43047. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43048. */
  43049. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43050. /**
  43051. * Disposes of the object
  43052. */
  43053. dispose(): void;
  43054. private _setManagedOutputCanvas;
  43055. private _addCanvas;
  43056. private _removeCanvas;
  43057. }
  43058. }
  43059. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43060. import { Observable } from "babylonjs/Misc/observable";
  43061. import { IDisposable, Scene } from "babylonjs/scene";
  43062. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43064. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43065. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43066. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43067. /**
  43068. * States of the webXR experience
  43069. */
  43070. export enum WebXRState {
  43071. /**
  43072. * Transitioning to being in XR mode
  43073. */
  43074. ENTERING_XR = 0,
  43075. /**
  43076. * Transitioning to non XR mode
  43077. */
  43078. EXITING_XR = 1,
  43079. /**
  43080. * In XR mode and presenting
  43081. */
  43082. IN_XR = 2,
  43083. /**
  43084. * Not entered XR mode
  43085. */
  43086. NOT_IN_XR = 3
  43087. }
  43088. /**
  43089. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43090. * @see https://doc.babylonjs.com/how_to/webxr
  43091. */
  43092. export class WebXRExperienceHelper implements IDisposable {
  43093. private scene;
  43094. /**
  43095. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  43096. */
  43097. container: AbstractMesh;
  43098. /**
  43099. * Camera used to render xr content
  43100. */
  43101. camera: WebXRCamera;
  43102. /**
  43103. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43104. */
  43105. state: WebXRState;
  43106. private _setState;
  43107. private static _TmpVector;
  43108. /**
  43109. * Fires when the state of the experience helper has changed
  43110. */
  43111. onStateChangedObservable: Observable<WebXRState>;
  43112. /** Session manager used to keep track of xr session */
  43113. sessionManager: WebXRSessionManager;
  43114. private _nonVRCamera;
  43115. private _originalSceneAutoClear;
  43116. private _supported;
  43117. /**
  43118. * Creates the experience helper
  43119. * @param scene the scene to attach the experience helper to
  43120. * @returns a promise for the experience helper
  43121. */
  43122. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43123. /**
  43124. * Creates a WebXRExperienceHelper
  43125. * @param scene The scene the helper should be created in
  43126. */
  43127. private constructor();
  43128. /**
  43129. * Exits XR mode and returns the scene to its original state
  43130. * @returns promise that resolves after xr mode has exited
  43131. */
  43132. exitXRAsync(): Promise<unknown>;
  43133. /**
  43134. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43135. * @param sessionCreationOptions options for the XR session
  43136. * @param referenceSpaceType frame of reference of the XR session
  43137. * @param outputCanvas the output canvas that will be used to enter XR mode
  43138. * @returns promise that resolves after xr mode has entered
  43139. */
  43140. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43141. /**
  43142. * Updates the global position of the camera by moving the camera's container
  43143. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43144. * @param position The desired global position of the camera
  43145. */
  43146. setPositionOfCameraUsingContainer(position: Vector3): void;
  43147. /**
  43148. * Rotates the xr camera by rotating the camera's container around the camera's position
  43149. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43150. * @param rotation the desired quaternion rotation to apply to the camera
  43151. */
  43152. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43153. /**
  43154. * Disposes of the experience helper
  43155. */
  43156. dispose(): void;
  43157. }
  43158. }
  43159. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43160. import { Nullable } from "babylonjs/types";
  43161. import { Observable } from "babylonjs/Misc/observable";
  43162. import { IDisposable, Scene } from "babylonjs/scene";
  43163. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43164. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43165. /**
  43166. * Button which can be used to enter a different mode of XR
  43167. */
  43168. export class WebXREnterExitUIButton {
  43169. /** button element */
  43170. element: HTMLElement;
  43171. /** XR initialization options for the button */
  43172. sessionMode: XRSessionMode;
  43173. /** Reference space type */
  43174. referenceSpaceType: XRReferenceSpaceType;
  43175. /**
  43176. * Creates a WebXREnterExitUIButton
  43177. * @param element button element
  43178. * @param sessionMode XR initialization session mode
  43179. * @param referenceSpaceType the type of reference space to be used
  43180. */
  43181. constructor(
  43182. /** button element */
  43183. element: HTMLElement,
  43184. /** XR initialization options for the button */
  43185. sessionMode: XRSessionMode,
  43186. /** Reference space type */
  43187. referenceSpaceType: XRReferenceSpaceType);
  43188. /**
  43189. * Overwritable function which can be used to update the button's visuals when the state changes
  43190. * @param activeButton the current active button in the UI
  43191. */
  43192. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43193. }
  43194. /**
  43195. * Options to create the webXR UI
  43196. */
  43197. export class WebXREnterExitUIOptions {
  43198. /**
  43199. * Context to enter xr with
  43200. */
  43201. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43202. /**
  43203. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43204. */
  43205. customButtons?: Array<WebXREnterExitUIButton>;
  43206. }
  43207. /**
  43208. * UI to allow the user to enter/exit XR mode
  43209. */
  43210. export class WebXREnterExitUI implements IDisposable {
  43211. private scene;
  43212. private _overlay;
  43213. private _buttons;
  43214. private _activeButton;
  43215. /**
  43216. * Fired every time the active button is changed.
  43217. *
  43218. * When xr is entered via a button that launches xr that button will be the callback parameter
  43219. *
  43220. * When exiting xr the callback parameter will be null)
  43221. */
  43222. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43223. /**
  43224. * Creates UI to allow the user to enter/exit XR mode
  43225. * @param scene the scene to add the ui to
  43226. * @param helper the xr experience helper to enter/exit xr with
  43227. * @param options options to configure the UI
  43228. * @returns the created ui
  43229. */
  43230. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43231. private constructor();
  43232. private _updateButtons;
  43233. /**
  43234. * Disposes of the object
  43235. */
  43236. dispose(): void;
  43237. }
  43238. }
  43239. declare module "babylonjs/Cameras/XR/webXRController" {
  43240. import { Nullable } from "babylonjs/types";
  43241. import { Observable } from "babylonjs/Misc/observable";
  43242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43243. import { Ray } from "babylonjs/Culling/ray";
  43244. import { Scene } from "babylonjs/scene";
  43245. /**
  43246. * Represents an XR input
  43247. */
  43248. export class WebXRController {
  43249. private scene;
  43250. /** The underlying input source for the controller */
  43251. inputSource: XRInputSource;
  43252. private parentContainer;
  43253. /**
  43254. * 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
  43255. */
  43256. grip?: AbstractMesh;
  43257. /**
  43258. * Pointer which can be used to select objects or attach a visible laser to
  43259. */
  43260. pointer: AbstractMesh;
  43261. /**
  43262. * Event that fires when the controller is removed/disposed
  43263. */
  43264. onDisposeObservable: Observable<{}>;
  43265. private _tmpMatrix;
  43266. private _tmpQuaternion;
  43267. private _tmpVector;
  43268. /**
  43269. * Creates the controller
  43270. * @see https://doc.babylonjs.com/how_to/webxr
  43271. * @param scene the scene which the controller should be associated to
  43272. * @param inputSource the underlying input source for the controller
  43273. * @param parentContainer parent that the controller meshes should be children of
  43274. */
  43275. constructor(scene: Scene,
  43276. /** The underlying input source for the controller */
  43277. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43278. /**
  43279. * Updates the controller pose based on the given XRFrame
  43280. * @param xrFrame xr frame to update the pose with
  43281. * @param referenceSpace reference space to use
  43282. */
  43283. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43284. /**
  43285. * Gets a world space ray coming from the controller
  43286. * @param result the resulting ray
  43287. */
  43288. getWorldPointerRayToRef(result: Ray): void;
  43289. /**
  43290. * Disposes of the object
  43291. */
  43292. dispose(): void;
  43293. }
  43294. }
  43295. declare module "babylonjs/Cameras/XR/webXRInput" {
  43296. import { Observable } from "babylonjs/Misc/observable";
  43297. import { IDisposable } from "babylonjs/scene";
  43298. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43299. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43300. /**
  43301. * XR input used to track XR inputs such as controllers/rays
  43302. */
  43303. export class WebXRInput implements IDisposable {
  43304. /**
  43305. * Base experience the input listens to
  43306. */
  43307. baseExperience: WebXRExperienceHelper;
  43308. /**
  43309. * XR controllers being tracked
  43310. */
  43311. controllers: Array<WebXRController>;
  43312. private _frameObserver;
  43313. private _stateObserver;
  43314. /**
  43315. * Event when a controller has been connected/added
  43316. */
  43317. onControllerAddedObservable: Observable<WebXRController>;
  43318. /**
  43319. * Event when a controller has been removed/disconnected
  43320. */
  43321. onControllerRemovedObservable: Observable<WebXRController>;
  43322. /**
  43323. * Initializes the WebXRInput
  43324. * @param baseExperience experience helper which the input should be created for
  43325. */
  43326. constructor(
  43327. /**
  43328. * Base experience the input listens to
  43329. */
  43330. baseExperience: WebXRExperienceHelper);
  43331. private _onInputSourcesChange;
  43332. private _addAndRemoveControllers;
  43333. /**
  43334. * Disposes of the object
  43335. */
  43336. dispose(): void;
  43337. }
  43338. }
  43339. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43341. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43342. /**
  43343. * Enables teleportation
  43344. */
  43345. export class WebXRControllerTeleportation {
  43346. private _teleportationFillColor;
  43347. private _teleportationBorderColor;
  43348. private _tmpRay;
  43349. private _tmpVector;
  43350. /**
  43351. * Creates a WebXRControllerTeleportation
  43352. * @param input input manager to add teleportation to
  43353. * @param floorMeshes floormeshes which can be teleported to
  43354. */
  43355. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43356. }
  43357. }
  43358. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43359. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43360. /**
  43361. * Handles pointer input automatically for the pointer of XR controllers
  43362. */
  43363. export class WebXRControllerPointerSelection {
  43364. private static _idCounter;
  43365. private _tmpRay;
  43366. /**
  43367. * Creates a WebXRControllerPointerSelection
  43368. * @param input input manager to setup pointer selection
  43369. */
  43370. constructor(input: WebXRInput);
  43371. private _convertNormalToDirectionOfRay;
  43372. private _updatePointerDistance;
  43373. }
  43374. }
  43375. declare module "babylonjs/Loading/sceneLoader" {
  43376. import { Observable } from "babylonjs/Misc/observable";
  43377. import { Nullable } from "babylonjs/types";
  43378. import { Scene } from "babylonjs/scene";
  43379. import { Engine } from "babylonjs/Engines/engine";
  43380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43381. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43382. import { AssetContainer } from "babylonjs/assetContainer";
  43383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43384. import { Skeleton } from "babylonjs/Bones/skeleton";
  43385. /**
  43386. * Class used to represent data loading progression
  43387. */
  43388. export class SceneLoaderProgressEvent {
  43389. /** defines if data length to load can be evaluated */
  43390. readonly lengthComputable: boolean;
  43391. /** defines the loaded data length */
  43392. readonly loaded: number;
  43393. /** defines the data length to load */
  43394. readonly total: number;
  43395. /**
  43396. * Create a new progress event
  43397. * @param lengthComputable defines if data length to load can be evaluated
  43398. * @param loaded defines the loaded data length
  43399. * @param total defines the data length to load
  43400. */
  43401. constructor(
  43402. /** defines if data length to load can be evaluated */
  43403. lengthComputable: boolean,
  43404. /** defines the loaded data length */
  43405. loaded: number,
  43406. /** defines the data length to load */
  43407. total: number);
  43408. /**
  43409. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43410. * @param event defines the source event
  43411. * @returns a new SceneLoaderProgressEvent
  43412. */
  43413. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43414. }
  43415. /**
  43416. * Interface used by SceneLoader plugins to define supported file extensions
  43417. */
  43418. export interface ISceneLoaderPluginExtensions {
  43419. /**
  43420. * Defines the list of supported extensions
  43421. */
  43422. [extension: string]: {
  43423. isBinary: boolean;
  43424. };
  43425. }
  43426. /**
  43427. * Interface used by SceneLoader plugin factory
  43428. */
  43429. export interface ISceneLoaderPluginFactory {
  43430. /**
  43431. * Defines the name of the factory
  43432. */
  43433. name: string;
  43434. /**
  43435. * Function called to create a new plugin
  43436. * @return the new plugin
  43437. */
  43438. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43439. /**
  43440. * Boolean indicating if the plugin can direct load specific data
  43441. */
  43442. canDirectLoad?: (data: string) => boolean;
  43443. }
  43444. /**
  43445. * Interface used to define a SceneLoader plugin
  43446. */
  43447. export interface ISceneLoaderPlugin {
  43448. /**
  43449. * The friendly name of this plugin.
  43450. */
  43451. name: string;
  43452. /**
  43453. * The file extensions supported by this plugin.
  43454. */
  43455. extensions: string | ISceneLoaderPluginExtensions;
  43456. /**
  43457. * Import meshes into a scene.
  43458. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43459. * @param scene The scene to import into
  43460. * @param data The data to import
  43461. * @param rootUrl The root url for scene and resources
  43462. * @param meshes The meshes array to import into
  43463. * @param particleSystems The particle systems array to import into
  43464. * @param skeletons The skeletons array to import into
  43465. * @param onError The callback when import fails
  43466. * @returns True if successful or false otherwise
  43467. */
  43468. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43469. /**
  43470. * Load into a scene.
  43471. * @param scene The scene to load into
  43472. * @param data The data to import
  43473. * @param rootUrl The root url for scene and resources
  43474. * @param onError The callback when import fails
  43475. * @returns true if successful or false otherwise
  43476. */
  43477. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43478. /**
  43479. * The callback that returns true if the data can be directly loaded.
  43480. */
  43481. canDirectLoad?: (data: string) => boolean;
  43482. /**
  43483. * The callback that allows custom handling of the root url based on the response url.
  43484. */
  43485. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43486. /**
  43487. * Load into an asset container.
  43488. * @param scene The scene to load into
  43489. * @param data The data to import
  43490. * @param rootUrl The root url for scene and resources
  43491. * @param onError The callback when import fails
  43492. * @returns The loaded asset container
  43493. */
  43494. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43495. }
  43496. /**
  43497. * Interface used to define an async SceneLoader plugin
  43498. */
  43499. export interface ISceneLoaderPluginAsync {
  43500. /**
  43501. * The friendly name of this plugin.
  43502. */
  43503. name: string;
  43504. /**
  43505. * The file extensions supported by this plugin.
  43506. */
  43507. extensions: string | ISceneLoaderPluginExtensions;
  43508. /**
  43509. * Import meshes into a scene.
  43510. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43511. * @param scene The scene to import into
  43512. * @param data The data to import
  43513. * @param rootUrl The root url for scene and resources
  43514. * @param onProgress The callback when the load progresses
  43515. * @param fileName Defines the name of the file to load
  43516. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43517. */
  43518. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43519. meshes: AbstractMesh[];
  43520. particleSystems: IParticleSystem[];
  43521. skeletons: Skeleton[];
  43522. animationGroups: AnimationGroup[];
  43523. }>;
  43524. /**
  43525. * Load into a scene.
  43526. * @param scene The scene to load into
  43527. * @param data The data to import
  43528. * @param rootUrl The root url for scene and resources
  43529. * @param onProgress The callback when the load progresses
  43530. * @param fileName Defines the name of the file to load
  43531. * @returns Nothing
  43532. */
  43533. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43534. /**
  43535. * The callback that returns true if the data can be directly loaded.
  43536. */
  43537. canDirectLoad?: (data: string) => boolean;
  43538. /**
  43539. * The callback that allows custom handling of the root url based on the response url.
  43540. */
  43541. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43542. /**
  43543. * Load into an asset container.
  43544. * @param scene The scene to load into
  43545. * @param data The data to import
  43546. * @param rootUrl The root url for scene and resources
  43547. * @param onProgress The callback when the load progresses
  43548. * @param fileName Defines the name of the file to load
  43549. * @returns The loaded asset container
  43550. */
  43551. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43552. }
  43553. /**
  43554. * Class used to load scene from various file formats using registered plugins
  43555. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43556. */
  43557. export class SceneLoader {
  43558. /**
  43559. * No logging while loading
  43560. */
  43561. static readonly NO_LOGGING: number;
  43562. /**
  43563. * Minimal logging while loading
  43564. */
  43565. static readonly MINIMAL_LOGGING: number;
  43566. /**
  43567. * Summary logging while loading
  43568. */
  43569. static readonly SUMMARY_LOGGING: number;
  43570. /**
  43571. * Detailled logging while loading
  43572. */
  43573. static readonly DETAILED_LOGGING: number;
  43574. /**
  43575. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43576. */
  43577. static ForceFullSceneLoadingForIncremental: boolean;
  43578. /**
  43579. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43580. */
  43581. static ShowLoadingScreen: boolean;
  43582. /**
  43583. * Defines the current logging level (while loading the scene)
  43584. * @ignorenaming
  43585. */
  43586. static loggingLevel: number;
  43587. /**
  43588. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43589. */
  43590. static CleanBoneMatrixWeights: boolean;
  43591. /**
  43592. * Event raised when a plugin is used to load a scene
  43593. */
  43594. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43595. private static _registeredPlugins;
  43596. private static _getDefaultPlugin;
  43597. private static _getPluginForExtension;
  43598. private static _getPluginForDirectLoad;
  43599. private static _getPluginForFilename;
  43600. private static _getDirectLoad;
  43601. private static _loadData;
  43602. private static _getFileInfo;
  43603. /**
  43604. * Gets a plugin that can load the given extension
  43605. * @param extension defines the extension to load
  43606. * @returns a plugin or null if none works
  43607. */
  43608. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43609. /**
  43610. * Gets a boolean indicating that the given extension can be loaded
  43611. * @param extension defines the extension to load
  43612. * @returns true if the extension is supported
  43613. */
  43614. static IsPluginForExtensionAvailable(extension: string): boolean;
  43615. /**
  43616. * Adds a new plugin to the list of registered plugins
  43617. * @param plugin defines the plugin to add
  43618. */
  43619. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43620. /**
  43621. * Import meshes into a scene
  43622. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43623. * @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)
  43624. * @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)
  43625. * @param scene the instance of BABYLON.Scene to append to
  43626. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43627. * @param onProgress a callback with a progress event for each file being loaded
  43628. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43629. * @param pluginExtension the extension used to determine the plugin
  43630. * @returns The loaded plugin
  43631. */
  43632. 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>;
  43633. /**
  43634. * Import meshes into a scene
  43635. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43636. * @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)
  43637. * @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)
  43638. * @param scene the instance of BABYLON.Scene to append to
  43639. * @param onProgress a callback with a progress event for each file being loaded
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43642. */
  43643. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43644. meshes: AbstractMesh[];
  43645. particleSystems: IParticleSystem[];
  43646. skeletons: Skeleton[];
  43647. animationGroups: AnimationGroup[];
  43648. }>;
  43649. /**
  43650. * Load a scene
  43651. * @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)
  43652. * @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)
  43653. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43654. * @param onSuccess a callback with the scene when import succeeds
  43655. * @param onProgress a callback with a progress event for each file being loaded
  43656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43657. * @param pluginExtension the extension used to determine the plugin
  43658. * @returns The loaded plugin
  43659. */
  43660. 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>;
  43661. /**
  43662. * Load a scene
  43663. * @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)
  43664. * @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)
  43665. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43666. * @param onProgress a callback with a progress event for each file being loaded
  43667. * @param pluginExtension the extension used to determine the plugin
  43668. * @returns The loaded scene
  43669. */
  43670. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43671. /**
  43672. * Append a scene
  43673. * @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)
  43674. * @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)
  43675. * @param scene is the instance of BABYLON.Scene to append to
  43676. * @param onSuccess a callback with the scene when import succeeds
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43679. * @param pluginExtension the extension used to determine the plugin
  43680. * @returns The loaded plugin
  43681. */
  43682. 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>;
  43683. /**
  43684. * Append a scene
  43685. * @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)
  43686. * @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)
  43687. * @param scene is the instance of BABYLON.Scene to append to
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param pluginExtension the extension used to determine the plugin
  43690. * @returns The given scene
  43691. */
  43692. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43693. /**
  43694. * Load a scene into an asset container
  43695. * @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)
  43696. * @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)
  43697. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43698. * @param onSuccess a callback with the scene when import succeeds
  43699. * @param onProgress a callback with a progress event for each file being loaded
  43700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43701. * @param pluginExtension the extension used to determine the plugin
  43702. * @returns The loaded plugin
  43703. */
  43704. 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>;
  43705. /**
  43706. * Load a scene into an asset container
  43707. * @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)
  43708. * @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)
  43709. * @param scene is the instance of Scene to append to
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param pluginExtension the extension used to determine the plugin
  43712. * @returns The loaded asset container
  43713. */
  43714. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43715. }
  43716. }
  43717. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43718. import { Scene } from "babylonjs/scene";
  43719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43720. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43721. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43722. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43723. /**
  43724. * Generic Controller
  43725. */
  43726. export class GenericController extends WebVRController {
  43727. /**
  43728. * Base Url for the controller model.
  43729. */
  43730. static readonly MODEL_BASE_URL: string;
  43731. /**
  43732. * File name for the controller model.
  43733. */
  43734. static readonly MODEL_FILENAME: string;
  43735. /**
  43736. * Creates a new GenericController from a gamepad
  43737. * @param vrGamepad the gamepad that the controller should be created from
  43738. */
  43739. constructor(vrGamepad: any);
  43740. /**
  43741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43742. * @param scene scene in which to add meshes
  43743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43744. */
  43745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43746. /**
  43747. * Called once for each button that changed state since the last frame
  43748. * @param buttonIdx Which button index changed
  43749. * @param state New state of the button
  43750. * @param changes Which properties on the state changed since last frame
  43751. */
  43752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43753. }
  43754. }
  43755. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43756. import { Observable } from "babylonjs/Misc/observable";
  43757. import { Scene } from "babylonjs/scene";
  43758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43759. import { Ray } from "babylonjs/Culling/ray";
  43760. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43761. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43762. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43763. /**
  43764. * Defines the WindowsMotionController object that the state of the windows motion controller
  43765. */
  43766. export class WindowsMotionController extends WebVRController {
  43767. /**
  43768. * The base url used to load the left and right controller models
  43769. */
  43770. static MODEL_BASE_URL: string;
  43771. /**
  43772. * The name of the left controller model file
  43773. */
  43774. static MODEL_LEFT_FILENAME: string;
  43775. /**
  43776. * The name of the right controller model file
  43777. */
  43778. static MODEL_RIGHT_FILENAME: string;
  43779. /**
  43780. * The controller name prefix for this controller type
  43781. */
  43782. static readonly GAMEPAD_ID_PREFIX: string;
  43783. /**
  43784. * The controller id pattern for this controller type
  43785. */
  43786. private static readonly GAMEPAD_ID_PATTERN;
  43787. private _loadedMeshInfo;
  43788. private readonly _mapping;
  43789. /**
  43790. * Fired when the trackpad on this controller is clicked
  43791. */
  43792. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43793. /**
  43794. * Fired when the trackpad on this controller is modified
  43795. */
  43796. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43797. /**
  43798. * The current x and y values of this controller's trackpad
  43799. */
  43800. trackpad: StickValues;
  43801. /**
  43802. * Creates a new WindowsMotionController from a gamepad
  43803. * @param vrGamepad the gamepad that the controller should be created from
  43804. */
  43805. constructor(vrGamepad: any);
  43806. /**
  43807. * Fired when the trigger on this controller is modified
  43808. */
  43809. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43810. /**
  43811. * Fired when the menu button on this controller is modified
  43812. */
  43813. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43814. /**
  43815. * Fired when the grip button on this controller is modified
  43816. */
  43817. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43818. /**
  43819. * Fired when the thumbstick button on this controller is modified
  43820. */
  43821. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43822. /**
  43823. * Fired when the touchpad button on this controller is modified
  43824. */
  43825. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43826. /**
  43827. * Fired when the touchpad values on this controller are modified
  43828. */
  43829. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43830. private _updateTrackpad;
  43831. /**
  43832. * Called once per frame by the engine.
  43833. */
  43834. update(): void;
  43835. /**
  43836. * Called once for each button that changed state since the last frame
  43837. * @param buttonIdx Which button index changed
  43838. * @param state New state of the button
  43839. * @param changes Which properties on the state changed since last frame
  43840. */
  43841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43842. /**
  43843. * Moves the buttons on the controller mesh based on their current state
  43844. * @param buttonName the name of the button to move
  43845. * @param buttonValue the value of the button which determines the buttons new position
  43846. */
  43847. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43848. /**
  43849. * Moves the axis on the controller mesh based on its current state
  43850. * @param axis the index of the axis
  43851. * @param axisValue the value of the axis which determines the meshes new position
  43852. * @hidden
  43853. */
  43854. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43855. /**
  43856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43857. * @param scene scene in which to add meshes
  43858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43859. */
  43860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43861. /**
  43862. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43863. * can be transformed by button presses and axes values, based on this._mapping.
  43864. *
  43865. * @param scene scene in which the meshes exist
  43866. * @param meshes list of meshes that make up the controller model to process
  43867. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43868. */
  43869. private processModel;
  43870. private createMeshInfo;
  43871. /**
  43872. * Gets the ray of the controller in the direction the controller is pointing
  43873. * @param length the length the resulting ray should be
  43874. * @returns a ray in the direction the controller is pointing
  43875. */
  43876. getForwardRay(length?: number): Ray;
  43877. /**
  43878. * Disposes of the controller
  43879. */
  43880. dispose(): void;
  43881. }
  43882. }
  43883. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43884. import { Observable } from "babylonjs/Misc/observable";
  43885. import { Scene } from "babylonjs/scene";
  43886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43887. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43888. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43889. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43890. /**
  43891. * Oculus Touch Controller
  43892. */
  43893. export class OculusTouchController extends WebVRController {
  43894. /**
  43895. * Base Url for the controller model.
  43896. */
  43897. static MODEL_BASE_URL: string;
  43898. /**
  43899. * File name for the left controller model.
  43900. */
  43901. static MODEL_LEFT_FILENAME: string;
  43902. /**
  43903. * File name for the right controller model.
  43904. */
  43905. static MODEL_RIGHT_FILENAME: string;
  43906. /**
  43907. * Base Url for the Quest controller model.
  43908. */
  43909. static QUEST_MODEL_BASE_URL: string;
  43910. /**
  43911. * @hidden
  43912. * If the controllers are running on a device that needs the updated Quest controller models
  43913. */
  43914. static _IsQuest: boolean;
  43915. /**
  43916. * Fired when the secondary trigger on this controller is modified
  43917. */
  43918. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43919. /**
  43920. * Fired when the thumb rest on this controller is modified
  43921. */
  43922. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43923. /**
  43924. * Creates a new OculusTouchController from a gamepad
  43925. * @param vrGamepad the gamepad that the controller should be created from
  43926. */
  43927. constructor(vrGamepad: any);
  43928. /**
  43929. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43930. * @param scene scene in which to add meshes
  43931. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43932. */
  43933. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43934. /**
  43935. * Fired when the A button on this controller is modified
  43936. */
  43937. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43938. /**
  43939. * Fired when the B button on this controller is modified
  43940. */
  43941. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43942. /**
  43943. * Fired when the X button on this controller is modified
  43944. */
  43945. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43946. /**
  43947. * Fired when the Y button on this controller is modified
  43948. */
  43949. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Called once for each button that changed state since the last frame
  43952. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43953. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43954. * 2) secondary trigger (same)
  43955. * 3) A (right) X (left), touch, pressed = value
  43956. * 4) B / Y
  43957. * 5) thumb rest
  43958. * @param buttonIdx Which button index changed
  43959. * @param state New state of the button
  43960. * @param changes Which properties on the state changed since last frame
  43961. */
  43962. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43963. }
  43964. }
  43965. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43966. import { Scene } from "babylonjs/scene";
  43967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43968. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43969. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43970. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43971. import { Observable } from "babylonjs/Misc/observable";
  43972. /**
  43973. * Vive Controller
  43974. */
  43975. export class ViveController extends WebVRController {
  43976. /**
  43977. * Base Url for the controller model.
  43978. */
  43979. static MODEL_BASE_URL: string;
  43980. /**
  43981. * File name for the controller model.
  43982. */
  43983. static MODEL_FILENAME: string;
  43984. /**
  43985. * Creates a new ViveController from a gamepad
  43986. * @param vrGamepad the gamepad that the controller should be created from
  43987. */
  43988. constructor(vrGamepad: any);
  43989. /**
  43990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43991. * @param scene scene in which to add meshes
  43992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43993. */
  43994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43995. /**
  43996. * Fired when the left button on this controller is modified
  43997. */
  43998. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43999. /**
  44000. * Fired when the right button on this controller is modified
  44001. */
  44002. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44003. /**
  44004. * Fired when the menu button on this controller is modified
  44005. */
  44006. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44007. /**
  44008. * Called once for each button that changed state since the last frame
  44009. * Vive mapping:
  44010. * 0: touchpad
  44011. * 1: trigger
  44012. * 2: left AND right buttons
  44013. * 3: menu button
  44014. * @param buttonIdx Which button index changed
  44015. * @param state New state of the button
  44016. * @param changes Which properties on the state changed since last frame
  44017. */
  44018. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44019. }
  44020. }
  44021. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44022. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44023. /**
  44024. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44025. */
  44026. export class WebXRControllerModelLoader {
  44027. /**
  44028. * Creates the WebXRControllerModelLoader
  44029. * @param input xr input that creates the controllers
  44030. */
  44031. constructor(input: WebXRInput);
  44032. }
  44033. }
  44034. declare module "babylonjs/Cameras/XR/index" {
  44035. export * from "babylonjs/Cameras/XR/webXRCamera";
  44036. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44037. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44038. export * from "babylonjs/Cameras/XR/webXRInput";
  44039. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44040. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44041. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44042. export * from "babylonjs/Cameras/XR/webXRController";
  44043. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44044. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44045. }
  44046. declare module "babylonjs/Cameras/RigModes/index" {
  44047. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44048. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44049. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44050. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44051. }
  44052. declare module "babylonjs/Cameras/index" {
  44053. export * from "babylonjs/Cameras/Inputs/index";
  44054. export * from "babylonjs/Cameras/cameraInputsManager";
  44055. export * from "babylonjs/Cameras/camera";
  44056. export * from "babylonjs/Cameras/targetCamera";
  44057. export * from "babylonjs/Cameras/freeCamera";
  44058. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44059. export * from "babylonjs/Cameras/touchCamera";
  44060. export * from "babylonjs/Cameras/arcRotateCamera";
  44061. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44062. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44063. export * from "babylonjs/Cameras/flyCamera";
  44064. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44065. export * from "babylonjs/Cameras/followCamera";
  44066. export * from "babylonjs/Cameras/followCameraInputsManager";
  44067. export * from "babylonjs/Cameras/gamepadCamera";
  44068. export * from "babylonjs/Cameras/Stereoscopic/index";
  44069. export * from "babylonjs/Cameras/universalCamera";
  44070. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44071. export * from "babylonjs/Cameras/VR/index";
  44072. export * from "babylonjs/Cameras/XR/index";
  44073. export * from "babylonjs/Cameras/RigModes/index";
  44074. }
  44075. declare module "babylonjs/Collisions/index" {
  44076. export * from "babylonjs/Collisions/collider";
  44077. export * from "babylonjs/Collisions/collisionCoordinator";
  44078. export * from "babylonjs/Collisions/pickingInfo";
  44079. export * from "babylonjs/Collisions/intersectionInfo";
  44080. export * from "babylonjs/Collisions/meshCollisionData";
  44081. }
  44082. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44083. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44084. import { Vector3 } from "babylonjs/Maths/math.vector";
  44085. import { Ray } from "babylonjs/Culling/ray";
  44086. import { Plane } from "babylonjs/Maths/math.plane";
  44087. /**
  44088. * Contains an array of blocks representing the octree
  44089. */
  44090. export interface IOctreeContainer<T> {
  44091. /**
  44092. * Blocks within the octree
  44093. */
  44094. blocks: Array<OctreeBlock<T>>;
  44095. }
  44096. /**
  44097. * Class used to store a cell in an octree
  44098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44099. */
  44100. export class OctreeBlock<T> {
  44101. /**
  44102. * Gets the content of the current block
  44103. */
  44104. entries: T[];
  44105. /**
  44106. * Gets the list of block children
  44107. */
  44108. blocks: Array<OctreeBlock<T>>;
  44109. private _depth;
  44110. private _maxDepth;
  44111. private _capacity;
  44112. private _minPoint;
  44113. private _maxPoint;
  44114. private _boundingVectors;
  44115. private _creationFunc;
  44116. /**
  44117. * Creates a new block
  44118. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44119. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44120. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44121. * @param depth defines the current depth of this block in the octree
  44122. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44123. * @param creationFunc defines a callback to call when an element is added to the block
  44124. */
  44125. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44126. /**
  44127. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44128. */
  44129. readonly capacity: number;
  44130. /**
  44131. * Gets the minimum vector (in world space) of the block's bounding box
  44132. */
  44133. readonly minPoint: Vector3;
  44134. /**
  44135. * Gets the maximum vector (in world space) of the block's bounding box
  44136. */
  44137. readonly maxPoint: Vector3;
  44138. /**
  44139. * Add a new element to this block
  44140. * @param entry defines the element to add
  44141. */
  44142. addEntry(entry: T): void;
  44143. /**
  44144. * Remove an element from this block
  44145. * @param entry defines the element to remove
  44146. */
  44147. removeEntry(entry: T): void;
  44148. /**
  44149. * Add an array of elements to this block
  44150. * @param entries defines the array of elements to add
  44151. */
  44152. addEntries(entries: T[]): void;
  44153. /**
  44154. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44155. * @param frustumPlanes defines the frustum planes to test
  44156. * @param selection defines the array to store current content if selection is positive
  44157. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44158. */
  44159. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44160. /**
  44161. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44162. * @param sphereCenter defines the bounding sphere center
  44163. * @param sphereRadius defines the bounding sphere radius
  44164. * @param selection defines the array to store current content if selection is positive
  44165. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44166. */
  44167. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44168. /**
  44169. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44170. * @param ray defines the ray to test with
  44171. * @param selection defines the array to store current content if selection is positive
  44172. */
  44173. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44174. /**
  44175. * Subdivide the content into child blocks (this block will then be empty)
  44176. */
  44177. createInnerBlocks(): void;
  44178. /**
  44179. * @hidden
  44180. */
  44181. 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;
  44182. }
  44183. }
  44184. declare module "babylonjs/Culling/Octrees/octree" {
  44185. import { SmartArray } from "babylonjs/Misc/smartArray";
  44186. import { Vector3 } from "babylonjs/Maths/math.vector";
  44187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44189. import { Ray } from "babylonjs/Culling/ray";
  44190. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44191. import { Plane } from "babylonjs/Maths/math.plane";
  44192. /**
  44193. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44195. */
  44196. export class Octree<T> {
  44197. /** 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.) */
  44198. maxDepth: number;
  44199. /**
  44200. * Blocks within the octree containing objects
  44201. */
  44202. blocks: Array<OctreeBlock<T>>;
  44203. /**
  44204. * Content stored in the octree
  44205. */
  44206. dynamicContent: T[];
  44207. private _maxBlockCapacity;
  44208. private _selectionContent;
  44209. private _creationFunc;
  44210. /**
  44211. * Creates a octree
  44212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44213. * @param creationFunc function to be used to instatiate the octree
  44214. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44215. * @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.)
  44216. */
  44217. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44218. /** 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.) */
  44219. maxDepth?: number);
  44220. /**
  44221. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44222. * @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);
  44223. * @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);
  44224. * @param entries meshes to be added to the octree blocks
  44225. */
  44226. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44227. /**
  44228. * Adds a mesh to the octree
  44229. * @param entry Mesh to add to the octree
  44230. */
  44231. addMesh(entry: T): void;
  44232. /**
  44233. * Remove an element from the octree
  44234. * @param entry defines the element to remove
  44235. */
  44236. removeMesh(entry: T): void;
  44237. /**
  44238. * Selects an array of meshes within the frustum
  44239. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44240. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44241. * @returns array of meshes within the frustum
  44242. */
  44243. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44244. /**
  44245. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44246. * @param sphereCenter defines the bounding sphere center
  44247. * @param sphereRadius defines the bounding sphere radius
  44248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44249. * @returns an array of objects that intersect the sphere
  44250. */
  44251. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44252. /**
  44253. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44254. * @param ray defines the ray to test with
  44255. * @returns array of intersected objects
  44256. */
  44257. intersectsRay(ray: Ray): SmartArray<T>;
  44258. /**
  44259. * Adds a mesh into the octree block if it intersects the block
  44260. */
  44261. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44262. /**
  44263. * Adds a submesh into the octree block if it intersects the block
  44264. */
  44265. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44266. }
  44267. }
  44268. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44269. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44270. import { Scene } from "babylonjs/scene";
  44271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44273. import { Ray } from "babylonjs/Culling/ray";
  44274. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44275. import { Collider } from "babylonjs/Collisions/collider";
  44276. module "babylonjs/scene" {
  44277. interface Scene {
  44278. /**
  44279. * @hidden
  44280. * Backing Filed
  44281. */
  44282. _selectionOctree: Octree<AbstractMesh>;
  44283. /**
  44284. * Gets the octree used to boost mesh selection (picking)
  44285. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44286. */
  44287. selectionOctree: Octree<AbstractMesh>;
  44288. /**
  44289. * Creates or updates the octree used to boost selection (picking)
  44290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44291. * @param maxCapacity defines the maximum capacity per leaf
  44292. * @param maxDepth defines the maximum depth of the octree
  44293. * @returns an octree of AbstractMesh
  44294. */
  44295. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44296. }
  44297. }
  44298. module "babylonjs/Meshes/abstractMesh" {
  44299. interface AbstractMesh {
  44300. /**
  44301. * @hidden
  44302. * Backing Field
  44303. */
  44304. _submeshesOctree: Octree<SubMesh>;
  44305. /**
  44306. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44307. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44308. * @param maxCapacity defines the maximum size of each block (64 by default)
  44309. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44310. * @returns the new octree
  44311. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44313. */
  44314. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44315. }
  44316. }
  44317. /**
  44318. * Defines the octree scene component responsible to manage any octrees
  44319. * in a given scene.
  44320. */
  44321. export class OctreeSceneComponent {
  44322. /**
  44323. * The component name help to identify the component in the list of scene components.
  44324. */
  44325. readonly name: string;
  44326. /**
  44327. * The scene the component belongs to.
  44328. */
  44329. scene: Scene;
  44330. /**
  44331. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44332. */
  44333. readonly checksIsEnabled: boolean;
  44334. /**
  44335. * Creates a new instance of the component for the given scene
  44336. * @param scene Defines the scene to register the component in
  44337. */
  44338. constructor(scene: Scene);
  44339. /**
  44340. * Registers the component in a given scene
  44341. */
  44342. register(): void;
  44343. /**
  44344. * Return the list of active meshes
  44345. * @returns the list of active meshes
  44346. */
  44347. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44348. /**
  44349. * Return the list of active sub meshes
  44350. * @param mesh The mesh to get the candidates sub meshes from
  44351. * @returns the list of active sub meshes
  44352. */
  44353. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44354. private _tempRay;
  44355. /**
  44356. * Return the list of sub meshes intersecting with a given local ray
  44357. * @param mesh defines the mesh to find the submesh for
  44358. * @param localRay defines the ray in local space
  44359. * @returns the list of intersecting sub meshes
  44360. */
  44361. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44362. /**
  44363. * Return the list of sub meshes colliding with a collider
  44364. * @param mesh defines the mesh to find the submesh for
  44365. * @param collider defines the collider to evaluate the collision against
  44366. * @returns the list of colliding sub meshes
  44367. */
  44368. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44369. /**
  44370. * Rebuilds the elements related to this component in case of
  44371. * context lost for instance.
  44372. */
  44373. rebuild(): void;
  44374. /**
  44375. * Disposes the component and the associated ressources.
  44376. */
  44377. dispose(): void;
  44378. }
  44379. }
  44380. declare module "babylonjs/Culling/Octrees/index" {
  44381. export * from "babylonjs/Culling/Octrees/octree";
  44382. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44383. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44384. }
  44385. declare module "babylonjs/Culling/index" {
  44386. export * from "babylonjs/Culling/boundingBox";
  44387. export * from "babylonjs/Culling/boundingInfo";
  44388. export * from "babylonjs/Culling/boundingSphere";
  44389. export * from "babylonjs/Culling/Octrees/index";
  44390. export * from "babylonjs/Culling/ray";
  44391. }
  44392. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44393. import { IDisposable, Scene } from "babylonjs/scene";
  44394. import { Nullable } from "babylonjs/types";
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44397. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44398. import { Camera } from "babylonjs/Cameras/camera";
  44399. /**
  44400. * Renders a layer on top of an existing scene
  44401. */
  44402. export class UtilityLayerRenderer implements IDisposable {
  44403. /** the original scene that will be rendered on top of */
  44404. originalScene: Scene;
  44405. private _pointerCaptures;
  44406. private _lastPointerEvents;
  44407. private static _DefaultUtilityLayer;
  44408. private static _DefaultKeepDepthUtilityLayer;
  44409. private _sharedGizmoLight;
  44410. private _renderCamera;
  44411. /**
  44412. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44413. * @returns the camera that is used when rendering the utility layer
  44414. */
  44415. getRenderCamera(): Nullable<Camera>;
  44416. /**
  44417. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44418. * @param cam the camera that should be used when rendering the utility layer
  44419. */
  44420. setRenderCamera(cam: Nullable<Camera>): void;
  44421. /**
  44422. * @hidden
  44423. * Light which used by gizmos to get light shading
  44424. */
  44425. _getSharedGizmoLight(): HemisphericLight;
  44426. /**
  44427. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44428. */
  44429. pickUtilitySceneFirst: boolean;
  44430. /**
  44431. * 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)
  44432. */
  44433. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44434. /**
  44435. * 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)
  44436. */
  44437. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44438. /**
  44439. * The scene that is rendered on top of the original scene
  44440. */
  44441. utilityLayerScene: Scene;
  44442. /**
  44443. * If the utility layer should automatically be rendered on top of existing scene
  44444. */
  44445. shouldRender: boolean;
  44446. /**
  44447. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44448. */
  44449. onlyCheckPointerDownEvents: boolean;
  44450. /**
  44451. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44452. */
  44453. processAllEvents: boolean;
  44454. /**
  44455. * Observable raised when the pointer move from the utility layer scene to the main scene
  44456. */
  44457. onPointerOutObservable: Observable<number>;
  44458. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44459. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44460. private _afterRenderObserver;
  44461. private _sceneDisposeObserver;
  44462. private _originalPointerObserver;
  44463. /**
  44464. * Instantiates a UtilityLayerRenderer
  44465. * @param originalScene the original scene that will be rendered on top of
  44466. * @param handleEvents boolean indicating if the utility layer should handle events
  44467. */
  44468. constructor(
  44469. /** the original scene that will be rendered on top of */
  44470. originalScene: Scene, handleEvents?: boolean);
  44471. private _notifyObservers;
  44472. /**
  44473. * Renders the utility layers scene on top of the original scene
  44474. */
  44475. render(): void;
  44476. /**
  44477. * Disposes of the renderer
  44478. */
  44479. dispose(): void;
  44480. private _updateCamera;
  44481. }
  44482. }
  44483. declare module "babylonjs/Gizmos/gizmo" {
  44484. import { Nullable } from "babylonjs/types";
  44485. import { IDisposable } from "babylonjs/scene";
  44486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44487. import { Mesh } from "babylonjs/Meshes/mesh";
  44488. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44489. /**
  44490. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44491. */
  44492. export class Gizmo implements IDisposable {
  44493. /** The utility layer the gizmo will be added to */
  44494. gizmoLayer: UtilityLayerRenderer;
  44495. /**
  44496. * The root mesh of the gizmo
  44497. */
  44498. _rootMesh: Mesh;
  44499. private _attachedMesh;
  44500. /**
  44501. * Ratio for the scale of the gizmo (Default: 1)
  44502. */
  44503. scaleRatio: number;
  44504. /**
  44505. * If a custom mesh has been set (Default: false)
  44506. */
  44507. protected _customMeshSet: boolean;
  44508. /**
  44509. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44510. * * When set, interactions will be enabled
  44511. */
  44512. attachedMesh: Nullable<AbstractMesh>;
  44513. /**
  44514. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44515. * @param mesh The mesh to replace the default mesh of the gizmo
  44516. */
  44517. setCustomMesh(mesh: Mesh): void;
  44518. /**
  44519. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44520. */
  44521. updateGizmoRotationToMatchAttachedMesh: boolean;
  44522. /**
  44523. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44524. */
  44525. updateGizmoPositionToMatchAttachedMesh: boolean;
  44526. /**
  44527. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44528. */
  44529. updateScale: boolean;
  44530. protected _interactionsEnabled: boolean;
  44531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44532. private _beforeRenderObserver;
  44533. private _tempVector;
  44534. /**
  44535. * Creates a gizmo
  44536. * @param gizmoLayer The utility layer the gizmo will be added to
  44537. */
  44538. constructor(
  44539. /** The utility layer the gizmo will be added to */
  44540. gizmoLayer?: UtilityLayerRenderer);
  44541. /**
  44542. * Updates the gizmo to match the attached mesh's position/rotation
  44543. */
  44544. protected _update(): void;
  44545. /**
  44546. * Disposes of the gizmo
  44547. */
  44548. dispose(): void;
  44549. }
  44550. }
  44551. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44552. import { Observable } from "babylonjs/Misc/observable";
  44553. import { Nullable } from "babylonjs/types";
  44554. import { Vector3 } from "babylonjs/Maths/math.vector";
  44555. import { Color3 } from "babylonjs/Maths/math.color";
  44556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44558. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44559. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44560. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44561. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44562. import { Scene } from "babylonjs/scene";
  44563. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44564. /**
  44565. * Single plane drag gizmo
  44566. */
  44567. export class PlaneDragGizmo extends Gizmo {
  44568. /**
  44569. * Drag behavior responsible for the gizmos dragging interactions
  44570. */
  44571. dragBehavior: PointerDragBehavior;
  44572. private _pointerObserver;
  44573. /**
  44574. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44575. */
  44576. snapDistance: number;
  44577. /**
  44578. * Event that fires each time the gizmo snaps to a new location.
  44579. * * snapDistance is the the change in distance
  44580. */
  44581. onSnapObservable: Observable<{
  44582. snapDistance: number;
  44583. }>;
  44584. private _plane;
  44585. private _coloredMaterial;
  44586. private _hoverMaterial;
  44587. private _isEnabled;
  44588. private _parent;
  44589. /** @hidden */
  44590. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44591. /** @hidden */
  44592. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44593. /**
  44594. * Creates a PlaneDragGizmo
  44595. * @param gizmoLayer The utility layer the gizmo will be added to
  44596. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44597. * @param color The color of the gizmo
  44598. */
  44599. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44600. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44601. /**
  44602. * If the gizmo is enabled
  44603. */
  44604. isEnabled: boolean;
  44605. /**
  44606. * Disposes of the gizmo
  44607. */
  44608. dispose(): void;
  44609. }
  44610. }
  44611. declare module "babylonjs/Gizmos/positionGizmo" {
  44612. import { Observable } from "babylonjs/Misc/observable";
  44613. import { Nullable } from "babylonjs/types";
  44614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44615. import { Mesh } from "babylonjs/Meshes/mesh";
  44616. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44617. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44618. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44619. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44620. /**
  44621. * Gizmo that enables dragging a mesh along 3 axis
  44622. */
  44623. export class PositionGizmo extends Gizmo {
  44624. /**
  44625. * Internal gizmo used for interactions on the x axis
  44626. */
  44627. xGizmo: AxisDragGizmo;
  44628. /**
  44629. * Internal gizmo used for interactions on the y axis
  44630. */
  44631. yGizmo: AxisDragGizmo;
  44632. /**
  44633. * Internal gizmo used for interactions on the z axis
  44634. */
  44635. zGizmo: AxisDragGizmo;
  44636. /**
  44637. * Internal gizmo used for interactions on the yz plane
  44638. */
  44639. xPlaneGizmo: PlaneDragGizmo;
  44640. /**
  44641. * Internal gizmo used for interactions on the xz plane
  44642. */
  44643. yPlaneGizmo: PlaneDragGizmo;
  44644. /**
  44645. * Internal gizmo used for interactions on the xy plane
  44646. */
  44647. zPlaneGizmo: PlaneDragGizmo;
  44648. /**
  44649. * private variables
  44650. */
  44651. private _meshAttached;
  44652. private _updateGizmoRotationToMatchAttachedMesh;
  44653. private _snapDistance;
  44654. private _scaleRatio;
  44655. /** Fires an event when any of it's sub gizmos are dragged */
  44656. onDragStartObservable: Observable<unknown>;
  44657. /** Fires an event when any of it's sub gizmos are released from dragging */
  44658. onDragEndObservable: Observable<unknown>;
  44659. /**
  44660. * If set to true, planar drag is enabled
  44661. */
  44662. private _planarGizmoEnabled;
  44663. attachedMesh: Nullable<AbstractMesh>;
  44664. /**
  44665. * Creates a PositionGizmo
  44666. * @param gizmoLayer The utility layer the gizmo will be added to
  44667. */
  44668. constructor(gizmoLayer?: UtilityLayerRenderer);
  44669. /**
  44670. * If the planar drag gizmo is enabled
  44671. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44672. */
  44673. planarGizmoEnabled: boolean;
  44674. updateGizmoRotationToMatchAttachedMesh: boolean;
  44675. /**
  44676. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44677. */
  44678. snapDistance: number;
  44679. /**
  44680. * Ratio for the scale of the gizmo (Default: 1)
  44681. */
  44682. scaleRatio: number;
  44683. /**
  44684. * Disposes of the gizmo
  44685. */
  44686. dispose(): void;
  44687. /**
  44688. * CustomMeshes are not supported by this gizmo
  44689. * @param mesh The mesh to replace the default mesh of the gizmo
  44690. */
  44691. setCustomMesh(mesh: Mesh): void;
  44692. }
  44693. }
  44694. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44695. import { Observable } from "babylonjs/Misc/observable";
  44696. import { Nullable } from "babylonjs/types";
  44697. import { Vector3 } from "babylonjs/Maths/math.vector";
  44698. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44700. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44701. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44702. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44703. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44704. import { Scene } from "babylonjs/scene";
  44705. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44706. import { Color3 } from "babylonjs/Maths/math.color";
  44707. /**
  44708. * Single axis drag gizmo
  44709. */
  44710. export class AxisDragGizmo extends Gizmo {
  44711. /**
  44712. * Drag behavior responsible for the gizmos dragging interactions
  44713. */
  44714. dragBehavior: PointerDragBehavior;
  44715. private _pointerObserver;
  44716. /**
  44717. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44718. */
  44719. snapDistance: number;
  44720. /**
  44721. * Event that fires each time the gizmo snaps to a new location.
  44722. * * snapDistance is the the change in distance
  44723. */
  44724. onSnapObservable: Observable<{
  44725. snapDistance: number;
  44726. }>;
  44727. private _isEnabled;
  44728. private _parent;
  44729. private _arrow;
  44730. private _coloredMaterial;
  44731. private _hoverMaterial;
  44732. /** @hidden */
  44733. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44734. /** @hidden */
  44735. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44736. /**
  44737. * Creates an AxisDragGizmo
  44738. * @param gizmoLayer The utility layer the gizmo will be added to
  44739. * @param dragAxis The axis which the gizmo will be able to drag on
  44740. * @param color The color of the gizmo
  44741. */
  44742. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44743. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44744. /**
  44745. * If the gizmo is enabled
  44746. */
  44747. isEnabled: boolean;
  44748. /**
  44749. * Disposes of the gizmo
  44750. */
  44751. dispose(): void;
  44752. }
  44753. }
  44754. declare module "babylonjs/Debug/axesViewer" {
  44755. import { Vector3 } from "babylonjs/Maths/math.vector";
  44756. import { Nullable } from "babylonjs/types";
  44757. import { Scene } from "babylonjs/scene";
  44758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44759. /**
  44760. * The Axes viewer will show 3 axes in a specific point in space
  44761. */
  44762. export class AxesViewer {
  44763. private _xAxis;
  44764. private _yAxis;
  44765. private _zAxis;
  44766. private _scaleLinesFactor;
  44767. private _instanced;
  44768. /**
  44769. * Gets the hosting scene
  44770. */
  44771. scene: Scene;
  44772. /**
  44773. * Gets or sets a number used to scale line length
  44774. */
  44775. scaleLines: number;
  44776. /** Gets the node hierarchy used to render x-axis */
  44777. readonly xAxis: TransformNode;
  44778. /** Gets the node hierarchy used to render y-axis */
  44779. readonly yAxis: TransformNode;
  44780. /** Gets the node hierarchy used to render z-axis */
  44781. readonly zAxis: TransformNode;
  44782. /**
  44783. * Creates a new AxesViewer
  44784. * @param scene defines the hosting scene
  44785. * @param scaleLines defines a number used to scale line length (1 by default)
  44786. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44787. * @param xAxis defines the node hierarchy used to render the x-axis
  44788. * @param yAxis defines the node hierarchy used to render the y-axis
  44789. * @param zAxis defines the node hierarchy used to render the z-axis
  44790. */
  44791. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44792. /**
  44793. * Force the viewer to update
  44794. * @param position defines the position of the viewer
  44795. * @param xaxis defines the x axis of the viewer
  44796. * @param yaxis defines the y axis of the viewer
  44797. * @param zaxis defines the z axis of the viewer
  44798. */
  44799. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44800. /**
  44801. * Creates an instance of this axes viewer.
  44802. * @returns a new axes viewer with instanced meshes
  44803. */
  44804. createInstance(): AxesViewer;
  44805. /** Releases resources */
  44806. dispose(): void;
  44807. private static _SetRenderingGroupId;
  44808. }
  44809. }
  44810. declare module "babylonjs/Debug/boneAxesViewer" {
  44811. import { Nullable } from "babylonjs/types";
  44812. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44813. import { Vector3 } from "babylonjs/Maths/math.vector";
  44814. import { Mesh } from "babylonjs/Meshes/mesh";
  44815. import { Bone } from "babylonjs/Bones/bone";
  44816. import { Scene } from "babylonjs/scene";
  44817. /**
  44818. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44819. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44820. */
  44821. export class BoneAxesViewer extends AxesViewer {
  44822. /**
  44823. * Gets or sets the target mesh where to display the axes viewer
  44824. */
  44825. mesh: Nullable<Mesh>;
  44826. /**
  44827. * Gets or sets the target bone where to display the axes viewer
  44828. */
  44829. bone: Nullable<Bone>;
  44830. /** Gets current position */
  44831. pos: Vector3;
  44832. /** Gets direction of X axis */
  44833. xaxis: Vector3;
  44834. /** Gets direction of Y axis */
  44835. yaxis: Vector3;
  44836. /** Gets direction of Z axis */
  44837. zaxis: Vector3;
  44838. /**
  44839. * Creates a new BoneAxesViewer
  44840. * @param scene defines the hosting scene
  44841. * @param bone defines the target bone
  44842. * @param mesh defines the target mesh
  44843. * @param scaleLines defines a scaling factor for line length (1 by default)
  44844. */
  44845. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44846. /**
  44847. * Force the viewer to update
  44848. */
  44849. update(): void;
  44850. /** Releases resources */
  44851. dispose(): void;
  44852. }
  44853. }
  44854. declare module "babylonjs/Debug/debugLayer" {
  44855. import { Scene } from "babylonjs/scene";
  44856. /**
  44857. * Interface used to define scene explorer extensibility option
  44858. */
  44859. export interface IExplorerExtensibilityOption {
  44860. /**
  44861. * Define the option label
  44862. */
  44863. label: string;
  44864. /**
  44865. * Defines the action to execute on click
  44866. */
  44867. action: (entity: any) => void;
  44868. }
  44869. /**
  44870. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44871. */
  44872. export interface IExplorerExtensibilityGroup {
  44873. /**
  44874. * Defines a predicate to test if a given type mut be extended
  44875. */
  44876. predicate: (entity: any) => boolean;
  44877. /**
  44878. * Gets the list of options added to a type
  44879. */
  44880. entries: IExplorerExtensibilityOption[];
  44881. }
  44882. /**
  44883. * Interface used to define the options to use to create the Inspector
  44884. */
  44885. export interface IInspectorOptions {
  44886. /**
  44887. * Display in overlay mode (default: false)
  44888. */
  44889. overlay?: boolean;
  44890. /**
  44891. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44892. */
  44893. globalRoot?: HTMLElement;
  44894. /**
  44895. * Display the Scene explorer
  44896. */
  44897. showExplorer?: boolean;
  44898. /**
  44899. * Display the property inspector
  44900. */
  44901. showInspector?: boolean;
  44902. /**
  44903. * Display in embed mode (both panes on the right)
  44904. */
  44905. embedMode?: boolean;
  44906. /**
  44907. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44908. */
  44909. handleResize?: boolean;
  44910. /**
  44911. * Allow the panes to popup (default: true)
  44912. */
  44913. enablePopup?: boolean;
  44914. /**
  44915. * Allow the panes to be closed by users (default: true)
  44916. */
  44917. enableClose?: boolean;
  44918. /**
  44919. * Optional list of extensibility entries
  44920. */
  44921. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44922. /**
  44923. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44924. */
  44925. inspectorURL?: string;
  44926. }
  44927. module "babylonjs/scene" {
  44928. interface Scene {
  44929. /**
  44930. * @hidden
  44931. * Backing field
  44932. */
  44933. _debugLayer: DebugLayer;
  44934. /**
  44935. * Gets the debug layer (aka Inspector) associated with the scene
  44936. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44937. */
  44938. debugLayer: DebugLayer;
  44939. }
  44940. }
  44941. /**
  44942. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44943. * what is happening in your scene
  44944. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44945. */
  44946. export class DebugLayer {
  44947. /**
  44948. * Define the url to get the inspector script from.
  44949. * By default it uses the babylonjs CDN.
  44950. * @ignoreNaming
  44951. */
  44952. static InspectorURL: string;
  44953. private _scene;
  44954. private BJSINSPECTOR;
  44955. private _onPropertyChangedObservable?;
  44956. /**
  44957. * Observable triggered when a property is changed through the inspector.
  44958. */
  44959. readonly onPropertyChangedObservable: any;
  44960. /**
  44961. * Instantiates a new debug layer.
  44962. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44963. * what is happening in your scene
  44964. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44965. * @param scene Defines the scene to inspect
  44966. */
  44967. constructor(scene: Scene);
  44968. /** Creates the inspector window. */
  44969. private _createInspector;
  44970. /**
  44971. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44972. * @param entity defines the entity to select
  44973. * @param lineContainerTitle defines the specific block to highlight
  44974. */
  44975. select(entity: any, lineContainerTitle?: string): void;
  44976. /** Get the inspector from bundle or global */
  44977. private _getGlobalInspector;
  44978. /**
  44979. * Get if the inspector is visible or not.
  44980. * @returns true if visible otherwise, false
  44981. */
  44982. isVisible(): boolean;
  44983. /**
  44984. * Hide the inspector and close its window.
  44985. */
  44986. hide(): void;
  44987. /**
  44988. * Launch the debugLayer.
  44989. * @param config Define the configuration of the inspector
  44990. * @return a promise fulfilled when the debug layer is visible
  44991. */
  44992. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44993. }
  44994. }
  44995. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44996. import { Nullable } from "babylonjs/types";
  44997. import { Scene } from "babylonjs/scene";
  44998. import { Vector4 } from "babylonjs/Maths/math.vector";
  44999. import { Color4 } from "babylonjs/Maths/math.color";
  45000. import { Mesh } from "babylonjs/Meshes/mesh";
  45001. /**
  45002. * Class containing static functions to help procedurally build meshes
  45003. */
  45004. export class BoxBuilder {
  45005. /**
  45006. * Creates a box mesh
  45007. * * The parameter `size` sets the size (float) of each box side (default 1)
  45008. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45009. * * 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)
  45010. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45014. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45015. * @param name defines the name of the mesh
  45016. * @param options defines the options used to create the mesh
  45017. * @param scene defines the hosting scene
  45018. * @returns the box mesh
  45019. */
  45020. static CreateBox(name: string, options: {
  45021. size?: number;
  45022. width?: number;
  45023. height?: number;
  45024. depth?: number;
  45025. faceUV?: Vector4[];
  45026. faceColors?: Color4[];
  45027. sideOrientation?: number;
  45028. frontUVs?: Vector4;
  45029. backUVs?: Vector4;
  45030. wrap?: boolean;
  45031. topBaseAt?: number;
  45032. bottomBaseAt?: number;
  45033. updatable?: boolean;
  45034. }, scene?: Nullable<Scene>): Mesh;
  45035. }
  45036. }
  45037. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45038. import { Vector4 } from "babylonjs/Maths/math.vector";
  45039. import { Mesh } from "babylonjs/Meshes/mesh";
  45040. import { Scene } from "babylonjs/scene";
  45041. import { Nullable } from "babylonjs/types";
  45042. /**
  45043. * Class containing static functions to help procedurally build meshes
  45044. */
  45045. export class SphereBuilder {
  45046. /**
  45047. * Creates a sphere mesh
  45048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45049. * * 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`)
  45050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45051. * * 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
  45052. * * 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)
  45053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45056. * @param name defines the name of the mesh
  45057. * @param options defines the options used to create the mesh
  45058. * @param scene defines the hosting scene
  45059. * @returns the sphere mesh
  45060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45061. */
  45062. static CreateSphere(name: string, options: {
  45063. segments?: number;
  45064. diameter?: number;
  45065. diameterX?: number;
  45066. diameterY?: number;
  45067. diameterZ?: number;
  45068. arc?: number;
  45069. slice?: number;
  45070. sideOrientation?: number;
  45071. frontUVs?: Vector4;
  45072. backUVs?: Vector4;
  45073. updatable?: boolean;
  45074. }, scene?: Nullable<Scene>): Mesh;
  45075. }
  45076. }
  45077. declare module "babylonjs/Debug/physicsViewer" {
  45078. import { Nullable } from "babylonjs/types";
  45079. import { Scene } from "babylonjs/scene";
  45080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45081. import { Mesh } from "babylonjs/Meshes/mesh";
  45082. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45083. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45084. /**
  45085. * Used to show the physics impostor around the specific mesh
  45086. */
  45087. export class PhysicsViewer {
  45088. /** @hidden */
  45089. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45090. /** @hidden */
  45091. protected _meshes: Array<Nullable<AbstractMesh>>;
  45092. /** @hidden */
  45093. protected _scene: Nullable<Scene>;
  45094. /** @hidden */
  45095. protected _numMeshes: number;
  45096. /** @hidden */
  45097. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45098. private _renderFunction;
  45099. private _utilityLayer;
  45100. private _debugBoxMesh;
  45101. private _debugSphereMesh;
  45102. private _debugCylinderMesh;
  45103. private _debugMaterial;
  45104. private _debugMeshMeshes;
  45105. /**
  45106. * Creates a new PhysicsViewer
  45107. * @param scene defines the hosting scene
  45108. */
  45109. constructor(scene: Scene);
  45110. /** @hidden */
  45111. protected _updateDebugMeshes(): void;
  45112. /**
  45113. * Renders a specified physic impostor
  45114. * @param impostor defines the impostor to render
  45115. * @param targetMesh defines the mesh represented by the impostor
  45116. * @returns the new debug mesh used to render the impostor
  45117. */
  45118. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45119. /**
  45120. * Hides a specified physic impostor
  45121. * @param impostor defines the impostor to hide
  45122. */
  45123. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45124. private _getDebugMaterial;
  45125. private _getDebugBoxMesh;
  45126. private _getDebugSphereMesh;
  45127. private _getDebugCylinderMesh;
  45128. private _getDebugMeshMesh;
  45129. private _getDebugMesh;
  45130. /** Releases all resources */
  45131. dispose(): void;
  45132. }
  45133. }
  45134. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45135. import { Vector3 } from "babylonjs/Maths/math.vector";
  45136. import { Color4 } from "babylonjs/Maths/math.color";
  45137. import { Nullable } from "babylonjs/types";
  45138. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45139. import { Scene } from "babylonjs/scene";
  45140. /**
  45141. * Class containing static functions to help procedurally build meshes
  45142. */
  45143. export class LinesBuilder {
  45144. /**
  45145. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45146. * * 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
  45147. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45148. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45149. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45150. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45151. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45152. * * 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
  45153. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45156. * @param name defines the name of the new line system
  45157. * @param options defines the options used to create the line system
  45158. * @param scene defines the hosting scene
  45159. * @returns a new line system mesh
  45160. */
  45161. static CreateLineSystem(name: string, options: {
  45162. lines: Vector3[][];
  45163. updatable?: boolean;
  45164. instance?: Nullable<LinesMesh>;
  45165. colors?: Nullable<Color4[][]>;
  45166. useVertexAlpha?: boolean;
  45167. }, scene: Nullable<Scene>): LinesMesh;
  45168. /**
  45169. * Creates a line mesh
  45170. * 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
  45171. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45172. * * The parameter `points` is an array successive Vector3
  45173. * * 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
  45174. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45175. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45176. * * When updating an instance, remember that only point positions can change, not the number of points
  45177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45179. * @param name defines the name of the new line system
  45180. * @param options defines the options used to create the line system
  45181. * @param scene defines the hosting scene
  45182. * @returns a new line mesh
  45183. */
  45184. static CreateLines(name: string, options: {
  45185. points: Vector3[];
  45186. updatable?: boolean;
  45187. instance?: Nullable<LinesMesh>;
  45188. colors?: Color4[];
  45189. useVertexAlpha?: boolean;
  45190. }, scene?: Nullable<Scene>): LinesMesh;
  45191. /**
  45192. * Creates a dashed line mesh
  45193. * * 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
  45194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45195. * * The parameter `points` is an array successive Vector3
  45196. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45197. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45198. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45199. * * 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
  45200. * * When updating an instance, remember that only point positions can change, not the number of points
  45201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45202. * @param name defines the name of the mesh
  45203. * @param options defines the options used to create the mesh
  45204. * @param scene defines the hosting scene
  45205. * @returns the dashed line mesh
  45206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45207. */
  45208. static CreateDashedLines(name: string, options: {
  45209. points: Vector3[];
  45210. dashSize?: number;
  45211. gapSize?: number;
  45212. dashNb?: number;
  45213. updatable?: boolean;
  45214. instance?: LinesMesh;
  45215. }, scene?: Nullable<Scene>): LinesMesh;
  45216. }
  45217. }
  45218. declare module "babylonjs/Debug/rayHelper" {
  45219. import { Nullable } from "babylonjs/types";
  45220. import { Ray } from "babylonjs/Culling/ray";
  45221. import { Vector3 } from "babylonjs/Maths/math.vector";
  45222. import { Color3 } from "babylonjs/Maths/math.color";
  45223. import { Scene } from "babylonjs/scene";
  45224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45225. import "babylonjs/Meshes/Builders/linesBuilder";
  45226. /**
  45227. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45228. * in order to better appreciate the issue one might have.
  45229. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45230. */
  45231. export class RayHelper {
  45232. /**
  45233. * Defines the ray we are currently tryin to visualize.
  45234. */
  45235. ray: Nullable<Ray>;
  45236. private _renderPoints;
  45237. private _renderLine;
  45238. private _renderFunction;
  45239. private _scene;
  45240. private _updateToMeshFunction;
  45241. private _attachedToMesh;
  45242. private _meshSpaceDirection;
  45243. private _meshSpaceOrigin;
  45244. /**
  45245. * Helper function to create a colored helper in a scene in one line.
  45246. * @param ray Defines the ray we are currently tryin to visualize
  45247. * @param scene Defines the scene the ray is used in
  45248. * @param color Defines the color we want to see the ray in
  45249. * @returns The newly created ray helper.
  45250. */
  45251. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45252. /**
  45253. * Instantiate a new ray helper.
  45254. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45255. * in order to better appreciate the issue one might have.
  45256. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45257. * @param ray Defines the ray we are currently tryin to visualize
  45258. */
  45259. constructor(ray: Ray);
  45260. /**
  45261. * Shows the ray we are willing to debug.
  45262. * @param scene Defines the scene the ray needs to be rendered in
  45263. * @param color Defines the color the ray needs to be rendered in
  45264. */
  45265. show(scene: Scene, color?: Color3): void;
  45266. /**
  45267. * Hides the ray we are debugging.
  45268. */
  45269. hide(): void;
  45270. private _render;
  45271. /**
  45272. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45273. * @param mesh Defines the mesh we want the helper attached to
  45274. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45275. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45276. * @param length Defines the length of the ray
  45277. */
  45278. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45279. /**
  45280. * Detach the ray helper from the mesh it has previously been attached to.
  45281. */
  45282. detachFromMesh(): void;
  45283. private _updateToMesh;
  45284. /**
  45285. * Dispose the helper and release its associated resources.
  45286. */
  45287. dispose(): void;
  45288. }
  45289. }
  45290. declare module "babylonjs/Debug/skeletonViewer" {
  45291. import { Color3 } from "babylonjs/Maths/math.color";
  45292. import { Scene } from "babylonjs/scene";
  45293. import { Nullable } from "babylonjs/types";
  45294. import { Skeleton } from "babylonjs/Bones/skeleton";
  45295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45296. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45297. /**
  45298. * Class used to render a debug view of a given skeleton
  45299. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45300. */
  45301. export class SkeletonViewer {
  45302. /** defines the skeleton to render */
  45303. skeleton: Skeleton;
  45304. /** defines the mesh attached to the skeleton */
  45305. mesh: AbstractMesh;
  45306. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45307. autoUpdateBonesMatrices: boolean;
  45308. /** defines the rendering group id to use with the viewer */
  45309. renderingGroupId: number;
  45310. /** Gets or sets the color used to render the skeleton */
  45311. color: Color3;
  45312. private _scene;
  45313. private _debugLines;
  45314. private _debugMesh;
  45315. private _isEnabled;
  45316. private _renderFunction;
  45317. private _utilityLayer;
  45318. /**
  45319. * Returns the mesh used to render the bones
  45320. */
  45321. readonly debugMesh: Nullable<LinesMesh>;
  45322. /**
  45323. * Creates a new SkeletonViewer
  45324. * @param skeleton defines the skeleton to render
  45325. * @param mesh defines the mesh attached to the skeleton
  45326. * @param scene defines the hosting scene
  45327. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45328. * @param renderingGroupId defines the rendering group id to use with the viewer
  45329. */
  45330. constructor(
  45331. /** defines the skeleton to render */
  45332. skeleton: Skeleton,
  45333. /** defines the mesh attached to the skeleton */
  45334. mesh: AbstractMesh, scene: Scene,
  45335. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45336. autoUpdateBonesMatrices?: boolean,
  45337. /** defines the rendering group id to use with the viewer */
  45338. renderingGroupId?: number);
  45339. /** Gets or sets a boolean indicating if the viewer is enabled */
  45340. isEnabled: boolean;
  45341. private _getBonePosition;
  45342. private _getLinesForBonesWithLength;
  45343. private _getLinesForBonesNoLength;
  45344. /** Update the viewer to sync with current skeleton state */
  45345. update(): void;
  45346. /** Release associated resources */
  45347. dispose(): void;
  45348. }
  45349. }
  45350. declare module "babylonjs/Debug/index" {
  45351. export * from "babylonjs/Debug/axesViewer";
  45352. export * from "babylonjs/Debug/boneAxesViewer";
  45353. export * from "babylonjs/Debug/debugLayer";
  45354. export * from "babylonjs/Debug/physicsViewer";
  45355. export * from "babylonjs/Debug/rayHelper";
  45356. export * from "babylonjs/Debug/skeletonViewer";
  45357. }
  45358. declare module "babylonjs/Engines/nullEngine" {
  45359. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45360. import { Scene } from "babylonjs/scene";
  45361. import { Engine } from "babylonjs/Engines/engine";
  45362. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45363. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45365. import { Effect } from "babylonjs/Materials/effect";
  45366. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45367. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45368. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45369. /**
  45370. * Options to create the null engine
  45371. */
  45372. export class NullEngineOptions {
  45373. /**
  45374. * Render width (Default: 512)
  45375. */
  45376. renderWidth: number;
  45377. /**
  45378. * Render height (Default: 256)
  45379. */
  45380. renderHeight: number;
  45381. /**
  45382. * Texture size (Default: 512)
  45383. */
  45384. textureSize: number;
  45385. /**
  45386. * If delta time between frames should be constant
  45387. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45388. */
  45389. deterministicLockstep: boolean;
  45390. /**
  45391. * Maximum about of steps between frames (Default: 4)
  45392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45393. */
  45394. lockstepMaxSteps: number;
  45395. }
  45396. /**
  45397. * The null engine class provides support for headless version of babylon.js.
  45398. * This can be used in server side scenario or for testing purposes
  45399. */
  45400. export class NullEngine extends Engine {
  45401. private _options;
  45402. /**
  45403. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45405. * @returns true if engine is in deterministic lock step mode
  45406. */
  45407. isDeterministicLockStep(): boolean;
  45408. /**
  45409. * Gets the max steps when engine is running in deterministic lock step
  45410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45411. * @returns the max steps
  45412. */
  45413. getLockstepMaxSteps(): number;
  45414. /**
  45415. * Gets the current hardware scaling level.
  45416. * By default the hardware scaling level is computed from the window device ratio.
  45417. * 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.
  45418. * @returns a number indicating the current hardware scaling level
  45419. */
  45420. getHardwareScalingLevel(): number;
  45421. constructor(options?: NullEngineOptions);
  45422. /**
  45423. * Creates a vertex buffer
  45424. * @param vertices the data for the vertex buffer
  45425. * @returns the new WebGL static buffer
  45426. */
  45427. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45428. /**
  45429. * Creates a new index buffer
  45430. * @param indices defines the content of the index buffer
  45431. * @param updatable defines if the index buffer must be updatable
  45432. * @returns a new webGL buffer
  45433. */
  45434. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45435. /**
  45436. * Clear the current render buffer or the current render target (if any is set up)
  45437. * @param color defines the color to use
  45438. * @param backBuffer defines if the back buffer must be cleared
  45439. * @param depth defines if the depth buffer must be cleared
  45440. * @param stencil defines if the stencil buffer must be cleared
  45441. */
  45442. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45443. /**
  45444. * Gets the current render width
  45445. * @param useScreen defines if screen size must be used (or the current render target if any)
  45446. * @returns a number defining the current render width
  45447. */
  45448. getRenderWidth(useScreen?: boolean): number;
  45449. /**
  45450. * Gets the current render height
  45451. * @param useScreen defines if screen size must be used (or the current render target if any)
  45452. * @returns a number defining the current render height
  45453. */
  45454. getRenderHeight(useScreen?: boolean): number;
  45455. /**
  45456. * Set the WebGL's viewport
  45457. * @param viewport defines the viewport element to be used
  45458. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45459. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45460. */
  45461. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45462. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45463. /**
  45464. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45465. * @param pipelineContext defines the pipeline context to use
  45466. * @param uniformsNames defines the list of uniform names
  45467. * @returns an array of webGL uniform locations
  45468. */
  45469. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45470. /**
  45471. * Gets the lsit of active attributes for a given webGL program
  45472. * @param pipelineContext defines the pipeline context to use
  45473. * @param attributesNames defines the list of attribute names to get
  45474. * @returns an array of indices indicating the offset of each attribute
  45475. */
  45476. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45477. /**
  45478. * Binds an effect to the webGL context
  45479. * @param effect defines the effect to bind
  45480. */
  45481. bindSamplers(effect: Effect): void;
  45482. /**
  45483. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45484. * @param effect defines the effect to activate
  45485. */
  45486. enableEffect(effect: Effect): void;
  45487. /**
  45488. * Set various states to the webGL context
  45489. * @param culling defines backface culling state
  45490. * @param zOffset defines the value to apply to zOffset (0 by default)
  45491. * @param force defines if states must be applied even if cache is up to date
  45492. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45493. */
  45494. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45495. /**
  45496. * Set the value of an uniform to an array of int32
  45497. * @param uniform defines the webGL uniform location where to store the value
  45498. * @param array defines the array of int32 to store
  45499. */
  45500. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45501. /**
  45502. * Set the value of an uniform to an array of int32 (stored as vec2)
  45503. * @param uniform defines the webGL uniform location where to store the value
  45504. * @param array defines the array of int32 to store
  45505. */
  45506. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45507. /**
  45508. * Set the value of an uniform to an array of int32 (stored as vec3)
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param array defines the array of int32 to store
  45511. */
  45512. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45513. /**
  45514. * Set the value of an uniform to an array of int32 (stored as vec4)
  45515. * @param uniform defines the webGL uniform location where to store the value
  45516. * @param array defines the array of int32 to store
  45517. */
  45518. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45519. /**
  45520. * Set the value of an uniform to an array of float32
  45521. * @param uniform defines the webGL uniform location where to store the value
  45522. * @param array defines the array of float32 to store
  45523. */
  45524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45525. /**
  45526. * Set the value of an uniform to an array of float32 (stored as vec2)
  45527. * @param uniform defines the webGL uniform location where to store the value
  45528. * @param array defines the array of float32 to store
  45529. */
  45530. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45531. /**
  45532. * Set the value of an uniform to an array of float32 (stored as vec3)
  45533. * @param uniform defines the webGL uniform location where to store the value
  45534. * @param array defines the array of float32 to store
  45535. */
  45536. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45537. /**
  45538. * Set the value of an uniform to an array of float32 (stored as vec4)
  45539. * @param uniform defines the webGL uniform location where to store the value
  45540. * @param array defines the array of float32 to store
  45541. */
  45542. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45543. /**
  45544. * Set the value of an uniform to an array of number
  45545. * @param uniform defines the webGL uniform location where to store the value
  45546. * @param array defines the array of number to store
  45547. */
  45548. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45549. /**
  45550. * Set the value of an uniform to an array of number (stored as vec2)
  45551. * @param uniform defines the webGL uniform location where to store the value
  45552. * @param array defines the array of number to store
  45553. */
  45554. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45555. /**
  45556. * Set the value of an uniform to an array of number (stored as vec3)
  45557. * @param uniform defines the webGL uniform location where to store the value
  45558. * @param array defines the array of number to store
  45559. */
  45560. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45561. /**
  45562. * Set the value of an uniform to an array of number (stored as vec4)
  45563. * @param uniform defines the webGL uniform location where to store the value
  45564. * @param array defines the array of number to store
  45565. */
  45566. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45567. /**
  45568. * Set the value of an uniform to an array of float32 (stored as matrices)
  45569. * @param uniform defines the webGL uniform location where to store the value
  45570. * @param matrices defines the array of float32 to store
  45571. */
  45572. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45573. /**
  45574. * Set the value of an uniform to a matrix (3x3)
  45575. * @param uniform defines the webGL uniform location where to store the value
  45576. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45577. */
  45578. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45579. /**
  45580. * Set the value of an uniform to a matrix (2x2)
  45581. * @param uniform defines the webGL uniform location where to store the value
  45582. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45583. */
  45584. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45585. /**
  45586. * Set the value of an uniform to a number (float)
  45587. * @param uniform defines the webGL uniform location where to store the value
  45588. * @param value defines the float number to store
  45589. */
  45590. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45591. /**
  45592. * Set the value of an uniform to a vec2
  45593. * @param uniform defines the webGL uniform location where to store the value
  45594. * @param x defines the 1st component of the value
  45595. * @param y defines the 2nd component of the value
  45596. */
  45597. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45598. /**
  45599. * Set the value of an uniform to a vec3
  45600. * @param uniform defines the webGL uniform location where to store the value
  45601. * @param x defines the 1st component of the value
  45602. * @param y defines the 2nd component of the value
  45603. * @param z defines the 3rd component of the value
  45604. */
  45605. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45606. /**
  45607. * Set the value of an uniform to a boolean
  45608. * @param uniform defines the webGL uniform location where to store the value
  45609. * @param bool defines the boolean to store
  45610. */
  45611. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45612. /**
  45613. * Set the value of an uniform to a vec4
  45614. * @param uniform defines the webGL uniform location where to store the value
  45615. * @param x defines the 1st component of the value
  45616. * @param y defines the 2nd component of the value
  45617. * @param z defines the 3rd component of the value
  45618. * @param w defines the 4th component of the value
  45619. */
  45620. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45621. /**
  45622. * Sets the current alpha mode
  45623. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45626. */
  45627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45628. /**
  45629. * Bind webGl buffers directly to the webGL context
  45630. * @param vertexBuffers defines the vertex buffer to bind
  45631. * @param indexBuffer defines the index buffer to bind
  45632. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45633. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45634. * @param effect defines the effect associated with the vertex buffer
  45635. */
  45636. bindBuffers(vertexBuffers: {
  45637. [key: string]: VertexBuffer;
  45638. }, indexBuffer: DataBuffer, effect: Effect): void;
  45639. /**
  45640. * Force the entire cache to be cleared
  45641. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45642. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45643. */
  45644. wipeCaches(bruteForce?: boolean): void;
  45645. /**
  45646. * Send a draw order
  45647. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45648. * @param indexStart defines the starting index
  45649. * @param indexCount defines the number of index to draw
  45650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45651. */
  45652. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45653. /**
  45654. * Draw a list of indexed primitives
  45655. * @param fillMode defines the primitive to use
  45656. * @param indexStart defines the starting index
  45657. * @param indexCount defines the number of index to draw
  45658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45659. */
  45660. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45661. /**
  45662. * Draw a list of unindexed primitives
  45663. * @param fillMode defines the primitive to use
  45664. * @param verticesStart defines the index of first vertex to draw
  45665. * @param verticesCount defines the count of vertices to draw
  45666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45667. */
  45668. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45669. /** @hidden */
  45670. _createTexture(): WebGLTexture;
  45671. /** @hidden */
  45672. _releaseTexture(texture: InternalTexture): void;
  45673. /**
  45674. * Usually called from Texture.ts.
  45675. * Passed information to create a WebGLTexture
  45676. * @param urlArg defines a value which contains one of the following:
  45677. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45678. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45679. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45681. * @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)
  45682. * @param scene needed for loading to the correct scene
  45683. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45684. * @param onLoad optional callback to be called upon successful completion
  45685. * @param onError optional callback to be called upon failure
  45686. * @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
  45687. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45688. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45689. * @param forcedExtension defines the extension to use to pick the right loader
  45690. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45691. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45692. */
  45693. 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;
  45694. /**
  45695. * Creates a new render target texture
  45696. * @param size defines the size of the texture
  45697. * @param options defines the options used to create the texture
  45698. * @returns a new render target texture stored in an InternalTexture
  45699. */
  45700. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45701. /**
  45702. * Update the sampling mode of a given texture
  45703. * @param samplingMode defines the required sampling mode
  45704. * @param texture defines the texture to update
  45705. */
  45706. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45707. /**
  45708. * Binds the frame buffer to the specified texture.
  45709. * @param texture The texture to render to or null for the default canvas
  45710. * @param faceIndex The face of the texture to render to in case of cube texture
  45711. * @param requiredWidth The width of the target to render to
  45712. * @param requiredHeight The height of the target to render to
  45713. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45714. * @param depthStencilTexture The depth stencil texture to use to render
  45715. * @param lodLevel defines le lod level to bind to the frame buffer
  45716. */
  45717. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45718. /**
  45719. * Unbind the current render target texture from the webGL context
  45720. * @param texture defines the render target texture to unbind
  45721. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45722. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45723. */
  45724. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45725. /**
  45726. * Creates a dynamic vertex buffer
  45727. * @param vertices the data for the dynamic vertex buffer
  45728. * @returns the new WebGL dynamic buffer
  45729. */
  45730. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45731. /**
  45732. * Update the content of a dynamic texture
  45733. * @param texture defines the texture to update
  45734. * @param canvas defines the canvas containing the source
  45735. * @param invertY defines if data must be stored with Y axis inverted
  45736. * @param premulAlpha defines if alpha is stored as premultiplied
  45737. * @param format defines the format of the data
  45738. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45739. */
  45740. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45741. /**
  45742. * Gets a boolean indicating if all created effects are ready
  45743. * @returns true if all effects are ready
  45744. */
  45745. areAllEffectsReady(): boolean;
  45746. /**
  45747. * @hidden
  45748. * Get the current error code of the webGL context
  45749. * @returns the error code
  45750. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45751. */
  45752. getError(): number;
  45753. /** @hidden */
  45754. _getUnpackAlignement(): number;
  45755. /** @hidden */
  45756. _unpackFlipY(value: boolean): void;
  45757. /**
  45758. * Update a dynamic index buffer
  45759. * @param indexBuffer defines the target index buffer
  45760. * @param indices defines the data to update
  45761. * @param offset defines the offset in the target index buffer where update should start
  45762. */
  45763. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45764. /**
  45765. * Updates a dynamic vertex buffer.
  45766. * @param vertexBuffer the vertex buffer to update
  45767. * @param vertices the data used to update the vertex buffer
  45768. * @param byteOffset the byte offset of the data (optional)
  45769. * @param byteLength the byte length of the data (optional)
  45770. */
  45771. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45772. /** @hidden */
  45773. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45774. /** @hidden */
  45775. _bindTexture(channel: number, texture: InternalTexture): void;
  45776. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45777. /**
  45778. * 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
  45779. */
  45780. releaseEffects(): void;
  45781. displayLoadingUI(): void;
  45782. hideLoadingUI(): void;
  45783. /** @hidden */
  45784. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45785. /** @hidden */
  45786. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45787. /** @hidden */
  45788. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45789. /** @hidden */
  45790. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45791. }
  45792. }
  45793. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45794. import { Nullable, int } from "babylonjs/types";
  45795. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45796. /** @hidden */
  45797. export class _OcclusionDataStorage {
  45798. /** @hidden */
  45799. occlusionInternalRetryCounter: number;
  45800. /** @hidden */
  45801. isOcclusionQueryInProgress: boolean;
  45802. /** @hidden */
  45803. isOccluded: boolean;
  45804. /** @hidden */
  45805. occlusionRetryCount: number;
  45806. /** @hidden */
  45807. occlusionType: number;
  45808. /** @hidden */
  45809. occlusionQueryAlgorithmType: number;
  45810. }
  45811. module "babylonjs/Engines/engine" {
  45812. interface Engine {
  45813. /**
  45814. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45815. * @return the new query
  45816. */
  45817. createQuery(): WebGLQuery;
  45818. /**
  45819. * Delete and release a webGL query
  45820. * @param query defines the query to delete
  45821. * @return the current engine
  45822. */
  45823. deleteQuery(query: WebGLQuery): Engine;
  45824. /**
  45825. * Check if a given query has resolved and got its value
  45826. * @param query defines the query to check
  45827. * @returns true if the query got its value
  45828. */
  45829. isQueryResultAvailable(query: WebGLQuery): boolean;
  45830. /**
  45831. * Gets the value of a given query
  45832. * @param query defines the query to check
  45833. * @returns the value of the query
  45834. */
  45835. getQueryResult(query: WebGLQuery): number;
  45836. /**
  45837. * Initiates an occlusion query
  45838. * @param algorithmType defines the algorithm to use
  45839. * @param query defines the query to use
  45840. * @returns the current engine
  45841. * @see http://doc.babylonjs.com/features/occlusionquery
  45842. */
  45843. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45844. /**
  45845. * Ends an occlusion query
  45846. * @see http://doc.babylonjs.com/features/occlusionquery
  45847. * @param algorithmType defines the algorithm to use
  45848. * @returns the current engine
  45849. */
  45850. endOcclusionQuery(algorithmType: number): Engine;
  45851. /**
  45852. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45853. * Please note that only one query can be issued at a time
  45854. * @returns a time token used to track the time span
  45855. */
  45856. startTimeQuery(): Nullable<_TimeToken>;
  45857. /**
  45858. * Ends a time query
  45859. * @param token defines the token used to measure the time span
  45860. * @returns the time spent (in ns)
  45861. */
  45862. endTimeQuery(token: _TimeToken): int;
  45863. /** @hidden */
  45864. _currentNonTimestampToken: Nullable<_TimeToken>;
  45865. /** @hidden */
  45866. _createTimeQuery(): WebGLQuery;
  45867. /** @hidden */
  45868. _deleteTimeQuery(query: WebGLQuery): void;
  45869. /** @hidden */
  45870. _getGlAlgorithmType(algorithmType: number): number;
  45871. /** @hidden */
  45872. _getTimeQueryResult(query: WebGLQuery): any;
  45873. /** @hidden */
  45874. _getTimeQueryAvailability(query: WebGLQuery): any;
  45875. }
  45876. }
  45877. module "babylonjs/Meshes/abstractMesh" {
  45878. interface AbstractMesh {
  45879. /**
  45880. * Backing filed
  45881. * @hidden
  45882. */
  45883. __occlusionDataStorage: _OcclusionDataStorage;
  45884. /**
  45885. * Access property
  45886. * @hidden
  45887. */
  45888. _occlusionDataStorage: _OcclusionDataStorage;
  45889. /**
  45890. * 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.
  45891. * The default value is -1 which means don't break the query and wait till the result
  45892. * @see http://doc.babylonjs.com/features/occlusionquery
  45893. */
  45894. occlusionRetryCount: number;
  45895. /**
  45896. * 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:
  45897. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45898. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45899. * * 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.
  45900. * @see http://doc.babylonjs.com/features/occlusionquery
  45901. */
  45902. occlusionType: number;
  45903. /**
  45904. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45905. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45906. * * 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.
  45907. * @see http://doc.babylonjs.com/features/occlusionquery
  45908. */
  45909. occlusionQueryAlgorithmType: number;
  45910. /**
  45911. * 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
  45912. * @see http://doc.babylonjs.com/features/occlusionquery
  45913. */
  45914. isOccluded: boolean;
  45915. /**
  45916. * Flag to check the progress status of the query
  45917. * @see http://doc.babylonjs.com/features/occlusionquery
  45918. */
  45919. isOcclusionQueryInProgress: boolean;
  45920. }
  45921. }
  45922. }
  45923. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45924. import { Nullable } from "babylonjs/types";
  45925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45926. /** @hidden */
  45927. export var _forceTransformFeedbackToBundle: boolean;
  45928. module "babylonjs/Engines/engine" {
  45929. interface Engine {
  45930. /**
  45931. * Creates a webGL transform feedback object
  45932. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45933. * @returns the webGL transform feedback object
  45934. */
  45935. createTransformFeedback(): WebGLTransformFeedback;
  45936. /**
  45937. * Delete a webGL transform feedback object
  45938. * @param value defines the webGL transform feedback object to delete
  45939. */
  45940. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45941. /**
  45942. * Bind a webGL transform feedback object to the webgl context
  45943. * @param value defines the webGL transform feedback object to bind
  45944. */
  45945. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45946. /**
  45947. * Begins a transform feedback operation
  45948. * @param usePoints defines if points or triangles must be used
  45949. */
  45950. beginTransformFeedback(usePoints: boolean): void;
  45951. /**
  45952. * Ends a transform feedback operation
  45953. */
  45954. endTransformFeedback(): void;
  45955. /**
  45956. * Specify the varyings to use with transform feedback
  45957. * @param program defines the associated webGL program
  45958. * @param value defines the list of strings representing the varying names
  45959. */
  45960. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45961. /**
  45962. * Bind a webGL buffer for a transform feedback operation
  45963. * @param value defines the webGL buffer to bind
  45964. */
  45965. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45966. }
  45967. }
  45968. }
  45969. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45970. import { Scene } from "babylonjs/scene";
  45971. import { Engine } from "babylonjs/Engines/engine";
  45972. import { Texture } from "babylonjs/Materials/Textures/texture";
  45973. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45974. import "babylonjs/Engines/Extensions/engine.multiRender";
  45975. /**
  45976. * Creation options of the multi render target texture.
  45977. */
  45978. export interface IMultiRenderTargetOptions {
  45979. /**
  45980. * Define if the texture needs to create mip maps after render.
  45981. */
  45982. generateMipMaps?: boolean;
  45983. /**
  45984. * Define the types of all the draw buffers we want to create
  45985. */
  45986. types?: number[];
  45987. /**
  45988. * Define the sampling modes of all the draw buffers we want to create
  45989. */
  45990. samplingModes?: number[];
  45991. /**
  45992. * Define if a depth buffer is required
  45993. */
  45994. generateDepthBuffer?: boolean;
  45995. /**
  45996. * Define if a stencil buffer is required
  45997. */
  45998. generateStencilBuffer?: boolean;
  45999. /**
  46000. * Define if a depth texture is required instead of a depth buffer
  46001. */
  46002. generateDepthTexture?: boolean;
  46003. /**
  46004. * Define the number of desired draw buffers
  46005. */
  46006. textureCount?: number;
  46007. /**
  46008. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46009. */
  46010. doNotChangeAspectRatio?: boolean;
  46011. /**
  46012. * Define the default type of the buffers we are creating
  46013. */
  46014. defaultType?: number;
  46015. }
  46016. /**
  46017. * A multi render target, like a render target provides the ability to render to a texture.
  46018. * Unlike the render target, it can render to several draw buffers in one draw.
  46019. * This is specially interesting in deferred rendering or for any effects requiring more than
  46020. * just one color from a single pass.
  46021. */
  46022. export class MultiRenderTarget extends RenderTargetTexture {
  46023. private _internalTextures;
  46024. private _textures;
  46025. private _multiRenderTargetOptions;
  46026. /**
  46027. * Get if draw buffers are currently supported by the used hardware and browser.
  46028. */
  46029. readonly isSupported: boolean;
  46030. /**
  46031. * Get the list of textures generated by the multi render target.
  46032. */
  46033. readonly textures: Texture[];
  46034. /**
  46035. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46036. */
  46037. readonly depthTexture: Texture;
  46038. /**
  46039. * Set the wrapping mode on U of all the textures we are rendering to.
  46040. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46041. */
  46042. wrapU: number;
  46043. /**
  46044. * Set the wrapping mode on V of all the textures we are rendering to.
  46045. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46046. */
  46047. wrapV: number;
  46048. /**
  46049. * Instantiate a new multi render target texture.
  46050. * A multi render target, like a render target provides the ability to render to a texture.
  46051. * Unlike the render target, it can render to several draw buffers in one draw.
  46052. * This is specially interesting in deferred rendering or for any effects requiring more than
  46053. * just one color from a single pass.
  46054. * @param name Define the name of the texture
  46055. * @param size Define the size of the buffers to render to
  46056. * @param count Define the number of target we are rendering into
  46057. * @param scene Define the scene the texture belongs to
  46058. * @param options Define the options used to create the multi render target
  46059. */
  46060. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46061. /** @hidden */
  46062. _rebuild(): void;
  46063. private _createInternalTextures;
  46064. private _createTextures;
  46065. /**
  46066. * Define the number of samples used if MSAA is enabled.
  46067. */
  46068. samples: number;
  46069. /**
  46070. * Resize all the textures in the multi render target.
  46071. * Be carrefull as it will recreate all the data in the new texture.
  46072. * @param size Define the new size
  46073. */
  46074. resize(size: any): void;
  46075. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46076. /**
  46077. * Dispose the render targets and their associated resources
  46078. */
  46079. dispose(): void;
  46080. /**
  46081. * Release all the underlying texture used as draw buffers.
  46082. */
  46083. releaseInternalTextures(): void;
  46084. }
  46085. }
  46086. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46087. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46088. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46089. import { Nullable } from "babylonjs/types";
  46090. module "babylonjs/Engines/thinEngine" {
  46091. interface ThinEngine {
  46092. /**
  46093. * Unbind a list of render target textures from the webGL context
  46094. * This is used only when drawBuffer extension or webGL2 are active
  46095. * @param textures defines the render target textures to unbind
  46096. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46097. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46098. */
  46099. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46100. /**
  46101. * Create a multi render target texture
  46102. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46103. * @param size defines the size of the texture
  46104. * @param options defines the creation options
  46105. * @returns the cube texture as an InternalTexture
  46106. */
  46107. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46108. /**
  46109. * Update the sample count for a given multiple render target texture
  46110. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46111. * @param textures defines the textures to update
  46112. * @param samples defines the sample count to set
  46113. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46114. */
  46115. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46116. }
  46117. }
  46118. }
  46119. declare module "babylonjs/Engines/Extensions/index" {
  46120. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46121. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46122. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46123. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46124. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46125. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46126. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46127. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46128. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46129. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46130. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46131. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46132. }
  46133. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46134. import { Nullable } from "babylonjs/types";
  46135. /**
  46136. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46137. */
  46138. export interface CubeMapInfo {
  46139. /**
  46140. * The pixel array for the front face.
  46141. * This is stored in format, left to right, up to down format.
  46142. */
  46143. front: Nullable<ArrayBufferView>;
  46144. /**
  46145. * The pixel array for the back face.
  46146. * This is stored in format, left to right, up to down format.
  46147. */
  46148. back: Nullable<ArrayBufferView>;
  46149. /**
  46150. * The pixel array for the left face.
  46151. * This is stored in format, left to right, up to down format.
  46152. */
  46153. left: Nullable<ArrayBufferView>;
  46154. /**
  46155. * The pixel array for the right face.
  46156. * This is stored in format, left to right, up to down format.
  46157. */
  46158. right: Nullable<ArrayBufferView>;
  46159. /**
  46160. * The pixel array for the up face.
  46161. * This is stored in format, left to right, up to down format.
  46162. */
  46163. up: Nullable<ArrayBufferView>;
  46164. /**
  46165. * The pixel array for the down face.
  46166. * This is stored in format, left to right, up to down format.
  46167. */
  46168. down: Nullable<ArrayBufferView>;
  46169. /**
  46170. * The size of the cubemap stored.
  46171. *
  46172. * Each faces will be size * size pixels.
  46173. */
  46174. size: number;
  46175. /**
  46176. * The format of the texture.
  46177. *
  46178. * RGBA, RGB.
  46179. */
  46180. format: number;
  46181. /**
  46182. * The type of the texture data.
  46183. *
  46184. * UNSIGNED_INT, FLOAT.
  46185. */
  46186. type: number;
  46187. /**
  46188. * Specifies whether the texture is in gamma space.
  46189. */
  46190. gammaSpace: boolean;
  46191. }
  46192. /**
  46193. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46194. */
  46195. export class PanoramaToCubeMapTools {
  46196. private static FACE_FRONT;
  46197. private static FACE_BACK;
  46198. private static FACE_RIGHT;
  46199. private static FACE_LEFT;
  46200. private static FACE_DOWN;
  46201. private static FACE_UP;
  46202. /**
  46203. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46204. *
  46205. * @param float32Array The source data.
  46206. * @param inputWidth The width of the input panorama.
  46207. * @param inputHeight The height of the input panorama.
  46208. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46209. * @return The cubemap data
  46210. */
  46211. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46212. private static CreateCubemapTexture;
  46213. private static CalcProjectionSpherical;
  46214. }
  46215. }
  46216. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46217. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46218. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46219. import { Nullable } from "babylonjs/types";
  46220. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46221. /**
  46222. * Helper class dealing with the extraction of spherical polynomial dataArray
  46223. * from a cube map.
  46224. */
  46225. export class CubeMapToSphericalPolynomialTools {
  46226. private static FileFaces;
  46227. /**
  46228. * Converts a texture to the according Spherical Polynomial data.
  46229. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46230. *
  46231. * @param texture The texture to extract the information from.
  46232. * @return The Spherical Polynomial data.
  46233. */
  46234. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46235. /**
  46236. * Converts a cubemap to the according Spherical Polynomial data.
  46237. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46238. *
  46239. * @param cubeInfo The Cube map to extract the information from.
  46240. * @return The Spherical Polynomial data.
  46241. */
  46242. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46243. }
  46244. }
  46245. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46246. import { Nullable } from "babylonjs/types";
  46247. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46248. module "babylonjs/Materials/Textures/baseTexture" {
  46249. interface BaseTexture {
  46250. /**
  46251. * Get the polynomial representation of the texture data.
  46252. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46253. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46254. */
  46255. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46256. }
  46257. }
  46258. }
  46259. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46260. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46261. /** @hidden */
  46262. export var rgbdEncodePixelShader: {
  46263. name: string;
  46264. shader: string;
  46265. };
  46266. }
  46267. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46269. /** @hidden */
  46270. export var rgbdDecodePixelShader: {
  46271. name: string;
  46272. shader: string;
  46273. };
  46274. }
  46275. declare module "babylonjs/Misc/environmentTextureTools" {
  46276. import { Nullable } from "babylonjs/types";
  46277. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46279. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46280. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46281. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46282. import "babylonjs/Shaders/rgbdEncode.fragment";
  46283. import "babylonjs/Shaders/rgbdDecode.fragment";
  46284. /**
  46285. * Raw texture data and descriptor sufficient for WebGL texture upload
  46286. */
  46287. export interface EnvironmentTextureInfo {
  46288. /**
  46289. * Version of the environment map
  46290. */
  46291. version: number;
  46292. /**
  46293. * Width of image
  46294. */
  46295. width: number;
  46296. /**
  46297. * Irradiance information stored in the file.
  46298. */
  46299. irradiance: any;
  46300. /**
  46301. * Specular information stored in the file.
  46302. */
  46303. specular: any;
  46304. }
  46305. /**
  46306. * Defines One Image in the file. It requires only the position in the file
  46307. * as well as the length.
  46308. */
  46309. interface BufferImageData {
  46310. /**
  46311. * Length of the image data.
  46312. */
  46313. length: number;
  46314. /**
  46315. * Position of the data from the null terminator delimiting the end of the JSON.
  46316. */
  46317. position: number;
  46318. }
  46319. /**
  46320. * Defines the specular data enclosed in the file.
  46321. * This corresponds to the version 1 of the data.
  46322. */
  46323. export interface EnvironmentTextureSpecularInfoV1 {
  46324. /**
  46325. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46326. */
  46327. specularDataPosition?: number;
  46328. /**
  46329. * This contains all the images data needed to reconstruct the cubemap.
  46330. */
  46331. mipmaps: Array<BufferImageData>;
  46332. /**
  46333. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46334. */
  46335. lodGenerationScale: number;
  46336. }
  46337. /**
  46338. * Sets of helpers addressing the serialization and deserialization of environment texture
  46339. * stored in a BabylonJS env file.
  46340. * Those files are usually stored as .env files.
  46341. */
  46342. export class EnvironmentTextureTools {
  46343. /**
  46344. * Magic number identifying the env file.
  46345. */
  46346. private static _MagicBytes;
  46347. /**
  46348. * Gets the environment info from an env file.
  46349. * @param data The array buffer containing the .env bytes.
  46350. * @returns the environment file info (the json header) if successfully parsed.
  46351. */
  46352. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46353. /**
  46354. * Creates an environment texture from a loaded cube texture.
  46355. * @param texture defines the cube texture to convert in env file
  46356. * @return a promise containing the environment data if succesfull.
  46357. */
  46358. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46359. /**
  46360. * Creates a JSON representation of the spherical data.
  46361. * @param texture defines the texture containing the polynomials
  46362. * @return the JSON representation of the spherical info
  46363. */
  46364. private static _CreateEnvTextureIrradiance;
  46365. /**
  46366. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46367. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46368. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46369. * @return the views described by info providing access to the underlying buffer
  46370. */
  46371. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46372. /**
  46373. * Uploads the texture info contained in the env file to the GPU.
  46374. * @param texture defines the internal texture to upload to
  46375. * @param arrayBuffer defines the buffer cotaining the data to load
  46376. * @param info defines the texture info retrieved through the GetEnvInfo method
  46377. * @returns a promise
  46378. */
  46379. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46380. private static _OnImageReadyAsync;
  46381. /**
  46382. * Uploads the levels of image data to the GPU.
  46383. * @param texture defines the internal texture to upload to
  46384. * @param imageData defines the array buffer views of image data [mipmap][face]
  46385. * @returns a promise
  46386. */
  46387. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46388. /**
  46389. * Uploads spherical polynomials information to the texture.
  46390. * @param texture defines the texture we are trying to upload the information to
  46391. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46392. */
  46393. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46394. /** @hidden */
  46395. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46396. }
  46397. }
  46398. declare module "babylonjs/Maths/math.vertexFormat" {
  46399. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46400. /**
  46401. * Contains position and normal vectors for a vertex
  46402. */
  46403. export class PositionNormalVertex {
  46404. /** the position of the vertex (defaut: 0,0,0) */
  46405. position: Vector3;
  46406. /** the normal of the vertex (defaut: 0,1,0) */
  46407. normal: Vector3;
  46408. /**
  46409. * Creates a PositionNormalVertex
  46410. * @param position the position of the vertex (defaut: 0,0,0)
  46411. * @param normal the normal of the vertex (defaut: 0,1,0)
  46412. */
  46413. constructor(
  46414. /** the position of the vertex (defaut: 0,0,0) */
  46415. position?: Vector3,
  46416. /** the normal of the vertex (defaut: 0,1,0) */
  46417. normal?: Vector3);
  46418. /**
  46419. * Clones the PositionNormalVertex
  46420. * @returns the cloned PositionNormalVertex
  46421. */
  46422. clone(): PositionNormalVertex;
  46423. }
  46424. /**
  46425. * Contains position, normal and uv vectors for a vertex
  46426. */
  46427. export class PositionNormalTextureVertex {
  46428. /** the position of the vertex (defaut: 0,0,0) */
  46429. position: Vector3;
  46430. /** the normal of the vertex (defaut: 0,1,0) */
  46431. normal: Vector3;
  46432. /** the uv of the vertex (default: 0,0) */
  46433. uv: Vector2;
  46434. /**
  46435. * Creates a PositionNormalTextureVertex
  46436. * @param position the position of the vertex (defaut: 0,0,0)
  46437. * @param normal the normal of the vertex (defaut: 0,1,0)
  46438. * @param uv the uv of the vertex (default: 0,0)
  46439. */
  46440. constructor(
  46441. /** the position of the vertex (defaut: 0,0,0) */
  46442. position?: Vector3,
  46443. /** the normal of the vertex (defaut: 0,1,0) */
  46444. normal?: Vector3,
  46445. /** the uv of the vertex (default: 0,0) */
  46446. uv?: Vector2);
  46447. /**
  46448. * Clones the PositionNormalTextureVertex
  46449. * @returns the cloned PositionNormalTextureVertex
  46450. */
  46451. clone(): PositionNormalTextureVertex;
  46452. }
  46453. }
  46454. declare module "babylonjs/Maths/math" {
  46455. export * from "babylonjs/Maths/math.axis";
  46456. export * from "babylonjs/Maths/math.color";
  46457. export * from "babylonjs/Maths/math.constants";
  46458. export * from "babylonjs/Maths/math.frustum";
  46459. export * from "babylonjs/Maths/math.path";
  46460. export * from "babylonjs/Maths/math.plane";
  46461. export * from "babylonjs/Maths/math.size";
  46462. export * from "babylonjs/Maths/math.vector";
  46463. export * from "babylonjs/Maths/math.vertexFormat";
  46464. export * from "babylonjs/Maths/math.viewport";
  46465. }
  46466. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46467. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46468. /** @hidden */
  46469. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46470. private _genericAttributeLocation;
  46471. private _varyingLocationCount;
  46472. private _varyingLocationMap;
  46473. private _replacements;
  46474. private _textureCount;
  46475. private _uniforms;
  46476. lineProcessor(line: string): string;
  46477. attributeProcessor(attribute: string): string;
  46478. varyingProcessor(varying: string, isFragment: boolean): string;
  46479. uniformProcessor(uniform: string): string;
  46480. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46481. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46482. }
  46483. }
  46484. declare module "babylonjs/Engines/nativeEngine" {
  46485. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46486. import { Engine } from "babylonjs/Engines/engine";
  46487. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46488. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46490. import { Effect } from "babylonjs/Materials/effect";
  46491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46492. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46493. import { Scene } from "babylonjs/scene";
  46494. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46495. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46496. /**
  46497. * Container for accessors for natively-stored mesh data buffers.
  46498. */
  46499. class NativeDataBuffer extends DataBuffer {
  46500. /**
  46501. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46502. */
  46503. nativeIndexBuffer?: any;
  46504. /**
  46505. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46506. */
  46507. nativeVertexBuffer?: any;
  46508. }
  46509. /** @hidden */
  46510. export class NativeEngine extends Engine {
  46511. private readonly _native;
  46512. getHardwareScalingLevel(): number;
  46513. constructor();
  46514. /**
  46515. * Can be used to override the current requestAnimationFrame requester.
  46516. * @hidden
  46517. */
  46518. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46519. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46520. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46521. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46522. recordVertexArrayObject(vertexBuffers: {
  46523. [key: string]: VertexBuffer;
  46524. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46525. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46526. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46527. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46528. /**
  46529. * Draw a list of indexed primitives
  46530. * @param fillMode defines the primitive to use
  46531. * @param indexStart defines the starting index
  46532. * @param indexCount defines the number of index to draw
  46533. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46534. */
  46535. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46536. /**
  46537. * Draw a list of unindexed primitives
  46538. * @param fillMode defines the primitive to use
  46539. * @param verticesStart defines the index of first vertex to draw
  46540. * @param verticesCount defines the count of vertices to draw
  46541. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46542. */
  46543. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46544. createPipelineContext(): IPipelineContext;
  46545. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46546. /** @hidden */
  46547. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46548. /** @hidden */
  46549. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46550. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46551. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46552. protected _setProgram(program: WebGLProgram): void;
  46553. _releaseEffect(effect: Effect): void;
  46554. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46555. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46556. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46557. bindSamplers(effect: Effect): void;
  46558. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46559. getRenderWidth(useScreen?: boolean): number;
  46560. getRenderHeight(useScreen?: boolean): number;
  46561. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46562. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46563. /**
  46564. * Set the z offset to apply to current rendering
  46565. * @param value defines the offset to apply
  46566. */
  46567. setZOffset(value: number): void;
  46568. /**
  46569. * Gets the current value of the zOffset
  46570. * @returns the current zOffset state
  46571. */
  46572. getZOffset(): number;
  46573. /**
  46574. * Enable or disable depth buffering
  46575. * @param enable defines the state to set
  46576. */
  46577. setDepthBuffer(enable: boolean): void;
  46578. /**
  46579. * Gets a boolean indicating if depth writing is enabled
  46580. * @returns the current depth writing state
  46581. */
  46582. getDepthWrite(): boolean;
  46583. /**
  46584. * Enable or disable depth writing
  46585. * @param enable defines the state to set
  46586. */
  46587. setDepthWrite(enable: boolean): void;
  46588. /**
  46589. * Enable or disable color writing
  46590. * @param enable defines the state to set
  46591. */
  46592. setColorWrite(enable: boolean): void;
  46593. /**
  46594. * Gets a boolean indicating if color writing is enabled
  46595. * @returns the current color writing state
  46596. */
  46597. getColorWrite(): boolean;
  46598. /**
  46599. * Sets alpha constants used by some alpha blending modes
  46600. * @param r defines the red component
  46601. * @param g defines the green component
  46602. * @param b defines the blue component
  46603. * @param a defines the alpha component
  46604. */
  46605. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46606. /**
  46607. * Sets the current alpha mode
  46608. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46609. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46610. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46611. */
  46612. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46613. /**
  46614. * Gets the current alpha mode
  46615. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46616. * @returns the current alpha mode
  46617. */
  46618. getAlphaMode(): number;
  46619. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46620. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46621. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46622. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46623. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46624. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46625. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46626. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46627. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46628. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46629. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46630. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46631. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46632. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46633. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46634. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46635. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46636. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46637. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46638. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46639. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46640. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46641. wipeCaches(bruteForce?: boolean): void;
  46642. _createTexture(): WebGLTexture;
  46643. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46644. /**
  46645. * Usually called from BABYLON.Texture.ts.
  46646. * Passed information to create a WebGLTexture
  46647. * @param urlArg defines a value which contains one of the following:
  46648. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46649. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46650. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46651. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46652. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46653. * @param scene needed for loading to the correct scene
  46654. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46655. * @param onLoad optional callback to be called upon successful completion
  46656. * @param onError optional callback to be called upon failure
  46657. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46658. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46659. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46660. * @param forcedExtension defines the extension to use to pick the right loader
  46661. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46662. */
  46663. 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;
  46664. /**
  46665. * Creates a cube texture
  46666. * @param rootUrl defines the url where the files to load is located
  46667. * @param scene defines the current scene
  46668. * @param files defines the list of files to load (1 per face)
  46669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46670. * @param onLoad defines an optional callback raised when the texture is loaded
  46671. * @param onError defines an optional callback raised if there is an issue to load the texture
  46672. * @param format defines the format of the data
  46673. * @param forcedExtension defines the extension to use to pick the right loader
  46674. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46675. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46676. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46677. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46678. * @returns the cube texture as an InternalTexture
  46679. */
  46680. 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;
  46681. private _getSamplingFilter;
  46682. private static _GetNativeTextureFormat;
  46683. createRenderTargetTexture(size: number | {
  46684. width: number;
  46685. height: number;
  46686. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46687. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46688. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46689. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46690. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46691. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46692. /**
  46693. * Updates a dynamic vertex buffer.
  46694. * @param vertexBuffer the vertex buffer to update
  46695. * @param data the data used to update the vertex buffer
  46696. * @param byteOffset the byte offset of the data (optional)
  46697. * @param byteLength the byte length of the data (optional)
  46698. */
  46699. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46700. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46701. private _updateAnisotropicLevel;
  46702. private _getAddressMode;
  46703. /** @hidden */
  46704. _bindTexture(channel: number, texture: InternalTexture): void;
  46705. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46706. releaseEffects(): void;
  46707. /** @hidden */
  46708. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46709. /** @hidden */
  46710. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46711. /** @hidden */
  46712. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46713. /** @hidden */
  46714. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46715. }
  46716. }
  46717. declare module "babylonjs/Engines/index" {
  46718. export * from "babylonjs/Engines/constants";
  46719. export * from "babylonjs/Engines/engineCapabilities";
  46720. export * from "babylonjs/Engines/instancingAttributeInfo";
  46721. export * from "babylonjs/Engines/thinEngine";
  46722. export * from "babylonjs/Engines/engine";
  46723. export * from "babylonjs/Engines/engineStore";
  46724. export * from "babylonjs/Engines/nullEngine";
  46725. export * from "babylonjs/Engines/Extensions/index";
  46726. export * from "babylonjs/Engines/IPipelineContext";
  46727. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46728. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46729. export * from "babylonjs/Engines/nativeEngine";
  46730. }
  46731. declare module "babylonjs/Events/clipboardEvents" {
  46732. /**
  46733. * Gather the list of clipboard event types as constants.
  46734. */
  46735. export class ClipboardEventTypes {
  46736. /**
  46737. * The clipboard event is fired when a copy command is active (pressed).
  46738. */
  46739. static readonly COPY: number;
  46740. /**
  46741. * The clipboard event is fired when a cut command is active (pressed).
  46742. */
  46743. static readonly CUT: number;
  46744. /**
  46745. * The clipboard event is fired when a paste command is active (pressed).
  46746. */
  46747. static readonly PASTE: number;
  46748. }
  46749. /**
  46750. * This class is used to store clipboard related info for the onClipboardObservable event.
  46751. */
  46752. export class ClipboardInfo {
  46753. /**
  46754. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46755. */
  46756. type: number;
  46757. /**
  46758. * Defines the related dom event
  46759. */
  46760. event: ClipboardEvent;
  46761. /**
  46762. *Creates an instance of ClipboardInfo.
  46763. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46764. * @param event Defines the related dom event
  46765. */
  46766. constructor(
  46767. /**
  46768. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46769. */
  46770. type: number,
  46771. /**
  46772. * Defines the related dom event
  46773. */
  46774. event: ClipboardEvent);
  46775. /**
  46776. * Get the clipboard event's type from the keycode.
  46777. * @param keyCode Defines the keyCode for the current keyboard event.
  46778. * @return {number}
  46779. */
  46780. static GetTypeFromCharacter(keyCode: number): number;
  46781. }
  46782. }
  46783. declare module "babylonjs/Events/index" {
  46784. export * from "babylonjs/Events/keyboardEvents";
  46785. export * from "babylonjs/Events/pointerEvents";
  46786. export * from "babylonjs/Events/clipboardEvents";
  46787. }
  46788. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46789. import { Scene } from "babylonjs/scene";
  46790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46791. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46792. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46793. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46794. /**
  46795. * Google Daydream controller
  46796. */
  46797. export class DaydreamController extends WebVRController {
  46798. /**
  46799. * Base Url for the controller model.
  46800. */
  46801. static MODEL_BASE_URL: string;
  46802. /**
  46803. * File name for the controller model.
  46804. */
  46805. static MODEL_FILENAME: string;
  46806. /**
  46807. * Gamepad Id prefix used to identify Daydream Controller.
  46808. */
  46809. static readonly GAMEPAD_ID_PREFIX: string;
  46810. /**
  46811. * Creates a new DaydreamController from a gamepad
  46812. * @param vrGamepad the gamepad that the controller should be created from
  46813. */
  46814. constructor(vrGamepad: any);
  46815. /**
  46816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46817. * @param scene scene in which to add meshes
  46818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46819. */
  46820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46821. /**
  46822. * Called once for each button that changed state since the last frame
  46823. * @param buttonIdx Which button index changed
  46824. * @param state New state of the button
  46825. * @param changes Which properties on the state changed since last frame
  46826. */
  46827. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46828. }
  46829. }
  46830. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46831. import { Scene } from "babylonjs/scene";
  46832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46833. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46834. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46835. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46836. /**
  46837. * Gear VR Controller
  46838. */
  46839. export class GearVRController extends WebVRController {
  46840. /**
  46841. * Base Url for the controller model.
  46842. */
  46843. static MODEL_BASE_URL: string;
  46844. /**
  46845. * File name for the controller model.
  46846. */
  46847. static MODEL_FILENAME: string;
  46848. /**
  46849. * Gamepad Id prefix used to identify this controller.
  46850. */
  46851. static readonly GAMEPAD_ID_PREFIX: string;
  46852. private readonly _buttonIndexToObservableNameMap;
  46853. /**
  46854. * Creates a new GearVRController from a gamepad
  46855. * @param vrGamepad the gamepad that the controller should be created from
  46856. */
  46857. constructor(vrGamepad: any);
  46858. /**
  46859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46860. * @param scene scene in which to add meshes
  46861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46862. */
  46863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46864. /**
  46865. * Called once for each button that changed state since the last frame
  46866. * @param buttonIdx Which button index changed
  46867. * @param state New state of the button
  46868. * @param changes Which properties on the state changed since last frame
  46869. */
  46870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46871. }
  46872. }
  46873. declare module "babylonjs/Gamepads/Controllers/index" {
  46874. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46875. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46876. export * from "babylonjs/Gamepads/Controllers/genericController";
  46877. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46878. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46879. export * from "babylonjs/Gamepads/Controllers/viveController";
  46880. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46881. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46882. }
  46883. declare module "babylonjs/Gamepads/index" {
  46884. export * from "babylonjs/Gamepads/Controllers/index";
  46885. export * from "babylonjs/Gamepads/gamepad";
  46886. export * from "babylonjs/Gamepads/gamepadManager";
  46887. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46888. export * from "babylonjs/Gamepads/xboxGamepad";
  46889. export * from "babylonjs/Gamepads/dualShockGamepad";
  46890. }
  46891. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46892. import { Scene } from "babylonjs/scene";
  46893. import { Vector4 } from "babylonjs/Maths/math.vector";
  46894. import { Color4 } from "babylonjs/Maths/math.color";
  46895. import { Mesh } from "babylonjs/Meshes/mesh";
  46896. import { Nullable } from "babylonjs/types";
  46897. /**
  46898. * Class containing static functions to help procedurally build meshes
  46899. */
  46900. export class PolyhedronBuilder {
  46901. /**
  46902. * Creates a polyhedron mesh
  46903. * * 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
  46904. * * The parameter `size` (positive float, default 1) sets the polygon size
  46905. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46906. * * 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`
  46907. * * 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
  46908. * * 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)`)
  46909. * * 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
  46910. * * 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
  46911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46914. * @param name defines the name of the mesh
  46915. * @param options defines the options used to create the mesh
  46916. * @param scene defines the hosting scene
  46917. * @returns the polyhedron mesh
  46918. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46919. */
  46920. static CreatePolyhedron(name: string, options: {
  46921. type?: number;
  46922. size?: number;
  46923. sizeX?: number;
  46924. sizeY?: number;
  46925. sizeZ?: number;
  46926. custom?: any;
  46927. faceUV?: Vector4[];
  46928. faceColors?: Color4[];
  46929. flat?: boolean;
  46930. updatable?: boolean;
  46931. sideOrientation?: number;
  46932. frontUVs?: Vector4;
  46933. backUVs?: Vector4;
  46934. }, scene?: Nullable<Scene>): Mesh;
  46935. }
  46936. }
  46937. declare module "babylonjs/Gizmos/scaleGizmo" {
  46938. import { Observable } from "babylonjs/Misc/observable";
  46939. import { Nullable } from "babylonjs/types";
  46940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46941. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46942. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46943. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46944. /**
  46945. * Gizmo that enables scaling a mesh along 3 axis
  46946. */
  46947. export class ScaleGizmo extends Gizmo {
  46948. /**
  46949. * Internal gizmo used for interactions on the x axis
  46950. */
  46951. xGizmo: AxisScaleGizmo;
  46952. /**
  46953. * Internal gizmo used for interactions on the y axis
  46954. */
  46955. yGizmo: AxisScaleGizmo;
  46956. /**
  46957. * Internal gizmo used for interactions on the z axis
  46958. */
  46959. zGizmo: AxisScaleGizmo;
  46960. /**
  46961. * Internal gizmo used to scale all axis equally
  46962. */
  46963. uniformScaleGizmo: AxisScaleGizmo;
  46964. private _meshAttached;
  46965. private _updateGizmoRotationToMatchAttachedMesh;
  46966. private _snapDistance;
  46967. private _scaleRatio;
  46968. private _uniformScalingMesh;
  46969. private _octahedron;
  46970. /** Fires an event when any of it's sub gizmos are dragged */
  46971. onDragStartObservable: Observable<unknown>;
  46972. /** Fires an event when any of it's sub gizmos are released from dragging */
  46973. onDragEndObservable: Observable<unknown>;
  46974. attachedMesh: Nullable<AbstractMesh>;
  46975. /**
  46976. * Creates a ScaleGizmo
  46977. * @param gizmoLayer The utility layer the gizmo will be added to
  46978. */
  46979. constructor(gizmoLayer?: UtilityLayerRenderer);
  46980. updateGizmoRotationToMatchAttachedMesh: boolean;
  46981. /**
  46982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46983. */
  46984. snapDistance: number;
  46985. /**
  46986. * Ratio for the scale of the gizmo (Default: 1)
  46987. */
  46988. scaleRatio: number;
  46989. /**
  46990. * Disposes of the gizmo
  46991. */
  46992. dispose(): void;
  46993. }
  46994. }
  46995. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46996. import { Observable } from "babylonjs/Misc/observable";
  46997. import { Nullable } from "babylonjs/types";
  46998. import { Vector3 } from "babylonjs/Maths/math.vector";
  46999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47000. import { Mesh } from "babylonjs/Meshes/mesh";
  47001. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47002. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47003. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47004. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47005. import { Color3 } from "babylonjs/Maths/math.color";
  47006. /**
  47007. * Single axis scale gizmo
  47008. */
  47009. export class AxisScaleGizmo extends Gizmo {
  47010. /**
  47011. * Drag behavior responsible for the gizmos dragging interactions
  47012. */
  47013. dragBehavior: PointerDragBehavior;
  47014. private _pointerObserver;
  47015. /**
  47016. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47017. */
  47018. snapDistance: number;
  47019. /**
  47020. * Event that fires each time the gizmo snaps to a new location.
  47021. * * snapDistance is the the change in distance
  47022. */
  47023. onSnapObservable: Observable<{
  47024. snapDistance: number;
  47025. }>;
  47026. /**
  47027. * If the scaling operation should be done on all axis (default: false)
  47028. */
  47029. uniformScaling: boolean;
  47030. private _isEnabled;
  47031. private _parent;
  47032. private _arrow;
  47033. private _coloredMaterial;
  47034. private _hoverMaterial;
  47035. /**
  47036. * Creates an AxisScaleGizmo
  47037. * @param gizmoLayer The utility layer the gizmo will be added to
  47038. * @param dragAxis The axis which the gizmo will be able to scale on
  47039. * @param color The color of the gizmo
  47040. */
  47041. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47043. /**
  47044. * If the gizmo is enabled
  47045. */
  47046. isEnabled: boolean;
  47047. /**
  47048. * Disposes of the gizmo
  47049. */
  47050. dispose(): void;
  47051. /**
  47052. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47053. * @param mesh The mesh to replace the default mesh of the gizmo
  47054. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47055. */
  47056. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47057. }
  47058. }
  47059. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47060. import { Observable } from "babylonjs/Misc/observable";
  47061. import { Nullable } from "babylonjs/types";
  47062. import { Vector3 } from "babylonjs/Maths/math.vector";
  47063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47064. import { Mesh } from "babylonjs/Meshes/mesh";
  47065. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47066. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47067. import { Color3 } from "babylonjs/Maths/math.color";
  47068. import "babylonjs/Meshes/Builders/boxBuilder";
  47069. /**
  47070. * Bounding box gizmo
  47071. */
  47072. export class BoundingBoxGizmo extends Gizmo {
  47073. private _lineBoundingBox;
  47074. private _rotateSpheresParent;
  47075. private _scaleBoxesParent;
  47076. private _boundingDimensions;
  47077. private _renderObserver;
  47078. private _pointerObserver;
  47079. private _scaleDragSpeed;
  47080. private _tmpQuaternion;
  47081. private _tmpVector;
  47082. private _tmpRotationMatrix;
  47083. /**
  47084. * 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)
  47085. */
  47086. ignoreChildren: boolean;
  47087. /**
  47088. * 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)
  47089. */
  47090. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47091. /**
  47092. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47093. */
  47094. rotationSphereSize: number;
  47095. /**
  47096. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47097. */
  47098. scaleBoxSize: number;
  47099. /**
  47100. * 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)
  47101. */
  47102. fixedDragMeshScreenSize: boolean;
  47103. /**
  47104. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47105. */
  47106. fixedDragMeshScreenSizeDistanceFactor: number;
  47107. /**
  47108. * Fired when a rotation sphere or scale box is dragged
  47109. */
  47110. onDragStartObservable: Observable<{}>;
  47111. /**
  47112. * Fired when a scale box is dragged
  47113. */
  47114. onScaleBoxDragObservable: Observable<{}>;
  47115. /**
  47116. * Fired when a scale box drag is ended
  47117. */
  47118. onScaleBoxDragEndObservable: Observable<{}>;
  47119. /**
  47120. * Fired when a rotation sphere is dragged
  47121. */
  47122. onRotationSphereDragObservable: Observable<{}>;
  47123. /**
  47124. * Fired when a rotation sphere drag is ended
  47125. */
  47126. onRotationSphereDragEndObservable: Observable<{}>;
  47127. /**
  47128. * 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)
  47129. */
  47130. scalePivot: Nullable<Vector3>;
  47131. /**
  47132. * Mesh used as a pivot to rotate the attached mesh
  47133. */
  47134. private _anchorMesh;
  47135. private _existingMeshScale;
  47136. private _dragMesh;
  47137. private pointerDragBehavior;
  47138. private coloredMaterial;
  47139. private hoverColoredMaterial;
  47140. /**
  47141. * Sets the color of the bounding box gizmo
  47142. * @param color the color to set
  47143. */
  47144. setColor(color: Color3): void;
  47145. /**
  47146. * Creates an BoundingBoxGizmo
  47147. * @param gizmoLayer The utility layer the gizmo will be added to
  47148. * @param color The color of the gizmo
  47149. */
  47150. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47152. private _selectNode;
  47153. /**
  47154. * Updates the bounding box information for the Gizmo
  47155. */
  47156. updateBoundingBox(): void;
  47157. private _updateRotationSpheres;
  47158. private _updateScaleBoxes;
  47159. /**
  47160. * Enables rotation on the specified axis and disables rotation on the others
  47161. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47162. */
  47163. setEnabledRotationAxis(axis: string): void;
  47164. /**
  47165. * Enables/disables scaling
  47166. * @param enable if scaling should be enabled
  47167. */
  47168. setEnabledScaling(enable: boolean): void;
  47169. private _updateDummy;
  47170. /**
  47171. * Enables a pointer drag behavior on the bounding box of the gizmo
  47172. */
  47173. enableDragBehavior(): void;
  47174. /**
  47175. * Disposes of the gizmo
  47176. */
  47177. dispose(): void;
  47178. /**
  47179. * 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)
  47180. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47181. * @returns the bounding box mesh with the passed in mesh as a child
  47182. */
  47183. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47184. /**
  47185. * CustomMeshes are not supported by this gizmo
  47186. * @param mesh The mesh to replace the default mesh of the gizmo
  47187. */
  47188. setCustomMesh(mesh: Mesh): void;
  47189. }
  47190. }
  47191. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47192. import { Observable } from "babylonjs/Misc/observable";
  47193. import { Nullable } from "babylonjs/types";
  47194. import { Vector3 } from "babylonjs/Maths/math.vector";
  47195. import { Color3 } from "babylonjs/Maths/math.color";
  47196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47197. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47198. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47200. import "babylonjs/Meshes/Builders/linesBuilder";
  47201. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47202. /**
  47203. * Single plane rotation gizmo
  47204. */
  47205. export class PlaneRotationGizmo extends Gizmo {
  47206. /**
  47207. * Drag behavior responsible for the gizmos dragging interactions
  47208. */
  47209. dragBehavior: PointerDragBehavior;
  47210. private _pointerObserver;
  47211. /**
  47212. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47213. */
  47214. snapDistance: number;
  47215. /**
  47216. * Event that fires each time the gizmo snaps to a new location.
  47217. * * snapDistance is the the change in distance
  47218. */
  47219. onSnapObservable: Observable<{
  47220. snapDistance: number;
  47221. }>;
  47222. private _isEnabled;
  47223. private _parent;
  47224. /**
  47225. * Creates a PlaneRotationGizmo
  47226. * @param gizmoLayer The utility layer the gizmo will be added to
  47227. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47228. * @param color The color of the gizmo
  47229. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47230. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47231. */
  47232. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47234. /**
  47235. * If the gizmo is enabled
  47236. */
  47237. isEnabled: boolean;
  47238. /**
  47239. * Disposes of the gizmo
  47240. */
  47241. dispose(): void;
  47242. }
  47243. }
  47244. declare module "babylonjs/Gizmos/rotationGizmo" {
  47245. import { Observable } from "babylonjs/Misc/observable";
  47246. import { Nullable } from "babylonjs/types";
  47247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47248. import { Mesh } from "babylonjs/Meshes/mesh";
  47249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47250. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47252. /**
  47253. * Gizmo that enables rotating a mesh along 3 axis
  47254. */
  47255. export class RotationGizmo extends Gizmo {
  47256. /**
  47257. * Internal gizmo used for interactions on the x axis
  47258. */
  47259. xGizmo: PlaneRotationGizmo;
  47260. /**
  47261. * Internal gizmo used for interactions on the y axis
  47262. */
  47263. yGizmo: PlaneRotationGizmo;
  47264. /**
  47265. * Internal gizmo used for interactions on the z axis
  47266. */
  47267. zGizmo: PlaneRotationGizmo;
  47268. /** Fires an event when any of it's sub gizmos are dragged */
  47269. onDragStartObservable: Observable<unknown>;
  47270. /** Fires an event when any of it's sub gizmos are released from dragging */
  47271. onDragEndObservable: Observable<unknown>;
  47272. private _meshAttached;
  47273. attachedMesh: Nullable<AbstractMesh>;
  47274. /**
  47275. * Creates a RotationGizmo
  47276. * @param gizmoLayer The utility layer the gizmo will be added to
  47277. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47278. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47279. */
  47280. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47281. updateGizmoRotationToMatchAttachedMesh: boolean;
  47282. /**
  47283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47284. */
  47285. snapDistance: number;
  47286. /**
  47287. * Ratio for the scale of the gizmo (Default: 1)
  47288. */
  47289. scaleRatio: number;
  47290. /**
  47291. * Disposes of the gizmo
  47292. */
  47293. dispose(): void;
  47294. /**
  47295. * CustomMeshes are not supported by this gizmo
  47296. * @param mesh The mesh to replace the default mesh of the gizmo
  47297. */
  47298. setCustomMesh(mesh: Mesh): void;
  47299. }
  47300. }
  47301. declare module "babylonjs/Gizmos/gizmoManager" {
  47302. import { Observable } from "babylonjs/Misc/observable";
  47303. import { Nullable } from "babylonjs/types";
  47304. import { Scene, IDisposable } from "babylonjs/scene";
  47305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47306. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47307. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47308. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47309. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47310. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47311. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47312. /**
  47313. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47314. */
  47315. export class GizmoManager implements IDisposable {
  47316. private scene;
  47317. /**
  47318. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47319. */
  47320. gizmos: {
  47321. positionGizmo: Nullable<PositionGizmo>;
  47322. rotationGizmo: Nullable<RotationGizmo>;
  47323. scaleGizmo: Nullable<ScaleGizmo>;
  47324. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47325. };
  47326. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47327. clearGizmoOnEmptyPointerEvent: boolean;
  47328. /** Fires an event when the manager is attached to a mesh */
  47329. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47330. private _gizmosEnabled;
  47331. private _pointerObserver;
  47332. private _attachedMesh;
  47333. private _boundingBoxColor;
  47334. private _defaultUtilityLayer;
  47335. private _defaultKeepDepthUtilityLayer;
  47336. /**
  47337. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47338. */
  47339. boundingBoxDragBehavior: SixDofDragBehavior;
  47340. /**
  47341. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47342. */
  47343. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47344. /**
  47345. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47346. */
  47347. usePointerToAttachGizmos: boolean;
  47348. /**
  47349. * Utility layer that the bounding box gizmo belongs to
  47350. */
  47351. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47352. /**
  47353. * Utility layer that all gizmos besides bounding box belong to
  47354. */
  47355. readonly utilityLayer: UtilityLayerRenderer;
  47356. /**
  47357. * Instatiates a gizmo manager
  47358. * @param scene the scene to overlay the gizmos on top of
  47359. */
  47360. constructor(scene: Scene);
  47361. /**
  47362. * Attaches a set of gizmos to the specified mesh
  47363. * @param mesh The mesh the gizmo's should be attached to
  47364. */
  47365. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47366. /**
  47367. * If the position gizmo is enabled
  47368. */
  47369. positionGizmoEnabled: boolean;
  47370. /**
  47371. * If the rotation gizmo is enabled
  47372. */
  47373. rotationGizmoEnabled: boolean;
  47374. /**
  47375. * If the scale gizmo is enabled
  47376. */
  47377. scaleGizmoEnabled: boolean;
  47378. /**
  47379. * If the boundingBox gizmo is enabled
  47380. */
  47381. boundingBoxGizmoEnabled: boolean;
  47382. /**
  47383. * Disposes of the gizmo manager
  47384. */
  47385. dispose(): void;
  47386. }
  47387. }
  47388. declare module "babylonjs/Lights/directionalLight" {
  47389. import { Camera } from "babylonjs/Cameras/camera";
  47390. import { Scene } from "babylonjs/scene";
  47391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47393. import { Light } from "babylonjs/Lights/light";
  47394. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47395. import { Effect } from "babylonjs/Materials/effect";
  47396. /**
  47397. * A directional light is defined by a direction (what a surprise!).
  47398. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47399. * 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.
  47400. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47401. */
  47402. export class DirectionalLight extends ShadowLight {
  47403. private _shadowFrustumSize;
  47404. /**
  47405. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47406. */
  47407. /**
  47408. * Specifies a fix frustum size for the shadow generation.
  47409. */
  47410. shadowFrustumSize: number;
  47411. private _shadowOrthoScale;
  47412. /**
  47413. * Gets the shadow projection scale against the optimal computed one.
  47414. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47415. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47416. */
  47417. /**
  47418. * Sets the shadow projection scale against the optimal computed one.
  47419. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47420. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47421. */
  47422. shadowOrthoScale: number;
  47423. /**
  47424. * Automatically compute the projection matrix to best fit (including all the casters)
  47425. * on each frame.
  47426. */
  47427. autoUpdateExtends: boolean;
  47428. private _orthoLeft;
  47429. private _orthoRight;
  47430. private _orthoTop;
  47431. private _orthoBottom;
  47432. /**
  47433. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47434. * The directional light is emitted from everywhere in the given direction.
  47435. * It can cast shadows.
  47436. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47437. * @param name The friendly name of the light
  47438. * @param direction The direction of the light
  47439. * @param scene The scene the light belongs to
  47440. */
  47441. constructor(name: string, direction: Vector3, scene: Scene);
  47442. /**
  47443. * Returns the string "DirectionalLight".
  47444. * @return The class name
  47445. */
  47446. getClassName(): string;
  47447. /**
  47448. * Returns the integer 1.
  47449. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47450. */
  47451. getTypeID(): number;
  47452. /**
  47453. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47454. * Returns the DirectionalLight Shadow projection matrix.
  47455. */
  47456. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47457. /**
  47458. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47459. * Returns the DirectionalLight Shadow projection matrix.
  47460. */
  47461. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47462. /**
  47463. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47464. * Returns the DirectionalLight Shadow projection matrix.
  47465. */
  47466. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47467. protected _buildUniformLayout(): void;
  47468. /**
  47469. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47470. * @param effect The effect to update
  47471. * @param lightIndex The index of the light in the effect to update
  47472. * @returns The directional light
  47473. */
  47474. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47475. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47476. /**
  47477. * Gets the minZ used for shadow according to both the scene and the light.
  47478. *
  47479. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47480. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47481. * @param activeCamera The camera we are returning the min for
  47482. * @returns the depth min z
  47483. */
  47484. getDepthMinZ(activeCamera: Camera): number;
  47485. /**
  47486. * Gets the maxZ used for shadow according to both the scene and the light.
  47487. *
  47488. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47489. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47490. * @param activeCamera The camera we are returning the max for
  47491. * @returns the depth max z
  47492. */
  47493. getDepthMaxZ(activeCamera: Camera): number;
  47494. /**
  47495. * Prepares the list of defines specific to the light type.
  47496. * @param defines the list of defines
  47497. * @param lightIndex defines the index of the light for the effect
  47498. */
  47499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47500. }
  47501. }
  47502. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47503. import { Mesh } from "babylonjs/Meshes/mesh";
  47504. /**
  47505. * Class containing static functions to help procedurally build meshes
  47506. */
  47507. export class HemisphereBuilder {
  47508. /**
  47509. * Creates a hemisphere mesh
  47510. * @param name defines the name of the mesh
  47511. * @param options defines the options used to create the mesh
  47512. * @param scene defines the hosting scene
  47513. * @returns the hemisphere mesh
  47514. */
  47515. static CreateHemisphere(name: string, options: {
  47516. segments?: number;
  47517. diameter?: number;
  47518. sideOrientation?: number;
  47519. }, scene: any): Mesh;
  47520. }
  47521. }
  47522. declare module "babylonjs/Lights/spotLight" {
  47523. import { Nullable } from "babylonjs/types";
  47524. import { Scene } from "babylonjs/scene";
  47525. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47527. import { Effect } from "babylonjs/Materials/effect";
  47528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47529. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47530. /**
  47531. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47532. * These values define a cone of light starting from the position, emitting toward the direction.
  47533. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47534. * and the exponent defines the speed of the decay of the light with distance (reach).
  47535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47536. */
  47537. export class SpotLight extends ShadowLight {
  47538. private _angle;
  47539. private _innerAngle;
  47540. private _cosHalfAngle;
  47541. private _lightAngleScale;
  47542. private _lightAngleOffset;
  47543. /**
  47544. * Gets the cone angle of the spot light in Radians.
  47545. */
  47546. /**
  47547. * Sets the cone angle of the spot light in Radians.
  47548. */
  47549. angle: number;
  47550. /**
  47551. * Only used in gltf falloff mode, this defines the angle where
  47552. * the directional falloff will start before cutting at angle which could be seen
  47553. * as outer angle.
  47554. */
  47555. /**
  47556. * Only used in gltf falloff mode, this defines the angle where
  47557. * the directional falloff will start before cutting at angle which could be seen
  47558. * as outer angle.
  47559. */
  47560. innerAngle: number;
  47561. private _shadowAngleScale;
  47562. /**
  47563. * Allows scaling the angle of the light for shadow generation only.
  47564. */
  47565. /**
  47566. * Allows scaling the angle of the light for shadow generation only.
  47567. */
  47568. shadowAngleScale: number;
  47569. /**
  47570. * The light decay speed with the distance from the emission spot.
  47571. */
  47572. exponent: number;
  47573. private _projectionTextureMatrix;
  47574. /**
  47575. * Allows reading the projecton texture
  47576. */
  47577. readonly projectionTextureMatrix: Matrix;
  47578. protected _projectionTextureLightNear: number;
  47579. /**
  47580. * Gets the near clip of the Spotlight for texture projection.
  47581. */
  47582. /**
  47583. * Sets the near clip of the Spotlight for texture projection.
  47584. */
  47585. projectionTextureLightNear: number;
  47586. protected _projectionTextureLightFar: number;
  47587. /**
  47588. * Gets the far clip of the Spotlight for texture projection.
  47589. */
  47590. /**
  47591. * Sets the far clip of the Spotlight for texture projection.
  47592. */
  47593. projectionTextureLightFar: number;
  47594. protected _projectionTextureUpDirection: Vector3;
  47595. /**
  47596. * Gets the Up vector of the Spotlight for texture projection.
  47597. */
  47598. /**
  47599. * Sets the Up vector of the Spotlight for texture projection.
  47600. */
  47601. projectionTextureUpDirection: Vector3;
  47602. private _projectionTexture;
  47603. /**
  47604. * Gets the projection texture of the light.
  47605. */
  47606. /**
  47607. * Sets the projection texture of the light.
  47608. */
  47609. projectionTexture: Nullable<BaseTexture>;
  47610. private _projectionTextureViewLightDirty;
  47611. private _projectionTextureProjectionLightDirty;
  47612. private _projectionTextureDirty;
  47613. private _projectionTextureViewTargetVector;
  47614. private _projectionTextureViewLightMatrix;
  47615. private _projectionTextureProjectionLightMatrix;
  47616. private _projectionTextureScalingMatrix;
  47617. /**
  47618. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47619. * It can cast shadows.
  47620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47621. * @param name The light friendly name
  47622. * @param position The position of the spot light in the scene
  47623. * @param direction The direction of the light in the scene
  47624. * @param angle The cone angle of the light in Radians
  47625. * @param exponent The light decay speed with the distance from the emission spot
  47626. * @param scene The scene the lights belongs to
  47627. */
  47628. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47629. /**
  47630. * Returns the string "SpotLight".
  47631. * @returns the class name
  47632. */
  47633. getClassName(): string;
  47634. /**
  47635. * Returns the integer 2.
  47636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47637. */
  47638. getTypeID(): number;
  47639. /**
  47640. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47641. */
  47642. protected _setDirection(value: Vector3): void;
  47643. /**
  47644. * Overrides the position setter to recompute the projection texture view light Matrix.
  47645. */
  47646. protected _setPosition(value: Vector3): void;
  47647. /**
  47648. * 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.
  47649. * Returns the SpotLight.
  47650. */
  47651. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47652. protected _computeProjectionTextureViewLightMatrix(): void;
  47653. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47654. /**
  47655. * Main function for light texture projection matrix computing.
  47656. */
  47657. protected _computeProjectionTextureMatrix(): void;
  47658. protected _buildUniformLayout(): void;
  47659. private _computeAngleValues;
  47660. /**
  47661. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47662. * @param effect The effect to update
  47663. * @param lightIndex The index of the light in the effect to update
  47664. * @returns The spot light
  47665. */
  47666. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47667. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47668. /**
  47669. * Disposes the light and the associated resources.
  47670. */
  47671. dispose(): void;
  47672. /**
  47673. * Prepares the list of defines specific to the light type.
  47674. * @param defines the list of defines
  47675. * @param lightIndex defines the index of the light for the effect
  47676. */
  47677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47678. }
  47679. }
  47680. declare module "babylonjs/Gizmos/lightGizmo" {
  47681. import { Nullable } from "babylonjs/types";
  47682. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47683. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47684. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47685. import { Light } from "babylonjs/Lights/light";
  47686. /**
  47687. * Gizmo that enables viewing a light
  47688. */
  47689. export class LightGizmo extends Gizmo {
  47690. private _lightMesh;
  47691. private _material;
  47692. private cachedPosition;
  47693. private cachedForward;
  47694. /**
  47695. * Creates a LightGizmo
  47696. * @param gizmoLayer The utility layer the gizmo will be added to
  47697. */
  47698. constructor(gizmoLayer?: UtilityLayerRenderer);
  47699. private _light;
  47700. /**
  47701. * The light that the gizmo is attached to
  47702. */
  47703. light: Nullable<Light>;
  47704. /**
  47705. * Gets the material used to render the light gizmo
  47706. */
  47707. readonly material: StandardMaterial;
  47708. /**
  47709. * @hidden
  47710. * Updates the gizmo to match the attached mesh's position/rotation
  47711. */
  47712. protected _update(): void;
  47713. private static _Scale;
  47714. /**
  47715. * Creates the lines for a light mesh
  47716. */
  47717. private static _createLightLines;
  47718. /**
  47719. * Disposes of the light gizmo
  47720. */
  47721. dispose(): void;
  47722. private static _CreateHemisphericLightMesh;
  47723. private static _CreatePointLightMesh;
  47724. private static _CreateSpotLightMesh;
  47725. private static _CreateDirectionalLightMesh;
  47726. }
  47727. }
  47728. declare module "babylonjs/Gizmos/index" {
  47729. export * from "babylonjs/Gizmos/axisDragGizmo";
  47730. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47731. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47732. export * from "babylonjs/Gizmos/gizmo";
  47733. export * from "babylonjs/Gizmos/gizmoManager";
  47734. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47735. export * from "babylonjs/Gizmos/positionGizmo";
  47736. export * from "babylonjs/Gizmos/rotationGizmo";
  47737. export * from "babylonjs/Gizmos/scaleGizmo";
  47738. export * from "babylonjs/Gizmos/lightGizmo";
  47739. export * from "babylonjs/Gizmos/planeDragGizmo";
  47740. }
  47741. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47742. /** @hidden */
  47743. export var backgroundFragmentDeclaration: {
  47744. name: string;
  47745. shader: string;
  47746. };
  47747. }
  47748. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47749. /** @hidden */
  47750. export var backgroundUboDeclaration: {
  47751. name: string;
  47752. shader: string;
  47753. };
  47754. }
  47755. declare module "babylonjs/Shaders/background.fragment" {
  47756. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47757. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47758. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47759. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47760. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47761. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47762. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47763. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47764. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47765. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47766. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47767. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47768. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47769. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47770. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47771. /** @hidden */
  47772. export var backgroundPixelShader: {
  47773. name: string;
  47774. shader: string;
  47775. };
  47776. }
  47777. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47778. /** @hidden */
  47779. export var backgroundVertexDeclaration: {
  47780. name: string;
  47781. shader: string;
  47782. };
  47783. }
  47784. declare module "babylonjs/Shaders/background.vertex" {
  47785. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47786. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47787. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47788. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47789. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47791. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47792. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47793. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47794. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47795. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47796. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47797. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47798. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47799. /** @hidden */
  47800. export var backgroundVertexShader: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47806. import { Nullable, int, float } from "babylonjs/types";
  47807. import { Scene } from "babylonjs/scene";
  47808. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47811. import { Mesh } from "babylonjs/Meshes/mesh";
  47812. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47813. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47814. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47816. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47817. import { Color3 } from "babylonjs/Maths/math.color";
  47818. import "babylonjs/Shaders/background.fragment";
  47819. import "babylonjs/Shaders/background.vertex";
  47820. /**
  47821. * Background material used to create an efficient environement around your scene.
  47822. */
  47823. export class BackgroundMaterial extends PushMaterial {
  47824. /**
  47825. * Standard reflectance value at parallel view angle.
  47826. */
  47827. static StandardReflectance0: number;
  47828. /**
  47829. * Standard reflectance value at grazing angle.
  47830. */
  47831. static StandardReflectance90: number;
  47832. protected _primaryColor: Color3;
  47833. /**
  47834. * Key light Color (multiply against the environement texture)
  47835. */
  47836. primaryColor: Color3;
  47837. protected __perceptualColor: Nullable<Color3>;
  47838. /**
  47839. * Experimental Internal Use Only.
  47840. *
  47841. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47842. * This acts as a helper to set the primary color to a more "human friendly" value.
  47843. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47844. * output color as close as possible from the chosen value.
  47845. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47846. * part of lighting setup.)
  47847. */
  47848. _perceptualColor: Nullable<Color3>;
  47849. protected _primaryColorShadowLevel: float;
  47850. /**
  47851. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47852. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47853. */
  47854. primaryColorShadowLevel: float;
  47855. protected _primaryColorHighlightLevel: float;
  47856. /**
  47857. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47858. * The primary color is used at the level chosen to define what the white area would look.
  47859. */
  47860. primaryColorHighlightLevel: float;
  47861. protected _reflectionTexture: Nullable<BaseTexture>;
  47862. /**
  47863. * Reflection Texture used in the material.
  47864. * Should be author in a specific way for the best result (refer to the documentation).
  47865. */
  47866. reflectionTexture: Nullable<BaseTexture>;
  47867. protected _reflectionBlur: float;
  47868. /**
  47869. * Reflection Texture level of blur.
  47870. *
  47871. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47872. * texture twice.
  47873. */
  47874. reflectionBlur: float;
  47875. protected _diffuseTexture: Nullable<BaseTexture>;
  47876. /**
  47877. * Diffuse Texture used in the material.
  47878. * Should be author in a specific way for the best result (refer to the documentation).
  47879. */
  47880. diffuseTexture: Nullable<BaseTexture>;
  47881. protected _shadowLights: Nullable<IShadowLight[]>;
  47882. /**
  47883. * Specify the list of lights casting shadow on the material.
  47884. * All scene shadow lights will be included if null.
  47885. */
  47886. shadowLights: Nullable<IShadowLight[]>;
  47887. protected _shadowLevel: float;
  47888. /**
  47889. * Helps adjusting the shadow to a softer level if required.
  47890. * 0 means black shadows and 1 means no shadows.
  47891. */
  47892. shadowLevel: float;
  47893. protected _sceneCenter: Vector3;
  47894. /**
  47895. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47896. * It is usually zero but might be interesting to modify according to your setup.
  47897. */
  47898. sceneCenter: Vector3;
  47899. protected _opacityFresnel: boolean;
  47900. /**
  47901. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47902. * This helps ensuring a nice transition when the camera goes under the ground.
  47903. */
  47904. opacityFresnel: boolean;
  47905. protected _reflectionFresnel: boolean;
  47906. /**
  47907. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47908. * This helps adding a mirror texture on the ground.
  47909. */
  47910. reflectionFresnel: boolean;
  47911. protected _reflectionFalloffDistance: number;
  47912. /**
  47913. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47914. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47915. */
  47916. reflectionFalloffDistance: number;
  47917. protected _reflectionAmount: number;
  47918. /**
  47919. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47920. */
  47921. reflectionAmount: number;
  47922. protected _reflectionReflectance0: number;
  47923. /**
  47924. * This specifies the weight of the reflection at grazing angle.
  47925. */
  47926. reflectionReflectance0: number;
  47927. protected _reflectionReflectance90: number;
  47928. /**
  47929. * This specifies the weight of the reflection at a perpendicular point of view.
  47930. */
  47931. reflectionReflectance90: number;
  47932. /**
  47933. * Sets the reflection reflectance fresnel values according to the default standard
  47934. * empirically know to work well :-)
  47935. */
  47936. reflectionStandardFresnelWeight: number;
  47937. protected _useRGBColor: boolean;
  47938. /**
  47939. * Helps to directly use the maps channels instead of their level.
  47940. */
  47941. useRGBColor: boolean;
  47942. protected _enableNoise: boolean;
  47943. /**
  47944. * This helps reducing the banding effect that could occur on the background.
  47945. */
  47946. enableNoise: boolean;
  47947. /**
  47948. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47949. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47950. * Recommended to be keep at 1.0 except for special cases.
  47951. */
  47952. fovMultiplier: number;
  47953. private _fovMultiplier;
  47954. /**
  47955. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47956. */
  47957. useEquirectangularFOV: boolean;
  47958. private _maxSimultaneousLights;
  47959. /**
  47960. * Number of Simultaneous lights allowed on the material.
  47961. */
  47962. maxSimultaneousLights: int;
  47963. /**
  47964. * Default configuration related to image processing available in the Background Material.
  47965. */
  47966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47967. /**
  47968. * Keep track of the image processing observer to allow dispose and replace.
  47969. */
  47970. private _imageProcessingObserver;
  47971. /**
  47972. * Attaches a new image processing configuration to the PBR Material.
  47973. * @param configuration (if null the scene configuration will be use)
  47974. */
  47975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47976. /**
  47977. * Gets the image processing configuration used either in this material.
  47978. */
  47979. /**
  47980. * Sets the Default image processing configuration used either in the this material.
  47981. *
  47982. * If sets to null, the scene one is in use.
  47983. */
  47984. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47985. /**
  47986. * Gets wether the color curves effect is enabled.
  47987. */
  47988. /**
  47989. * Sets wether the color curves effect is enabled.
  47990. */
  47991. cameraColorCurvesEnabled: boolean;
  47992. /**
  47993. * Gets wether the color grading effect is enabled.
  47994. */
  47995. /**
  47996. * Gets wether the color grading effect is enabled.
  47997. */
  47998. cameraColorGradingEnabled: boolean;
  47999. /**
  48000. * Gets wether tonemapping is enabled or not.
  48001. */
  48002. /**
  48003. * Sets wether tonemapping is enabled or not
  48004. */
  48005. cameraToneMappingEnabled: boolean;
  48006. /**
  48007. * The camera exposure used on this material.
  48008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48009. * This corresponds to a photographic exposure.
  48010. */
  48011. /**
  48012. * The camera exposure used on this material.
  48013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48014. * This corresponds to a photographic exposure.
  48015. */
  48016. cameraExposure: float;
  48017. /**
  48018. * Gets The camera contrast used on this material.
  48019. */
  48020. /**
  48021. * Sets The camera contrast used on this material.
  48022. */
  48023. cameraContrast: float;
  48024. /**
  48025. * Gets the Color Grading 2D Lookup Texture.
  48026. */
  48027. /**
  48028. * Sets the Color Grading 2D Lookup Texture.
  48029. */
  48030. cameraColorGradingTexture: Nullable<BaseTexture>;
  48031. /**
  48032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48034. * 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;
  48035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48036. */
  48037. /**
  48038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48040. * 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;
  48041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48042. */
  48043. cameraColorCurves: Nullable<ColorCurves>;
  48044. /**
  48045. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48046. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48047. */
  48048. switchToBGR: boolean;
  48049. private _renderTargets;
  48050. private _reflectionControls;
  48051. private _white;
  48052. private _primaryShadowColor;
  48053. private _primaryHighlightColor;
  48054. /**
  48055. * Instantiates a Background Material in the given scene
  48056. * @param name The friendly name of the material
  48057. * @param scene The scene to add the material to
  48058. */
  48059. constructor(name: string, scene: Scene);
  48060. /**
  48061. * Gets a boolean indicating that current material needs to register RTT
  48062. */
  48063. readonly hasRenderTargetTextures: boolean;
  48064. /**
  48065. * The entire material has been created in order to prevent overdraw.
  48066. * @returns false
  48067. */
  48068. needAlphaTesting(): boolean;
  48069. /**
  48070. * The entire material has been created in order to prevent overdraw.
  48071. * @returns true if blending is enable
  48072. */
  48073. needAlphaBlending(): boolean;
  48074. /**
  48075. * Checks wether the material is ready to be rendered for a given mesh.
  48076. * @param mesh The mesh to render
  48077. * @param subMesh The submesh to check against
  48078. * @param useInstances Specify wether or not the material is used with instances
  48079. * @returns true if all the dependencies are ready (Textures, Effects...)
  48080. */
  48081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48082. /**
  48083. * Compute the primary color according to the chosen perceptual color.
  48084. */
  48085. private _computePrimaryColorFromPerceptualColor;
  48086. /**
  48087. * Compute the highlights and shadow colors according to their chosen levels.
  48088. */
  48089. private _computePrimaryColors;
  48090. /**
  48091. * Build the uniform buffer used in the material.
  48092. */
  48093. buildUniformLayout(): void;
  48094. /**
  48095. * Unbind the material.
  48096. */
  48097. unbind(): void;
  48098. /**
  48099. * Bind only the world matrix to the material.
  48100. * @param world The world matrix to bind.
  48101. */
  48102. bindOnlyWorldMatrix(world: Matrix): void;
  48103. /**
  48104. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48105. * @param world The world matrix to bind.
  48106. * @param subMesh The submesh to bind for.
  48107. */
  48108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48109. /**
  48110. * Checks to see if a texture is used in the material.
  48111. * @param texture - Base texture to use.
  48112. * @returns - Boolean specifying if a texture is used in the material.
  48113. */
  48114. hasTexture(texture: BaseTexture): boolean;
  48115. /**
  48116. * Dispose the material.
  48117. * @param forceDisposeEffect Force disposal of the associated effect.
  48118. * @param forceDisposeTextures Force disposal of the associated textures.
  48119. */
  48120. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48121. /**
  48122. * Clones the material.
  48123. * @param name The cloned name.
  48124. * @returns The cloned material.
  48125. */
  48126. clone(name: string): BackgroundMaterial;
  48127. /**
  48128. * Serializes the current material to its JSON representation.
  48129. * @returns The JSON representation.
  48130. */
  48131. serialize(): any;
  48132. /**
  48133. * Gets the class name of the material
  48134. * @returns "BackgroundMaterial"
  48135. */
  48136. getClassName(): string;
  48137. /**
  48138. * Parse a JSON input to create back a background material.
  48139. * @param source The JSON data to parse
  48140. * @param scene The scene to create the parsed material in
  48141. * @param rootUrl The root url of the assets the material depends upon
  48142. * @returns the instantiated BackgroundMaterial.
  48143. */
  48144. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48145. }
  48146. }
  48147. declare module "babylonjs/Helpers/environmentHelper" {
  48148. import { Observable } from "babylonjs/Misc/observable";
  48149. import { Nullable } from "babylonjs/types";
  48150. import { Scene } from "babylonjs/scene";
  48151. import { Vector3 } from "babylonjs/Maths/math.vector";
  48152. import { Color3 } from "babylonjs/Maths/math.color";
  48153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48154. import { Mesh } from "babylonjs/Meshes/mesh";
  48155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48156. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48157. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48158. import "babylonjs/Meshes/Builders/planeBuilder";
  48159. import "babylonjs/Meshes/Builders/boxBuilder";
  48160. /**
  48161. * Represents the different options available during the creation of
  48162. * a Environment helper.
  48163. *
  48164. * This can control the default ground, skybox and image processing setup of your scene.
  48165. */
  48166. export interface IEnvironmentHelperOptions {
  48167. /**
  48168. * Specifies wether or not to create a ground.
  48169. * True by default.
  48170. */
  48171. createGround: boolean;
  48172. /**
  48173. * Specifies the ground size.
  48174. * 15 by default.
  48175. */
  48176. groundSize: number;
  48177. /**
  48178. * The texture used on the ground for the main color.
  48179. * Comes from the BabylonJS CDN by default.
  48180. *
  48181. * Remarks: Can be either a texture or a url.
  48182. */
  48183. groundTexture: string | BaseTexture;
  48184. /**
  48185. * The color mixed in the ground texture by default.
  48186. * BabylonJS clearColor by default.
  48187. */
  48188. groundColor: Color3;
  48189. /**
  48190. * Specifies the ground opacity.
  48191. * 1 by default.
  48192. */
  48193. groundOpacity: number;
  48194. /**
  48195. * Enables the ground to receive shadows.
  48196. * True by default.
  48197. */
  48198. enableGroundShadow: boolean;
  48199. /**
  48200. * Helps preventing the shadow to be fully black on the ground.
  48201. * 0.5 by default.
  48202. */
  48203. groundShadowLevel: number;
  48204. /**
  48205. * Creates a mirror texture attach to the ground.
  48206. * false by default.
  48207. */
  48208. enableGroundMirror: boolean;
  48209. /**
  48210. * Specifies the ground mirror size ratio.
  48211. * 0.3 by default as the default kernel is 64.
  48212. */
  48213. groundMirrorSizeRatio: number;
  48214. /**
  48215. * Specifies the ground mirror blur kernel size.
  48216. * 64 by default.
  48217. */
  48218. groundMirrorBlurKernel: number;
  48219. /**
  48220. * Specifies the ground mirror visibility amount.
  48221. * 1 by default
  48222. */
  48223. groundMirrorAmount: number;
  48224. /**
  48225. * Specifies the ground mirror reflectance weight.
  48226. * This uses the standard weight of the background material to setup the fresnel effect
  48227. * of the mirror.
  48228. * 1 by default.
  48229. */
  48230. groundMirrorFresnelWeight: number;
  48231. /**
  48232. * Specifies the ground mirror Falloff distance.
  48233. * This can helps reducing the size of the reflection.
  48234. * 0 by Default.
  48235. */
  48236. groundMirrorFallOffDistance: number;
  48237. /**
  48238. * Specifies the ground mirror texture type.
  48239. * Unsigned Int by Default.
  48240. */
  48241. groundMirrorTextureType: number;
  48242. /**
  48243. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48244. * the shown objects.
  48245. */
  48246. groundYBias: number;
  48247. /**
  48248. * Specifies wether or not to create a skybox.
  48249. * True by default.
  48250. */
  48251. createSkybox: boolean;
  48252. /**
  48253. * Specifies the skybox size.
  48254. * 20 by default.
  48255. */
  48256. skyboxSize: number;
  48257. /**
  48258. * The texture used on the skybox for the main color.
  48259. * Comes from the BabylonJS CDN by default.
  48260. *
  48261. * Remarks: Can be either a texture or a url.
  48262. */
  48263. skyboxTexture: string | BaseTexture;
  48264. /**
  48265. * The color mixed in the skybox texture by default.
  48266. * BabylonJS clearColor by default.
  48267. */
  48268. skyboxColor: Color3;
  48269. /**
  48270. * The background rotation around the Y axis of the scene.
  48271. * This helps aligning the key lights of your scene with the background.
  48272. * 0 by default.
  48273. */
  48274. backgroundYRotation: number;
  48275. /**
  48276. * Compute automatically the size of the elements to best fit with the scene.
  48277. */
  48278. sizeAuto: boolean;
  48279. /**
  48280. * Default position of the rootMesh if autoSize is not true.
  48281. */
  48282. rootPosition: Vector3;
  48283. /**
  48284. * Sets up the image processing in the scene.
  48285. * true by default.
  48286. */
  48287. setupImageProcessing: boolean;
  48288. /**
  48289. * The texture used as your environment texture in the scene.
  48290. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48291. *
  48292. * Remarks: Can be either a texture or a url.
  48293. */
  48294. environmentTexture: string | BaseTexture;
  48295. /**
  48296. * The value of the exposure to apply to the scene.
  48297. * 0.6 by default if setupImageProcessing is true.
  48298. */
  48299. cameraExposure: number;
  48300. /**
  48301. * The value of the contrast to apply to the scene.
  48302. * 1.6 by default if setupImageProcessing is true.
  48303. */
  48304. cameraContrast: number;
  48305. /**
  48306. * Specifies wether or not tonemapping should be enabled in the scene.
  48307. * true by default if setupImageProcessing is true.
  48308. */
  48309. toneMappingEnabled: boolean;
  48310. }
  48311. /**
  48312. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48313. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48314. * It also helps with the default setup of your imageProcessing configuration.
  48315. */
  48316. export class EnvironmentHelper {
  48317. /**
  48318. * Default ground texture URL.
  48319. */
  48320. private static _groundTextureCDNUrl;
  48321. /**
  48322. * Default skybox texture URL.
  48323. */
  48324. private static _skyboxTextureCDNUrl;
  48325. /**
  48326. * Default environment texture URL.
  48327. */
  48328. private static _environmentTextureCDNUrl;
  48329. /**
  48330. * Creates the default options for the helper.
  48331. */
  48332. private static _getDefaultOptions;
  48333. private _rootMesh;
  48334. /**
  48335. * Gets the root mesh created by the helper.
  48336. */
  48337. readonly rootMesh: Mesh;
  48338. private _skybox;
  48339. /**
  48340. * Gets the skybox created by the helper.
  48341. */
  48342. readonly skybox: Nullable<Mesh>;
  48343. private _skyboxTexture;
  48344. /**
  48345. * Gets the skybox texture created by the helper.
  48346. */
  48347. readonly skyboxTexture: Nullable<BaseTexture>;
  48348. private _skyboxMaterial;
  48349. /**
  48350. * Gets the skybox material created by the helper.
  48351. */
  48352. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48353. private _ground;
  48354. /**
  48355. * Gets the ground mesh created by the helper.
  48356. */
  48357. readonly ground: Nullable<Mesh>;
  48358. private _groundTexture;
  48359. /**
  48360. * Gets the ground texture created by the helper.
  48361. */
  48362. readonly groundTexture: Nullable<BaseTexture>;
  48363. private _groundMirror;
  48364. /**
  48365. * Gets the ground mirror created by the helper.
  48366. */
  48367. readonly groundMirror: Nullable<MirrorTexture>;
  48368. /**
  48369. * Gets the ground mirror render list to helps pushing the meshes
  48370. * you wish in the ground reflection.
  48371. */
  48372. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48373. private _groundMaterial;
  48374. /**
  48375. * Gets the ground material created by the helper.
  48376. */
  48377. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48378. /**
  48379. * Stores the creation options.
  48380. */
  48381. private readonly _scene;
  48382. private _options;
  48383. /**
  48384. * This observable will be notified with any error during the creation of the environment,
  48385. * mainly texture creation errors.
  48386. */
  48387. onErrorObservable: Observable<{
  48388. message?: string;
  48389. exception?: any;
  48390. }>;
  48391. /**
  48392. * constructor
  48393. * @param options Defines the options we want to customize the helper
  48394. * @param scene The scene to add the material to
  48395. */
  48396. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48397. /**
  48398. * Updates the background according to the new options
  48399. * @param options
  48400. */
  48401. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48402. /**
  48403. * Sets the primary color of all the available elements.
  48404. * @param color the main color to affect to the ground and the background
  48405. */
  48406. setMainColor(color: Color3): void;
  48407. /**
  48408. * Setup the image processing according to the specified options.
  48409. */
  48410. private _setupImageProcessing;
  48411. /**
  48412. * Setup the environment texture according to the specified options.
  48413. */
  48414. private _setupEnvironmentTexture;
  48415. /**
  48416. * Setup the background according to the specified options.
  48417. */
  48418. private _setupBackground;
  48419. /**
  48420. * Get the scene sizes according to the setup.
  48421. */
  48422. private _getSceneSize;
  48423. /**
  48424. * Setup the ground according to the specified options.
  48425. */
  48426. private _setupGround;
  48427. /**
  48428. * Setup the ground material according to the specified options.
  48429. */
  48430. private _setupGroundMaterial;
  48431. /**
  48432. * Setup the ground diffuse texture according to the specified options.
  48433. */
  48434. private _setupGroundDiffuseTexture;
  48435. /**
  48436. * Setup the ground mirror texture according to the specified options.
  48437. */
  48438. private _setupGroundMirrorTexture;
  48439. /**
  48440. * Setup the ground to receive the mirror texture.
  48441. */
  48442. private _setupMirrorInGroundMaterial;
  48443. /**
  48444. * Setup the skybox according to the specified options.
  48445. */
  48446. private _setupSkybox;
  48447. /**
  48448. * Setup the skybox material according to the specified options.
  48449. */
  48450. private _setupSkyboxMaterial;
  48451. /**
  48452. * Setup the skybox reflection texture according to the specified options.
  48453. */
  48454. private _setupSkyboxReflectionTexture;
  48455. private _errorHandler;
  48456. /**
  48457. * Dispose all the elements created by the Helper.
  48458. */
  48459. dispose(): void;
  48460. }
  48461. }
  48462. declare module "babylonjs/Helpers/photoDome" {
  48463. import { Observable } from "babylonjs/Misc/observable";
  48464. import { Nullable } from "babylonjs/types";
  48465. import { Scene } from "babylonjs/scene";
  48466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48467. import { Mesh } from "babylonjs/Meshes/mesh";
  48468. import { Texture } from "babylonjs/Materials/Textures/texture";
  48469. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48470. import "babylonjs/Meshes/Builders/sphereBuilder";
  48471. /**
  48472. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48473. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48474. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48475. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48476. */
  48477. export class PhotoDome extends TransformNode {
  48478. /**
  48479. * Define the image as a Monoscopic panoramic 360 image.
  48480. */
  48481. static readonly MODE_MONOSCOPIC: number;
  48482. /**
  48483. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48484. */
  48485. static readonly MODE_TOPBOTTOM: number;
  48486. /**
  48487. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48488. */
  48489. static readonly MODE_SIDEBYSIDE: number;
  48490. private _useDirectMapping;
  48491. /**
  48492. * The texture being displayed on the sphere
  48493. */
  48494. protected _photoTexture: Texture;
  48495. /**
  48496. * Gets or sets the texture being displayed on the sphere
  48497. */
  48498. photoTexture: Texture;
  48499. /**
  48500. * Observable raised when an error occured while loading the 360 image
  48501. */
  48502. onLoadErrorObservable: Observable<string>;
  48503. /**
  48504. * The skybox material
  48505. */
  48506. protected _material: BackgroundMaterial;
  48507. /**
  48508. * The surface used for the skybox
  48509. */
  48510. protected _mesh: Mesh;
  48511. /**
  48512. * Gets the mesh used for the skybox.
  48513. */
  48514. readonly mesh: Mesh;
  48515. /**
  48516. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48517. * Also see the options.resolution property.
  48518. */
  48519. fovMultiplier: number;
  48520. private _imageMode;
  48521. /**
  48522. * Gets or set the current video mode for the video. It can be:
  48523. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48524. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48525. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48526. */
  48527. imageMode: number;
  48528. /**
  48529. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48530. * @param name Element's name, child elements will append suffixes for their own names.
  48531. * @param urlsOfPhoto defines the url of the photo to display
  48532. * @param options defines an object containing optional or exposed sub element properties
  48533. * @param onError defines a callback called when an error occured while loading the texture
  48534. */
  48535. constructor(name: string, urlOfPhoto: string, options: {
  48536. resolution?: number;
  48537. size?: number;
  48538. useDirectMapping?: boolean;
  48539. faceForward?: boolean;
  48540. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48541. private _onBeforeCameraRenderObserver;
  48542. private _changeImageMode;
  48543. /**
  48544. * Releases resources associated with this node.
  48545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48547. */
  48548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48549. }
  48550. }
  48551. declare module "babylonjs/Misc/rgbdTextureTools" {
  48552. import "babylonjs/Shaders/rgbdDecode.fragment";
  48553. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48554. import { Texture } from "babylonjs/Materials/Textures/texture";
  48555. /**
  48556. * Class used to host RGBD texture specific utilities
  48557. */
  48558. export class RGBDTextureTools {
  48559. /**
  48560. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48561. * @param texture the texture to expand.
  48562. */
  48563. static ExpandRGBDTexture(texture: Texture): void;
  48564. }
  48565. }
  48566. declare module "babylonjs/Misc/brdfTextureTools" {
  48567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48568. import { Scene } from "babylonjs/scene";
  48569. /**
  48570. * Class used to host texture specific utilities
  48571. */
  48572. export class BRDFTextureTools {
  48573. /**
  48574. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48575. * @param scene defines the hosting scene
  48576. * @returns the environment BRDF texture
  48577. */
  48578. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48579. private static _environmentBRDFBase64Texture;
  48580. }
  48581. }
  48582. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48583. import { Nullable } from "babylonjs/types";
  48584. import { Color3 } from "babylonjs/Maths/math.color";
  48585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48586. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48588. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48589. import { Engine } from "babylonjs/Engines/engine";
  48590. import { Scene } from "babylonjs/scene";
  48591. /**
  48592. * @hidden
  48593. */
  48594. export interface IMaterialClearCoatDefines {
  48595. CLEARCOAT: boolean;
  48596. CLEARCOAT_DEFAULTIOR: boolean;
  48597. CLEARCOAT_TEXTURE: boolean;
  48598. CLEARCOAT_TEXTUREDIRECTUV: number;
  48599. CLEARCOAT_BUMP: boolean;
  48600. CLEARCOAT_BUMPDIRECTUV: number;
  48601. CLEARCOAT_TINT: boolean;
  48602. CLEARCOAT_TINT_TEXTURE: boolean;
  48603. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48604. /** @hidden */
  48605. _areTexturesDirty: boolean;
  48606. }
  48607. /**
  48608. * Define the code related to the clear coat parameters of the pbr material.
  48609. */
  48610. export class PBRClearCoatConfiguration {
  48611. /**
  48612. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48613. * The default fits with a polyurethane material.
  48614. */
  48615. private static readonly _DefaultIndexOfRefraction;
  48616. private _isEnabled;
  48617. /**
  48618. * Defines if the clear coat is enabled in the material.
  48619. */
  48620. isEnabled: boolean;
  48621. /**
  48622. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48623. */
  48624. intensity: number;
  48625. /**
  48626. * Defines the clear coat layer roughness.
  48627. */
  48628. roughness: number;
  48629. private _indexOfRefraction;
  48630. /**
  48631. * Defines the index of refraction of the clear coat.
  48632. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48633. * The default fits with a polyurethane material.
  48634. * Changing the default value is more performance intensive.
  48635. */
  48636. indexOfRefraction: number;
  48637. private _texture;
  48638. /**
  48639. * Stores the clear coat values in a texture.
  48640. */
  48641. texture: Nullable<BaseTexture>;
  48642. private _bumpTexture;
  48643. /**
  48644. * Define the clear coat specific bump texture.
  48645. */
  48646. bumpTexture: Nullable<BaseTexture>;
  48647. private _isTintEnabled;
  48648. /**
  48649. * Defines if the clear coat tint is enabled in the material.
  48650. */
  48651. isTintEnabled: boolean;
  48652. /**
  48653. * Defines the clear coat tint of the material.
  48654. * This is only use if tint is enabled
  48655. */
  48656. tintColor: Color3;
  48657. /**
  48658. * Defines the distance at which the tint color should be found in the
  48659. * clear coat media.
  48660. * This is only use if tint is enabled
  48661. */
  48662. tintColorAtDistance: number;
  48663. /**
  48664. * Defines the clear coat layer thickness.
  48665. * This is only use if tint is enabled
  48666. */
  48667. tintThickness: number;
  48668. private _tintTexture;
  48669. /**
  48670. * Stores the clear tint values in a texture.
  48671. * rgb is tint
  48672. * a is a thickness factor
  48673. */
  48674. tintTexture: Nullable<BaseTexture>;
  48675. /** @hidden */
  48676. private _internalMarkAllSubMeshesAsTexturesDirty;
  48677. /** @hidden */
  48678. _markAllSubMeshesAsTexturesDirty(): void;
  48679. /**
  48680. * Instantiate a new istance of clear coat configuration.
  48681. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48682. */
  48683. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48684. /**
  48685. * Gets wehter the submesh is ready to be used or not.
  48686. * @param defines the list of "defines" to update.
  48687. * @param scene defines the scene the material belongs to.
  48688. * @param engine defines the engine the material belongs to.
  48689. * @param disableBumpMap defines wether the material disables bump or not.
  48690. * @returns - boolean indicating that the submesh is ready or not.
  48691. */
  48692. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48693. /**
  48694. * Checks to see if a texture is used in the material.
  48695. * @param defines the list of "defines" to update.
  48696. * @param scene defines the scene to the material belongs to.
  48697. */
  48698. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48699. /**
  48700. * Binds the material data.
  48701. * @param uniformBuffer defines the Uniform buffer to fill in.
  48702. * @param scene defines the scene the material belongs to.
  48703. * @param engine defines the engine the material belongs to.
  48704. * @param disableBumpMap defines wether the material disables bump or not.
  48705. * @param isFrozen defines wether the material is frozen or not.
  48706. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48707. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48708. */
  48709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48710. /**
  48711. * Checks to see if a texture is used in the material.
  48712. * @param texture - Base texture to use.
  48713. * @returns - Boolean specifying if a texture is used in the material.
  48714. */
  48715. hasTexture(texture: BaseTexture): boolean;
  48716. /**
  48717. * Returns an array of the actively used textures.
  48718. * @param activeTextures Array of BaseTextures
  48719. */
  48720. getActiveTextures(activeTextures: BaseTexture[]): void;
  48721. /**
  48722. * Returns the animatable textures.
  48723. * @param animatables Array of animatable textures.
  48724. */
  48725. getAnimatables(animatables: IAnimatable[]): void;
  48726. /**
  48727. * Disposes the resources of the material.
  48728. * @param forceDisposeTextures - Forces the disposal of all textures.
  48729. */
  48730. dispose(forceDisposeTextures?: boolean): void;
  48731. /**
  48732. * Get the current class name of the texture useful for serialization or dynamic coding.
  48733. * @returns "PBRClearCoatConfiguration"
  48734. */
  48735. getClassName(): string;
  48736. /**
  48737. * Add fallbacks to the effect fallbacks list.
  48738. * @param defines defines the Base texture to use.
  48739. * @param fallbacks defines the current fallback list.
  48740. * @param currentRank defines the current fallback rank.
  48741. * @returns the new fallback rank.
  48742. */
  48743. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48744. /**
  48745. * Add the required uniforms to the current list.
  48746. * @param uniforms defines the current uniform list.
  48747. */
  48748. static AddUniforms(uniforms: string[]): void;
  48749. /**
  48750. * Add the required samplers to the current list.
  48751. * @param samplers defines the current sampler list.
  48752. */
  48753. static AddSamplers(samplers: string[]): void;
  48754. /**
  48755. * Add the required uniforms to the current buffer.
  48756. * @param uniformBuffer defines the current uniform buffer.
  48757. */
  48758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48759. /**
  48760. * Makes a duplicate of the current configuration into another one.
  48761. * @param clearCoatConfiguration define the config where to copy the info
  48762. */
  48763. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48764. /**
  48765. * Serializes this clear coat configuration.
  48766. * @returns - An object with the serialized config.
  48767. */
  48768. serialize(): any;
  48769. /**
  48770. * Parses a anisotropy Configuration from a serialized object.
  48771. * @param source - Serialized object.
  48772. * @param scene Defines the scene we are parsing for
  48773. * @param rootUrl Defines the rootUrl to load from
  48774. */
  48775. parse(source: any, scene: Scene, rootUrl: string): void;
  48776. }
  48777. }
  48778. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48781. import { Vector2 } from "babylonjs/Maths/math.vector";
  48782. import { Scene } from "babylonjs/scene";
  48783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48784. import { Nullable } from "babylonjs/types";
  48785. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48786. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48787. /**
  48788. * @hidden
  48789. */
  48790. export interface IMaterialAnisotropicDefines {
  48791. ANISOTROPIC: boolean;
  48792. ANISOTROPIC_TEXTURE: boolean;
  48793. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48794. MAINUV1: boolean;
  48795. _areTexturesDirty: boolean;
  48796. _needUVs: boolean;
  48797. }
  48798. /**
  48799. * Define the code related to the anisotropic parameters of the pbr material.
  48800. */
  48801. export class PBRAnisotropicConfiguration {
  48802. private _isEnabled;
  48803. /**
  48804. * Defines if the anisotropy is enabled in the material.
  48805. */
  48806. isEnabled: boolean;
  48807. /**
  48808. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48809. */
  48810. intensity: number;
  48811. /**
  48812. * Defines if the effect is along the tangents, bitangents or in between.
  48813. * By default, the effect is "strectching" the highlights along the tangents.
  48814. */
  48815. direction: Vector2;
  48816. private _texture;
  48817. /**
  48818. * Stores the anisotropy values in a texture.
  48819. * rg is direction (like normal from -1 to 1)
  48820. * b is a intensity
  48821. */
  48822. texture: Nullable<BaseTexture>;
  48823. /** @hidden */
  48824. private _internalMarkAllSubMeshesAsTexturesDirty;
  48825. /** @hidden */
  48826. _markAllSubMeshesAsTexturesDirty(): void;
  48827. /**
  48828. * Instantiate a new istance of anisotropy configuration.
  48829. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48830. */
  48831. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48832. /**
  48833. * Specifies that the submesh is ready to be used.
  48834. * @param defines the list of "defines" to update.
  48835. * @param scene defines the scene the material belongs to.
  48836. * @returns - boolean indicating that the submesh is ready or not.
  48837. */
  48838. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48839. /**
  48840. * Checks to see if a texture is used in the material.
  48841. * @param defines the list of "defines" to update.
  48842. * @param mesh the mesh we are preparing the defines for.
  48843. * @param scene defines the scene the material belongs to.
  48844. */
  48845. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48846. /**
  48847. * Binds the material data.
  48848. * @param uniformBuffer defines the Uniform buffer to fill in.
  48849. * @param scene defines the scene the material belongs to.
  48850. * @param isFrozen defines wether the material is frozen or not.
  48851. */
  48852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48853. /**
  48854. * Checks to see if a texture is used in the material.
  48855. * @param texture - Base texture to use.
  48856. * @returns - Boolean specifying if a texture is used in the material.
  48857. */
  48858. hasTexture(texture: BaseTexture): boolean;
  48859. /**
  48860. * Returns an array of the actively used textures.
  48861. * @param activeTextures Array of BaseTextures
  48862. */
  48863. getActiveTextures(activeTextures: BaseTexture[]): void;
  48864. /**
  48865. * Returns the animatable textures.
  48866. * @param animatables Array of animatable textures.
  48867. */
  48868. getAnimatables(animatables: IAnimatable[]): void;
  48869. /**
  48870. * Disposes the resources of the material.
  48871. * @param forceDisposeTextures - Forces the disposal of all textures.
  48872. */
  48873. dispose(forceDisposeTextures?: boolean): void;
  48874. /**
  48875. * Get the current class name of the texture useful for serialization or dynamic coding.
  48876. * @returns "PBRAnisotropicConfiguration"
  48877. */
  48878. getClassName(): string;
  48879. /**
  48880. * Add fallbacks to the effect fallbacks list.
  48881. * @param defines defines the Base texture to use.
  48882. * @param fallbacks defines the current fallback list.
  48883. * @param currentRank defines the current fallback rank.
  48884. * @returns the new fallback rank.
  48885. */
  48886. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48887. /**
  48888. * Add the required uniforms to the current list.
  48889. * @param uniforms defines the current uniform list.
  48890. */
  48891. static AddUniforms(uniforms: string[]): void;
  48892. /**
  48893. * Add the required uniforms to the current buffer.
  48894. * @param uniformBuffer defines the current uniform buffer.
  48895. */
  48896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48897. /**
  48898. * Add the required samplers to the current list.
  48899. * @param samplers defines the current sampler list.
  48900. */
  48901. static AddSamplers(samplers: string[]): void;
  48902. /**
  48903. * Makes a duplicate of the current configuration into another one.
  48904. * @param anisotropicConfiguration define the config where to copy the info
  48905. */
  48906. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48907. /**
  48908. * Serializes this anisotropy configuration.
  48909. * @returns - An object with the serialized config.
  48910. */
  48911. serialize(): any;
  48912. /**
  48913. * Parses a anisotropy Configuration from a serialized object.
  48914. * @param source - Serialized object.
  48915. * @param scene Defines the scene we are parsing for
  48916. * @param rootUrl Defines the rootUrl to load from
  48917. */
  48918. parse(source: any, scene: Scene, rootUrl: string): void;
  48919. }
  48920. }
  48921. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48922. import { Scene } from "babylonjs/scene";
  48923. /**
  48924. * @hidden
  48925. */
  48926. export interface IMaterialBRDFDefines {
  48927. BRDF_V_HEIGHT_CORRELATED: boolean;
  48928. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48929. SPHERICAL_HARMONICS: boolean;
  48930. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48931. /** @hidden */
  48932. _areMiscDirty: boolean;
  48933. }
  48934. /**
  48935. * Define the code related to the BRDF parameters of the pbr material.
  48936. */
  48937. export class PBRBRDFConfiguration {
  48938. /**
  48939. * Default value used for the energy conservation.
  48940. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48941. */
  48942. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48943. /**
  48944. * Default value used for the Smith Visibility Height Correlated mode.
  48945. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48946. */
  48947. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48948. /**
  48949. * Default value used for the IBL diffuse part.
  48950. * This can help switching back to the polynomials mode globally which is a tiny bit
  48951. * less GPU intensive at the drawback of a lower quality.
  48952. */
  48953. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48954. /**
  48955. * Default value used for activating energy conservation for the specular workflow.
  48956. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48957. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48958. */
  48959. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48960. private _useEnergyConservation;
  48961. /**
  48962. * Defines if the material uses energy conservation.
  48963. */
  48964. useEnergyConservation: boolean;
  48965. private _useSmithVisibilityHeightCorrelated;
  48966. /**
  48967. * LEGACY Mode set to false
  48968. * Defines if the material uses height smith correlated visibility term.
  48969. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48970. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48971. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48972. * Not relying on height correlated will also disable energy conservation.
  48973. */
  48974. useSmithVisibilityHeightCorrelated: boolean;
  48975. private _useSphericalHarmonics;
  48976. /**
  48977. * LEGACY Mode set to false
  48978. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48979. * diffuse part of the IBL.
  48980. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48981. * to the ground truth.
  48982. */
  48983. useSphericalHarmonics: boolean;
  48984. private _useSpecularGlossinessInputEnergyConservation;
  48985. /**
  48986. * Defines if the material uses energy conservation, when the specular workflow is active.
  48987. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48988. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48989. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48990. */
  48991. useSpecularGlossinessInputEnergyConservation: boolean;
  48992. /** @hidden */
  48993. private _internalMarkAllSubMeshesAsMiscDirty;
  48994. /** @hidden */
  48995. _markAllSubMeshesAsMiscDirty(): void;
  48996. /**
  48997. * Instantiate a new istance of clear coat configuration.
  48998. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48999. */
  49000. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49001. /**
  49002. * Checks to see if a texture is used in the material.
  49003. * @param defines the list of "defines" to update.
  49004. */
  49005. prepareDefines(defines: IMaterialBRDFDefines): void;
  49006. /**
  49007. * Get the current class name of the texture useful for serialization or dynamic coding.
  49008. * @returns "PBRClearCoatConfiguration"
  49009. */
  49010. getClassName(): string;
  49011. /**
  49012. * Makes a duplicate of the current configuration into another one.
  49013. * @param brdfConfiguration define the config where to copy the info
  49014. */
  49015. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49016. /**
  49017. * Serializes this BRDF configuration.
  49018. * @returns - An object with the serialized config.
  49019. */
  49020. serialize(): any;
  49021. /**
  49022. * Parses a anisotropy Configuration from a serialized object.
  49023. * @param source - Serialized object.
  49024. * @param scene Defines the scene we are parsing for
  49025. * @param rootUrl Defines the rootUrl to load from
  49026. */
  49027. parse(source: any, scene: Scene, rootUrl: string): void;
  49028. }
  49029. }
  49030. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49031. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49032. import { Color3 } from "babylonjs/Maths/math.color";
  49033. import { Scene } from "babylonjs/scene";
  49034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49035. import { Nullable } from "babylonjs/types";
  49036. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49037. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49038. /**
  49039. * @hidden
  49040. */
  49041. export interface IMaterialSheenDefines {
  49042. SHEEN: boolean;
  49043. SHEEN_TEXTURE: boolean;
  49044. SHEEN_TEXTUREDIRECTUV: number;
  49045. SHEEN_LINKWITHALBEDO: boolean;
  49046. /** @hidden */
  49047. _areTexturesDirty: boolean;
  49048. }
  49049. /**
  49050. * Define the code related to the Sheen parameters of the pbr material.
  49051. */
  49052. export class PBRSheenConfiguration {
  49053. private _isEnabled;
  49054. /**
  49055. * Defines if the material uses sheen.
  49056. */
  49057. isEnabled: boolean;
  49058. private _linkSheenWithAlbedo;
  49059. /**
  49060. * Defines if the sheen is linked to the sheen color.
  49061. */
  49062. linkSheenWithAlbedo: boolean;
  49063. /**
  49064. * Defines the sheen intensity.
  49065. */
  49066. intensity: number;
  49067. /**
  49068. * Defines the sheen color.
  49069. */
  49070. color: Color3;
  49071. private _texture;
  49072. /**
  49073. * Stores the sheen tint values in a texture.
  49074. * rgb is tint
  49075. * a is a intensity
  49076. */
  49077. texture: Nullable<BaseTexture>;
  49078. /** @hidden */
  49079. private _internalMarkAllSubMeshesAsTexturesDirty;
  49080. /** @hidden */
  49081. _markAllSubMeshesAsTexturesDirty(): void;
  49082. /**
  49083. * Instantiate a new istance of clear coat configuration.
  49084. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49085. */
  49086. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49087. /**
  49088. * Specifies that the submesh is ready to be used.
  49089. * @param defines the list of "defines" to update.
  49090. * @param scene defines the scene the material belongs to.
  49091. * @returns - boolean indicating that the submesh is ready or not.
  49092. */
  49093. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49094. /**
  49095. * Checks to see if a texture is used in the material.
  49096. * @param defines the list of "defines" to update.
  49097. * @param scene defines the scene the material belongs to.
  49098. */
  49099. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49100. /**
  49101. * Binds the material data.
  49102. * @param uniformBuffer defines the Uniform buffer to fill in.
  49103. * @param scene defines the scene the material belongs to.
  49104. * @param isFrozen defines wether the material is frozen or not.
  49105. */
  49106. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49107. /**
  49108. * Checks to see if a texture is used in the material.
  49109. * @param texture - Base texture to use.
  49110. * @returns - Boolean specifying if a texture is used in the material.
  49111. */
  49112. hasTexture(texture: BaseTexture): boolean;
  49113. /**
  49114. * Returns an array of the actively used textures.
  49115. * @param activeTextures Array of BaseTextures
  49116. */
  49117. getActiveTextures(activeTextures: BaseTexture[]): void;
  49118. /**
  49119. * Returns the animatable textures.
  49120. * @param animatables Array of animatable textures.
  49121. */
  49122. getAnimatables(animatables: IAnimatable[]): void;
  49123. /**
  49124. * Disposes the resources of the material.
  49125. * @param forceDisposeTextures - Forces the disposal of all textures.
  49126. */
  49127. dispose(forceDisposeTextures?: boolean): void;
  49128. /**
  49129. * Get the current class name of the texture useful for serialization or dynamic coding.
  49130. * @returns "PBRSheenConfiguration"
  49131. */
  49132. getClassName(): string;
  49133. /**
  49134. * Add fallbacks to the effect fallbacks list.
  49135. * @param defines defines the Base texture to use.
  49136. * @param fallbacks defines the current fallback list.
  49137. * @param currentRank defines the current fallback rank.
  49138. * @returns the new fallback rank.
  49139. */
  49140. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49141. /**
  49142. * Add the required uniforms to the current list.
  49143. * @param uniforms defines the current uniform list.
  49144. */
  49145. static AddUniforms(uniforms: string[]): void;
  49146. /**
  49147. * Add the required uniforms to the current buffer.
  49148. * @param uniformBuffer defines the current uniform buffer.
  49149. */
  49150. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49151. /**
  49152. * Add the required samplers to the current list.
  49153. * @param samplers defines the current sampler list.
  49154. */
  49155. static AddSamplers(samplers: string[]): void;
  49156. /**
  49157. * Makes a duplicate of the current configuration into another one.
  49158. * @param sheenConfiguration define the config where to copy the info
  49159. */
  49160. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49161. /**
  49162. * Serializes this BRDF configuration.
  49163. * @returns - An object with the serialized config.
  49164. */
  49165. serialize(): any;
  49166. /**
  49167. * Parses a anisotropy Configuration from a serialized object.
  49168. * @param source - Serialized object.
  49169. * @param scene Defines the scene we are parsing for
  49170. * @param rootUrl Defines the rootUrl to load from
  49171. */
  49172. parse(source: any, scene: Scene, rootUrl: string): void;
  49173. }
  49174. }
  49175. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49176. import { Nullable } from "babylonjs/types";
  49177. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49178. import { Color3 } from "babylonjs/Maths/math.color";
  49179. import { SmartArray } from "babylonjs/Misc/smartArray";
  49180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49182. import { Effect } from "babylonjs/Materials/effect";
  49183. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49184. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49185. import { Engine } from "babylonjs/Engines/engine";
  49186. import { Scene } from "babylonjs/scene";
  49187. /**
  49188. * @hidden
  49189. */
  49190. export interface IMaterialSubSurfaceDefines {
  49191. SUBSURFACE: boolean;
  49192. SS_REFRACTION: boolean;
  49193. SS_TRANSLUCENCY: boolean;
  49194. SS_SCATERRING: boolean;
  49195. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49196. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49197. SS_REFRACTIONMAP_3D: boolean;
  49198. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49199. SS_LODINREFRACTIONALPHA: boolean;
  49200. SS_GAMMAREFRACTION: boolean;
  49201. SS_RGBDREFRACTION: boolean;
  49202. SS_LINEARSPECULARREFRACTION: boolean;
  49203. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49204. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49205. /** @hidden */
  49206. _areTexturesDirty: boolean;
  49207. }
  49208. /**
  49209. * Define the code related to the sub surface parameters of the pbr material.
  49210. */
  49211. export class PBRSubSurfaceConfiguration {
  49212. private _isRefractionEnabled;
  49213. /**
  49214. * Defines if the refraction is enabled in the material.
  49215. */
  49216. isRefractionEnabled: boolean;
  49217. private _isTranslucencyEnabled;
  49218. /**
  49219. * Defines if the translucency is enabled in the material.
  49220. */
  49221. isTranslucencyEnabled: boolean;
  49222. private _isScatteringEnabled;
  49223. /**
  49224. * Defines the refraction intensity of the material.
  49225. * The refraction when enabled replaces the Diffuse part of the material.
  49226. * The intensity helps transitionning between diffuse and refraction.
  49227. */
  49228. refractionIntensity: number;
  49229. /**
  49230. * Defines the translucency intensity of the material.
  49231. * When translucency has been enabled, this defines how much of the "translucency"
  49232. * is addded to the diffuse part of the material.
  49233. */
  49234. translucencyIntensity: number;
  49235. /**
  49236. * Defines the scattering intensity of the material.
  49237. * When scattering has been enabled, this defines how much of the "scattered light"
  49238. * is addded to the diffuse part of the material.
  49239. */
  49240. scatteringIntensity: number;
  49241. private _thicknessTexture;
  49242. /**
  49243. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49244. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49245. * 0 would mean minimumThickness
  49246. * 1 would mean maximumThickness
  49247. * The other channels might be use as a mask to vary the different effects intensity.
  49248. */
  49249. thicknessTexture: Nullable<BaseTexture>;
  49250. private _refractionTexture;
  49251. /**
  49252. * Defines the texture to use for refraction.
  49253. */
  49254. refractionTexture: Nullable<BaseTexture>;
  49255. private _indexOfRefraction;
  49256. /**
  49257. * Defines the index of refraction used in the material.
  49258. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49259. */
  49260. indexOfRefraction: number;
  49261. private _invertRefractionY;
  49262. /**
  49263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49264. */
  49265. invertRefractionY: boolean;
  49266. private _linkRefractionWithTransparency;
  49267. /**
  49268. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49269. * Materials half opaque for instance using refraction could benefit from this control.
  49270. */
  49271. linkRefractionWithTransparency: boolean;
  49272. /**
  49273. * Defines the minimum thickness stored in the thickness map.
  49274. * If no thickness map is defined, this value will be used to simulate thickness.
  49275. */
  49276. minimumThickness: number;
  49277. /**
  49278. * Defines the maximum thickness stored in the thickness map.
  49279. */
  49280. maximumThickness: number;
  49281. /**
  49282. * Defines the volume tint of the material.
  49283. * This is used for both translucency and scattering.
  49284. */
  49285. tintColor: Color3;
  49286. /**
  49287. * Defines the distance at which the tint color should be found in the media.
  49288. * This is used for refraction only.
  49289. */
  49290. tintColorAtDistance: number;
  49291. /**
  49292. * Defines how far each channel transmit through the media.
  49293. * It is defined as a color to simplify it selection.
  49294. */
  49295. diffusionDistance: Color3;
  49296. private _useMaskFromThicknessTexture;
  49297. /**
  49298. * Stores the intensity of the different subsurface effects in the thickness texture.
  49299. * * the green channel is the translucency intensity.
  49300. * * the blue channel is the scattering intensity.
  49301. * * the alpha channel is the refraction intensity.
  49302. */
  49303. useMaskFromThicknessTexture: boolean;
  49304. /** @hidden */
  49305. private _internalMarkAllSubMeshesAsTexturesDirty;
  49306. /** @hidden */
  49307. _markAllSubMeshesAsTexturesDirty(): void;
  49308. /**
  49309. * Instantiate a new istance of sub surface configuration.
  49310. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49311. */
  49312. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49313. /**
  49314. * Gets wehter the submesh is ready to be used or not.
  49315. * @param defines the list of "defines" to update.
  49316. * @param scene defines the scene the material belongs to.
  49317. * @returns - boolean indicating that the submesh is ready or not.
  49318. */
  49319. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49320. /**
  49321. * Checks to see if a texture is used in the material.
  49322. * @param defines the list of "defines" to update.
  49323. * @param scene defines the scene to the material belongs to.
  49324. */
  49325. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49326. /**
  49327. * Binds the material data.
  49328. * @param uniformBuffer defines the Uniform buffer to fill in.
  49329. * @param scene defines the scene the material belongs to.
  49330. * @param engine defines the engine the material belongs to.
  49331. * @param isFrozen defines wether the material is frozen or not.
  49332. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49333. */
  49334. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49335. /**
  49336. * Unbinds the material from the mesh.
  49337. * @param activeEffect defines the effect that should be unbound from.
  49338. * @returns true if unbound, otherwise false
  49339. */
  49340. unbind(activeEffect: Effect): boolean;
  49341. /**
  49342. * Returns the texture used for refraction or null if none is used.
  49343. * @param scene defines the scene the material belongs to.
  49344. * @returns - Refraction texture if present. If no refraction texture and refraction
  49345. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49346. */
  49347. private _getRefractionTexture;
  49348. /**
  49349. * Returns true if alpha blending should be disabled.
  49350. */
  49351. readonly disableAlphaBlending: boolean;
  49352. /**
  49353. * Fills the list of render target textures.
  49354. * @param renderTargets the list of render targets to update
  49355. */
  49356. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49357. /**
  49358. * Checks to see if a texture is used in the material.
  49359. * @param texture - Base texture to use.
  49360. * @returns - Boolean specifying if a texture is used in the material.
  49361. */
  49362. hasTexture(texture: BaseTexture): boolean;
  49363. /**
  49364. * Gets a boolean indicating that current material needs to register RTT
  49365. * @returns true if this uses a render target otherwise false.
  49366. */
  49367. hasRenderTargetTextures(): boolean;
  49368. /**
  49369. * Returns an array of the actively used textures.
  49370. * @param activeTextures Array of BaseTextures
  49371. */
  49372. getActiveTextures(activeTextures: BaseTexture[]): void;
  49373. /**
  49374. * Returns the animatable textures.
  49375. * @param animatables Array of animatable textures.
  49376. */
  49377. getAnimatables(animatables: IAnimatable[]): void;
  49378. /**
  49379. * Disposes the resources of the material.
  49380. * @param forceDisposeTextures - Forces the disposal of all textures.
  49381. */
  49382. dispose(forceDisposeTextures?: boolean): void;
  49383. /**
  49384. * Get the current class name of the texture useful for serialization or dynamic coding.
  49385. * @returns "PBRSubSurfaceConfiguration"
  49386. */
  49387. getClassName(): string;
  49388. /**
  49389. * Add fallbacks to the effect fallbacks list.
  49390. * @param defines defines the Base texture to use.
  49391. * @param fallbacks defines the current fallback list.
  49392. * @param currentRank defines the current fallback rank.
  49393. * @returns the new fallback rank.
  49394. */
  49395. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49396. /**
  49397. * Add the required uniforms to the current list.
  49398. * @param uniforms defines the current uniform list.
  49399. */
  49400. static AddUniforms(uniforms: string[]): void;
  49401. /**
  49402. * Add the required samplers to the current list.
  49403. * @param samplers defines the current sampler list.
  49404. */
  49405. static AddSamplers(samplers: string[]): void;
  49406. /**
  49407. * Add the required uniforms to the current buffer.
  49408. * @param uniformBuffer defines the current uniform buffer.
  49409. */
  49410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49411. /**
  49412. * Makes a duplicate of the current configuration into another one.
  49413. * @param configuration define the config where to copy the info
  49414. */
  49415. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49416. /**
  49417. * Serializes this Sub Surface configuration.
  49418. * @returns - An object with the serialized config.
  49419. */
  49420. serialize(): any;
  49421. /**
  49422. * Parses a anisotropy Configuration from a serialized object.
  49423. * @param source - Serialized object.
  49424. * @param scene Defines the scene we are parsing for
  49425. * @param rootUrl Defines the rootUrl to load from
  49426. */
  49427. parse(source: any, scene: Scene, rootUrl: string): void;
  49428. }
  49429. }
  49430. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49431. /** @hidden */
  49432. export var pbrFragmentDeclaration: {
  49433. name: string;
  49434. shader: string;
  49435. };
  49436. }
  49437. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49438. /** @hidden */
  49439. export var pbrUboDeclaration: {
  49440. name: string;
  49441. shader: string;
  49442. };
  49443. }
  49444. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49445. /** @hidden */
  49446. export var pbrFragmentExtraDeclaration: {
  49447. name: string;
  49448. shader: string;
  49449. };
  49450. }
  49451. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49452. /** @hidden */
  49453. export var pbrFragmentSamplersDeclaration: {
  49454. name: string;
  49455. shader: string;
  49456. };
  49457. }
  49458. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49459. /** @hidden */
  49460. export var pbrHelperFunctions: {
  49461. name: string;
  49462. shader: string;
  49463. };
  49464. }
  49465. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49466. /** @hidden */
  49467. export var harmonicsFunctions: {
  49468. name: string;
  49469. shader: string;
  49470. };
  49471. }
  49472. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49473. /** @hidden */
  49474. export var pbrDirectLightingSetupFunctions: {
  49475. name: string;
  49476. shader: string;
  49477. };
  49478. }
  49479. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49480. /** @hidden */
  49481. export var pbrDirectLightingFalloffFunctions: {
  49482. name: string;
  49483. shader: string;
  49484. };
  49485. }
  49486. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49487. /** @hidden */
  49488. export var pbrBRDFFunctions: {
  49489. name: string;
  49490. shader: string;
  49491. };
  49492. }
  49493. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49494. /** @hidden */
  49495. export var pbrDirectLightingFunctions: {
  49496. name: string;
  49497. shader: string;
  49498. };
  49499. }
  49500. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49501. /** @hidden */
  49502. export var pbrIBLFunctions: {
  49503. name: string;
  49504. shader: string;
  49505. };
  49506. }
  49507. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49508. /** @hidden */
  49509. export var pbrDebug: {
  49510. name: string;
  49511. shader: string;
  49512. };
  49513. }
  49514. declare module "babylonjs/Shaders/pbr.fragment" {
  49515. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49516. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49517. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49518. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49519. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49520. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49521. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49522. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49523. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49524. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49525. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49526. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49527. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49528. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49529. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49530. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49531. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49532. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49533. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49534. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49535. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49536. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49537. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49538. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49539. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49540. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49541. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49542. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49543. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49544. /** @hidden */
  49545. export var pbrPixelShader: {
  49546. name: string;
  49547. shader: string;
  49548. };
  49549. }
  49550. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49551. /** @hidden */
  49552. export var pbrVertexDeclaration: {
  49553. name: string;
  49554. shader: string;
  49555. };
  49556. }
  49557. declare module "babylonjs/Shaders/pbr.vertex" {
  49558. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49559. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49560. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49561. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49562. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49563. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49564. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49565. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49566. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49567. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49568. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49571. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49572. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49573. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49574. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49575. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49576. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49577. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49578. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49579. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49580. /** @hidden */
  49581. export var pbrVertexShader: {
  49582. name: string;
  49583. shader: string;
  49584. };
  49585. }
  49586. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49587. import { Nullable } from "babylonjs/types";
  49588. import { Scene } from "babylonjs/scene";
  49589. import { Matrix } from "babylonjs/Maths/math.vector";
  49590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49592. import { Mesh } from "babylonjs/Meshes/mesh";
  49593. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49594. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49595. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49596. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49597. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49598. import { Color3 } from "babylonjs/Maths/math.color";
  49599. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49600. import { Material } from "babylonjs/Materials/material";
  49601. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49602. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49604. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49605. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49606. import "babylonjs/Shaders/pbr.fragment";
  49607. import "babylonjs/Shaders/pbr.vertex";
  49608. /**
  49609. * Manages the defines for the PBR Material.
  49610. * @hidden
  49611. */
  49612. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49613. PBR: boolean;
  49614. MAINUV1: boolean;
  49615. MAINUV2: boolean;
  49616. UV1: boolean;
  49617. UV2: boolean;
  49618. ALBEDO: boolean;
  49619. ALBEDODIRECTUV: number;
  49620. VERTEXCOLOR: boolean;
  49621. AMBIENT: boolean;
  49622. AMBIENTDIRECTUV: number;
  49623. AMBIENTINGRAYSCALE: boolean;
  49624. OPACITY: boolean;
  49625. VERTEXALPHA: boolean;
  49626. OPACITYDIRECTUV: number;
  49627. OPACITYRGB: boolean;
  49628. ALPHATEST: boolean;
  49629. DEPTHPREPASS: boolean;
  49630. ALPHABLEND: boolean;
  49631. ALPHAFROMALBEDO: boolean;
  49632. ALPHATESTVALUE: string;
  49633. SPECULAROVERALPHA: boolean;
  49634. RADIANCEOVERALPHA: boolean;
  49635. ALPHAFRESNEL: boolean;
  49636. LINEARALPHAFRESNEL: boolean;
  49637. PREMULTIPLYALPHA: boolean;
  49638. EMISSIVE: boolean;
  49639. EMISSIVEDIRECTUV: number;
  49640. REFLECTIVITY: boolean;
  49641. REFLECTIVITYDIRECTUV: number;
  49642. SPECULARTERM: boolean;
  49643. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49644. MICROSURFACEAUTOMATIC: boolean;
  49645. LODBASEDMICROSFURACE: boolean;
  49646. MICROSURFACEMAP: boolean;
  49647. MICROSURFACEMAPDIRECTUV: number;
  49648. METALLICWORKFLOW: boolean;
  49649. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49650. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49651. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49652. AOSTOREINMETALMAPRED: boolean;
  49653. ENVIRONMENTBRDF: boolean;
  49654. ENVIRONMENTBRDF_RGBD: boolean;
  49655. NORMAL: boolean;
  49656. TANGENT: boolean;
  49657. BUMP: boolean;
  49658. BUMPDIRECTUV: number;
  49659. OBJECTSPACE_NORMALMAP: boolean;
  49660. PARALLAX: boolean;
  49661. PARALLAXOCCLUSION: boolean;
  49662. NORMALXYSCALE: boolean;
  49663. LIGHTMAP: boolean;
  49664. LIGHTMAPDIRECTUV: number;
  49665. USELIGHTMAPASSHADOWMAP: boolean;
  49666. GAMMALIGHTMAP: boolean;
  49667. RGBDLIGHTMAP: boolean;
  49668. REFLECTION: boolean;
  49669. REFLECTIONMAP_3D: boolean;
  49670. REFLECTIONMAP_SPHERICAL: boolean;
  49671. REFLECTIONMAP_PLANAR: boolean;
  49672. REFLECTIONMAP_CUBIC: boolean;
  49673. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49674. REFLECTIONMAP_PROJECTION: boolean;
  49675. REFLECTIONMAP_SKYBOX: boolean;
  49676. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49677. REFLECTIONMAP_EXPLICIT: boolean;
  49678. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49679. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49680. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49681. INVERTCUBICMAP: boolean;
  49682. USESPHERICALFROMREFLECTIONMAP: boolean;
  49683. USEIRRADIANCEMAP: boolean;
  49684. SPHERICAL_HARMONICS: boolean;
  49685. USESPHERICALINVERTEX: boolean;
  49686. REFLECTIONMAP_OPPOSITEZ: boolean;
  49687. LODINREFLECTIONALPHA: boolean;
  49688. GAMMAREFLECTION: boolean;
  49689. RGBDREFLECTION: boolean;
  49690. LINEARSPECULARREFLECTION: boolean;
  49691. RADIANCEOCCLUSION: boolean;
  49692. HORIZONOCCLUSION: boolean;
  49693. INSTANCES: boolean;
  49694. NUM_BONE_INFLUENCERS: number;
  49695. BonesPerMesh: number;
  49696. BONETEXTURE: boolean;
  49697. NONUNIFORMSCALING: boolean;
  49698. MORPHTARGETS: boolean;
  49699. MORPHTARGETS_NORMAL: boolean;
  49700. MORPHTARGETS_TANGENT: boolean;
  49701. MORPHTARGETS_UV: boolean;
  49702. NUM_MORPH_INFLUENCERS: number;
  49703. IMAGEPROCESSING: boolean;
  49704. VIGNETTE: boolean;
  49705. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49706. VIGNETTEBLENDMODEOPAQUE: boolean;
  49707. TONEMAPPING: boolean;
  49708. TONEMAPPING_ACES: boolean;
  49709. CONTRAST: boolean;
  49710. COLORCURVES: boolean;
  49711. COLORGRADING: boolean;
  49712. COLORGRADING3D: boolean;
  49713. SAMPLER3DGREENDEPTH: boolean;
  49714. SAMPLER3DBGRMAP: boolean;
  49715. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49716. EXPOSURE: boolean;
  49717. MULTIVIEW: boolean;
  49718. USEPHYSICALLIGHTFALLOFF: boolean;
  49719. USEGLTFLIGHTFALLOFF: boolean;
  49720. TWOSIDEDLIGHTING: boolean;
  49721. SHADOWFLOAT: boolean;
  49722. CLIPPLANE: boolean;
  49723. CLIPPLANE2: boolean;
  49724. CLIPPLANE3: boolean;
  49725. CLIPPLANE4: boolean;
  49726. POINTSIZE: boolean;
  49727. FOG: boolean;
  49728. LOGARITHMICDEPTH: boolean;
  49729. FORCENORMALFORWARD: boolean;
  49730. SPECULARAA: boolean;
  49731. CLEARCOAT: boolean;
  49732. CLEARCOAT_DEFAULTIOR: boolean;
  49733. CLEARCOAT_TEXTURE: boolean;
  49734. CLEARCOAT_TEXTUREDIRECTUV: number;
  49735. CLEARCOAT_BUMP: boolean;
  49736. CLEARCOAT_BUMPDIRECTUV: number;
  49737. CLEARCOAT_TINT: boolean;
  49738. CLEARCOAT_TINT_TEXTURE: boolean;
  49739. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49740. ANISOTROPIC: boolean;
  49741. ANISOTROPIC_TEXTURE: boolean;
  49742. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49743. BRDF_V_HEIGHT_CORRELATED: boolean;
  49744. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49745. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49746. SHEEN: boolean;
  49747. SHEEN_TEXTURE: boolean;
  49748. SHEEN_TEXTUREDIRECTUV: number;
  49749. SHEEN_LINKWITHALBEDO: boolean;
  49750. SUBSURFACE: boolean;
  49751. SS_REFRACTION: boolean;
  49752. SS_TRANSLUCENCY: boolean;
  49753. SS_SCATERRING: boolean;
  49754. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49755. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49756. SS_REFRACTIONMAP_3D: boolean;
  49757. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49758. SS_LODINREFRACTIONALPHA: boolean;
  49759. SS_GAMMAREFRACTION: boolean;
  49760. SS_RGBDREFRACTION: boolean;
  49761. SS_LINEARSPECULARREFRACTION: boolean;
  49762. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49763. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49764. UNLIT: boolean;
  49765. DEBUGMODE: number;
  49766. /**
  49767. * Initializes the PBR Material defines.
  49768. */
  49769. constructor();
  49770. /**
  49771. * Resets the PBR Material defines.
  49772. */
  49773. reset(): void;
  49774. }
  49775. /**
  49776. * The Physically based material base class of BJS.
  49777. *
  49778. * This offers the main features of a standard PBR material.
  49779. * For more information, please refer to the documentation :
  49780. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49781. */
  49782. export abstract class PBRBaseMaterial extends PushMaterial {
  49783. /**
  49784. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49785. */
  49786. static readonly PBRMATERIAL_OPAQUE: number;
  49787. /**
  49788. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49789. */
  49790. static readonly PBRMATERIAL_ALPHATEST: number;
  49791. /**
  49792. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49793. */
  49794. static readonly PBRMATERIAL_ALPHABLEND: number;
  49795. /**
  49796. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49797. * They are also discarded below the alpha cutoff threshold to improve performances.
  49798. */
  49799. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49800. /**
  49801. * Defines the default value of how much AO map is occluding the analytical lights
  49802. * (point spot...).
  49803. */
  49804. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49805. /**
  49806. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49807. */
  49808. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49809. /**
  49810. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49811. * to enhance interoperability with other engines.
  49812. */
  49813. static readonly LIGHTFALLOFF_GLTF: number;
  49814. /**
  49815. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49816. * to enhance interoperability with other materials.
  49817. */
  49818. static readonly LIGHTFALLOFF_STANDARD: number;
  49819. /**
  49820. * Intensity of the direct lights e.g. the four lights available in your scene.
  49821. * This impacts both the direct diffuse and specular highlights.
  49822. */
  49823. protected _directIntensity: number;
  49824. /**
  49825. * Intensity of the emissive part of the material.
  49826. * This helps controlling the emissive effect without modifying the emissive color.
  49827. */
  49828. protected _emissiveIntensity: number;
  49829. /**
  49830. * Intensity of the environment e.g. how much the environment will light the object
  49831. * either through harmonics for rough material or through the refelction for shiny ones.
  49832. */
  49833. protected _environmentIntensity: number;
  49834. /**
  49835. * This is a special control allowing the reduction of the specular highlights coming from the
  49836. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49837. */
  49838. protected _specularIntensity: number;
  49839. /**
  49840. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49841. */
  49842. private _lightingInfos;
  49843. /**
  49844. * Debug Control allowing disabling the bump map on this material.
  49845. */
  49846. protected _disableBumpMap: boolean;
  49847. /**
  49848. * AKA Diffuse Texture in standard nomenclature.
  49849. */
  49850. protected _albedoTexture: Nullable<BaseTexture>;
  49851. /**
  49852. * AKA Occlusion Texture in other nomenclature.
  49853. */
  49854. protected _ambientTexture: Nullable<BaseTexture>;
  49855. /**
  49856. * AKA Occlusion Texture Intensity in other nomenclature.
  49857. */
  49858. protected _ambientTextureStrength: number;
  49859. /**
  49860. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49861. * 1 means it completely occludes it
  49862. * 0 mean it has no impact
  49863. */
  49864. protected _ambientTextureImpactOnAnalyticalLights: number;
  49865. /**
  49866. * Stores the alpha values in a texture.
  49867. */
  49868. protected _opacityTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Stores the reflection values in a texture.
  49871. */
  49872. protected _reflectionTexture: Nullable<BaseTexture>;
  49873. /**
  49874. * Stores the emissive values in a texture.
  49875. */
  49876. protected _emissiveTexture: Nullable<BaseTexture>;
  49877. /**
  49878. * AKA Specular texture in other nomenclature.
  49879. */
  49880. protected _reflectivityTexture: Nullable<BaseTexture>;
  49881. /**
  49882. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49883. */
  49884. protected _metallicTexture: Nullable<BaseTexture>;
  49885. /**
  49886. * Specifies the metallic scalar of the metallic/roughness workflow.
  49887. * Can also be used to scale the metalness values of the metallic texture.
  49888. */
  49889. protected _metallic: Nullable<number>;
  49890. /**
  49891. * Specifies the roughness scalar of the metallic/roughness workflow.
  49892. * Can also be used to scale the roughness values of the metallic texture.
  49893. */
  49894. protected _roughness: Nullable<number>;
  49895. /**
  49896. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49897. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49898. */
  49899. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49900. /**
  49901. * Stores surface normal data used to displace a mesh in a texture.
  49902. */
  49903. protected _bumpTexture: Nullable<BaseTexture>;
  49904. /**
  49905. * Stores the pre-calculated light information of a mesh in a texture.
  49906. */
  49907. protected _lightmapTexture: Nullable<BaseTexture>;
  49908. /**
  49909. * The color of a material in ambient lighting.
  49910. */
  49911. protected _ambientColor: Color3;
  49912. /**
  49913. * AKA Diffuse Color in other nomenclature.
  49914. */
  49915. protected _albedoColor: Color3;
  49916. /**
  49917. * AKA Specular Color in other nomenclature.
  49918. */
  49919. protected _reflectivityColor: Color3;
  49920. /**
  49921. * The color applied when light is reflected from a material.
  49922. */
  49923. protected _reflectionColor: Color3;
  49924. /**
  49925. * The color applied when light is emitted from a material.
  49926. */
  49927. protected _emissiveColor: Color3;
  49928. /**
  49929. * AKA Glossiness in other nomenclature.
  49930. */
  49931. protected _microSurface: number;
  49932. /**
  49933. * Specifies that the material will use the light map as a show map.
  49934. */
  49935. protected _useLightmapAsShadowmap: boolean;
  49936. /**
  49937. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49938. * makes the reflect vector face the model (under horizon).
  49939. */
  49940. protected _useHorizonOcclusion: boolean;
  49941. /**
  49942. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49943. * too much the area relying on ambient texture to define their ambient occlusion.
  49944. */
  49945. protected _useRadianceOcclusion: boolean;
  49946. /**
  49947. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49948. */
  49949. protected _useAlphaFromAlbedoTexture: boolean;
  49950. /**
  49951. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49952. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49953. */
  49954. protected _useSpecularOverAlpha: boolean;
  49955. /**
  49956. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49957. */
  49958. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49959. /**
  49960. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49961. */
  49962. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49963. /**
  49964. * Specifies if the metallic texture contains the roughness information in its green channel.
  49965. */
  49966. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49967. /**
  49968. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49969. */
  49970. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49971. /**
  49972. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49973. */
  49974. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49975. /**
  49976. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49977. */
  49978. protected _useAmbientInGrayScale: boolean;
  49979. /**
  49980. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49981. * The material will try to infer what glossiness each pixel should be.
  49982. */
  49983. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49984. /**
  49985. * Defines the falloff type used in this material.
  49986. * It by default is Physical.
  49987. */
  49988. protected _lightFalloff: number;
  49989. /**
  49990. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49991. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49992. */
  49993. protected _useRadianceOverAlpha: boolean;
  49994. /**
  49995. * Allows using an object space normal map (instead of tangent space).
  49996. */
  49997. protected _useObjectSpaceNormalMap: boolean;
  49998. /**
  49999. * Allows using the bump map in parallax mode.
  50000. */
  50001. protected _useParallax: boolean;
  50002. /**
  50003. * Allows using the bump map in parallax occlusion mode.
  50004. */
  50005. protected _useParallaxOcclusion: boolean;
  50006. /**
  50007. * Controls the scale bias of the parallax mode.
  50008. */
  50009. protected _parallaxScaleBias: number;
  50010. /**
  50011. * If sets to true, disables all the lights affecting the material.
  50012. */
  50013. protected _disableLighting: boolean;
  50014. /**
  50015. * Number of Simultaneous lights allowed on the material.
  50016. */
  50017. protected _maxSimultaneousLights: number;
  50018. /**
  50019. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50020. */
  50021. protected _invertNormalMapX: boolean;
  50022. /**
  50023. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50024. */
  50025. protected _invertNormalMapY: boolean;
  50026. /**
  50027. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50028. */
  50029. protected _twoSidedLighting: boolean;
  50030. /**
  50031. * Defines the alpha limits in alpha test mode.
  50032. */
  50033. protected _alphaCutOff: number;
  50034. /**
  50035. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50036. */
  50037. protected _forceAlphaTest: boolean;
  50038. /**
  50039. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50040. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50041. */
  50042. protected _useAlphaFresnel: boolean;
  50043. /**
  50044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50045. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50046. */
  50047. protected _useLinearAlphaFresnel: boolean;
  50048. /**
  50049. * The transparency mode of the material.
  50050. */
  50051. protected _transparencyMode: Nullable<number>;
  50052. /**
  50053. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50054. * from cos thetav and roughness:
  50055. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50056. */
  50057. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50058. /**
  50059. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50060. */
  50061. protected _forceIrradianceInFragment: boolean;
  50062. /**
  50063. * Force normal to face away from face.
  50064. */
  50065. protected _forceNormalForward: boolean;
  50066. /**
  50067. * Enables specular anti aliasing in the PBR shader.
  50068. * It will both interacts on the Geometry for analytical and IBL lighting.
  50069. * It also prefilter the roughness map based on the bump values.
  50070. */
  50071. protected _enableSpecularAntiAliasing: boolean;
  50072. /**
  50073. * Default configuration related to image processing available in the PBR Material.
  50074. */
  50075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50076. /**
  50077. * Keep track of the image processing observer to allow dispose and replace.
  50078. */
  50079. private _imageProcessingObserver;
  50080. /**
  50081. * Attaches a new image processing configuration to the PBR Material.
  50082. * @param configuration
  50083. */
  50084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50085. /**
  50086. * Stores the available render targets.
  50087. */
  50088. private _renderTargets;
  50089. /**
  50090. * Sets the global ambient color for the material used in lighting calculations.
  50091. */
  50092. private _globalAmbientColor;
  50093. /**
  50094. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50095. */
  50096. private _useLogarithmicDepth;
  50097. /**
  50098. * If set to true, no lighting calculations will be applied.
  50099. */
  50100. private _unlit;
  50101. private _debugMode;
  50102. /**
  50103. * @hidden
  50104. * This is reserved for the inspector.
  50105. * Defines the material debug mode.
  50106. * It helps seeing only some components of the material while troubleshooting.
  50107. */
  50108. debugMode: number;
  50109. /**
  50110. * @hidden
  50111. * This is reserved for the inspector.
  50112. * Specify from where on screen the debug mode should start.
  50113. * The value goes from -1 (full screen) to 1 (not visible)
  50114. * It helps with side by side comparison against the final render
  50115. * This defaults to -1
  50116. */
  50117. private debugLimit;
  50118. /**
  50119. * @hidden
  50120. * This is reserved for the inspector.
  50121. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50122. * You can use the factor to better multiply the final value.
  50123. */
  50124. private debugFactor;
  50125. /**
  50126. * Defines the clear coat layer parameters for the material.
  50127. */
  50128. readonly clearCoat: PBRClearCoatConfiguration;
  50129. /**
  50130. * Defines the anisotropic parameters for the material.
  50131. */
  50132. readonly anisotropy: PBRAnisotropicConfiguration;
  50133. /**
  50134. * Defines the BRDF parameters for the material.
  50135. */
  50136. readonly brdf: PBRBRDFConfiguration;
  50137. /**
  50138. * Defines the Sheen parameters for the material.
  50139. */
  50140. readonly sheen: PBRSheenConfiguration;
  50141. /**
  50142. * Defines the SubSurface parameters for the material.
  50143. */
  50144. readonly subSurface: PBRSubSurfaceConfiguration;
  50145. /**
  50146. * Custom callback helping to override the default shader used in the material.
  50147. */
  50148. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50149. protected _rebuildInParallel: boolean;
  50150. /**
  50151. * Instantiates a new PBRMaterial instance.
  50152. *
  50153. * @param name The material name
  50154. * @param scene The scene the material will be use in.
  50155. */
  50156. constructor(name: string, scene: Scene);
  50157. /**
  50158. * Gets a boolean indicating that current material needs to register RTT
  50159. */
  50160. readonly hasRenderTargetTextures: boolean;
  50161. /**
  50162. * Gets the name of the material class.
  50163. */
  50164. getClassName(): string;
  50165. /**
  50166. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50167. */
  50168. /**
  50169. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50170. */
  50171. useLogarithmicDepth: boolean;
  50172. /**
  50173. * Gets the current transparency mode.
  50174. */
  50175. /**
  50176. * Sets the transparency mode of the material.
  50177. *
  50178. * | Value | Type | Description |
  50179. * | ----- | ----------------------------------- | ----------- |
  50180. * | 0 | OPAQUE | |
  50181. * | 1 | ALPHATEST | |
  50182. * | 2 | ALPHABLEND | |
  50183. * | 3 | ALPHATESTANDBLEND | |
  50184. *
  50185. */
  50186. transparencyMode: Nullable<number>;
  50187. /**
  50188. * Returns true if alpha blending should be disabled.
  50189. */
  50190. private readonly _disableAlphaBlending;
  50191. /**
  50192. * Specifies whether or not this material should be rendered in alpha blend mode.
  50193. */
  50194. needAlphaBlending(): boolean;
  50195. /**
  50196. * Specifies if the mesh will require alpha blending.
  50197. * @param mesh - BJS mesh.
  50198. */
  50199. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50200. /**
  50201. * Specifies whether or not this material should be rendered in alpha test mode.
  50202. */
  50203. needAlphaTesting(): boolean;
  50204. /**
  50205. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50206. */
  50207. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50208. /**
  50209. * Gets the texture used for the alpha test.
  50210. */
  50211. getAlphaTestTexture(): Nullable<BaseTexture>;
  50212. /**
  50213. * Specifies that the submesh is ready to be used.
  50214. * @param mesh - BJS mesh.
  50215. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50216. * @param useInstances - Specifies that instances should be used.
  50217. * @returns - boolean indicating that the submesh is ready or not.
  50218. */
  50219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50220. /**
  50221. * Specifies if the material uses metallic roughness workflow.
  50222. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50223. */
  50224. isMetallicWorkflow(): boolean;
  50225. private _prepareEffect;
  50226. private _prepareDefines;
  50227. /**
  50228. * Force shader compilation
  50229. */
  50230. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50231. clipPlane: boolean;
  50232. }>): void;
  50233. /**
  50234. * Initializes the uniform buffer layout for the shader.
  50235. */
  50236. buildUniformLayout(): void;
  50237. /**
  50238. * Unbinds the material from the mesh
  50239. */
  50240. unbind(): void;
  50241. /**
  50242. * Binds the submesh data.
  50243. * @param world - The world matrix.
  50244. * @param mesh - The BJS mesh.
  50245. * @param subMesh - A submesh of the BJS mesh.
  50246. */
  50247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50248. /**
  50249. * Returns the animatable textures.
  50250. * @returns - Array of animatable textures.
  50251. */
  50252. getAnimatables(): IAnimatable[];
  50253. /**
  50254. * Returns the texture used for reflections.
  50255. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50256. */
  50257. private _getReflectionTexture;
  50258. /**
  50259. * Returns an array of the actively used textures.
  50260. * @returns - Array of BaseTextures
  50261. */
  50262. getActiveTextures(): BaseTexture[];
  50263. /**
  50264. * Checks to see if a texture is used in the material.
  50265. * @param texture - Base texture to use.
  50266. * @returns - Boolean specifying if a texture is used in the material.
  50267. */
  50268. hasTexture(texture: BaseTexture): boolean;
  50269. /**
  50270. * Disposes the resources of the material.
  50271. * @param forceDisposeEffect - Forces the disposal of effects.
  50272. * @param forceDisposeTextures - Forces the disposal of all textures.
  50273. */
  50274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50275. }
  50276. }
  50277. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50278. import { Nullable } from "babylonjs/types";
  50279. import { Scene } from "babylonjs/scene";
  50280. import { Color3 } from "babylonjs/Maths/math.color";
  50281. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50282. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50284. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50285. /**
  50286. * The Physically based material of BJS.
  50287. *
  50288. * This offers the main features of a standard PBR material.
  50289. * For more information, please refer to the documentation :
  50290. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50291. */
  50292. export class PBRMaterial extends PBRBaseMaterial {
  50293. /**
  50294. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50295. */
  50296. static readonly PBRMATERIAL_OPAQUE: number;
  50297. /**
  50298. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50299. */
  50300. static readonly PBRMATERIAL_ALPHATEST: number;
  50301. /**
  50302. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50303. */
  50304. static readonly PBRMATERIAL_ALPHABLEND: number;
  50305. /**
  50306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50307. * They are also discarded below the alpha cutoff threshold to improve performances.
  50308. */
  50309. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50310. /**
  50311. * Defines the default value of how much AO map is occluding the analytical lights
  50312. * (point spot...).
  50313. */
  50314. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50315. /**
  50316. * Intensity of the direct lights e.g. the four lights available in your scene.
  50317. * This impacts both the direct diffuse and specular highlights.
  50318. */
  50319. directIntensity: number;
  50320. /**
  50321. * Intensity of the emissive part of the material.
  50322. * This helps controlling the emissive effect without modifying the emissive color.
  50323. */
  50324. emissiveIntensity: number;
  50325. /**
  50326. * Intensity of the environment e.g. how much the environment will light the object
  50327. * either through harmonics for rough material or through the refelction for shiny ones.
  50328. */
  50329. environmentIntensity: number;
  50330. /**
  50331. * This is a special control allowing the reduction of the specular highlights coming from the
  50332. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50333. */
  50334. specularIntensity: number;
  50335. /**
  50336. * Debug Control allowing disabling the bump map on this material.
  50337. */
  50338. disableBumpMap: boolean;
  50339. /**
  50340. * AKA Diffuse Texture in standard nomenclature.
  50341. */
  50342. albedoTexture: BaseTexture;
  50343. /**
  50344. * AKA Occlusion Texture in other nomenclature.
  50345. */
  50346. ambientTexture: BaseTexture;
  50347. /**
  50348. * AKA Occlusion Texture Intensity in other nomenclature.
  50349. */
  50350. ambientTextureStrength: number;
  50351. /**
  50352. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50353. * 1 means it completely occludes it
  50354. * 0 mean it has no impact
  50355. */
  50356. ambientTextureImpactOnAnalyticalLights: number;
  50357. /**
  50358. * Stores the alpha values in a texture.
  50359. */
  50360. opacityTexture: BaseTexture;
  50361. /**
  50362. * Stores the reflection values in a texture.
  50363. */
  50364. reflectionTexture: Nullable<BaseTexture>;
  50365. /**
  50366. * Stores the emissive values in a texture.
  50367. */
  50368. emissiveTexture: BaseTexture;
  50369. /**
  50370. * AKA Specular texture in other nomenclature.
  50371. */
  50372. reflectivityTexture: BaseTexture;
  50373. /**
  50374. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50375. */
  50376. metallicTexture: BaseTexture;
  50377. /**
  50378. * Specifies the metallic scalar of the metallic/roughness workflow.
  50379. * Can also be used to scale the metalness values of the metallic texture.
  50380. */
  50381. metallic: Nullable<number>;
  50382. /**
  50383. * Specifies the roughness scalar of the metallic/roughness workflow.
  50384. * Can also be used to scale the roughness values of the metallic texture.
  50385. */
  50386. roughness: Nullable<number>;
  50387. /**
  50388. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50389. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50390. */
  50391. microSurfaceTexture: BaseTexture;
  50392. /**
  50393. * Stores surface normal data used to displace a mesh in a texture.
  50394. */
  50395. bumpTexture: BaseTexture;
  50396. /**
  50397. * Stores the pre-calculated light information of a mesh in a texture.
  50398. */
  50399. lightmapTexture: BaseTexture;
  50400. /**
  50401. * Stores the refracted light information in a texture.
  50402. */
  50403. refractionTexture: Nullable<BaseTexture>;
  50404. /**
  50405. * The color of a material in ambient lighting.
  50406. */
  50407. ambientColor: Color3;
  50408. /**
  50409. * AKA Diffuse Color in other nomenclature.
  50410. */
  50411. albedoColor: Color3;
  50412. /**
  50413. * AKA Specular Color in other nomenclature.
  50414. */
  50415. reflectivityColor: Color3;
  50416. /**
  50417. * The color reflected from the material.
  50418. */
  50419. reflectionColor: Color3;
  50420. /**
  50421. * The color emitted from the material.
  50422. */
  50423. emissiveColor: Color3;
  50424. /**
  50425. * AKA Glossiness in other nomenclature.
  50426. */
  50427. microSurface: number;
  50428. /**
  50429. * source material index of refraction (IOR)' / 'destination material IOR.
  50430. */
  50431. indexOfRefraction: number;
  50432. /**
  50433. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50434. */
  50435. invertRefractionY: boolean;
  50436. /**
  50437. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50438. * Materials half opaque for instance using refraction could benefit from this control.
  50439. */
  50440. linkRefractionWithTransparency: boolean;
  50441. /**
  50442. * If true, the light map contains occlusion information instead of lighting info.
  50443. */
  50444. useLightmapAsShadowmap: boolean;
  50445. /**
  50446. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50447. */
  50448. useAlphaFromAlbedoTexture: boolean;
  50449. /**
  50450. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50451. */
  50452. forceAlphaTest: boolean;
  50453. /**
  50454. * Defines the alpha limits in alpha test mode.
  50455. */
  50456. alphaCutOff: number;
  50457. /**
  50458. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50459. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50460. */
  50461. useSpecularOverAlpha: boolean;
  50462. /**
  50463. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50464. */
  50465. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50466. /**
  50467. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50468. */
  50469. useRoughnessFromMetallicTextureAlpha: boolean;
  50470. /**
  50471. * Specifies if the metallic texture contains the roughness information in its green channel.
  50472. */
  50473. useRoughnessFromMetallicTextureGreen: boolean;
  50474. /**
  50475. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50476. */
  50477. useMetallnessFromMetallicTextureBlue: boolean;
  50478. /**
  50479. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50480. */
  50481. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50482. /**
  50483. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50484. */
  50485. useAmbientInGrayScale: boolean;
  50486. /**
  50487. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50488. * The material will try to infer what glossiness each pixel should be.
  50489. */
  50490. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50491. /**
  50492. * BJS is using an harcoded light falloff based on a manually sets up range.
  50493. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50494. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50495. */
  50496. /**
  50497. * BJS is using an harcoded light falloff based on a manually sets up range.
  50498. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50499. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50500. */
  50501. usePhysicalLightFalloff: boolean;
  50502. /**
  50503. * In order to support the falloff compatibility with gltf, a special mode has been added
  50504. * to reproduce the gltf light falloff.
  50505. */
  50506. /**
  50507. * In order to support the falloff compatibility with gltf, a special mode has been added
  50508. * to reproduce the gltf light falloff.
  50509. */
  50510. useGLTFLightFalloff: boolean;
  50511. /**
  50512. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50513. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50514. */
  50515. useRadianceOverAlpha: boolean;
  50516. /**
  50517. * Allows using an object space normal map (instead of tangent space).
  50518. */
  50519. useObjectSpaceNormalMap: boolean;
  50520. /**
  50521. * Allows using the bump map in parallax mode.
  50522. */
  50523. useParallax: boolean;
  50524. /**
  50525. * Allows using the bump map in parallax occlusion mode.
  50526. */
  50527. useParallaxOcclusion: boolean;
  50528. /**
  50529. * Controls the scale bias of the parallax mode.
  50530. */
  50531. parallaxScaleBias: number;
  50532. /**
  50533. * If sets to true, disables all the lights affecting the material.
  50534. */
  50535. disableLighting: boolean;
  50536. /**
  50537. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50538. */
  50539. forceIrradianceInFragment: boolean;
  50540. /**
  50541. * Number of Simultaneous lights allowed on the material.
  50542. */
  50543. maxSimultaneousLights: number;
  50544. /**
  50545. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50546. */
  50547. invertNormalMapX: boolean;
  50548. /**
  50549. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50550. */
  50551. invertNormalMapY: boolean;
  50552. /**
  50553. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50554. */
  50555. twoSidedLighting: boolean;
  50556. /**
  50557. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50558. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50559. */
  50560. useAlphaFresnel: boolean;
  50561. /**
  50562. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50563. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50564. */
  50565. useLinearAlphaFresnel: boolean;
  50566. /**
  50567. * Let user defines the brdf lookup texture used for IBL.
  50568. * A default 8bit version is embedded but you could point at :
  50569. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50570. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50571. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50572. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50573. */
  50574. environmentBRDFTexture: Nullable<BaseTexture>;
  50575. /**
  50576. * Force normal to face away from face.
  50577. */
  50578. forceNormalForward: boolean;
  50579. /**
  50580. * Enables specular anti aliasing in the PBR shader.
  50581. * It will both interacts on the Geometry for analytical and IBL lighting.
  50582. * It also prefilter the roughness map based on the bump values.
  50583. */
  50584. enableSpecularAntiAliasing: boolean;
  50585. /**
  50586. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50587. * makes the reflect vector face the model (under horizon).
  50588. */
  50589. useHorizonOcclusion: boolean;
  50590. /**
  50591. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50592. * too much the area relying on ambient texture to define their ambient occlusion.
  50593. */
  50594. useRadianceOcclusion: boolean;
  50595. /**
  50596. * If set to true, no lighting calculations will be applied.
  50597. */
  50598. unlit: boolean;
  50599. /**
  50600. * Gets the image processing configuration used either in this material.
  50601. */
  50602. /**
  50603. * Sets the Default image processing configuration used either in the this material.
  50604. *
  50605. * If sets to null, the scene one is in use.
  50606. */
  50607. imageProcessingConfiguration: ImageProcessingConfiguration;
  50608. /**
  50609. * Gets wether the color curves effect is enabled.
  50610. */
  50611. /**
  50612. * Sets wether the color curves effect is enabled.
  50613. */
  50614. cameraColorCurvesEnabled: boolean;
  50615. /**
  50616. * Gets wether the color grading effect is enabled.
  50617. */
  50618. /**
  50619. * Gets wether the color grading effect is enabled.
  50620. */
  50621. cameraColorGradingEnabled: boolean;
  50622. /**
  50623. * Gets wether tonemapping is enabled or not.
  50624. */
  50625. /**
  50626. * Sets wether tonemapping is enabled or not
  50627. */
  50628. cameraToneMappingEnabled: boolean;
  50629. /**
  50630. * The camera exposure used on this material.
  50631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50632. * This corresponds to a photographic exposure.
  50633. */
  50634. /**
  50635. * The camera exposure used on this material.
  50636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50637. * This corresponds to a photographic exposure.
  50638. */
  50639. cameraExposure: number;
  50640. /**
  50641. * Gets The camera contrast used on this material.
  50642. */
  50643. /**
  50644. * Sets The camera contrast used on this material.
  50645. */
  50646. cameraContrast: number;
  50647. /**
  50648. * Gets the Color Grading 2D Lookup Texture.
  50649. */
  50650. /**
  50651. * Sets the Color Grading 2D Lookup Texture.
  50652. */
  50653. cameraColorGradingTexture: Nullable<BaseTexture>;
  50654. /**
  50655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50657. * 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;
  50658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50659. */
  50660. /**
  50661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50663. * 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;
  50664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50665. */
  50666. cameraColorCurves: Nullable<ColorCurves>;
  50667. /**
  50668. * Instantiates a new PBRMaterial instance.
  50669. *
  50670. * @param name The material name
  50671. * @param scene The scene the material will be use in.
  50672. */
  50673. constructor(name: string, scene: Scene);
  50674. /**
  50675. * Returns the name of this material class.
  50676. */
  50677. getClassName(): string;
  50678. /**
  50679. * Makes a duplicate of the current material.
  50680. * @param name - name to use for the new material.
  50681. */
  50682. clone(name: string): PBRMaterial;
  50683. /**
  50684. * Serializes this PBR Material.
  50685. * @returns - An object with the serialized material.
  50686. */
  50687. serialize(): any;
  50688. /**
  50689. * Parses a PBR Material from a serialized object.
  50690. * @param source - Serialized object.
  50691. * @param scene - BJS scene instance.
  50692. * @param rootUrl - url for the scene object
  50693. * @returns - PBRMaterial
  50694. */
  50695. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50696. }
  50697. }
  50698. declare module "babylonjs/Misc/dds" {
  50699. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50701. import { Nullable } from "babylonjs/types";
  50702. import { Scene } from "babylonjs/scene";
  50703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50705. /**
  50706. * Direct draw surface info
  50707. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50708. */
  50709. export interface DDSInfo {
  50710. /**
  50711. * Width of the texture
  50712. */
  50713. width: number;
  50714. /**
  50715. * Width of the texture
  50716. */
  50717. height: number;
  50718. /**
  50719. * Number of Mipmaps for the texture
  50720. * @see https://en.wikipedia.org/wiki/Mipmap
  50721. */
  50722. mipmapCount: number;
  50723. /**
  50724. * If the textures format is a known fourCC format
  50725. * @see https://www.fourcc.org/
  50726. */
  50727. isFourCC: boolean;
  50728. /**
  50729. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50730. */
  50731. isRGB: boolean;
  50732. /**
  50733. * If the texture is a lumincance format
  50734. */
  50735. isLuminance: boolean;
  50736. /**
  50737. * If this is a cube texture
  50738. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50739. */
  50740. isCube: boolean;
  50741. /**
  50742. * If the texture is a compressed format eg. FOURCC_DXT1
  50743. */
  50744. isCompressed: boolean;
  50745. /**
  50746. * The dxgiFormat of the texture
  50747. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50748. */
  50749. dxgiFormat: number;
  50750. /**
  50751. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50752. */
  50753. textureType: number;
  50754. /**
  50755. * Sphericle polynomial created for the dds texture
  50756. */
  50757. sphericalPolynomial?: SphericalPolynomial;
  50758. }
  50759. /**
  50760. * Class used to provide DDS decompression tools
  50761. */
  50762. export class DDSTools {
  50763. /**
  50764. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50765. */
  50766. static StoreLODInAlphaChannel: boolean;
  50767. /**
  50768. * Gets DDS information from an array buffer
  50769. * @param arrayBuffer defines the array buffer to read data from
  50770. * @returns the DDS information
  50771. */
  50772. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50773. private static _FloatView;
  50774. private static _Int32View;
  50775. private static _ToHalfFloat;
  50776. private static _FromHalfFloat;
  50777. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50778. private static _GetHalfFloatRGBAArrayBuffer;
  50779. private static _GetFloatRGBAArrayBuffer;
  50780. private static _GetFloatAsUIntRGBAArrayBuffer;
  50781. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50782. private static _GetRGBAArrayBuffer;
  50783. private static _ExtractLongWordOrder;
  50784. private static _GetRGBArrayBuffer;
  50785. private static _GetLuminanceArrayBuffer;
  50786. /**
  50787. * Uploads DDS Levels to a Babylon Texture
  50788. * @hidden
  50789. */
  50790. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50791. }
  50792. module "babylonjs/Engines/thinEngine" {
  50793. interface ThinEngine {
  50794. /**
  50795. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50796. * @param rootUrl defines the url where the file to load is located
  50797. * @param scene defines the current scene
  50798. * @param lodScale defines scale to apply to the mip map selection
  50799. * @param lodOffset defines offset to apply to the mip map selection
  50800. * @param onLoad defines an optional callback raised when the texture is loaded
  50801. * @param onError defines an optional callback raised if there is an issue to load the texture
  50802. * @param format defines the format of the data
  50803. * @param forcedExtension defines the extension to use to pick the right loader
  50804. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50805. * @returns the cube texture as an InternalTexture
  50806. */
  50807. 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;
  50808. }
  50809. }
  50810. }
  50811. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50812. import { Nullable } from "babylonjs/types";
  50813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50814. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50815. /**
  50816. * Implementation of the DDS Texture Loader.
  50817. * @hidden
  50818. */
  50819. export class _DDSTextureLoader implements IInternalTextureLoader {
  50820. /**
  50821. * Defines wether the loader supports cascade loading the different faces.
  50822. */
  50823. readonly supportCascades: boolean;
  50824. /**
  50825. * This returns if the loader support the current file information.
  50826. * @param extension defines the file extension of the file being loaded
  50827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50828. * @param fallback defines the fallback internal texture if any
  50829. * @param isBase64 defines whether the texture is encoded as a base64
  50830. * @param isBuffer defines whether the texture data are stored as a buffer
  50831. * @returns true if the loader can load the specified file
  50832. */
  50833. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50834. /**
  50835. * Transform the url before loading if required.
  50836. * @param rootUrl the url of the texture
  50837. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50838. * @returns the transformed texture
  50839. */
  50840. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50841. /**
  50842. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50843. * @param rootUrl the url of the texture
  50844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50845. * @returns the fallback texture
  50846. */
  50847. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50848. /**
  50849. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50850. * @param data contains the texture data
  50851. * @param texture defines the BabylonJS internal texture
  50852. * @param createPolynomials will be true if polynomials have been requested
  50853. * @param onLoad defines the callback to trigger once the texture is ready
  50854. * @param onError defines the callback to trigger in case of error
  50855. */
  50856. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50857. /**
  50858. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50859. * @param data contains the texture data
  50860. * @param texture defines the BabylonJS internal texture
  50861. * @param callback defines the method to call once ready to upload
  50862. */
  50863. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50864. }
  50865. }
  50866. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50867. import { Nullable } from "babylonjs/types";
  50868. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50869. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50870. /**
  50871. * Implementation of the ENV Texture Loader.
  50872. * @hidden
  50873. */
  50874. export class _ENVTextureLoader implements IInternalTextureLoader {
  50875. /**
  50876. * Defines wether the loader supports cascade loading the different faces.
  50877. */
  50878. readonly supportCascades: boolean;
  50879. /**
  50880. * This returns if the loader support the current file information.
  50881. * @param extension defines the file extension of the file being loaded
  50882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50883. * @param fallback defines the fallback internal texture if any
  50884. * @param isBase64 defines whether the texture is encoded as a base64
  50885. * @param isBuffer defines whether the texture data are stored as a buffer
  50886. * @returns true if the loader can load the specified file
  50887. */
  50888. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50889. /**
  50890. * Transform the url before loading if required.
  50891. * @param rootUrl the url of the texture
  50892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50893. * @returns the transformed texture
  50894. */
  50895. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50896. /**
  50897. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50898. * @param rootUrl the url of the texture
  50899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50900. * @returns the fallback texture
  50901. */
  50902. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50903. /**
  50904. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50905. * @param data contains the texture data
  50906. * @param texture defines the BabylonJS internal texture
  50907. * @param createPolynomials will be true if polynomials have been requested
  50908. * @param onLoad defines the callback to trigger once the texture is ready
  50909. * @param onError defines the callback to trigger in case of error
  50910. */
  50911. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50912. /**
  50913. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50914. * @param data contains the texture data
  50915. * @param texture defines the BabylonJS internal texture
  50916. * @param callback defines the method to call once ready to upload
  50917. */
  50918. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50919. }
  50920. }
  50921. declare module "babylonjs/Misc/khronosTextureContainer" {
  50922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50923. /**
  50924. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50925. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50926. */
  50927. export class KhronosTextureContainer {
  50928. /** contents of the KTX container file */
  50929. arrayBuffer: any;
  50930. private static HEADER_LEN;
  50931. private static COMPRESSED_2D;
  50932. private static COMPRESSED_3D;
  50933. private static TEX_2D;
  50934. private static TEX_3D;
  50935. /**
  50936. * Gets the openGL type
  50937. */
  50938. glType: number;
  50939. /**
  50940. * Gets the openGL type size
  50941. */
  50942. glTypeSize: number;
  50943. /**
  50944. * Gets the openGL format
  50945. */
  50946. glFormat: number;
  50947. /**
  50948. * Gets the openGL internal format
  50949. */
  50950. glInternalFormat: number;
  50951. /**
  50952. * Gets the base internal format
  50953. */
  50954. glBaseInternalFormat: number;
  50955. /**
  50956. * Gets image width in pixel
  50957. */
  50958. pixelWidth: number;
  50959. /**
  50960. * Gets image height in pixel
  50961. */
  50962. pixelHeight: number;
  50963. /**
  50964. * Gets image depth in pixels
  50965. */
  50966. pixelDepth: number;
  50967. /**
  50968. * Gets the number of array elements
  50969. */
  50970. numberOfArrayElements: number;
  50971. /**
  50972. * Gets the number of faces
  50973. */
  50974. numberOfFaces: number;
  50975. /**
  50976. * Gets the number of mipmap levels
  50977. */
  50978. numberOfMipmapLevels: number;
  50979. /**
  50980. * Gets the bytes of key value data
  50981. */
  50982. bytesOfKeyValueData: number;
  50983. /**
  50984. * Gets the load type
  50985. */
  50986. loadType: number;
  50987. /**
  50988. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50989. */
  50990. isInvalid: boolean;
  50991. /**
  50992. * Creates a new KhronosTextureContainer
  50993. * @param arrayBuffer contents of the KTX container file
  50994. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50995. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50996. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50997. */
  50998. constructor(
  50999. /** contents of the KTX container file */
  51000. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51001. /**
  51002. * Uploads KTX content to a Babylon Texture.
  51003. * It is assumed that the texture has already been created & is currently bound
  51004. * @hidden
  51005. */
  51006. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51007. private _upload2DCompressedLevels;
  51008. }
  51009. }
  51010. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51011. import { Nullable } from "babylonjs/types";
  51012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51013. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51014. /**
  51015. * Implementation of the KTX Texture Loader.
  51016. * @hidden
  51017. */
  51018. export class _KTXTextureLoader implements IInternalTextureLoader {
  51019. /**
  51020. * Defines wether the loader supports cascade loading the different faces.
  51021. */
  51022. readonly supportCascades: boolean;
  51023. /**
  51024. * This returns if the loader support the current file information.
  51025. * @param extension defines the file extension of the file being loaded
  51026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51027. * @param fallback defines the fallback internal texture if any
  51028. * @param isBase64 defines whether the texture is encoded as a base64
  51029. * @param isBuffer defines whether the texture data are stored as a buffer
  51030. * @returns true if the loader can load the specified file
  51031. */
  51032. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51033. /**
  51034. * Transform the url before loading if required.
  51035. * @param rootUrl the url of the texture
  51036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51037. * @returns the transformed texture
  51038. */
  51039. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51040. /**
  51041. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51042. * @param rootUrl the url of the texture
  51043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51044. * @returns the fallback texture
  51045. */
  51046. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51047. /**
  51048. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51049. * @param data contains the texture data
  51050. * @param texture defines the BabylonJS internal texture
  51051. * @param createPolynomials will be true if polynomials have been requested
  51052. * @param onLoad defines the callback to trigger once the texture is ready
  51053. * @param onError defines the callback to trigger in case of error
  51054. */
  51055. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51056. /**
  51057. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51058. * @param data contains the texture data
  51059. * @param texture defines the BabylonJS internal texture
  51060. * @param callback defines the method to call once ready to upload
  51061. */
  51062. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51063. }
  51064. }
  51065. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51066. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51067. import { Scene } from "babylonjs/scene";
  51068. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51069. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51070. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51071. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51072. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  51073. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51075. /**
  51076. * Options for the default xr helper
  51077. */
  51078. export class WebXRDefaultExperienceOptions {
  51079. /**
  51080. * Floor meshes that should be used for teleporting
  51081. */
  51082. floorMeshes: Array<AbstractMesh>;
  51083. }
  51084. /**
  51085. * Default experience which provides a similar setup to the previous webVRExperience
  51086. */
  51087. export class WebXRDefaultExperience {
  51088. /**
  51089. * Base experience
  51090. */
  51091. baseExperience: WebXRExperienceHelper;
  51092. /**
  51093. * Input experience extension
  51094. */
  51095. input: WebXRInput;
  51096. /**
  51097. * Loads the controller models
  51098. */
  51099. controllerModelLoader: WebXRControllerModelLoader;
  51100. /**
  51101. * Enables laser pointer and selection
  51102. */
  51103. pointerSelection: WebXRControllerPointerSelection;
  51104. /**
  51105. * Enables teleportation
  51106. */
  51107. teleportation: WebXRControllerTeleportation;
  51108. /**
  51109. * Enables ui for enetering/exiting xr
  51110. */
  51111. enterExitUI: WebXREnterExitUI;
  51112. /**
  51113. * Default output canvas xr should render to
  51114. */
  51115. outputCanvas: WebXRManagedOutputCanvas;
  51116. /**
  51117. * Creates the default xr experience
  51118. * @param scene scene
  51119. * @param options options for basic configuration
  51120. * @returns resulting WebXRDefaultExperience
  51121. */
  51122. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51123. private constructor();
  51124. /**
  51125. * DIsposes of the experience helper
  51126. */
  51127. dispose(): void;
  51128. }
  51129. }
  51130. declare module "babylonjs/Helpers/sceneHelpers" {
  51131. import { Nullable } from "babylonjs/types";
  51132. import { Mesh } from "babylonjs/Meshes/mesh";
  51133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51134. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51135. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51136. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51137. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51138. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51139. import "babylonjs/Meshes/Builders/boxBuilder";
  51140. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51141. /** @hidden */
  51142. export var _forceSceneHelpersToBundle: boolean;
  51143. module "babylonjs/scene" {
  51144. interface Scene {
  51145. /**
  51146. * Creates a default light for the scene.
  51147. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51148. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51149. */
  51150. createDefaultLight(replace?: boolean): void;
  51151. /**
  51152. * Creates a default camera for the scene.
  51153. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51154. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51155. * @param replace has default false, when true replaces the active camera in the scene
  51156. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51157. */
  51158. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51159. /**
  51160. * Creates a default camera and a default light.
  51161. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51162. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51163. * @param replace has the default false, when true replaces the active camera/light in the scene
  51164. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51165. */
  51166. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51167. /**
  51168. * Creates a new sky box
  51169. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51170. * @param environmentTexture defines the texture to use as environment texture
  51171. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51172. * @param scale defines the overall scale of the skybox
  51173. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51174. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51175. * @returns a new mesh holding the sky box
  51176. */
  51177. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51178. /**
  51179. * Creates a new environment
  51180. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51181. * @param options defines the options you can use to configure the environment
  51182. * @returns the new EnvironmentHelper
  51183. */
  51184. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51185. /**
  51186. * Creates a new VREXperienceHelper
  51187. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51188. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51189. * @returns a new VREXperienceHelper
  51190. */
  51191. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51192. /**
  51193. * Creates a new WebXRDefaultExperience
  51194. * @see http://doc.babylonjs.com/how_to/webxr
  51195. * @param options experience options
  51196. * @returns a promise for a new WebXRDefaultExperience
  51197. */
  51198. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51199. }
  51200. }
  51201. }
  51202. declare module "babylonjs/Helpers/videoDome" {
  51203. import { Scene } from "babylonjs/scene";
  51204. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51205. import { Mesh } from "babylonjs/Meshes/mesh";
  51206. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51207. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51208. import "babylonjs/Meshes/Builders/sphereBuilder";
  51209. /**
  51210. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51211. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51212. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51213. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51214. */
  51215. export class VideoDome extends TransformNode {
  51216. /**
  51217. * Define the video source as a Monoscopic panoramic 360 video.
  51218. */
  51219. static readonly MODE_MONOSCOPIC: number;
  51220. /**
  51221. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51222. */
  51223. static readonly MODE_TOPBOTTOM: number;
  51224. /**
  51225. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51226. */
  51227. static readonly MODE_SIDEBYSIDE: number;
  51228. private _halfDome;
  51229. private _useDirectMapping;
  51230. /**
  51231. * The video texture being displayed on the sphere
  51232. */
  51233. protected _videoTexture: VideoTexture;
  51234. /**
  51235. * Gets the video texture being displayed on the sphere
  51236. */
  51237. readonly videoTexture: VideoTexture;
  51238. /**
  51239. * The skybox material
  51240. */
  51241. protected _material: BackgroundMaterial;
  51242. /**
  51243. * The surface used for the skybox
  51244. */
  51245. protected _mesh: Mesh;
  51246. /**
  51247. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51248. */
  51249. private _halfDomeMask;
  51250. /**
  51251. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51252. * Also see the options.resolution property.
  51253. */
  51254. fovMultiplier: number;
  51255. private _videoMode;
  51256. /**
  51257. * Gets or set the current video mode for the video. It can be:
  51258. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51259. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51260. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51261. */
  51262. videoMode: number;
  51263. /**
  51264. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51265. *
  51266. */
  51267. /**
  51268. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51269. */
  51270. halfDome: boolean;
  51271. /**
  51272. * Oberserver used in Stereoscopic VR Mode.
  51273. */
  51274. private _onBeforeCameraRenderObserver;
  51275. /**
  51276. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51277. * @param name Element's name, child elements will append suffixes for their own names.
  51278. * @param urlsOrVideo defines the url(s) or the video element to use
  51279. * @param options An object containing optional or exposed sub element properties
  51280. */
  51281. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51282. resolution?: number;
  51283. clickToPlay?: boolean;
  51284. autoPlay?: boolean;
  51285. loop?: boolean;
  51286. size?: number;
  51287. poster?: string;
  51288. faceForward?: boolean;
  51289. useDirectMapping?: boolean;
  51290. halfDomeMode?: boolean;
  51291. }, scene: Scene);
  51292. private _changeVideoMode;
  51293. /**
  51294. * Releases resources associated with this node.
  51295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51297. */
  51298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51299. }
  51300. }
  51301. declare module "babylonjs/Helpers/index" {
  51302. export * from "babylonjs/Helpers/environmentHelper";
  51303. export * from "babylonjs/Helpers/photoDome";
  51304. export * from "babylonjs/Helpers/sceneHelpers";
  51305. export * from "babylonjs/Helpers/videoDome";
  51306. }
  51307. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51308. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51309. import { IDisposable } from "babylonjs/scene";
  51310. import { Engine } from "babylonjs/Engines/engine";
  51311. /**
  51312. * This class can be used to get instrumentation data from a Babylon engine
  51313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51314. */
  51315. export class EngineInstrumentation implements IDisposable {
  51316. /**
  51317. * Define the instrumented engine.
  51318. */
  51319. engine: Engine;
  51320. private _captureGPUFrameTime;
  51321. private _gpuFrameTimeToken;
  51322. private _gpuFrameTime;
  51323. private _captureShaderCompilationTime;
  51324. private _shaderCompilationTime;
  51325. private _onBeginFrameObserver;
  51326. private _onEndFrameObserver;
  51327. private _onBeforeShaderCompilationObserver;
  51328. private _onAfterShaderCompilationObserver;
  51329. /**
  51330. * Gets the perf counter used for GPU frame time
  51331. */
  51332. readonly gpuFrameTimeCounter: PerfCounter;
  51333. /**
  51334. * Gets the GPU frame time capture status
  51335. */
  51336. /**
  51337. * Enable or disable the GPU frame time capture
  51338. */
  51339. captureGPUFrameTime: boolean;
  51340. /**
  51341. * Gets the perf counter used for shader compilation time
  51342. */
  51343. readonly shaderCompilationTimeCounter: PerfCounter;
  51344. /**
  51345. * Gets the shader compilation time capture status
  51346. */
  51347. /**
  51348. * Enable or disable the shader compilation time capture
  51349. */
  51350. captureShaderCompilationTime: boolean;
  51351. /**
  51352. * Instantiates a new engine instrumentation.
  51353. * This class can be used to get instrumentation data from a Babylon engine
  51354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51355. * @param engine Defines the engine to instrument
  51356. */
  51357. constructor(
  51358. /**
  51359. * Define the instrumented engine.
  51360. */
  51361. engine: Engine);
  51362. /**
  51363. * Dispose and release associated resources.
  51364. */
  51365. dispose(): void;
  51366. }
  51367. }
  51368. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51369. import { Scene, IDisposable } from "babylonjs/scene";
  51370. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51371. /**
  51372. * This class can be used to get instrumentation data from a Babylon engine
  51373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51374. */
  51375. export class SceneInstrumentation implements IDisposable {
  51376. /**
  51377. * Defines the scene to instrument
  51378. */
  51379. scene: Scene;
  51380. private _captureActiveMeshesEvaluationTime;
  51381. private _activeMeshesEvaluationTime;
  51382. private _captureRenderTargetsRenderTime;
  51383. private _renderTargetsRenderTime;
  51384. private _captureFrameTime;
  51385. private _frameTime;
  51386. private _captureRenderTime;
  51387. private _renderTime;
  51388. private _captureInterFrameTime;
  51389. private _interFrameTime;
  51390. private _captureParticlesRenderTime;
  51391. private _particlesRenderTime;
  51392. private _captureSpritesRenderTime;
  51393. private _spritesRenderTime;
  51394. private _capturePhysicsTime;
  51395. private _physicsTime;
  51396. private _captureAnimationsTime;
  51397. private _animationsTime;
  51398. private _captureCameraRenderTime;
  51399. private _cameraRenderTime;
  51400. private _onBeforeActiveMeshesEvaluationObserver;
  51401. private _onAfterActiveMeshesEvaluationObserver;
  51402. private _onBeforeRenderTargetsRenderObserver;
  51403. private _onAfterRenderTargetsRenderObserver;
  51404. private _onAfterRenderObserver;
  51405. private _onBeforeDrawPhaseObserver;
  51406. private _onAfterDrawPhaseObserver;
  51407. private _onBeforeAnimationsObserver;
  51408. private _onBeforeParticlesRenderingObserver;
  51409. private _onAfterParticlesRenderingObserver;
  51410. private _onBeforeSpritesRenderingObserver;
  51411. private _onAfterSpritesRenderingObserver;
  51412. private _onBeforePhysicsObserver;
  51413. private _onAfterPhysicsObserver;
  51414. private _onAfterAnimationsObserver;
  51415. private _onBeforeCameraRenderObserver;
  51416. private _onAfterCameraRenderObserver;
  51417. /**
  51418. * Gets the perf counter used for active meshes evaluation time
  51419. */
  51420. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51421. /**
  51422. * Gets the active meshes evaluation time capture status
  51423. */
  51424. /**
  51425. * Enable or disable the active meshes evaluation time capture
  51426. */
  51427. captureActiveMeshesEvaluationTime: boolean;
  51428. /**
  51429. * Gets the perf counter used for render targets render time
  51430. */
  51431. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51432. /**
  51433. * Gets the render targets render time capture status
  51434. */
  51435. /**
  51436. * Enable or disable the render targets render time capture
  51437. */
  51438. captureRenderTargetsRenderTime: boolean;
  51439. /**
  51440. * Gets the perf counter used for particles render time
  51441. */
  51442. readonly particlesRenderTimeCounter: PerfCounter;
  51443. /**
  51444. * Gets the particles render time capture status
  51445. */
  51446. /**
  51447. * Enable or disable the particles render time capture
  51448. */
  51449. captureParticlesRenderTime: boolean;
  51450. /**
  51451. * Gets the perf counter used for sprites render time
  51452. */
  51453. readonly spritesRenderTimeCounter: PerfCounter;
  51454. /**
  51455. * Gets the sprites render time capture status
  51456. */
  51457. /**
  51458. * Enable or disable the sprites render time capture
  51459. */
  51460. captureSpritesRenderTime: boolean;
  51461. /**
  51462. * Gets the perf counter used for physics time
  51463. */
  51464. readonly physicsTimeCounter: PerfCounter;
  51465. /**
  51466. * Gets the physics time capture status
  51467. */
  51468. /**
  51469. * Enable or disable the physics time capture
  51470. */
  51471. capturePhysicsTime: boolean;
  51472. /**
  51473. * Gets the perf counter used for animations time
  51474. */
  51475. readonly animationsTimeCounter: PerfCounter;
  51476. /**
  51477. * Gets the animations time capture status
  51478. */
  51479. /**
  51480. * Enable or disable the animations time capture
  51481. */
  51482. captureAnimationsTime: boolean;
  51483. /**
  51484. * Gets the perf counter used for frame time capture
  51485. */
  51486. readonly frameTimeCounter: PerfCounter;
  51487. /**
  51488. * Gets the frame time capture status
  51489. */
  51490. /**
  51491. * Enable or disable the frame time capture
  51492. */
  51493. captureFrameTime: boolean;
  51494. /**
  51495. * Gets the perf counter used for inter-frames time capture
  51496. */
  51497. readonly interFrameTimeCounter: PerfCounter;
  51498. /**
  51499. * Gets the inter-frames time capture status
  51500. */
  51501. /**
  51502. * Enable or disable the inter-frames time capture
  51503. */
  51504. captureInterFrameTime: boolean;
  51505. /**
  51506. * Gets the perf counter used for render time capture
  51507. */
  51508. readonly renderTimeCounter: PerfCounter;
  51509. /**
  51510. * Gets the render time capture status
  51511. */
  51512. /**
  51513. * Enable or disable the render time capture
  51514. */
  51515. captureRenderTime: boolean;
  51516. /**
  51517. * Gets the perf counter used for camera render time capture
  51518. */
  51519. readonly cameraRenderTimeCounter: PerfCounter;
  51520. /**
  51521. * Gets the camera render time capture status
  51522. */
  51523. /**
  51524. * Enable or disable the camera render time capture
  51525. */
  51526. captureCameraRenderTime: boolean;
  51527. /**
  51528. * Gets the perf counter used for draw calls
  51529. */
  51530. readonly drawCallsCounter: PerfCounter;
  51531. /**
  51532. * Instantiates a new scene instrumentation.
  51533. * This class can be used to get instrumentation data from a Babylon engine
  51534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51535. * @param scene Defines the scene to instrument
  51536. */
  51537. constructor(
  51538. /**
  51539. * Defines the scene to instrument
  51540. */
  51541. scene: Scene);
  51542. /**
  51543. * Dispose and release associated resources.
  51544. */
  51545. dispose(): void;
  51546. }
  51547. }
  51548. declare module "babylonjs/Instrumentation/index" {
  51549. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51550. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51551. export * from "babylonjs/Instrumentation/timeToken";
  51552. }
  51553. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51554. /** @hidden */
  51555. export var glowMapGenerationPixelShader: {
  51556. name: string;
  51557. shader: string;
  51558. };
  51559. }
  51560. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51561. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51562. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51564. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51566. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51567. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51568. /** @hidden */
  51569. export var glowMapGenerationVertexShader: {
  51570. name: string;
  51571. shader: string;
  51572. };
  51573. }
  51574. declare module "babylonjs/Layers/effectLayer" {
  51575. import { Observable } from "babylonjs/Misc/observable";
  51576. import { Nullable } from "babylonjs/types";
  51577. import { Camera } from "babylonjs/Cameras/camera";
  51578. import { Scene } from "babylonjs/scene";
  51579. import { ISize } from "babylonjs/Maths/math.size";
  51580. import { Color4 } from "babylonjs/Maths/math.color";
  51581. import { Engine } from "babylonjs/Engines/engine";
  51582. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51584. import { Mesh } from "babylonjs/Meshes/mesh";
  51585. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51588. import { Effect } from "babylonjs/Materials/effect";
  51589. import { Material } from "babylonjs/Materials/material";
  51590. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51591. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51592. /**
  51593. * Effect layer options. This helps customizing the behaviour
  51594. * of the effect layer.
  51595. */
  51596. export interface IEffectLayerOptions {
  51597. /**
  51598. * Multiplication factor apply to the canvas size to compute the render target size
  51599. * used to generated the objects (the smaller the faster).
  51600. */
  51601. mainTextureRatio: number;
  51602. /**
  51603. * Enforces a fixed size texture to ensure effect stability across devices.
  51604. */
  51605. mainTextureFixedSize?: number;
  51606. /**
  51607. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51608. */
  51609. alphaBlendingMode: number;
  51610. /**
  51611. * The camera attached to the layer.
  51612. */
  51613. camera: Nullable<Camera>;
  51614. /**
  51615. * The rendering group to draw the layer in.
  51616. */
  51617. renderingGroupId: number;
  51618. }
  51619. /**
  51620. * The effect layer Helps adding post process effect blended with the main pass.
  51621. *
  51622. * This can be for instance use to generate glow or higlight effects on the scene.
  51623. *
  51624. * The effect layer class can not be used directly and is intented to inherited from to be
  51625. * customized per effects.
  51626. */
  51627. export abstract class EffectLayer {
  51628. private _vertexBuffers;
  51629. private _indexBuffer;
  51630. private _cachedDefines;
  51631. private _effectLayerMapGenerationEffect;
  51632. private _effectLayerOptions;
  51633. private _mergeEffect;
  51634. protected _scene: Scene;
  51635. protected _engine: Engine;
  51636. protected _maxSize: number;
  51637. protected _mainTextureDesiredSize: ISize;
  51638. protected _mainTexture: RenderTargetTexture;
  51639. protected _shouldRender: boolean;
  51640. protected _postProcesses: PostProcess[];
  51641. protected _textures: BaseTexture[];
  51642. protected _emissiveTextureAndColor: {
  51643. texture: Nullable<BaseTexture>;
  51644. color: Color4;
  51645. };
  51646. /**
  51647. * The name of the layer
  51648. */
  51649. name: string;
  51650. /**
  51651. * The clear color of the texture used to generate the glow map.
  51652. */
  51653. neutralColor: Color4;
  51654. /**
  51655. * Specifies wether the highlight layer is enabled or not.
  51656. */
  51657. isEnabled: boolean;
  51658. /**
  51659. * Gets the camera attached to the layer.
  51660. */
  51661. readonly camera: Nullable<Camera>;
  51662. /**
  51663. * Gets the rendering group id the layer should render in.
  51664. */
  51665. renderingGroupId: number;
  51666. /**
  51667. * An event triggered when the effect layer has been disposed.
  51668. */
  51669. onDisposeObservable: Observable<EffectLayer>;
  51670. /**
  51671. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51672. */
  51673. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51674. /**
  51675. * An event triggered when the generated texture is being merged in the scene.
  51676. */
  51677. onBeforeComposeObservable: Observable<EffectLayer>;
  51678. /**
  51679. * An event triggered when the generated texture has been merged in the scene.
  51680. */
  51681. onAfterComposeObservable: Observable<EffectLayer>;
  51682. /**
  51683. * An event triggered when the efffect layer changes its size.
  51684. */
  51685. onSizeChangedObservable: Observable<EffectLayer>;
  51686. /** @hidden */
  51687. static _SceneComponentInitialization: (scene: Scene) => void;
  51688. /**
  51689. * Instantiates a new effect Layer and references it in the scene.
  51690. * @param name The name of the layer
  51691. * @param scene The scene to use the layer in
  51692. */
  51693. constructor(
  51694. /** The Friendly of the effect in the scene */
  51695. name: string, scene: Scene);
  51696. /**
  51697. * Get the effect name of the layer.
  51698. * @return The effect name
  51699. */
  51700. abstract getEffectName(): string;
  51701. /**
  51702. * Checks for the readiness of the element composing the layer.
  51703. * @param subMesh the mesh to check for
  51704. * @param useInstances specify wether or not to use instances to render the mesh
  51705. * @return true if ready otherwise, false
  51706. */
  51707. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51708. /**
  51709. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51710. * @returns true if the effect requires stencil during the main canvas render pass.
  51711. */
  51712. abstract needStencil(): boolean;
  51713. /**
  51714. * Create the merge effect. This is the shader use to blit the information back
  51715. * to the main canvas at the end of the scene rendering.
  51716. * @returns The effect containing the shader used to merge the effect on the main canvas
  51717. */
  51718. protected abstract _createMergeEffect(): Effect;
  51719. /**
  51720. * Creates the render target textures and post processes used in the effect layer.
  51721. */
  51722. protected abstract _createTextureAndPostProcesses(): void;
  51723. /**
  51724. * Implementation specific of rendering the generating effect on the main canvas.
  51725. * @param effect The effect used to render through
  51726. */
  51727. protected abstract _internalRender(effect: Effect): void;
  51728. /**
  51729. * Sets the required values for both the emissive texture and and the main color.
  51730. */
  51731. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51732. /**
  51733. * Free any resources and references associated to a mesh.
  51734. * Internal use
  51735. * @param mesh The mesh to free.
  51736. */
  51737. abstract _disposeMesh(mesh: Mesh): void;
  51738. /**
  51739. * Serializes this layer (Glow or Highlight for example)
  51740. * @returns a serialized layer object
  51741. */
  51742. abstract serialize?(): any;
  51743. /**
  51744. * Initializes the effect layer with the required options.
  51745. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51746. */
  51747. protected _init(options: Partial<IEffectLayerOptions>): void;
  51748. /**
  51749. * Generates the index buffer of the full screen quad blending to the main canvas.
  51750. */
  51751. private _generateIndexBuffer;
  51752. /**
  51753. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51754. */
  51755. private _generateVertexBuffer;
  51756. /**
  51757. * Sets the main texture desired size which is the closest power of two
  51758. * of the engine canvas size.
  51759. */
  51760. private _setMainTextureSize;
  51761. /**
  51762. * Creates the main texture for the effect layer.
  51763. */
  51764. protected _createMainTexture(): void;
  51765. /**
  51766. * Adds specific effects defines.
  51767. * @param defines The defines to add specifics to.
  51768. */
  51769. protected _addCustomEffectDefines(defines: string[]): void;
  51770. /**
  51771. * Checks for the readiness of the element composing the layer.
  51772. * @param subMesh the mesh to check for
  51773. * @param useInstances specify wether or not to use instances to render the mesh
  51774. * @param emissiveTexture the associated emissive texture used to generate the glow
  51775. * @return true if ready otherwise, false
  51776. */
  51777. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51778. /**
  51779. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51780. */
  51781. render(): void;
  51782. /**
  51783. * Determine if a given mesh will be used in the current effect.
  51784. * @param mesh mesh to test
  51785. * @returns true if the mesh will be used
  51786. */
  51787. hasMesh(mesh: AbstractMesh): boolean;
  51788. /**
  51789. * Returns true if the layer contains information to display, otherwise false.
  51790. * @returns true if the glow layer should be rendered
  51791. */
  51792. shouldRender(): boolean;
  51793. /**
  51794. * Returns true if the mesh should render, otherwise false.
  51795. * @param mesh The mesh to render
  51796. * @returns true if it should render otherwise false
  51797. */
  51798. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51799. /**
  51800. * Returns true if the mesh can be rendered, otherwise false.
  51801. * @param mesh The mesh to render
  51802. * @param material The material used on the mesh
  51803. * @returns true if it can be rendered otherwise false
  51804. */
  51805. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51806. /**
  51807. * Returns true if the mesh should render, otherwise false.
  51808. * @param mesh The mesh to render
  51809. * @returns true if it should render otherwise false
  51810. */
  51811. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51812. /**
  51813. * Renders the submesh passed in parameter to the generation map.
  51814. */
  51815. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51816. /**
  51817. * Rebuild the required buffers.
  51818. * @hidden Internal use only.
  51819. */
  51820. _rebuild(): void;
  51821. /**
  51822. * Dispose only the render target textures and post process.
  51823. */
  51824. private _disposeTextureAndPostProcesses;
  51825. /**
  51826. * Dispose the highlight layer and free resources.
  51827. */
  51828. dispose(): void;
  51829. /**
  51830. * Gets the class name of the effect layer
  51831. * @returns the string with the class name of the effect layer
  51832. */
  51833. getClassName(): string;
  51834. /**
  51835. * Creates an effect layer from parsed effect layer data
  51836. * @param parsedEffectLayer defines effect layer data
  51837. * @param scene defines the current scene
  51838. * @param rootUrl defines the root URL containing the effect layer information
  51839. * @returns a parsed effect Layer
  51840. */
  51841. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51842. }
  51843. }
  51844. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51845. import { Scene } from "babylonjs/scene";
  51846. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51847. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51848. import { AbstractScene } from "babylonjs/abstractScene";
  51849. module "babylonjs/abstractScene" {
  51850. interface AbstractScene {
  51851. /**
  51852. * The list of effect layers (highlights/glow) added to the scene
  51853. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51854. * @see http://doc.babylonjs.com/how_to/glow_layer
  51855. */
  51856. effectLayers: Array<EffectLayer>;
  51857. /**
  51858. * Removes the given effect layer from this scene.
  51859. * @param toRemove defines the effect layer to remove
  51860. * @returns the index of the removed effect layer
  51861. */
  51862. removeEffectLayer(toRemove: EffectLayer): number;
  51863. /**
  51864. * Adds the given effect layer to this scene
  51865. * @param newEffectLayer defines the effect layer to add
  51866. */
  51867. addEffectLayer(newEffectLayer: EffectLayer): void;
  51868. }
  51869. }
  51870. /**
  51871. * Defines the layer scene component responsible to manage any effect layers
  51872. * in a given scene.
  51873. */
  51874. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51875. /**
  51876. * The component name helpfull to identify the component in the list of scene components.
  51877. */
  51878. readonly name: string;
  51879. /**
  51880. * The scene the component belongs to.
  51881. */
  51882. scene: Scene;
  51883. private _engine;
  51884. private _renderEffects;
  51885. private _needStencil;
  51886. private _previousStencilState;
  51887. /**
  51888. * Creates a new instance of the component for the given scene
  51889. * @param scene Defines the scene to register the component in
  51890. */
  51891. constructor(scene: Scene);
  51892. /**
  51893. * Registers the component in a given scene
  51894. */
  51895. register(): void;
  51896. /**
  51897. * Rebuilds the elements related to this component in case of
  51898. * context lost for instance.
  51899. */
  51900. rebuild(): void;
  51901. /**
  51902. * Serializes the component data to the specified json object
  51903. * @param serializationObject The object to serialize to
  51904. */
  51905. serialize(serializationObject: any): void;
  51906. /**
  51907. * Adds all the elements from the container to the scene
  51908. * @param container the container holding the elements
  51909. */
  51910. addFromContainer(container: AbstractScene): void;
  51911. /**
  51912. * Removes all the elements in the container from the scene
  51913. * @param container contains the elements to remove
  51914. * @param dispose if the removed element should be disposed (default: false)
  51915. */
  51916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51917. /**
  51918. * Disposes the component and the associated ressources.
  51919. */
  51920. dispose(): void;
  51921. private _isReadyForMesh;
  51922. private _renderMainTexture;
  51923. private _setStencil;
  51924. private _setStencilBack;
  51925. private _draw;
  51926. private _drawCamera;
  51927. private _drawRenderingGroup;
  51928. }
  51929. }
  51930. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51931. /** @hidden */
  51932. export var glowMapMergePixelShader: {
  51933. name: string;
  51934. shader: string;
  51935. };
  51936. }
  51937. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51938. /** @hidden */
  51939. export var glowMapMergeVertexShader: {
  51940. name: string;
  51941. shader: string;
  51942. };
  51943. }
  51944. declare module "babylonjs/Layers/glowLayer" {
  51945. import { Nullable } from "babylonjs/types";
  51946. import { Camera } from "babylonjs/Cameras/camera";
  51947. import { Scene } from "babylonjs/scene";
  51948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { Mesh } from "babylonjs/Meshes/mesh";
  51951. import { Texture } from "babylonjs/Materials/Textures/texture";
  51952. import { Effect } from "babylonjs/Materials/effect";
  51953. import { Material } from "babylonjs/Materials/material";
  51954. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51955. import { Color4 } from "babylonjs/Maths/math.color";
  51956. import "babylonjs/Shaders/glowMapMerge.fragment";
  51957. import "babylonjs/Shaders/glowMapMerge.vertex";
  51958. import "babylonjs/Layers/effectLayerSceneComponent";
  51959. module "babylonjs/abstractScene" {
  51960. interface AbstractScene {
  51961. /**
  51962. * Return a the first highlight layer of the scene with a given name.
  51963. * @param name The name of the highlight layer to look for.
  51964. * @return The highlight layer if found otherwise null.
  51965. */
  51966. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51967. }
  51968. }
  51969. /**
  51970. * Glow layer options. This helps customizing the behaviour
  51971. * of the glow layer.
  51972. */
  51973. export interface IGlowLayerOptions {
  51974. /**
  51975. * Multiplication factor apply to the canvas size to compute the render target size
  51976. * used to generated the glowing objects (the smaller the faster).
  51977. */
  51978. mainTextureRatio: number;
  51979. /**
  51980. * Enforces a fixed size texture to ensure resize independant blur.
  51981. */
  51982. mainTextureFixedSize?: number;
  51983. /**
  51984. * How big is the kernel of the blur texture.
  51985. */
  51986. blurKernelSize: number;
  51987. /**
  51988. * The camera attached to the layer.
  51989. */
  51990. camera: Nullable<Camera>;
  51991. /**
  51992. * Enable MSAA by chosing the number of samples.
  51993. */
  51994. mainTextureSamples?: number;
  51995. /**
  51996. * The rendering group to draw the layer in.
  51997. */
  51998. renderingGroupId: number;
  51999. }
  52000. /**
  52001. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52002. *
  52003. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52004. * glowy meshes to your scene.
  52005. *
  52006. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52007. */
  52008. export class GlowLayer extends EffectLayer {
  52009. /**
  52010. * Effect Name of the layer.
  52011. */
  52012. static readonly EffectName: string;
  52013. /**
  52014. * The default blur kernel size used for the glow.
  52015. */
  52016. static DefaultBlurKernelSize: number;
  52017. /**
  52018. * The default texture size ratio used for the glow.
  52019. */
  52020. static DefaultTextureRatio: number;
  52021. /**
  52022. * Sets the kernel size of the blur.
  52023. */
  52024. /**
  52025. * Gets the kernel size of the blur.
  52026. */
  52027. blurKernelSize: number;
  52028. /**
  52029. * Sets the glow intensity.
  52030. */
  52031. /**
  52032. * Gets the glow intensity.
  52033. */
  52034. intensity: number;
  52035. private _options;
  52036. private _intensity;
  52037. private _horizontalBlurPostprocess1;
  52038. private _verticalBlurPostprocess1;
  52039. private _horizontalBlurPostprocess2;
  52040. private _verticalBlurPostprocess2;
  52041. private _blurTexture1;
  52042. private _blurTexture2;
  52043. private _postProcesses1;
  52044. private _postProcesses2;
  52045. private _includedOnlyMeshes;
  52046. private _excludedMeshes;
  52047. /**
  52048. * Callback used to let the user override the color selection on a per mesh basis
  52049. */
  52050. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52051. /**
  52052. * Callback used to let the user override the texture selection on a per mesh basis
  52053. */
  52054. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52055. /**
  52056. * Instantiates a new glow Layer and references it to the scene.
  52057. * @param name The name of the layer
  52058. * @param scene The scene to use the layer in
  52059. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52060. */
  52061. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52062. /**
  52063. * Get the effect name of the layer.
  52064. * @return The effect name
  52065. */
  52066. getEffectName(): string;
  52067. /**
  52068. * Create the merge effect. This is the shader use to blit the information back
  52069. * to the main canvas at the end of the scene rendering.
  52070. */
  52071. protected _createMergeEffect(): Effect;
  52072. /**
  52073. * Creates the render target textures and post processes used in the glow layer.
  52074. */
  52075. protected _createTextureAndPostProcesses(): void;
  52076. /**
  52077. * Checks for the readiness of the element composing the layer.
  52078. * @param subMesh the mesh to check for
  52079. * @param useInstances specify wether or not to use instances to render the mesh
  52080. * @param emissiveTexture the associated emissive texture used to generate the glow
  52081. * @return true if ready otherwise, false
  52082. */
  52083. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52084. /**
  52085. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52086. */
  52087. needStencil(): boolean;
  52088. /**
  52089. * Returns true if the mesh can be rendered, otherwise false.
  52090. * @param mesh The mesh to render
  52091. * @param material The material used on the mesh
  52092. * @returns true if it can be rendered otherwise false
  52093. */
  52094. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52095. /**
  52096. * Implementation specific of rendering the generating effect on the main canvas.
  52097. * @param effect The effect used to render through
  52098. */
  52099. protected _internalRender(effect: Effect): void;
  52100. /**
  52101. * Sets the required values for both the emissive texture and and the main color.
  52102. */
  52103. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52104. /**
  52105. * Returns true if the mesh should render, otherwise false.
  52106. * @param mesh The mesh to render
  52107. * @returns true if it should render otherwise false
  52108. */
  52109. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52110. /**
  52111. * Adds specific effects defines.
  52112. * @param defines The defines to add specifics to.
  52113. */
  52114. protected _addCustomEffectDefines(defines: string[]): void;
  52115. /**
  52116. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52117. * @param mesh The mesh to exclude from the glow layer
  52118. */
  52119. addExcludedMesh(mesh: Mesh): void;
  52120. /**
  52121. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52122. * @param mesh The mesh to remove
  52123. */
  52124. removeExcludedMesh(mesh: Mesh): void;
  52125. /**
  52126. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52127. * @param mesh The mesh to include in the glow layer
  52128. */
  52129. addIncludedOnlyMesh(mesh: Mesh): void;
  52130. /**
  52131. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52132. * @param mesh The mesh to remove
  52133. */
  52134. removeIncludedOnlyMesh(mesh: Mesh): void;
  52135. /**
  52136. * Determine if a given mesh will be used in the glow layer
  52137. * @param mesh The mesh to test
  52138. * @returns true if the mesh will be highlighted by the current glow layer
  52139. */
  52140. hasMesh(mesh: AbstractMesh): boolean;
  52141. /**
  52142. * Free any resources and references associated to a mesh.
  52143. * Internal use
  52144. * @param mesh The mesh to free.
  52145. * @hidden
  52146. */
  52147. _disposeMesh(mesh: Mesh): void;
  52148. /**
  52149. * Gets the class name of the effect layer
  52150. * @returns the string with the class name of the effect layer
  52151. */
  52152. getClassName(): string;
  52153. /**
  52154. * Serializes this glow layer
  52155. * @returns a serialized glow layer object
  52156. */
  52157. serialize(): any;
  52158. /**
  52159. * Creates a Glow Layer from parsed glow layer data
  52160. * @param parsedGlowLayer defines glow layer data
  52161. * @param scene defines the current scene
  52162. * @param rootUrl defines the root URL containing the glow layer information
  52163. * @returns a parsed Glow Layer
  52164. */
  52165. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52166. }
  52167. }
  52168. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52169. /** @hidden */
  52170. export var glowBlurPostProcessPixelShader: {
  52171. name: string;
  52172. shader: string;
  52173. };
  52174. }
  52175. declare module "babylonjs/Layers/highlightLayer" {
  52176. import { Observable } from "babylonjs/Misc/observable";
  52177. import { Nullable } from "babylonjs/types";
  52178. import { Camera } from "babylonjs/Cameras/camera";
  52179. import { Scene } from "babylonjs/scene";
  52180. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52182. import { Mesh } from "babylonjs/Meshes/mesh";
  52183. import { Effect } from "babylonjs/Materials/effect";
  52184. import { Material } from "babylonjs/Materials/material";
  52185. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52186. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52187. import "babylonjs/Shaders/glowMapMerge.fragment";
  52188. import "babylonjs/Shaders/glowMapMerge.vertex";
  52189. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52190. module "babylonjs/abstractScene" {
  52191. interface AbstractScene {
  52192. /**
  52193. * Return a the first highlight layer of the scene with a given name.
  52194. * @param name The name of the highlight layer to look for.
  52195. * @return The highlight layer if found otherwise null.
  52196. */
  52197. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52198. }
  52199. }
  52200. /**
  52201. * Highlight layer options. This helps customizing the behaviour
  52202. * of the highlight layer.
  52203. */
  52204. export interface IHighlightLayerOptions {
  52205. /**
  52206. * Multiplication factor apply to the canvas size to compute the render target size
  52207. * used to generated the glowing objects (the smaller the faster).
  52208. */
  52209. mainTextureRatio: number;
  52210. /**
  52211. * Enforces a fixed size texture to ensure resize independant blur.
  52212. */
  52213. mainTextureFixedSize?: number;
  52214. /**
  52215. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52216. * of the picture to blur (the smaller the faster).
  52217. */
  52218. blurTextureSizeRatio: number;
  52219. /**
  52220. * How big in texel of the blur texture is the vertical blur.
  52221. */
  52222. blurVerticalSize: number;
  52223. /**
  52224. * How big in texel of the blur texture is the horizontal blur.
  52225. */
  52226. blurHorizontalSize: number;
  52227. /**
  52228. * Alpha blending mode used to apply the blur. Default is combine.
  52229. */
  52230. alphaBlendingMode: number;
  52231. /**
  52232. * The camera attached to the layer.
  52233. */
  52234. camera: Nullable<Camera>;
  52235. /**
  52236. * Should we display highlight as a solid stroke?
  52237. */
  52238. isStroke?: boolean;
  52239. /**
  52240. * The rendering group to draw the layer in.
  52241. */
  52242. renderingGroupId: number;
  52243. }
  52244. /**
  52245. * The highlight layer Helps adding a glow effect around a mesh.
  52246. *
  52247. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52248. * glowy meshes to your scene.
  52249. *
  52250. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52251. */
  52252. export class HighlightLayer extends EffectLayer {
  52253. name: string;
  52254. /**
  52255. * Effect Name of the highlight layer.
  52256. */
  52257. static readonly EffectName: string;
  52258. /**
  52259. * The neutral color used during the preparation of the glow effect.
  52260. * This is black by default as the blend operation is a blend operation.
  52261. */
  52262. static NeutralColor: Color4;
  52263. /**
  52264. * Stencil value used for glowing meshes.
  52265. */
  52266. static GlowingMeshStencilReference: number;
  52267. /**
  52268. * Stencil value used for the other meshes in the scene.
  52269. */
  52270. static NormalMeshStencilReference: number;
  52271. /**
  52272. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52273. */
  52274. innerGlow: boolean;
  52275. /**
  52276. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52277. */
  52278. outerGlow: boolean;
  52279. /**
  52280. * Specifies the horizontal size of the blur.
  52281. */
  52282. /**
  52283. * Gets the horizontal size of the blur.
  52284. */
  52285. blurHorizontalSize: number;
  52286. /**
  52287. * Specifies the vertical size of the blur.
  52288. */
  52289. /**
  52290. * Gets the vertical size of the blur.
  52291. */
  52292. blurVerticalSize: number;
  52293. /**
  52294. * An event triggered when the highlight layer is being blurred.
  52295. */
  52296. onBeforeBlurObservable: Observable<HighlightLayer>;
  52297. /**
  52298. * An event triggered when the highlight layer has been blurred.
  52299. */
  52300. onAfterBlurObservable: Observable<HighlightLayer>;
  52301. private _instanceGlowingMeshStencilReference;
  52302. private _options;
  52303. private _downSamplePostprocess;
  52304. private _horizontalBlurPostprocess;
  52305. private _verticalBlurPostprocess;
  52306. private _blurTexture;
  52307. private _meshes;
  52308. private _excludedMeshes;
  52309. /**
  52310. * Instantiates a new highlight Layer and references it to the scene..
  52311. * @param name The name of the layer
  52312. * @param scene The scene to use the layer in
  52313. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52314. */
  52315. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52316. /**
  52317. * Get the effect name of the layer.
  52318. * @return The effect name
  52319. */
  52320. getEffectName(): string;
  52321. /**
  52322. * Create the merge effect. This is the shader use to blit the information back
  52323. * to the main canvas at the end of the scene rendering.
  52324. */
  52325. protected _createMergeEffect(): Effect;
  52326. /**
  52327. * Creates the render target textures and post processes used in the highlight layer.
  52328. */
  52329. protected _createTextureAndPostProcesses(): void;
  52330. /**
  52331. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52332. */
  52333. needStencil(): boolean;
  52334. /**
  52335. * Checks for the readiness of the element composing the layer.
  52336. * @param subMesh the mesh to check for
  52337. * @param useInstances specify wether or not to use instances to render the mesh
  52338. * @param emissiveTexture the associated emissive texture used to generate the glow
  52339. * @return true if ready otherwise, false
  52340. */
  52341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52342. /**
  52343. * Implementation specific of rendering the generating effect on the main canvas.
  52344. * @param effect The effect used to render through
  52345. */
  52346. protected _internalRender(effect: Effect): void;
  52347. /**
  52348. * Returns true if the layer contains information to display, otherwise false.
  52349. */
  52350. shouldRender(): boolean;
  52351. /**
  52352. * Returns true if the mesh should render, otherwise false.
  52353. * @param mesh The mesh to render
  52354. * @returns true if it should render otherwise false
  52355. */
  52356. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52357. /**
  52358. * Sets the required values for both the emissive texture and and the main color.
  52359. */
  52360. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52361. /**
  52362. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52363. * @param mesh The mesh to exclude from the highlight layer
  52364. */
  52365. addExcludedMesh(mesh: Mesh): void;
  52366. /**
  52367. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52368. * @param mesh The mesh to highlight
  52369. */
  52370. removeExcludedMesh(mesh: Mesh): void;
  52371. /**
  52372. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52373. * @param mesh mesh to test
  52374. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52375. */
  52376. hasMesh(mesh: AbstractMesh): boolean;
  52377. /**
  52378. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52379. * @param mesh The mesh to highlight
  52380. * @param color The color of the highlight
  52381. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52382. */
  52383. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52384. /**
  52385. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52386. * @param mesh The mesh to highlight
  52387. */
  52388. removeMesh(mesh: Mesh): void;
  52389. /**
  52390. * Force the stencil to the normal expected value for none glowing parts
  52391. */
  52392. private _defaultStencilReference;
  52393. /**
  52394. * Free any resources and references associated to a mesh.
  52395. * Internal use
  52396. * @param mesh The mesh to free.
  52397. * @hidden
  52398. */
  52399. _disposeMesh(mesh: Mesh): void;
  52400. /**
  52401. * Dispose the highlight layer and free resources.
  52402. */
  52403. dispose(): void;
  52404. /**
  52405. * Gets the class name of the effect layer
  52406. * @returns the string with the class name of the effect layer
  52407. */
  52408. getClassName(): string;
  52409. /**
  52410. * Serializes this Highlight layer
  52411. * @returns a serialized Highlight layer object
  52412. */
  52413. serialize(): any;
  52414. /**
  52415. * Creates a Highlight layer from parsed Highlight layer data
  52416. * @param parsedHightlightLayer defines the Highlight layer data
  52417. * @param scene defines the current scene
  52418. * @param rootUrl defines the root URL containing the Highlight layer information
  52419. * @returns a parsed Highlight layer
  52420. */
  52421. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52422. }
  52423. }
  52424. declare module "babylonjs/Layers/layerSceneComponent" {
  52425. import { Scene } from "babylonjs/scene";
  52426. import { ISceneComponent } from "babylonjs/sceneComponent";
  52427. import { Layer } from "babylonjs/Layers/layer";
  52428. import { AbstractScene } from "babylonjs/abstractScene";
  52429. module "babylonjs/abstractScene" {
  52430. interface AbstractScene {
  52431. /**
  52432. * The list of layers (background and foreground) of the scene
  52433. */
  52434. layers: Array<Layer>;
  52435. }
  52436. }
  52437. /**
  52438. * Defines the layer scene component responsible to manage any layers
  52439. * in a given scene.
  52440. */
  52441. export class LayerSceneComponent implements ISceneComponent {
  52442. /**
  52443. * The component name helpfull to identify the component in the list of scene components.
  52444. */
  52445. readonly name: string;
  52446. /**
  52447. * The scene the component belongs to.
  52448. */
  52449. scene: Scene;
  52450. private _engine;
  52451. /**
  52452. * Creates a new instance of the component for the given scene
  52453. * @param scene Defines the scene to register the component in
  52454. */
  52455. constructor(scene: Scene);
  52456. /**
  52457. * Registers the component in a given scene
  52458. */
  52459. register(): void;
  52460. /**
  52461. * Rebuilds the elements related to this component in case of
  52462. * context lost for instance.
  52463. */
  52464. rebuild(): void;
  52465. /**
  52466. * Disposes the component and the associated ressources.
  52467. */
  52468. dispose(): void;
  52469. private _draw;
  52470. private _drawCameraPredicate;
  52471. private _drawCameraBackground;
  52472. private _drawCameraForeground;
  52473. private _drawRenderTargetPredicate;
  52474. private _drawRenderTargetBackground;
  52475. private _drawRenderTargetForeground;
  52476. /**
  52477. * Adds all the elements from the container to the scene
  52478. * @param container the container holding the elements
  52479. */
  52480. addFromContainer(container: AbstractScene): void;
  52481. /**
  52482. * Removes all the elements in the container from the scene
  52483. * @param container contains the elements to remove
  52484. * @param dispose if the removed element should be disposed (default: false)
  52485. */
  52486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52487. }
  52488. }
  52489. declare module "babylonjs/Shaders/layer.fragment" {
  52490. /** @hidden */
  52491. export var layerPixelShader: {
  52492. name: string;
  52493. shader: string;
  52494. };
  52495. }
  52496. declare module "babylonjs/Shaders/layer.vertex" {
  52497. /** @hidden */
  52498. export var layerVertexShader: {
  52499. name: string;
  52500. shader: string;
  52501. };
  52502. }
  52503. declare module "babylonjs/Layers/layer" {
  52504. import { Observable } from "babylonjs/Misc/observable";
  52505. import { Nullable } from "babylonjs/types";
  52506. import { Scene } from "babylonjs/scene";
  52507. import { Vector2 } from "babylonjs/Maths/math.vector";
  52508. import { Color4 } from "babylonjs/Maths/math.color";
  52509. import { Texture } from "babylonjs/Materials/Textures/texture";
  52510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52511. import "babylonjs/Shaders/layer.fragment";
  52512. import "babylonjs/Shaders/layer.vertex";
  52513. /**
  52514. * This represents a full screen 2d layer.
  52515. * This can be useful to display a picture in the background of your scene for instance.
  52516. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52517. */
  52518. export class Layer {
  52519. /**
  52520. * Define the name of the layer.
  52521. */
  52522. name: string;
  52523. /**
  52524. * Define the texture the layer should display.
  52525. */
  52526. texture: Nullable<Texture>;
  52527. /**
  52528. * Is the layer in background or foreground.
  52529. */
  52530. isBackground: boolean;
  52531. /**
  52532. * Define the color of the layer (instead of texture).
  52533. */
  52534. color: Color4;
  52535. /**
  52536. * Define the scale of the layer in order to zoom in out of the texture.
  52537. */
  52538. scale: Vector2;
  52539. /**
  52540. * Define an offset for the layer in order to shift the texture.
  52541. */
  52542. offset: Vector2;
  52543. /**
  52544. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52545. */
  52546. alphaBlendingMode: number;
  52547. /**
  52548. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52549. * Alpha test will not mix with the background color in case of transparency.
  52550. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52551. */
  52552. alphaTest: boolean;
  52553. /**
  52554. * Define a mask to restrict the layer to only some of the scene cameras.
  52555. */
  52556. layerMask: number;
  52557. /**
  52558. * Define the list of render target the layer is visible into.
  52559. */
  52560. renderTargetTextures: RenderTargetTexture[];
  52561. /**
  52562. * Define if the layer is only used in renderTarget or if it also
  52563. * renders in the main frame buffer of the canvas.
  52564. */
  52565. renderOnlyInRenderTargetTextures: boolean;
  52566. private _scene;
  52567. private _vertexBuffers;
  52568. private _indexBuffer;
  52569. private _effect;
  52570. private _alphaTestEffect;
  52571. /**
  52572. * An event triggered when the layer is disposed.
  52573. */
  52574. onDisposeObservable: Observable<Layer>;
  52575. private _onDisposeObserver;
  52576. /**
  52577. * Back compatibility with callback before the onDisposeObservable existed.
  52578. * The set callback will be triggered when the layer has been disposed.
  52579. */
  52580. onDispose: () => void;
  52581. /**
  52582. * An event triggered before rendering the scene
  52583. */
  52584. onBeforeRenderObservable: Observable<Layer>;
  52585. private _onBeforeRenderObserver;
  52586. /**
  52587. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52588. * The set callback will be triggered just before rendering the layer.
  52589. */
  52590. onBeforeRender: () => void;
  52591. /**
  52592. * An event triggered after rendering the scene
  52593. */
  52594. onAfterRenderObservable: Observable<Layer>;
  52595. private _onAfterRenderObserver;
  52596. /**
  52597. * Back compatibility with callback before the onAfterRenderObservable existed.
  52598. * The set callback will be triggered just after rendering the layer.
  52599. */
  52600. onAfterRender: () => void;
  52601. /**
  52602. * Instantiates a new layer.
  52603. * This represents a full screen 2d layer.
  52604. * This can be useful to display a picture in the background of your scene for instance.
  52605. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52606. * @param name Define the name of the layer in the scene
  52607. * @param imgUrl Define the url of the texture to display in the layer
  52608. * @param scene Define the scene the layer belongs to
  52609. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52610. * @param color Defines a color for the layer
  52611. */
  52612. constructor(
  52613. /**
  52614. * Define the name of the layer.
  52615. */
  52616. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52617. private _createIndexBuffer;
  52618. /** @hidden */
  52619. _rebuild(): void;
  52620. /**
  52621. * Renders the layer in the scene.
  52622. */
  52623. render(): void;
  52624. /**
  52625. * Disposes and releases the associated ressources.
  52626. */
  52627. dispose(): void;
  52628. }
  52629. }
  52630. declare module "babylonjs/Layers/index" {
  52631. export * from "babylonjs/Layers/effectLayer";
  52632. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52633. export * from "babylonjs/Layers/glowLayer";
  52634. export * from "babylonjs/Layers/highlightLayer";
  52635. export * from "babylonjs/Layers/layer";
  52636. export * from "babylonjs/Layers/layerSceneComponent";
  52637. }
  52638. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52639. /** @hidden */
  52640. export var lensFlarePixelShader: {
  52641. name: string;
  52642. shader: string;
  52643. };
  52644. }
  52645. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52646. /** @hidden */
  52647. export var lensFlareVertexShader: {
  52648. name: string;
  52649. shader: string;
  52650. };
  52651. }
  52652. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52653. import { Scene } from "babylonjs/scene";
  52654. import { Vector3 } from "babylonjs/Maths/math.vector";
  52655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52656. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52657. import "babylonjs/Shaders/lensFlare.fragment";
  52658. import "babylonjs/Shaders/lensFlare.vertex";
  52659. import { Viewport } from "babylonjs/Maths/math.viewport";
  52660. /**
  52661. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52662. * It is usually composed of several `lensFlare`.
  52663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52664. */
  52665. export class LensFlareSystem {
  52666. /**
  52667. * Define the name of the lens flare system
  52668. */
  52669. name: string;
  52670. /**
  52671. * List of lens flares used in this system.
  52672. */
  52673. lensFlares: LensFlare[];
  52674. /**
  52675. * Define a limit from the border the lens flare can be visible.
  52676. */
  52677. borderLimit: number;
  52678. /**
  52679. * Define a viewport border we do not want to see the lens flare in.
  52680. */
  52681. viewportBorder: number;
  52682. /**
  52683. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52684. */
  52685. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52686. /**
  52687. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52688. */
  52689. layerMask: number;
  52690. /**
  52691. * Define the id of the lens flare system in the scene.
  52692. * (equal to name by default)
  52693. */
  52694. id: string;
  52695. private _scene;
  52696. private _emitter;
  52697. private _vertexBuffers;
  52698. private _indexBuffer;
  52699. private _effect;
  52700. private _positionX;
  52701. private _positionY;
  52702. private _isEnabled;
  52703. /** @hidden */
  52704. static _SceneComponentInitialization: (scene: Scene) => void;
  52705. /**
  52706. * Instantiates a lens flare system.
  52707. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52708. * It is usually composed of several `lensFlare`.
  52709. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52710. * @param name Define the name of the lens flare system in the scene
  52711. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52712. * @param scene Define the scene the lens flare system belongs to
  52713. */
  52714. constructor(
  52715. /**
  52716. * Define the name of the lens flare system
  52717. */
  52718. name: string, emitter: any, scene: Scene);
  52719. /**
  52720. * Define if the lens flare system is enabled.
  52721. */
  52722. isEnabled: boolean;
  52723. /**
  52724. * Get the scene the effects belongs to.
  52725. * @returns the scene holding the lens flare system
  52726. */
  52727. getScene(): Scene;
  52728. /**
  52729. * Get the emitter of the lens flare system.
  52730. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52731. * @returns the emitter of the lens flare system
  52732. */
  52733. getEmitter(): any;
  52734. /**
  52735. * Set the emitter of the lens flare system.
  52736. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52737. * @param newEmitter Define the new emitter of the system
  52738. */
  52739. setEmitter(newEmitter: any): void;
  52740. /**
  52741. * Get the lens flare system emitter position.
  52742. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52743. * @returns the position
  52744. */
  52745. getEmitterPosition(): Vector3;
  52746. /**
  52747. * @hidden
  52748. */
  52749. computeEffectivePosition(globalViewport: Viewport): boolean;
  52750. /** @hidden */
  52751. _isVisible(): boolean;
  52752. /**
  52753. * @hidden
  52754. */
  52755. render(): boolean;
  52756. /**
  52757. * Dispose and release the lens flare with its associated resources.
  52758. */
  52759. dispose(): void;
  52760. /**
  52761. * Parse a lens flare system from a JSON repressentation
  52762. * @param parsedLensFlareSystem Define the JSON to parse
  52763. * @param scene Define the scene the parsed system should be instantiated in
  52764. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52765. * @returns the parsed system
  52766. */
  52767. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52768. /**
  52769. * Serialize the current Lens Flare System into a JSON representation.
  52770. * @returns the serialized JSON
  52771. */
  52772. serialize(): any;
  52773. }
  52774. }
  52775. declare module "babylonjs/LensFlares/lensFlare" {
  52776. import { Nullable } from "babylonjs/types";
  52777. import { Color3 } from "babylonjs/Maths/math.color";
  52778. import { Texture } from "babylonjs/Materials/Textures/texture";
  52779. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52780. /**
  52781. * This represents one of the lens effect in a `lensFlareSystem`.
  52782. * It controls one of the indiviual texture used in the effect.
  52783. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52784. */
  52785. export class LensFlare {
  52786. /**
  52787. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52788. */
  52789. size: number;
  52790. /**
  52791. * 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.
  52792. */
  52793. position: number;
  52794. /**
  52795. * Define the lens color.
  52796. */
  52797. color: Color3;
  52798. /**
  52799. * Define the lens texture.
  52800. */
  52801. texture: Nullable<Texture>;
  52802. /**
  52803. * Define the alpha mode to render this particular lens.
  52804. */
  52805. alphaMode: number;
  52806. private _system;
  52807. /**
  52808. * Creates a new Lens Flare.
  52809. * This represents one of the lens effect in a `lensFlareSystem`.
  52810. * It controls one of the indiviual texture used in the effect.
  52811. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52812. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52813. * @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.
  52814. * @param color Define the lens color
  52815. * @param imgUrl Define the lens texture url
  52816. * @param system Define the `lensFlareSystem` this flare is part of
  52817. * @returns The newly created Lens Flare
  52818. */
  52819. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52820. /**
  52821. * Instantiates a new Lens Flare.
  52822. * This represents one of the lens effect in a `lensFlareSystem`.
  52823. * It controls one of the indiviual texture used in the effect.
  52824. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52825. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52826. * @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.
  52827. * @param color Define the lens color
  52828. * @param imgUrl Define the lens texture url
  52829. * @param system Define the `lensFlareSystem` this flare is part of
  52830. */
  52831. constructor(
  52832. /**
  52833. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52834. */
  52835. size: number,
  52836. /**
  52837. * 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.
  52838. */
  52839. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52840. /**
  52841. * Dispose and release the lens flare with its associated resources.
  52842. */
  52843. dispose(): void;
  52844. }
  52845. }
  52846. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52847. import { Nullable } from "babylonjs/types";
  52848. import { Scene } from "babylonjs/scene";
  52849. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52850. import { AbstractScene } from "babylonjs/abstractScene";
  52851. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52852. module "babylonjs/abstractScene" {
  52853. interface AbstractScene {
  52854. /**
  52855. * The list of lens flare system added to the scene
  52856. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52857. */
  52858. lensFlareSystems: Array<LensFlareSystem>;
  52859. /**
  52860. * Removes the given lens flare system from this scene.
  52861. * @param toRemove The lens flare system to remove
  52862. * @returns The index of the removed lens flare system
  52863. */
  52864. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52865. /**
  52866. * Adds the given lens flare system to this scene
  52867. * @param newLensFlareSystem The lens flare system to add
  52868. */
  52869. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52870. /**
  52871. * Gets a lens flare system using its name
  52872. * @param name defines the name to look for
  52873. * @returns the lens flare system or null if not found
  52874. */
  52875. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52876. /**
  52877. * Gets a lens flare system using its id
  52878. * @param id defines the id to look for
  52879. * @returns the lens flare system or null if not found
  52880. */
  52881. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52882. }
  52883. }
  52884. /**
  52885. * Defines the lens flare scene component responsible to manage any lens flares
  52886. * in a given scene.
  52887. */
  52888. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52889. /**
  52890. * The component name helpfull to identify the component in the list of scene components.
  52891. */
  52892. readonly name: string;
  52893. /**
  52894. * The scene the component belongs to.
  52895. */
  52896. scene: Scene;
  52897. /**
  52898. * Creates a new instance of the component for the given scene
  52899. * @param scene Defines the scene to register the component in
  52900. */
  52901. constructor(scene: Scene);
  52902. /**
  52903. * Registers the component in a given scene
  52904. */
  52905. register(): void;
  52906. /**
  52907. * Rebuilds the elements related to this component in case of
  52908. * context lost for instance.
  52909. */
  52910. rebuild(): void;
  52911. /**
  52912. * Adds all the elements from the container to the scene
  52913. * @param container the container holding the elements
  52914. */
  52915. addFromContainer(container: AbstractScene): void;
  52916. /**
  52917. * Removes all the elements in the container from the scene
  52918. * @param container contains the elements to remove
  52919. * @param dispose if the removed element should be disposed (default: false)
  52920. */
  52921. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52922. /**
  52923. * Serializes the component data to the specified json object
  52924. * @param serializationObject The object to serialize to
  52925. */
  52926. serialize(serializationObject: any): void;
  52927. /**
  52928. * Disposes the component and the associated ressources.
  52929. */
  52930. dispose(): void;
  52931. private _draw;
  52932. }
  52933. }
  52934. declare module "babylonjs/LensFlares/index" {
  52935. export * from "babylonjs/LensFlares/lensFlare";
  52936. export * from "babylonjs/LensFlares/lensFlareSystem";
  52937. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52938. }
  52939. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52940. import { Scene } from "babylonjs/scene";
  52941. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52942. import { AbstractScene } from "babylonjs/abstractScene";
  52943. /**
  52944. * Defines the shadow generator component responsible to manage any shadow generators
  52945. * in a given scene.
  52946. */
  52947. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52948. /**
  52949. * The component name helpfull to identify the component in the list of scene components.
  52950. */
  52951. readonly name: string;
  52952. /**
  52953. * The scene the component belongs to.
  52954. */
  52955. scene: Scene;
  52956. /**
  52957. * Creates a new instance of the component for the given scene
  52958. * @param scene Defines the scene to register the component in
  52959. */
  52960. constructor(scene: Scene);
  52961. /**
  52962. * Registers the component in a given scene
  52963. */
  52964. register(): void;
  52965. /**
  52966. * Rebuilds the elements related to this component in case of
  52967. * context lost for instance.
  52968. */
  52969. rebuild(): void;
  52970. /**
  52971. * Serializes the component data to the specified json object
  52972. * @param serializationObject The object to serialize to
  52973. */
  52974. serialize(serializationObject: any): void;
  52975. /**
  52976. * Adds all the elements from the container to the scene
  52977. * @param container the container holding the elements
  52978. */
  52979. addFromContainer(container: AbstractScene): void;
  52980. /**
  52981. * Removes all the elements in the container from the scene
  52982. * @param container contains the elements to remove
  52983. * @param dispose if the removed element should be disposed (default: false)
  52984. */
  52985. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52986. /**
  52987. * Rebuilds the elements related to this component in case of
  52988. * context lost for instance.
  52989. */
  52990. dispose(): void;
  52991. private _gatherRenderTargets;
  52992. }
  52993. }
  52994. declare module "babylonjs/Lights/Shadows/index" {
  52995. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52996. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52997. }
  52998. declare module "babylonjs/Lights/pointLight" {
  52999. import { Scene } from "babylonjs/scene";
  53000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53002. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53003. import { Effect } from "babylonjs/Materials/effect";
  53004. /**
  53005. * A point light is a light defined by an unique point in world space.
  53006. * The light is emitted in every direction from this point.
  53007. * A good example of a point light is a standard light bulb.
  53008. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53009. */
  53010. export class PointLight extends ShadowLight {
  53011. private _shadowAngle;
  53012. /**
  53013. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53014. * This specifies what angle the shadow will use to be created.
  53015. *
  53016. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53017. */
  53018. /**
  53019. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53020. * This specifies what angle the shadow will use to be created.
  53021. *
  53022. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53023. */
  53024. shadowAngle: number;
  53025. /**
  53026. * Gets the direction if it has been set.
  53027. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53028. */
  53029. /**
  53030. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53031. */
  53032. direction: Vector3;
  53033. /**
  53034. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53035. * A PointLight emits the light in every direction.
  53036. * It can cast shadows.
  53037. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53038. * ```javascript
  53039. * var pointLight = new PointLight("pl", camera.position, scene);
  53040. * ```
  53041. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53042. * @param name The light friendly name
  53043. * @param position The position of the point light in the scene
  53044. * @param scene The scene the lights belongs to
  53045. */
  53046. constructor(name: string, position: Vector3, scene: Scene);
  53047. /**
  53048. * Returns the string "PointLight"
  53049. * @returns the class name
  53050. */
  53051. getClassName(): string;
  53052. /**
  53053. * Returns the integer 0.
  53054. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53055. */
  53056. getTypeID(): number;
  53057. /**
  53058. * Specifies wether or not the shadowmap should be a cube texture.
  53059. * @returns true if the shadowmap needs to be a cube texture.
  53060. */
  53061. needCube(): boolean;
  53062. /**
  53063. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53064. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53065. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53066. */
  53067. getShadowDirection(faceIndex?: number): Vector3;
  53068. /**
  53069. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53070. * - fov = PI / 2
  53071. * - aspect ratio : 1.0
  53072. * - z-near and far equal to the active camera minZ and maxZ.
  53073. * Returns the PointLight.
  53074. */
  53075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53076. protected _buildUniformLayout(): void;
  53077. /**
  53078. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53079. * @param effect The effect to update
  53080. * @param lightIndex The index of the light in the effect to update
  53081. * @returns The point light
  53082. */
  53083. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53084. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53085. /**
  53086. * Prepares the list of defines specific to the light type.
  53087. * @param defines the list of defines
  53088. * @param lightIndex defines the index of the light for the effect
  53089. */
  53090. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53091. }
  53092. }
  53093. declare module "babylonjs/Lights/index" {
  53094. export * from "babylonjs/Lights/light";
  53095. export * from "babylonjs/Lights/shadowLight";
  53096. export * from "babylonjs/Lights/Shadows/index";
  53097. export * from "babylonjs/Lights/directionalLight";
  53098. export * from "babylonjs/Lights/hemisphericLight";
  53099. export * from "babylonjs/Lights/pointLight";
  53100. export * from "babylonjs/Lights/spotLight";
  53101. }
  53102. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53103. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53104. /**
  53105. * Header information of HDR texture files.
  53106. */
  53107. export interface HDRInfo {
  53108. /**
  53109. * The height of the texture in pixels.
  53110. */
  53111. height: number;
  53112. /**
  53113. * The width of the texture in pixels.
  53114. */
  53115. width: number;
  53116. /**
  53117. * The index of the beginning of the data in the binary file.
  53118. */
  53119. dataPosition: number;
  53120. }
  53121. /**
  53122. * This groups tools to convert HDR texture to native colors array.
  53123. */
  53124. export class HDRTools {
  53125. private static Ldexp;
  53126. private static Rgbe2float;
  53127. private static readStringLine;
  53128. /**
  53129. * Reads header information from an RGBE texture stored in a native array.
  53130. * More information on this format are available here:
  53131. * https://en.wikipedia.org/wiki/RGBE_image_format
  53132. *
  53133. * @param uint8array The binary file stored in native array.
  53134. * @return The header information.
  53135. */
  53136. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53137. /**
  53138. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53139. * This RGBE texture needs to store the information as a panorama.
  53140. *
  53141. * More information on this format are available here:
  53142. * https://en.wikipedia.org/wiki/RGBE_image_format
  53143. *
  53144. * @param buffer The binary file stored in an array buffer.
  53145. * @param size The expected size of the extracted cubemap.
  53146. * @return The Cube Map information.
  53147. */
  53148. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53149. /**
  53150. * Returns the pixels data extracted from an RGBE texture.
  53151. * This pixels will be stored left to right up to down in the R G B order in one array.
  53152. *
  53153. * More information on this format are available here:
  53154. * https://en.wikipedia.org/wiki/RGBE_image_format
  53155. *
  53156. * @param uint8array The binary file stored in an array buffer.
  53157. * @param hdrInfo The header information of the file.
  53158. * @return The pixels data in RGB right to left up to down order.
  53159. */
  53160. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53161. private static RGBE_ReadPixels_RLE;
  53162. }
  53163. }
  53164. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53165. import { Nullable } from "babylonjs/types";
  53166. import { Scene } from "babylonjs/scene";
  53167. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53169. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53170. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53171. /**
  53172. * This represents a texture coming from an HDR input.
  53173. *
  53174. * The only supported format is currently panorama picture stored in RGBE format.
  53175. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53176. */
  53177. export class HDRCubeTexture extends BaseTexture {
  53178. private static _facesMapping;
  53179. private _generateHarmonics;
  53180. private _noMipmap;
  53181. private _textureMatrix;
  53182. private _size;
  53183. private _onLoad;
  53184. private _onError;
  53185. /**
  53186. * The texture URL.
  53187. */
  53188. url: string;
  53189. /**
  53190. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53191. */
  53192. coordinatesMode: number;
  53193. protected _isBlocking: boolean;
  53194. /**
  53195. * Sets wether or not the texture is blocking during loading.
  53196. */
  53197. /**
  53198. * Gets wether or not the texture is blocking during loading.
  53199. */
  53200. isBlocking: boolean;
  53201. protected _rotationY: number;
  53202. /**
  53203. * Sets texture matrix rotation angle around Y axis in radians.
  53204. */
  53205. /**
  53206. * Gets texture matrix rotation angle around Y axis radians.
  53207. */
  53208. rotationY: number;
  53209. /**
  53210. * Gets or sets the center of the bounding box associated with the cube texture
  53211. * It must define where the camera used to render the texture was set
  53212. */
  53213. boundingBoxPosition: Vector3;
  53214. private _boundingBoxSize;
  53215. /**
  53216. * Gets or sets the size of the bounding box associated with the cube texture
  53217. * When defined, the cubemap will switch to local mode
  53218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53219. * @example https://www.babylonjs-playground.com/#RNASML
  53220. */
  53221. boundingBoxSize: Vector3;
  53222. /**
  53223. * Instantiates an HDRTexture from the following parameters.
  53224. *
  53225. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53226. * @param scene The scene the texture will be used in
  53227. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53228. * @param noMipmap Forces to not generate the mipmap if true
  53229. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53230. * @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)
  53231. * @param reserved Reserved flag for internal use.
  53232. */
  53233. 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>);
  53234. /**
  53235. * Get the current class name of the texture useful for serialization or dynamic coding.
  53236. * @returns "HDRCubeTexture"
  53237. */
  53238. getClassName(): string;
  53239. /**
  53240. * Occurs when the file is raw .hdr file.
  53241. */
  53242. private loadTexture;
  53243. clone(): HDRCubeTexture;
  53244. delayLoad(): void;
  53245. /**
  53246. * Get the texture reflection matrix used to rotate/transform the reflection.
  53247. * @returns the reflection matrix
  53248. */
  53249. getReflectionTextureMatrix(): Matrix;
  53250. /**
  53251. * Set the texture reflection matrix used to rotate/transform the reflection.
  53252. * @param value Define the reflection matrix to set
  53253. */
  53254. setReflectionTextureMatrix(value: Matrix): void;
  53255. /**
  53256. * Parses a JSON representation of an HDR Texture in order to create the texture
  53257. * @param parsedTexture Define the JSON representation
  53258. * @param scene Define the scene the texture should be created in
  53259. * @param rootUrl Define the root url in case we need to load relative dependencies
  53260. * @returns the newly created texture after parsing
  53261. */
  53262. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53263. serialize(): any;
  53264. }
  53265. }
  53266. declare module "babylonjs/Physics/physicsEngine" {
  53267. import { Nullable } from "babylonjs/types";
  53268. import { Vector3 } from "babylonjs/Maths/math.vector";
  53269. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53270. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53271. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53272. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53273. /**
  53274. * Class used to control physics engine
  53275. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53276. */
  53277. export class PhysicsEngine implements IPhysicsEngine {
  53278. private _physicsPlugin;
  53279. /**
  53280. * Global value used to control the smallest number supported by the simulation
  53281. */
  53282. static Epsilon: number;
  53283. private _impostors;
  53284. private _joints;
  53285. /**
  53286. * Gets the gravity vector used by the simulation
  53287. */
  53288. gravity: Vector3;
  53289. /**
  53290. * Factory used to create the default physics plugin.
  53291. * @returns The default physics plugin
  53292. */
  53293. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53294. /**
  53295. * Creates a new Physics Engine
  53296. * @param gravity defines the gravity vector used by the simulation
  53297. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53298. */
  53299. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53300. /**
  53301. * Sets the gravity vector used by the simulation
  53302. * @param gravity defines the gravity vector to use
  53303. */
  53304. setGravity(gravity: Vector3): void;
  53305. /**
  53306. * Set the time step of the physics engine.
  53307. * Default is 1/60.
  53308. * To slow it down, enter 1/600 for example.
  53309. * To speed it up, 1/30
  53310. * @param newTimeStep defines the new timestep to apply to this world.
  53311. */
  53312. setTimeStep(newTimeStep?: number): void;
  53313. /**
  53314. * Get the time step of the physics engine.
  53315. * @returns the current time step
  53316. */
  53317. getTimeStep(): number;
  53318. /**
  53319. * Release all resources
  53320. */
  53321. dispose(): void;
  53322. /**
  53323. * Gets the name of the current physics plugin
  53324. * @returns the name of the plugin
  53325. */
  53326. getPhysicsPluginName(): string;
  53327. /**
  53328. * Adding a new impostor for the impostor tracking.
  53329. * This will be done by the impostor itself.
  53330. * @param impostor the impostor to add
  53331. */
  53332. addImpostor(impostor: PhysicsImpostor): void;
  53333. /**
  53334. * Remove an impostor from the engine.
  53335. * This impostor and its mesh will not longer be updated by the physics engine.
  53336. * @param impostor the impostor to remove
  53337. */
  53338. removeImpostor(impostor: PhysicsImpostor): void;
  53339. /**
  53340. * Add a joint to the physics engine
  53341. * @param mainImpostor defines the main impostor to which the joint is added.
  53342. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53343. * @param joint defines the joint that will connect both impostors.
  53344. */
  53345. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53346. /**
  53347. * Removes a joint from the simulation
  53348. * @param mainImpostor defines the impostor used with the joint
  53349. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53350. * @param joint defines the joint to remove
  53351. */
  53352. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53353. /**
  53354. * Called by the scene. No need to call it.
  53355. * @param delta defines the timespam between frames
  53356. */
  53357. _step(delta: number): void;
  53358. /**
  53359. * Gets the current plugin used to run the simulation
  53360. * @returns current plugin
  53361. */
  53362. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53363. /**
  53364. * Gets the list of physic impostors
  53365. * @returns an array of PhysicsImpostor
  53366. */
  53367. getImpostors(): Array<PhysicsImpostor>;
  53368. /**
  53369. * Gets the impostor for a physics enabled object
  53370. * @param object defines the object impersonated by the impostor
  53371. * @returns the PhysicsImpostor or null if not found
  53372. */
  53373. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53374. /**
  53375. * Gets the impostor for a physics body object
  53376. * @param body defines physics body used by the impostor
  53377. * @returns the PhysicsImpostor or null if not found
  53378. */
  53379. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53380. /**
  53381. * Does a raycast in the physics world
  53382. * @param from when should the ray start?
  53383. * @param to when should the ray end?
  53384. * @returns PhysicsRaycastResult
  53385. */
  53386. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53387. }
  53388. }
  53389. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53390. import { Nullable } from "babylonjs/types";
  53391. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53393. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53394. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53395. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53396. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53397. /** @hidden */
  53398. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53399. private _useDeltaForWorldStep;
  53400. world: any;
  53401. name: string;
  53402. private _physicsMaterials;
  53403. private _fixedTimeStep;
  53404. private _cannonRaycastResult;
  53405. private _raycastResult;
  53406. private _physicsBodysToRemoveAfterStep;
  53407. BJSCANNON: any;
  53408. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53409. setGravity(gravity: Vector3): void;
  53410. setTimeStep(timeStep: number): void;
  53411. getTimeStep(): number;
  53412. executeStep(delta: number): void;
  53413. private _removeMarkedPhysicsBodiesFromWorld;
  53414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53415. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53416. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53417. private _processChildMeshes;
  53418. removePhysicsBody(impostor: PhysicsImpostor): void;
  53419. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53420. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53421. private _addMaterial;
  53422. private _checkWithEpsilon;
  53423. private _createShape;
  53424. private _createHeightmap;
  53425. private _minus90X;
  53426. private _plus90X;
  53427. private _tmpPosition;
  53428. private _tmpDeltaPosition;
  53429. private _tmpUnityRotation;
  53430. private _updatePhysicsBodyTransformation;
  53431. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53433. isSupported(): boolean;
  53434. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53435. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53436. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53437. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53438. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53439. getBodyMass(impostor: PhysicsImpostor): number;
  53440. getBodyFriction(impostor: PhysicsImpostor): number;
  53441. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53442. getBodyRestitution(impostor: PhysicsImpostor): number;
  53443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53444. sleepBody(impostor: PhysicsImpostor): void;
  53445. wakeUpBody(impostor: PhysicsImpostor): void;
  53446. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53447. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53448. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53449. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53450. getRadius(impostor: PhysicsImpostor): number;
  53451. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53452. dispose(): void;
  53453. private _extendNamespace;
  53454. /**
  53455. * Does a raycast in the physics world
  53456. * @param from when should the ray start?
  53457. * @param to when should the ray end?
  53458. * @returns PhysicsRaycastResult
  53459. */
  53460. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53461. }
  53462. }
  53463. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53464. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53465. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53466. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53468. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53469. import { Nullable } from "babylonjs/types";
  53470. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53471. /** @hidden */
  53472. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53473. world: any;
  53474. name: string;
  53475. BJSOIMO: any;
  53476. private _raycastResult;
  53477. constructor(iterations?: number, oimoInjection?: any);
  53478. setGravity(gravity: Vector3): void;
  53479. setTimeStep(timeStep: number): void;
  53480. getTimeStep(): number;
  53481. private _tmpImpostorsArray;
  53482. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53483. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53484. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53486. private _tmpPositionVector;
  53487. removePhysicsBody(impostor: PhysicsImpostor): void;
  53488. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53489. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53490. isSupported(): boolean;
  53491. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53492. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53493. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53494. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53495. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53496. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53497. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53498. getBodyMass(impostor: PhysicsImpostor): number;
  53499. getBodyFriction(impostor: PhysicsImpostor): number;
  53500. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53501. getBodyRestitution(impostor: PhysicsImpostor): number;
  53502. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53503. sleepBody(impostor: PhysicsImpostor): void;
  53504. wakeUpBody(impostor: PhysicsImpostor): void;
  53505. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53506. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53507. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53508. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53509. getRadius(impostor: PhysicsImpostor): number;
  53510. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53511. dispose(): void;
  53512. /**
  53513. * Does a raycast in the physics world
  53514. * @param from when should the ray start?
  53515. * @param to when should the ray end?
  53516. * @returns PhysicsRaycastResult
  53517. */
  53518. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53519. }
  53520. }
  53521. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53522. import { Nullable } from "babylonjs/types";
  53523. import { Scene } from "babylonjs/scene";
  53524. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53525. import { Color4 } from "babylonjs/Maths/math.color";
  53526. import { Mesh } from "babylonjs/Meshes/mesh";
  53527. /**
  53528. * Class containing static functions to help procedurally build meshes
  53529. */
  53530. export class RibbonBuilder {
  53531. /**
  53532. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53533. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53534. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53535. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53536. * * 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
  53537. * * 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
  53538. * * 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
  53539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53542. * * 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
  53543. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53544. * * 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
  53545. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53547. * @param name defines the name of the mesh
  53548. * @param options defines the options used to create the mesh
  53549. * @param scene defines the hosting scene
  53550. * @returns the ribbon mesh
  53551. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53553. */
  53554. static CreateRibbon(name: string, options: {
  53555. pathArray: Vector3[][];
  53556. closeArray?: boolean;
  53557. closePath?: boolean;
  53558. offset?: number;
  53559. updatable?: boolean;
  53560. sideOrientation?: number;
  53561. frontUVs?: Vector4;
  53562. backUVs?: Vector4;
  53563. instance?: Mesh;
  53564. invertUV?: boolean;
  53565. uvs?: Vector2[];
  53566. colors?: Color4[];
  53567. }, scene?: Nullable<Scene>): Mesh;
  53568. }
  53569. }
  53570. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53571. import { Nullable } from "babylonjs/types";
  53572. import { Scene } from "babylonjs/scene";
  53573. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53574. import { Mesh } from "babylonjs/Meshes/mesh";
  53575. /**
  53576. * Class containing static functions to help procedurally build meshes
  53577. */
  53578. export class ShapeBuilder {
  53579. /**
  53580. * 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.
  53581. * * 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.
  53582. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53583. * * 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.
  53584. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53585. * * 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
  53586. * * 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
  53587. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53592. * @param name defines the name of the mesh
  53593. * @param options defines the options used to create the mesh
  53594. * @param scene defines the hosting scene
  53595. * @returns the extruded shape mesh
  53596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53598. */
  53599. static ExtrudeShape(name: string, options: {
  53600. shape: Vector3[];
  53601. path: Vector3[];
  53602. scale?: number;
  53603. rotation?: number;
  53604. cap?: number;
  53605. updatable?: boolean;
  53606. sideOrientation?: number;
  53607. frontUVs?: Vector4;
  53608. backUVs?: Vector4;
  53609. instance?: Mesh;
  53610. invertUV?: boolean;
  53611. }, scene?: Nullable<Scene>): Mesh;
  53612. /**
  53613. * Creates an custom extruded shape mesh.
  53614. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53615. * * 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.
  53616. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53617. * * 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
  53618. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53619. * * 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
  53620. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53621. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53622. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53623. * * 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
  53624. * * 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
  53625. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53630. * @param name defines the name of the mesh
  53631. * @param options defines the options used to create the mesh
  53632. * @param scene defines the hosting scene
  53633. * @returns the custom extruded shape mesh
  53634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53637. */
  53638. static ExtrudeShapeCustom(name: string, options: {
  53639. shape: Vector3[];
  53640. path: Vector3[];
  53641. scaleFunction?: any;
  53642. rotationFunction?: any;
  53643. ribbonCloseArray?: boolean;
  53644. ribbonClosePath?: boolean;
  53645. cap?: number;
  53646. updatable?: boolean;
  53647. sideOrientation?: number;
  53648. frontUVs?: Vector4;
  53649. backUVs?: Vector4;
  53650. instance?: Mesh;
  53651. invertUV?: boolean;
  53652. }, scene?: Nullable<Scene>): Mesh;
  53653. private static _ExtrudeShapeGeneric;
  53654. }
  53655. }
  53656. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53657. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53658. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53659. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53660. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53661. import { Nullable } from "babylonjs/types";
  53662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53663. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53664. /**
  53665. * AmmoJS Physics plugin
  53666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53667. * @see https://github.com/kripken/ammo.js/
  53668. */
  53669. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53670. private _useDeltaForWorldStep;
  53671. /**
  53672. * Reference to the Ammo library
  53673. */
  53674. bjsAMMO: any;
  53675. /**
  53676. * Created ammoJS world which physics bodies are added to
  53677. */
  53678. world: any;
  53679. /**
  53680. * Name of the plugin
  53681. */
  53682. name: string;
  53683. private _timeStep;
  53684. private _fixedTimeStep;
  53685. private _maxSteps;
  53686. private _tmpQuaternion;
  53687. private _tmpAmmoTransform;
  53688. private _tmpAmmoQuaternion;
  53689. private _tmpAmmoConcreteContactResultCallback;
  53690. private _collisionConfiguration;
  53691. private _dispatcher;
  53692. private _overlappingPairCache;
  53693. private _solver;
  53694. private _softBodySolver;
  53695. private _tmpAmmoVectorA;
  53696. private _tmpAmmoVectorB;
  53697. private _tmpAmmoVectorC;
  53698. private _tmpAmmoVectorD;
  53699. private _tmpContactCallbackResult;
  53700. private _tmpAmmoVectorRCA;
  53701. private _tmpAmmoVectorRCB;
  53702. private _raycastResult;
  53703. private static readonly DISABLE_COLLISION_FLAG;
  53704. private static readonly KINEMATIC_FLAG;
  53705. private static readonly DISABLE_DEACTIVATION_FLAG;
  53706. /**
  53707. * Initializes the ammoJS plugin
  53708. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53709. * @param ammoInjection can be used to inject your own ammo reference
  53710. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53711. */
  53712. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53713. /**
  53714. * Sets the gravity of the physics world (m/(s^2))
  53715. * @param gravity Gravity to set
  53716. */
  53717. setGravity(gravity: Vector3): void;
  53718. /**
  53719. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53720. * @param timeStep timestep to use in seconds
  53721. */
  53722. setTimeStep(timeStep: number): void;
  53723. /**
  53724. * 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)
  53725. * @param fixedTimeStep fixedTimeStep to use in seconds
  53726. */
  53727. setFixedTimeStep(fixedTimeStep: number): void;
  53728. /**
  53729. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53730. * @param maxSteps the maximum number of steps by the physics engine per frame
  53731. */
  53732. setMaxSteps(maxSteps: number): void;
  53733. /**
  53734. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53735. * @returns the current timestep in seconds
  53736. */
  53737. getTimeStep(): number;
  53738. private _isImpostorInContact;
  53739. private _isImpostorPairInContact;
  53740. private _stepSimulation;
  53741. /**
  53742. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53743. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53744. * After the step the babylon meshes are set to the position of the physics imposters
  53745. * @param delta amount of time to step forward
  53746. * @param impostors array of imposters to update before/after the step
  53747. */
  53748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53749. /**
  53750. * Update babylon mesh to match physics world object
  53751. * @param impostor imposter to match
  53752. */
  53753. private _afterSoftStep;
  53754. /**
  53755. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53756. * @param impostor imposter to match
  53757. */
  53758. private _ropeStep;
  53759. /**
  53760. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53761. * @param impostor imposter to match
  53762. */
  53763. private _softbodyOrClothStep;
  53764. private _tmpVector;
  53765. private _tmpMatrix;
  53766. /**
  53767. * Applies an impulse on the imposter
  53768. * @param impostor imposter to apply impulse to
  53769. * @param force amount of force to be applied to the imposter
  53770. * @param contactPoint the location to apply the impulse on the imposter
  53771. */
  53772. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53773. /**
  53774. * Applies a force on the imposter
  53775. * @param impostor imposter to apply force
  53776. * @param force amount of force to be applied to the imposter
  53777. * @param contactPoint the location to apply the force on the imposter
  53778. */
  53779. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53780. /**
  53781. * Creates a physics body using the plugin
  53782. * @param impostor the imposter to create the physics body on
  53783. */
  53784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53785. /**
  53786. * Removes the physics body from the imposter and disposes of the body's memory
  53787. * @param impostor imposter to remove the physics body from
  53788. */
  53789. removePhysicsBody(impostor: PhysicsImpostor): void;
  53790. /**
  53791. * Generates a joint
  53792. * @param impostorJoint the imposter joint to create the joint with
  53793. */
  53794. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53795. /**
  53796. * Removes a joint
  53797. * @param impostorJoint the imposter joint to remove the joint from
  53798. */
  53799. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53800. private _addMeshVerts;
  53801. /**
  53802. * Initialise the soft body vertices to match its object's (mesh) vertices
  53803. * Softbody vertices (nodes) are in world space and to match this
  53804. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53805. * @param impostor to create the softbody for
  53806. */
  53807. private _softVertexData;
  53808. /**
  53809. * Create an impostor's soft body
  53810. * @param impostor to create the softbody for
  53811. */
  53812. private _createSoftbody;
  53813. /**
  53814. * Create cloth for an impostor
  53815. * @param impostor to create the softbody for
  53816. */
  53817. private _createCloth;
  53818. /**
  53819. * Create rope for an impostor
  53820. * @param impostor to create the softbody for
  53821. */
  53822. private _createRope;
  53823. private _addHullVerts;
  53824. private _createShape;
  53825. /**
  53826. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53827. * @param impostor imposter containing the physics body and babylon object
  53828. */
  53829. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53830. /**
  53831. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53832. * @param impostor imposter containing the physics body and babylon object
  53833. * @param newPosition new position
  53834. * @param newRotation new rotation
  53835. */
  53836. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53837. /**
  53838. * If this plugin is supported
  53839. * @returns true if its supported
  53840. */
  53841. isSupported(): boolean;
  53842. /**
  53843. * Sets the linear velocity of the physics body
  53844. * @param impostor imposter to set the velocity on
  53845. * @param velocity velocity to set
  53846. */
  53847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53848. /**
  53849. * Sets the angular velocity of the physics body
  53850. * @param impostor imposter to set the velocity on
  53851. * @param velocity velocity to set
  53852. */
  53853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53854. /**
  53855. * gets the linear velocity
  53856. * @param impostor imposter to get linear velocity from
  53857. * @returns linear velocity
  53858. */
  53859. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53860. /**
  53861. * gets the angular velocity
  53862. * @param impostor imposter to get angular velocity from
  53863. * @returns angular velocity
  53864. */
  53865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53866. /**
  53867. * Sets the mass of physics body
  53868. * @param impostor imposter to set the mass on
  53869. * @param mass mass to set
  53870. */
  53871. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53872. /**
  53873. * Gets the mass of the physics body
  53874. * @param impostor imposter to get the mass from
  53875. * @returns mass
  53876. */
  53877. getBodyMass(impostor: PhysicsImpostor): number;
  53878. /**
  53879. * Gets friction of the impostor
  53880. * @param impostor impostor to get friction from
  53881. * @returns friction value
  53882. */
  53883. getBodyFriction(impostor: PhysicsImpostor): number;
  53884. /**
  53885. * Sets friction of the impostor
  53886. * @param impostor impostor to set friction on
  53887. * @param friction friction value
  53888. */
  53889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53890. /**
  53891. * Gets restitution of the impostor
  53892. * @param impostor impostor to get restitution from
  53893. * @returns restitution value
  53894. */
  53895. getBodyRestitution(impostor: PhysicsImpostor): number;
  53896. /**
  53897. * Sets resitution of the impostor
  53898. * @param impostor impostor to set resitution on
  53899. * @param restitution resitution value
  53900. */
  53901. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53902. /**
  53903. * Gets pressure inside the impostor
  53904. * @param impostor impostor to get pressure from
  53905. * @returns pressure value
  53906. */
  53907. getBodyPressure(impostor: PhysicsImpostor): number;
  53908. /**
  53909. * Sets pressure inside a soft body impostor
  53910. * Cloth and rope must remain 0 pressure
  53911. * @param impostor impostor to set pressure on
  53912. * @param pressure pressure value
  53913. */
  53914. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53915. /**
  53916. * Gets stiffness of the impostor
  53917. * @param impostor impostor to get stiffness from
  53918. * @returns pressure value
  53919. */
  53920. getBodyStiffness(impostor: PhysicsImpostor): number;
  53921. /**
  53922. * Sets stiffness of the impostor
  53923. * @param impostor impostor to set stiffness on
  53924. * @param stiffness stiffness value from 0 to 1
  53925. */
  53926. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53927. /**
  53928. * Gets velocityIterations of the impostor
  53929. * @param impostor impostor to get velocity iterations from
  53930. * @returns velocityIterations value
  53931. */
  53932. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53933. /**
  53934. * Sets velocityIterations of the impostor
  53935. * @param impostor impostor to set velocity iterations on
  53936. * @param velocityIterations velocityIterations value
  53937. */
  53938. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53939. /**
  53940. * Gets positionIterations of the impostor
  53941. * @param impostor impostor to get position iterations from
  53942. * @returns positionIterations value
  53943. */
  53944. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53945. /**
  53946. * Sets positionIterations of the impostor
  53947. * @param impostor impostor to set position on
  53948. * @param positionIterations positionIterations value
  53949. */
  53950. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53951. /**
  53952. * Append an anchor to a cloth object
  53953. * @param impostor is the cloth impostor to add anchor to
  53954. * @param otherImpostor is the rigid impostor to anchor to
  53955. * @param width ratio across width from 0 to 1
  53956. * @param height ratio up height from 0 to 1
  53957. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53958. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53959. */
  53960. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53961. /**
  53962. * Append an hook to a rope object
  53963. * @param impostor is the rope impostor to add hook to
  53964. * @param otherImpostor is the rigid impostor to hook to
  53965. * @param length ratio along the rope from 0 to 1
  53966. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53967. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53968. */
  53969. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53970. /**
  53971. * Sleeps the physics body and stops it from being active
  53972. * @param impostor impostor to sleep
  53973. */
  53974. sleepBody(impostor: PhysicsImpostor): void;
  53975. /**
  53976. * Activates the physics body
  53977. * @param impostor impostor to activate
  53978. */
  53979. wakeUpBody(impostor: PhysicsImpostor): void;
  53980. /**
  53981. * Updates the distance parameters of the joint
  53982. * @param joint joint to update
  53983. * @param maxDistance maximum distance of the joint
  53984. * @param minDistance minimum distance of the joint
  53985. */
  53986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53987. /**
  53988. * Sets a motor on the joint
  53989. * @param joint joint to set motor on
  53990. * @param speed speed of the motor
  53991. * @param maxForce maximum force of the motor
  53992. * @param motorIndex index of the motor
  53993. */
  53994. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53995. /**
  53996. * Sets the motors limit
  53997. * @param joint joint to set limit on
  53998. * @param upperLimit upper limit
  53999. * @param lowerLimit lower limit
  54000. */
  54001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54002. /**
  54003. * Syncs the position and rotation of a mesh with the impostor
  54004. * @param mesh mesh to sync
  54005. * @param impostor impostor to update the mesh with
  54006. */
  54007. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54008. /**
  54009. * Gets the radius of the impostor
  54010. * @param impostor impostor to get radius from
  54011. * @returns the radius
  54012. */
  54013. getRadius(impostor: PhysicsImpostor): number;
  54014. /**
  54015. * Gets the box size of the impostor
  54016. * @param impostor impostor to get box size from
  54017. * @param result the resulting box size
  54018. */
  54019. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54020. /**
  54021. * Disposes of the impostor
  54022. */
  54023. dispose(): void;
  54024. /**
  54025. * Does a raycast in the physics world
  54026. * @param from when should the ray start?
  54027. * @param to when should the ray end?
  54028. * @returns PhysicsRaycastResult
  54029. */
  54030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54031. }
  54032. }
  54033. declare module "babylonjs/Probes/reflectionProbe" {
  54034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54035. import { Vector3 } from "babylonjs/Maths/math.vector";
  54036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54037. import { Nullable } from "babylonjs/types";
  54038. import { Scene } from "babylonjs/scene";
  54039. module "babylonjs/abstractScene" {
  54040. interface AbstractScene {
  54041. /**
  54042. * The list of reflection probes added to the scene
  54043. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54044. */
  54045. reflectionProbes: Array<ReflectionProbe>;
  54046. /**
  54047. * Removes the given reflection probe from this scene.
  54048. * @param toRemove The reflection probe to remove
  54049. * @returns The index of the removed reflection probe
  54050. */
  54051. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54052. /**
  54053. * Adds the given reflection probe to this scene.
  54054. * @param newReflectionProbe The reflection probe to add
  54055. */
  54056. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54057. }
  54058. }
  54059. /**
  54060. * Class used to generate realtime reflection / refraction cube textures
  54061. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54062. */
  54063. export class ReflectionProbe {
  54064. /** defines the name of the probe */
  54065. name: string;
  54066. private _scene;
  54067. private _renderTargetTexture;
  54068. private _projectionMatrix;
  54069. private _viewMatrix;
  54070. private _target;
  54071. private _add;
  54072. private _attachedMesh;
  54073. private _invertYAxis;
  54074. /** Gets or sets probe position (center of the cube map) */
  54075. position: Vector3;
  54076. /**
  54077. * Creates a new reflection probe
  54078. * @param name defines the name of the probe
  54079. * @param size defines the texture resolution (for each face)
  54080. * @param scene defines the hosting scene
  54081. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54082. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54083. */
  54084. constructor(
  54085. /** defines the name of the probe */
  54086. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54087. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54088. samples: number;
  54089. /** Gets or sets the refresh rate to use (on every frame by default) */
  54090. refreshRate: number;
  54091. /**
  54092. * Gets the hosting scene
  54093. * @returns a Scene
  54094. */
  54095. getScene(): Scene;
  54096. /** Gets the internal CubeTexture used to render to */
  54097. readonly cubeTexture: RenderTargetTexture;
  54098. /** Gets the list of meshes to render */
  54099. readonly renderList: Nullable<AbstractMesh[]>;
  54100. /**
  54101. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54102. * @param mesh defines the mesh to attach to
  54103. */
  54104. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54105. /**
  54106. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54107. * @param renderingGroupId The rendering group id corresponding to its index
  54108. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54109. */
  54110. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54111. /**
  54112. * Clean all associated resources
  54113. */
  54114. dispose(): void;
  54115. /**
  54116. * Converts the reflection probe information to a readable string for debug purpose.
  54117. * @param fullDetails Supports for multiple levels of logging within scene loading
  54118. * @returns the human readable reflection probe info
  54119. */
  54120. toString(fullDetails?: boolean): string;
  54121. /**
  54122. * Get the class name of the relfection probe.
  54123. * @returns "ReflectionProbe"
  54124. */
  54125. getClassName(): string;
  54126. /**
  54127. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54128. * @returns The JSON representation of the texture
  54129. */
  54130. serialize(): any;
  54131. /**
  54132. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54133. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54134. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54135. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54136. * @returns The parsed reflection probe if successful
  54137. */
  54138. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54139. }
  54140. }
  54141. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54142. /** @hidden */
  54143. export var _BabylonLoaderRegistered: boolean;
  54144. }
  54145. declare module "babylonjs/Loading/Plugins/index" {
  54146. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54147. }
  54148. declare module "babylonjs/Loading/index" {
  54149. export * from "babylonjs/Loading/loadingScreen";
  54150. export * from "babylonjs/Loading/Plugins/index";
  54151. export * from "babylonjs/Loading/sceneLoader";
  54152. export * from "babylonjs/Loading/sceneLoaderFlags";
  54153. }
  54154. declare module "babylonjs/Materials/Background/index" {
  54155. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54156. }
  54157. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54158. import { Scene } from "babylonjs/scene";
  54159. import { Color3 } from "babylonjs/Maths/math.color";
  54160. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54162. /**
  54163. * The Physically based simple base material of BJS.
  54164. *
  54165. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54166. * It is used as the base class for both the specGloss and metalRough conventions.
  54167. */
  54168. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54169. /**
  54170. * Number of Simultaneous lights allowed on the material.
  54171. */
  54172. maxSimultaneousLights: number;
  54173. /**
  54174. * If sets to true, disables all the lights affecting the material.
  54175. */
  54176. disableLighting: boolean;
  54177. /**
  54178. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54179. */
  54180. environmentTexture: BaseTexture;
  54181. /**
  54182. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54183. */
  54184. invertNormalMapX: boolean;
  54185. /**
  54186. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54187. */
  54188. invertNormalMapY: boolean;
  54189. /**
  54190. * Normal map used in the model.
  54191. */
  54192. normalTexture: BaseTexture;
  54193. /**
  54194. * Emissivie color used to self-illuminate the model.
  54195. */
  54196. emissiveColor: Color3;
  54197. /**
  54198. * Emissivie texture used to self-illuminate the model.
  54199. */
  54200. emissiveTexture: BaseTexture;
  54201. /**
  54202. * Occlusion Channel Strenght.
  54203. */
  54204. occlusionStrength: number;
  54205. /**
  54206. * Occlusion Texture of the material (adding extra occlusion effects).
  54207. */
  54208. occlusionTexture: BaseTexture;
  54209. /**
  54210. * Defines the alpha limits in alpha test mode.
  54211. */
  54212. alphaCutOff: number;
  54213. /**
  54214. * Gets the current double sided mode.
  54215. */
  54216. /**
  54217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54218. */
  54219. doubleSided: boolean;
  54220. /**
  54221. * Stores the pre-calculated light information of a mesh in a texture.
  54222. */
  54223. lightmapTexture: BaseTexture;
  54224. /**
  54225. * If true, the light map contains occlusion information instead of lighting info.
  54226. */
  54227. useLightmapAsShadowmap: boolean;
  54228. /**
  54229. * Instantiates a new PBRMaterial instance.
  54230. *
  54231. * @param name The material name
  54232. * @param scene The scene the material will be use in.
  54233. */
  54234. constructor(name: string, scene: Scene);
  54235. getClassName(): string;
  54236. }
  54237. }
  54238. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54239. import { Scene } from "babylonjs/scene";
  54240. import { Color3 } from "babylonjs/Maths/math.color";
  54241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54242. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54243. /**
  54244. * The PBR material of BJS following the metal roughness convention.
  54245. *
  54246. * This fits to the PBR convention in the GLTF definition:
  54247. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54248. */
  54249. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54250. /**
  54251. * The base color has two different interpretations depending on the value of metalness.
  54252. * When the material is a metal, the base color is the specific measured reflectance value
  54253. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54254. * of the material.
  54255. */
  54256. baseColor: Color3;
  54257. /**
  54258. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54259. * well as opacity information in the alpha channel.
  54260. */
  54261. baseTexture: BaseTexture;
  54262. /**
  54263. * Specifies the metallic scalar value of the material.
  54264. * Can also be used to scale the metalness values of the metallic texture.
  54265. */
  54266. metallic: number;
  54267. /**
  54268. * Specifies the roughness scalar value of the material.
  54269. * Can also be used to scale the roughness values of the metallic texture.
  54270. */
  54271. roughness: number;
  54272. /**
  54273. * Texture containing both the metallic value in the B channel and the
  54274. * roughness value in the G channel to keep better precision.
  54275. */
  54276. metallicRoughnessTexture: BaseTexture;
  54277. /**
  54278. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54279. *
  54280. * @param name The material name
  54281. * @param scene The scene the material will be use in.
  54282. */
  54283. constructor(name: string, scene: Scene);
  54284. /**
  54285. * Return the currrent class name of the material.
  54286. */
  54287. getClassName(): string;
  54288. /**
  54289. * Makes a duplicate of the current material.
  54290. * @param name - name to use for the new material.
  54291. */
  54292. clone(name: string): PBRMetallicRoughnessMaterial;
  54293. /**
  54294. * Serialize the material to a parsable JSON object.
  54295. */
  54296. serialize(): any;
  54297. /**
  54298. * Parses a JSON object correponding to the serialize function.
  54299. */
  54300. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54304. import { Scene } from "babylonjs/scene";
  54305. import { Color3 } from "babylonjs/Maths/math.color";
  54306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54307. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54308. /**
  54309. * The PBR material of BJS following the specular glossiness convention.
  54310. *
  54311. * This fits to the PBR convention in the GLTF definition:
  54312. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54313. */
  54314. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54315. /**
  54316. * Specifies the diffuse color of the material.
  54317. */
  54318. diffuseColor: Color3;
  54319. /**
  54320. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54321. * channel.
  54322. */
  54323. diffuseTexture: BaseTexture;
  54324. /**
  54325. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54326. */
  54327. specularColor: Color3;
  54328. /**
  54329. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54330. */
  54331. glossiness: number;
  54332. /**
  54333. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54334. */
  54335. specularGlossinessTexture: BaseTexture;
  54336. /**
  54337. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54338. *
  54339. * @param name The material name
  54340. * @param scene The scene the material will be use in.
  54341. */
  54342. constructor(name: string, scene: Scene);
  54343. /**
  54344. * Return the currrent class name of the material.
  54345. */
  54346. getClassName(): string;
  54347. /**
  54348. * Makes a duplicate of the current material.
  54349. * @param name - name to use for the new material.
  54350. */
  54351. clone(name: string): PBRSpecularGlossinessMaterial;
  54352. /**
  54353. * Serialize the material to a parsable JSON object.
  54354. */
  54355. serialize(): any;
  54356. /**
  54357. * Parses a JSON object correponding to the serialize function.
  54358. */
  54359. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54360. }
  54361. }
  54362. declare module "babylonjs/Materials/PBR/index" {
  54363. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54364. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54365. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54366. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54367. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54368. }
  54369. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54370. import { Nullable } from "babylonjs/types";
  54371. import { Scene } from "babylonjs/scene";
  54372. import { Matrix } from "babylonjs/Maths/math.vector";
  54373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54374. /**
  54375. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54376. * It can help converting any input color in a desired output one. This can then be used to create effects
  54377. * from sepia, black and white to sixties or futuristic rendering...
  54378. *
  54379. * The only supported format is currently 3dl.
  54380. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54381. */
  54382. export class ColorGradingTexture extends BaseTexture {
  54383. /**
  54384. * The current texture matrix. (will always be identity in color grading texture)
  54385. */
  54386. private _textureMatrix;
  54387. /**
  54388. * The texture URL.
  54389. */
  54390. url: string;
  54391. /**
  54392. * Empty line regex stored for GC.
  54393. */
  54394. private static _noneEmptyLineRegex;
  54395. private _engine;
  54396. /**
  54397. * Instantiates a ColorGradingTexture from the following parameters.
  54398. *
  54399. * @param url The location of the color gradind data (currently only supporting 3dl)
  54400. * @param scene The scene the texture will be used in
  54401. */
  54402. constructor(url: string, scene: Scene);
  54403. /**
  54404. * Returns the texture matrix used in most of the material.
  54405. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54406. */
  54407. getTextureMatrix(): Matrix;
  54408. /**
  54409. * Occurs when the file being loaded is a .3dl LUT file.
  54410. */
  54411. private load3dlTexture;
  54412. /**
  54413. * Starts the loading process of the texture.
  54414. */
  54415. private loadTexture;
  54416. /**
  54417. * Clones the color gradind texture.
  54418. */
  54419. clone(): ColorGradingTexture;
  54420. /**
  54421. * Called during delayed load for textures.
  54422. */
  54423. delayLoad(): void;
  54424. /**
  54425. * Parses a color grading texture serialized by Babylon.
  54426. * @param parsedTexture The texture information being parsedTexture
  54427. * @param scene The scene to load the texture in
  54428. * @param rootUrl The root url of the data assets to load
  54429. * @return A color gradind texture
  54430. */
  54431. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54432. /**
  54433. * Serializes the LUT texture to json format.
  54434. */
  54435. serialize(): any;
  54436. }
  54437. }
  54438. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54440. import { Scene } from "babylonjs/scene";
  54441. import { Nullable } from "babylonjs/types";
  54442. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54443. /**
  54444. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54445. */
  54446. export class EquiRectangularCubeTexture extends BaseTexture {
  54447. /** The six faces of the cube. */
  54448. private static _FacesMapping;
  54449. private _noMipmap;
  54450. private _onLoad;
  54451. private _onError;
  54452. /** The size of the cubemap. */
  54453. private _size;
  54454. /** The buffer of the image. */
  54455. private _buffer;
  54456. /** The width of the input image. */
  54457. private _width;
  54458. /** The height of the input image. */
  54459. private _height;
  54460. /** The URL to the image. */
  54461. url: string;
  54462. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54463. coordinatesMode: number;
  54464. /**
  54465. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54466. * @param url The location of the image
  54467. * @param scene The scene the texture will be used in
  54468. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54469. * @param noMipmap Forces to not generate the mipmap if true
  54470. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54471. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54472. * @param onLoad — defines a callback called when texture is loaded
  54473. * @param onError — defines a callback called if there is an error
  54474. */
  54475. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54476. /**
  54477. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54478. */
  54479. private loadImage;
  54480. /**
  54481. * Convert the image buffer into a cubemap and create a CubeTexture.
  54482. */
  54483. private loadTexture;
  54484. /**
  54485. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54486. * @param buffer The ArrayBuffer that should be converted.
  54487. * @returns The buffer as Float32Array.
  54488. */
  54489. private getFloat32ArrayFromArrayBuffer;
  54490. /**
  54491. * Get the current class name of the texture useful for serialization or dynamic coding.
  54492. * @returns "EquiRectangularCubeTexture"
  54493. */
  54494. getClassName(): string;
  54495. /**
  54496. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54497. * @returns A clone of the current EquiRectangularCubeTexture.
  54498. */
  54499. clone(): EquiRectangularCubeTexture;
  54500. }
  54501. }
  54502. declare module "babylonjs/Misc/tga" {
  54503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54504. /**
  54505. * Based on jsTGALoader - Javascript loader for TGA file
  54506. * By Vincent Thibault
  54507. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54508. */
  54509. export class TGATools {
  54510. private static _TYPE_INDEXED;
  54511. private static _TYPE_RGB;
  54512. private static _TYPE_GREY;
  54513. private static _TYPE_RLE_INDEXED;
  54514. private static _TYPE_RLE_RGB;
  54515. private static _TYPE_RLE_GREY;
  54516. private static _ORIGIN_MASK;
  54517. private static _ORIGIN_SHIFT;
  54518. private static _ORIGIN_BL;
  54519. private static _ORIGIN_BR;
  54520. private static _ORIGIN_UL;
  54521. private static _ORIGIN_UR;
  54522. /**
  54523. * Gets the header of a TGA file
  54524. * @param data defines the TGA data
  54525. * @returns the header
  54526. */
  54527. static GetTGAHeader(data: Uint8Array): any;
  54528. /**
  54529. * Uploads TGA content to a Babylon Texture
  54530. * @hidden
  54531. */
  54532. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54533. /** @hidden */
  54534. 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;
  54535. /** @hidden */
  54536. 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;
  54537. /** @hidden */
  54538. 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;
  54539. /** @hidden */
  54540. 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;
  54541. /** @hidden */
  54542. 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;
  54543. /** @hidden */
  54544. 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;
  54545. }
  54546. }
  54547. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54548. import { Nullable } from "babylonjs/types";
  54549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54550. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54551. /**
  54552. * Implementation of the TGA Texture Loader.
  54553. * @hidden
  54554. */
  54555. export class _TGATextureLoader implements IInternalTextureLoader {
  54556. /**
  54557. * Defines wether the loader supports cascade loading the different faces.
  54558. */
  54559. readonly supportCascades: boolean;
  54560. /**
  54561. * This returns if the loader support the current file information.
  54562. * @param extension defines the file extension of the file being loaded
  54563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54564. * @param fallback defines the fallback internal texture if any
  54565. * @param isBase64 defines whether the texture is encoded as a base64
  54566. * @param isBuffer defines whether the texture data are stored as a buffer
  54567. * @returns true if the loader can load the specified file
  54568. */
  54569. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54570. /**
  54571. * Transform the url before loading if required.
  54572. * @param rootUrl the url of the texture
  54573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54574. * @returns the transformed texture
  54575. */
  54576. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54577. /**
  54578. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54579. * @param rootUrl the url of the texture
  54580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54581. * @returns the fallback texture
  54582. */
  54583. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54584. /**
  54585. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54586. * @param data contains the texture data
  54587. * @param texture defines the BabylonJS internal texture
  54588. * @param createPolynomials will be true if polynomials have been requested
  54589. * @param onLoad defines the callback to trigger once the texture is ready
  54590. * @param onError defines the callback to trigger in case of error
  54591. */
  54592. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54593. /**
  54594. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54595. * @param data contains the texture data
  54596. * @param texture defines the BabylonJS internal texture
  54597. * @param callback defines the method to call once ready to upload
  54598. */
  54599. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54600. }
  54601. }
  54602. declare module "babylonjs/Misc/basis" {
  54603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54604. /**
  54605. * Info about the .basis files
  54606. */
  54607. class BasisFileInfo {
  54608. /**
  54609. * If the file has alpha
  54610. */
  54611. hasAlpha: boolean;
  54612. /**
  54613. * Info about each image of the basis file
  54614. */
  54615. images: Array<{
  54616. levels: Array<{
  54617. width: number;
  54618. height: number;
  54619. transcodedPixels: ArrayBufferView;
  54620. }>;
  54621. }>;
  54622. }
  54623. /**
  54624. * Result of transcoding a basis file
  54625. */
  54626. class TranscodeResult {
  54627. /**
  54628. * Info about the .basis file
  54629. */
  54630. fileInfo: BasisFileInfo;
  54631. /**
  54632. * Format to use when loading the file
  54633. */
  54634. format: number;
  54635. }
  54636. /**
  54637. * Configuration options for the Basis transcoder
  54638. */
  54639. export class BasisTranscodeConfiguration {
  54640. /**
  54641. * Supported compression formats used to determine the supported output format of the transcoder
  54642. */
  54643. supportedCompressionFormats?: {
  54644. /**
  54645. * etc1 compression format
  54646. */
  54647. etc1?: boolean;
  54648. /**
  54649. * s3tc compression format
  54650. */
  54651. s3tc?: boolean;
  54652. /**
  54653. * pvrtc compression format
  54654. */
  54655. pvrtc?: boolean;
  54656. /**
  54657. * etc2 compression format
  54658. */
  54659. etc2?: boolean;
  54660. };
  54661. /**
  54662. * If mipmap levels should be loaded for transcoded images (Default: true)
  54663. */
  54664. loadMipmapLevels?: boolean;
  54665. /**
  54666. * Index of a single image to load (Default: all images)
  54667. */
  54668. loadSingleImage?: number;
  54669. }
  54670. /**
  54671. * Used to load .Basis files
  54672. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54673. */
  54674. export class BasisTools {
  54675. private static _IgnoreSupportedFormats;
  54676. /**
  54677. * URL to use when loading the basis transcoder
  54678. */
  54679. static JSModuleURL: string;
  54680. /**
  54681. * URL to use when loading the wasm module for the transcoder
  54682. */
  54683. static WasmModuleURL: string;
  54684. /**
  54685. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54686. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54687. * @returns internal format corresponding to the Basis format
  54688. */
  54689. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54690. private static _WorkerPromise;
  54691. private static _Worker;
  54692. private static _actionId;
  54693. private static _CreateWorkerAsync;
  54694. /**
  54695. * Transcodes a loaded image file to compressed pixel data
  54696. * @param imageData image data to transcode
  54697. * @param config configuration options for the transcoding
  54698. * @returns a promise resulting in the transcoded image
  54699. */
  54700. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54701. /**
  54702. * Loads a texture from the transcode result
  54703. * @param texture texture load to
  54704. * @param transcodeResult the result of transcoding the basis file to load from
  54705. */
  54706. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54707. }
  54708. }
  54709. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54710. import { Nullable } from "babylonjs/types";
  54711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54712. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54713. /**
  54714. * Loader for .basis file format
  54715. */
  54716. export class _BasisTextureLoader implements IInternalTextureLoader {
  54717. /**
  54718. * Defines whether the loader supports cascade loading the different faces.
  54719. */
  54720. readonly supportCascades: boolean;
  54721. /**
  54722. * This returns if the loader support the current file information.
  54723. * @param extension defines the file extension of the file being loaded
  54724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54725. * @param fallback defines the fallback internal texture if any
  54726. * @param isBase64 defines whether the texture is encoded as a base64
  54727. * @param isBuffer defines whether the texture data are stored as a buffer
  54728. * @returns true if the loader can load the specified file
  54729. */
  54730. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54731. /**
  54732. * Transform the url before loading if required.
  54733. * @param rootUrl the url of the texture
  54734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54735. * @returns the transformed texture
  54736. */
  54737. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54738. /**
  54739. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54740. * @param rootUrl the url of the texture
  54741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54742. * @returns the fallback texture
  54743. */
  54744. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54745. /**
  54746. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54747. * @param data contains the texture data
  54748. * @param texture defines the BabylonJS internal texture
  54749. * @param createPolynomials will be true if polynomials have been requested
  54750. * @param onLoad defines the callback to trigger once the texture is ready
  54751. * @param onError defines the callback to trigger in case of error
  54752. */
  54753. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54754. /**
  54755. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54756. * @param data contains the texture data
  54757. * @param texture defines the BabylonJS internal texture
  54758. * @param callback defines the method to call once ready to upload
  54759. */
  54760. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54761. }
  54762. }
  54763. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54764. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54765. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54766. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54767. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54768. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54769. }
  54770. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54771. import { Scene } from "babylonjs/scene";
  54772. import { Texture } from "babylonjs/Materials/Textures/texture";
  54773. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54774. /**
  54775. * 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.
  54776. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54777. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54778. */
  54779. export class CustomProceduralTexture extends ProceduralTexture {
  54780. private _animate;
  54781. private _time;
  54782. private _config;
  54783. private _texturePath;
  54784. /**
  54785. * Instantiates a new Custom Procedural Texture.
  54786. * 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.
  54787. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54788. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54789. * @param name Define the name of the texture
  54790. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54791. * @param size Define the size of the texture to create
  54792. * @param scene Define the scene the texture belongs to
  54793. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54794. * @param generateMipMaps Define if the texture should creates mip maps or not
  54795. */
  54796. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54797. private _loadJson;
  54798. /**
  54799. * Is the texture ready to be used ? (rendered at least once)
  54800. * @returns true if ready, otherwise, false.
  54801. */
  54802. isReady(): boolean;
  54803. /**
  54804. * Render the texture to its associated render target.
  54805. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54806. */
  54807. render(useCameraPostProcess?: boolean): void;
  54808. /**
  54809. * Update the list of dependant textures samplers in the shader.
  54810. */
  54811. updateTextures(): void;
  54812. /**
  54813. * Update the uniform values of the procedural texture in the shader.
  54814. */
  54815. updateShaderUniforms(): void;
  54816. /**
  54817. * Define if the texture animates or not.
  54818. */
  54819. animate: boolean;
  54820. }
  54821. }
  54822. declare module "babylonjs/Shaders/noise.fragment" {
  54823. /** @hidden */
  54824. export var noisePixelShader: {
  54825. name: string;
  54826. shader: string;
  54827. };
  54828. }
  54829. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { Scene } from "babylonjs/scene";
  54832. import { Texture } from "babylonjs/Materials/Textures/texture";
  54833. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54834. import "babylonjs/Shaders/noise.fragment";
  54835. /**
  54836. * Class used to generate noise procedural textures
  54837. */
  54838. export class NoiseProceduralTexture extends ProceduralTexture {
  54839. private _time;
  54840. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54841. brightness: number;
  54842. /** Defines the number of octaves to process */
  54843. octaves: number;
  54844. /** Defines the level of persistence (0.8 by default) */
  54845. persistence: number;
  54846. /** Gets or sets animation speed factor (default is 1) */
  54847. animationSpeedFactor: number;
  54848. /**
  54849. * Creates a new NoiseProceduralTexture
  54850. * @param name defines the name fo the texture
  54851. * @param size defines the size of the texture (default is 256)
  54852. * @param scene defines the hosting scene
  54853. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54854. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54855. */
  54856. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54857. private _updateShaderUniforms;
  54858. protected _getDefines(): string;
  54859. /** Generate the current state of the procedural texture */
  54860. render(useCameraPostProcess?: boolean): void;
  54861. /**
  54862. * Serializes this noise procedural texture
  54863. * @returns a serialized noise procedural texture object
  54864. */
  54865. serialize(): any;
  54866. /**
  54867. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54868. * @param parsedTexture defines parsed texture data
  54869. * @param scene defines the current scene
  54870. * @param rootUrl defines the root URL containing noise procedural texture information
  54871. * @returns a parsed NoiseProceduralTexture
  54872. */
  54873. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54874. }
  54875. }
  54876. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54877. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54878. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54879. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54880. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54881. }
  54882. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54883. import { Nullable } from "babylonjs/types";
  54884. import { Scene } from "babylonjs/scene";
  54885. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54886. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54887. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54888. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54889. /**
  54890. * Raw cube texture where the raw buffers are passed in
  54891. */
  54892. export class RawCubeTexture extends CubeTexture {
  54893. /**
  54894. * Creates a cube texture where the raw buffers are passed in.
  54895. * @param scene defines the scene the texture is attached to
  54896. * @param data defines the array of data to use to create each face
  54897. * @param size defines the size of the textures
  54898. * @param format defines the format of the data
  54899. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54900. * @param generateMipMaps defines if the engine should generate the mip levels
  54901. * @param invertY defines if data must be stored with Y axis inverted
  54902. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54903. * @param compression defines the compression used (null by default)
  54904. */
  54905. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54906. /**
  54907. * Updates the raw cube texture.
  54908. * @param data defines the data to store
  54909. * @param format defines the data format
  54910. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54911. * @param invertY defines if data must be stored with Y axis inverted
  54912. * @param compression defines the compression used (null by default)
  54913. * @param level defines which level of the texture to update
  54914. */
  54915. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54916. /**
  54917. * Updates a raw cube texture with RGBD encoded data.
  54918. * @param data defines the array of data [mipmap][face] to use to create each face
  54919. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54920. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54921. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54922. * @returns a promsie that resolves when the operation is complete
  54923. */
  54924. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54925. /**
  54926. * Clones the raw cube texture.
  54927. * @return a new cube texture
  54928. */
  54929. clone(): CubeTexture;
  54930. /** @hidden */
  54931. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54932. }
  54933. }
  54934. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54935. import { Scene } from "babylonjs/scene";
  54936. import { Texture } from "babylonjs/Materials/Textures/texture";
  54937. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54938. /**
  54939. * Class used to store 3D textures containing user data
  54940. */
  54941. export class RawTexture3D extends Texture {
  54942. /** Gets or sets the texture format to use */
  54943. format: number;
  54944. private _engine;
  54945. /**
  54946. * Create a new RawTexture3D
  54947. * @param data defines the data of the texture
  54948. * @param width defines the width of the texture
  54949. * @param height defines the height of the texture
  54950. * @param depth defines the depth of the texture
  54951. * @param format defines the texture format to use
  54952. * @param scene defines the hosting scene
  54953. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54954. * @param invertY defines if texture must be stored with Y axis inverted
  54955. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54956. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54957. */
  54958. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54959. /** Gets or sets the texture format to use */
  54960. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54961. /**
  54962. * Update the texture with new data
  54963. * @param data defines the data to store in the texture
  54964. */
  54965. update(data: ArrayBufferView): void;
  54966. }
  54967. }
  54968. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54969. import { Scene } from "babylonjs/scene";
  54970. import { Plane } from "babylonjs/Maths/math.plane";
  54971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54972. /**
  54973. * Creates a refraction texture used by refraction channel of the standard material.
  54974. * It is like a mirror but to see through a material.
  54975. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54976. */
  54977. export class RefractionTexture extends RenderTargetTexture {
  54978. /**
  54979. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54980. * 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.
  54981. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54982. */
  54983. refractionPlane: Plane;
  54984. /**
  54985. * Define how deep under the surface we should see.
  54986. */
  54987. depth: number;
  54988. /**
  54989. * Creates a refraction texture used by refraction channel of the standard material.
  54990. * It is like a mirror but to see through a material.
  54991. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54992. * @param name Define the texture name
  54993. * @param size Define the size of the underlying texture
  54994. * @param scene Define the scene the refraction belongs to
  54995. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54996. */
  54997. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54998. /**
  54999. * Clone the refraction texture.
  55000. * @returns the cloned texture
  55001. */
  55002. clone(): RefractionTexture;
  55003. /**
  55004. * Serialize the texture to a JSON representation you could use in Parse later on
  55005. * @returns the serialized JSON representation
  55006. */
  55007. serialize(): any;
  55008. }
  55009. }
  55010. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55011. import { Nullable } from "babylonjs/types";
  55012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55013. import { Matrix } from "babylonjs/Maths/math.vector";
  55014. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55015. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55016. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55017. import { Scene } from "babylonjs/scene";
  55018. /**
  55019. * Defines the options related to the creation of an HtmlElementTexture
  55020. */
  55021. export interface IHtmlElementTextureOptions {
  55022. /**
  55023. * Defines wether mip maps should be created or not.
  55024. */
  55025. generateMipMaps?: boolean;
  55026. /**
  55027. * Defines the sampling mode of the texture.
  55028. */
  55029. samplingMode?: number;
  55030. /**
  55031. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55032. */
  55033. engine: Nullable<ThinEngine>;
  55034. /**
  55035. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55036. */
  55037. scene: Nullable<Scene>;
  55038. }
  55039. /**
  55040. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55041. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55042. * is automatically managed.
  55043. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55044. * in your application.
  55045. *
  55046. * As the update is not automatic, you need to call them manually.
  55047. */
  55048. export class HtmlElementTexture extends BaseTexture {
  55049. /**
  55050. * The texture URL.
  55051. */
  55052. element: HTMLVideoElement | HTMLCanvasElement;
  55053. private static readonly DefaultOptions;
  55054. private _textureMatrix;
  55055. private _engine;
  55056. private _isVideo;
  55057. private _generateMipMaps;
  55058. private _samplingMode;
  55059. /**
  55060. * Instantiates a HtmlElementTexture from the following parameters.
  55061. *
  55062. * @param name Defines the name of the texture
  55063. * @param element Defines the video or canvas the texture is filled with
  55064. * @param options Defines the other none mandatory texture creation options
  55065. */
  55066. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55067. private _createInternalTexture;
  55068. /**
  55069. * Returns the texture matrix used in most of the material.
  55070. */
  55071. getTextureMatrix(): Matrix;
  55072. /**
  55073. * Updates the content of the texture.
  55074. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55075. */
  55076. update(invertY?: Nullable<boolean>): void;
  55077. }
  55078. }
  55079. declare module "babylonjs/Materials/Textures/index" {
  55080. export * from "babylonjs/Materials/Textures/baseTexture";
  55081. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55082. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55083. export * from "babylonjs/Materials/Textures/cubeTexture";
  55084. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55085. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55086. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55087. export * from "babylonjs/Materials/Textures/internalTexture";
  55088. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55089. export * from "babylonjs/Materials/Textures/Loaders/index";
  55090. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55091. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55092. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55093. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55094. export * from "babylonjs/Materials/Textures/rawTexture";
  55095. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55096. export * from "babylonjs/Materials/Textures/refractionTexture";
  55097. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55098. export * from "babylonjs/Materials/Textures/texture";
  55099. export * from "babylonjs/Materials/Textures/videoTexture";
  55100. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55101. }
  55102. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55103. /**
  55104. * Enum used to define the target of a block
  55105. */
  55106. export enum NodeMaterialBlockTargets {
  55107. /** Vertex shader */
  55108. Vertex = 1,
  55109. /** Fragment shader */
  55110. Fragment = 2,
  55111. /** Neutral */
  55112. Neutral = 4,
  55113. /** Vertex and Fragment */
  55114. VertexAndFragment = 3
  55115. }
  55116. }
  55117. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55118. /**
  55119. * Defines the kind of connection point for node based material
  55120. */
  55121. export enum NodeMaterialBlockConnectionPointTypes {
  55122. /** Float */
  55123. Float = 1,
  55124. /** Int */
  55125. Int = 2,
  55126. /** Vector2 */
  55127. Vector2 = 4,
  55128. /** Vector3 */
  55129. Vector3 = 8,
  55130. /** Vector4 */
  55131. Vector4 = 16,
  55132. /** Color3 */
  55133. Color3 = 32,
  55134. /** Color4 */
  55135. Color4 = 64,
  55136. /** Matrix */
  55137. Matrix = 128,
  55138. /** Detect type based on connection */
  55139. AutoDetect = 1024,
  55140. /** Output type that will be defined by input type */
  55141. BasedOnInput = 2048
  55142. }
  55143. }
  55144. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55145. /**
  55146. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55147. */
  55148. export enum NodeMaterialBlockConnectionPointMode {
  55149. /** Value is an uniform */
  55150. Uniform = 0,
  55151. /** Value is a mesh attribute */
  55152. Attribute = 1,
  55153. /** Value is a varying between vertex and fragment shaders */
  55154. Varying = 2,
  55155. /** Mode is undefined */
  55156. Undefined = 3
  55157. }
  55158. }
  55159. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55160. /**
  55161. * Enum used to define system values e.g. values automatically provided by the system
  55162. */
  55163. export enum NodeMaterialSystemValues {
  55164. /** World */
  55165. World = 1,
  55166. /** View */
  55167. View = 2,
  55168. /** Projection */
  55169. Projection = 3,
  55170. /** ViewProjection */
  55171. ViewProjection = 4,
  55172. /** WorldView */
  55173. WorldView = 5,
  55174. /** WorldViewProjection */
  55175. WorldViewProjection = 6,
  55176. /** CameraPosition */
  55177. CameraPosition = 7,
  55178. /** Fog Color */
  55179. FogColor = 8,
  55180. /** Delta time */
  55181. DeltaTime = 9
  55182. }
  55183. }
  55184. declare module "babylonjs/Materials/Node/Enums/index" {
  55185. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55186. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55187. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55188. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55189. }
  55190. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55192. /**
  55193. * Root class for all node material optimizers
  55194. */
  55195. export class NodeMaterialOptimizer {
  55196. /**
  55197. * Function used to optimize a NodeMaterial graph
  55198. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55199. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55200. */
  55201. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55202. }
  55203. }
  55204. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55208. import { Scene } from "babylonjs/scene";
  55209. /**
  55210. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55211. */
  55212. export class TransformBlock extends NodeMaterialBlock {
  55213. /**
  55214. * Defines the value to use to complement W value to transform it to a Vector4
  55215. */
  55216. complementW: number;
  55217. /**
  55218. * Defines the value to use to complement z value to transform it to a Vector4
  55219. */
  55220. complementZ: number;
  55221. /**
  55222. * Creates a new TransformBlock
  55223. * @param name defines the block name
  55224. */
  55225. constructor(name: string);
  55226. /**
  55227. * Gets the current class name
  55228. * @returns the class name
  55229. */
  55230. getClassName(): string;
  55231. /**
  55232. * Gets the vector input
  55233. */
  55234. readonly vector: NodeMaterialConnectionPoint;
  55235. /**
  55236. * Gets the output component
  55237. */
  55238. readonly output: NodeMaterialConnectionPoint;
  55239. /**
  55240. * Gets the matrix transform input
  55241. */
  55242. readonly transform: NodeMaterialConnectionPoint;
  55243. protected _buildBlock(state: NodeMaterialBuildState): this;
  55244. serialize(): any;
  55245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55246. protected _dumpPropertiesCode(): string;
  55247. }
  55248. }
  55249. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55253. /**
  55254. * Block used to output the vertex position
  55255. */
  55256. export class VertexOutputBlock extends NodeMaterialBlock {
  55257. /**
  55258. * Creates a new VertexOutputBlock
  55259. * @param name defines the block name
  55260. */
  55261. constructor(name: string);
  55262. /**
  55263. * Gets the current class name
  55264. * @returns the class name
  55265. */
  55266. getClassName(): string;
  55267. /**
  55268. * Gets the vector input component
  55269. */
  55270. readonly vector: NodeMaterialConnectionPoint;
  55271. protected _buildBlock(state: NodeMaterialBuildState): this;
  55272. }
  55273. }
  55274. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55278. /**
  55279. * Block used to output the final color
  55280. */
  55281. export class FragmentOutputBlock extends NodeMaterialBlock {
  55282. /**
  55283. * Create a new FragmentOutputBlock
  55284. * @param name defines the block name
  55285. */
  55286. constructor(name: string);
  55287. /**
  55288. * Gets the current class name
  55289. * @returns the class name
  55290. */
  55291. getClassName(): string;
  55292. /**
  55293. * Gets the rgba input component
  55294. */
  55295. readonly rgba: NodeMaterialConnectionPoint;
  55296. /**
  55297. * Gets the rgb input component
  55298. */
  55299. readonly rgb: NodeMaterialConnectionPoint;
  55300. /**
  55301. * Gets the a input component
  55302. */
  55303. readonly a: NodeMaterialConnectionPoint;
  55304. protected _buildBlock(state: NodeMaterialBuildState): this;
  55305. }
  55306. }
  55307. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55313. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55314. import { Effect } from "babylonjs/Materials/effect";
  55315. import { Mesh } from "babylonjs/Meshes/mesh";
  55316. import { Nullable } from "babylonjs/types";
  55317. import { Scene } from "babylonjs/scene";
  55318. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55319. /**
  55320. * Block used to read a reflection texture from a sampler
  55321. */
  55322. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55323. private _define3DName;
  55324. private _defineCubicName;
  55325. private _defineExplicitName;
  55326. private _defineProjectionName;
  55327. private _defineLocalCubicName;
  55328. private _defineSphericalName;
  55329. private _definePlanarName;
  55330. private _defineEquirectangularName;
  55331. private _defineMirroredEquirectangularFixedName;
  55332. private _defineEquirectangularFixedName;
  55333. private _defineSkyboxName;
  55334. private _cubeSamplerName;
  55335. private _2DSamplerName;
  55336. private _positionUVWName;
  55337. private _directionWName;
  55338. private _reflectionCoordsName;
  55339. private _reflection2DCoordsName;
  55340. private _reflectionColorName;
  55341. private _reflectionMatrixName;
  55342. /**
  55343. * Gets or sets the texture associated with the node
  55344. */
  55345. texture: Nullable<BaseTexture>;
  55346. /**
  55347. * Create a new TextureBlock
  55348. * @param name defines the block name
  55349. */
  55350. constructor(name: string);
  55351. /**
  55352. * Gets the current class name
  55353. * @returns the class name
  55354. */
  55355. getClassName(): string;
  55356. /**
  55357. * Gets the world position input component
  55358. */
  55359. readonly position: NodeMaterialConnectionPoint;
  55360. /**
  55361. * Gets the world position input component
  55362. */
  55363. readonly worldPosition: NodeMaterialConnectionPoint;
  55364. /**
  55365. * Gets the world normal input component
  55366. */
  55367. readonly worldNormal: NodeMaterialConnectionPoint;
  55368. /**
  55369. * Gets the world input component
  55370. */
  55371. readonly world: NodeMaterialConnectionPoint;
  55372. /**
  55373. * Gets the camera (or eye) position component
  55374. */
  55375. readonly cameraPosition: NodeMaterialConnectionPoint;
  55376. /**
  55377. * Gets the view input component
  55378. */
  55379. readonly view: NodeMaterialConnectionPoint;
  55380. /**
  55381. * Gets the rgb output component
  55382. */
  55383. readonly rgb: NodeMaterialConnectionPoint;
  55384. /**
  55385. * Gets the r output component
  55386. */
  55387. readonly r: NodeMaterialConnectionPoint;
  55388. /**
  55389. * Gets the g output component
  55390. */
  55391. readonly g: NodeMaterialConnectionPoint;
  55392. /**
  55393. * Gets the b output component
  55394. */
  55395. readonly b: NodeMaterialConnectionPoint;
  55396. autoConfigure(material: NodeMaterial): void;
  55397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55398. isReady(): boolean;
  55399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55400. private _injectVertexCode;
  55401. private _writeOutput;
  55402. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55403. serialize(): any;
  55404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55405. }
  55406. }
  55407. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55409. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55410. import { Scene } from "babylonjs/scene";
  55411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55412. import { Matrix } from "babylonjs/Maths/math.vector";
  55413. import { Mesh } from "babylonjs/Meshes/mesh";
  55414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55415. import { Observable } from "babylonjs/Misc/observable";
  55416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55417. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55418. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55419. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55420. import { Nullable } from "babylonjs/types";
  55421. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55422. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55423. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55424. /**
  55425. * Interface used to configure the node material editor
  55426. */
  55427. export interface INodeMaterialEditorOptions {
  55428. /** Define the URl to load node editor script */
  55429. editorURL?: string;
  55430. }
  55431. /** @hidden */
  55432. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55433. /** BONES */
  55434. NUM_BONE_INFLUENCERS: number;
  55435. BonesPerMesh: number;
  55436. BONETEXTURE: boolean;
  55437. /** MORPH TARGETS */
  55438. MORPHTARGETS: boolean;
  55439. MORPHTARGETS_NORMAL: boolean;
  55440. MORPHTARGETS_TANGENT: boolean;
  55441. MORPHTARGETS_UV: boolean;
  55442. NUM_MORPH_INFLUENCERS: number;
  55443. /** IMAGE PROCESSING */
  55444. IMAGEPROCESSING: boolean;
  55445. VIGNETTE: boolean;
  55446. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55447. VIGNETTEBLENDMODEOPAQUE: boolean;
  55448. TONEMAPPING: boolean;
  55449. TONEMAPPING_ACES: boolean;
  55450. CONTRAST: boolean;
  55451. EXPOSURE: boolean;
  55452. COLORCURVES: boolean;
  55453. COLORGRADING: boolean;
  55454. COLORGRADING3D: boolean;
  55455. SAMPLER3DGREENDEPTH: boolean;
  55456. SAMPLER3DBGRMAP: boolean;
  55457. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55458. /** MISC. */
  55459. BUMPDIRECTUV: number;
  55460. constructor();
  55461. setValue(name: string, value: boolean): void;
  55462. }
  55463. /**
  55464. * Class used to configure NodeMaterial
  55465. */
  55466. export interface INodeMaterialOptions {
  55467. /**
  55468. * Defines if blocks should emit comments
  55469. */
  55470. emitComments: boolean;
  55471. }
  55472. /**
  55473. * Class used to create a node based material built by assembling shader blocks
  55474. */
  55475. export class NodeMaterial extends PushMaterial {
  55476. private static _BuildIdGenerator;
  55477. private _options;
  55478. private _vertexCompilationState;
  55479. private _fragmentCompilationState;
  55480. private _sharedData;
  55481. private _buildId;
  55482. private _buildWasSuccessful;
  55483. private _cachedWorldViewMatrix;
  55484. private _cachedWorldViewProjectionMatrix;
  55485. private _optimizers;
  55486. private _animationFrame;
  55487. /** Define the URl to load node editor script */
  55488. static EditorURL: string;
  55489. private BJSNODEMATERIALEDITOR;
  55490. /** Get the inspector from bundle or global */
  55491. private _getGlobalNodeMaterialEditor;
  55492. /**
  55493. * 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)
  55494. */
  55495. ignoreAlpha: boolean;
  55496. /**
  55497. * Defines the maximum number of lights that can be used in the material
  55498. */
  55499. maxSimultaneousLights: number;
  55500. /**
  55501. * Observable raised when the material is built
  55502. */
  55503. onBuildObservable: Observable<NodeMaterial>;
  55504. /**
  55505. * Gets or sets the root nodes of the material vertex shader
  55506. */
  55507. _vertexOutputNodes: NodeMaterialBlock[];
  55508. /**
  55509. * Gets or sets the root nodes of the material fragment (pixel) shader
  55510. */
  55511. _fragmentOutputNodes: NodeMaterialBlock[];
  55512. /** Gets or sets options to control the node material overall behavior */
  55513. options: INodeMaterialOptions;
  55514. /**
  55515. * Default configuration related to image processing available in the standard Material.
  55516. */
  55517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55518. /**
  55519. * Gets the image processing configuration used either in this material.
  55520. */
  55521. /**
  55522. * Sets the Default image processing configuration used either in the this material.
  55523. *
  55524. * If sets to null, the scene one is in use.
  55525. */
  55526. imageProcessingConfiguration: ImageProcessingConfiguration;
  55527. /**
  55528. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55529. */
  55530. attachedBlocks: NodeMaterialBlock[];
  55531. /**
  55532. * Create a new node based material
  55533. * @param name defines the material name
  55534. * @param scene defines the hosting scene
  55535. * @param options defines creation option
  55536. */
  55537. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55538. /**
  55539. * Gets the current class name of the material e.g. "NodeMaterial"
  55540. * @returns the class name
  55541. */
  55542. getClassName(): string;
  55543. /**
  55544. * Keep track of the image processing observer to allow dispose and replace.
  55545. */
  55546. private _imageProcessingObserver;
  55547. /**
  55548. * Attaches a new image processing configuration to the Standard Material.
  55549. * @param configuration
  55550. */
  55551. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55552. /**
  55553. * Get a block by its name
  55554. * @param name defines the name of the block to retrieve
  55555. * @returns the required block or null if not found
  55556. */
  55557. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55558. /**
  55559. * Get a block by its name
  55560. * @param predicate defines the predicate used to find the good candidate
  55561. * @returns the required block or null if not found
  55562. */
  55563. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55564. /**
  55565. * Get an input block by its name
  55566. * @param predicate defines the predicate used to find the good candidate
  55567. * @returns the required input block or null if not found
  55568. */
  55569. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55570. /**
  55571. * Gets the list of input blocks attached to this material
  55572. * @returns an array of InputBlocks
  55573. */
  55574. getInputBlocks(): InputBlock[];
  55575. /**
  55576. * Adds a new optimizer to the list of optimizers
  55577. * @param optimizer defines the optimizers to add
  55578. * @returns the current material
  55579. */
  55580. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55581. /**
  55582. * Remove an optimizer from the list of optimizers
  55583. * @param optimizer defines the optimizers to remove
  55584. * @returns the current material
  55585. */
  55586. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55587. /**
  55588. * Add a new block to the list of output nodes
  55589. * @param node defines the node to add
  55590. * @returns the current material
  55591. */
  55592. addOutputNode(node: NodeMaterialBlock): this;
  55593. /**
  55594. * Remove a block from the list of root nodes
  55595. * @param node defines the node to remove
  55596. * @returns the current material
  55597. */
  55598. removeOutputNode(node: NodeMaterialBlock): this;
  55599. private _addVertexOutputNode;
  55600. private _removeVertexOutputNode;
  55601. private _addFragmentOutputNode;
  55602. private _removeFragmentOutputNode;
  55603. /**
  55604. * Specifies if the material will require alpha blending
  55605. * @returns a boolean specifying if alpha blending is needed
  55606. */
  55607. needAlphaBlending(): boolean;
  55608. /**
  55609. * Specifies if this material should be rendered in alpha test mode
  55610. * @returns a boolean specifying if an alpha test is needed.
  55611. */
  55612. needAlphaTesting(): boolean;
  55613. private _initializeBlock;
  55614. private _resetDualBlocks;
  55615. /**
  55616. * Build the material and generates the inner effect
  55617. * @param verbose defines if the build should log activity
  55618. */
  55619. build(verbose?: boolean): void;
  55620. /**
  55621. * Runs an otpimization phase to try to improve the shader code
  55622. */
  55623. optimize(): void;
  55624. private _prepareDefinesForAttributes;
  55625. /**
  55626. * Get if the submesh is ready to be used and all its information available.
  55627. * Child classes can use it to update shaders
  55628. * @param mesh defines the mesh to check
  55629. * @param subMesh defines which submesh to check
  55630. * @param useInstances specifies that instances should be used
  55631. * @returns a boolean indicating that the submesh is ready or not
  55632. */
  55633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55634. /**
  55635. * Get a string representing the shaders built by the current node graph
  55636. */
  55637. readonly compiledShaders: string;
  55638. /**
  55639. * Binds the world matrix to the material
  55640. * @param world defines the world transformation matrix
  55641. */
  55642. bindOnlyWorldMatrix(world: Matrix): void;
  55643. /**
  55644. * Binds the submesh to this material by preparing the effect and shader to draw
  55645. * @param world defines the world transformation matrix
  55646. * @param mesh defines the mesh containing the submesh
  55647. * @param subMesh defines the submesh to bind the material to
  55648. */
  55649. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55650. /**
  55651. * Gets the active textures from the material
  55652. * @returns an array of textures
  55653. */
  55654. getActiveTextures(): BaseTexture[];
  55655. /**
  55656. * Gets the list of texture blocks
  55657. * @returns an array of texture blocks
  55658. */
  55659. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55660. /**
  55661. * Specifies if the material uses a texture
  55662. * @param texture defines the texture to check against the material
  55663. * @returns a boolean specifying if the material uses the texture
  55664. */
  55665. hasTexture(texture: BaseTexture): boolean;
  55666. /**
  55667. * Disposes the material
  55668. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55669. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55670. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55671. */
  55672. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55673. /** Creates the node editor window. */
  55674. private _createNodeEditor;
  55675. /**
  55676. * Launch the node material editor
  55677. * @param config Define the configuration of the editor
  55678. * @return a promise fulfilled when the node editor is visible
  55679. */
  55680. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55681. /**
  55682. * Clear the current material
  55683. */
  55684. clear(): void;
  55685. /**
  55686. * Clear the current material and set it to a default state
  55687. */
  55688. setToDefault(): void;
  55689. /**
  55690. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55691. * @param url defines the url to load from
  55692. * @returns a promise that will fullfil when the material is fully loaded
  55693. */
  55694. loadAsync(url: string): Promise<unknown>;
  55695. private _gatherBlocks;
  55696. /**
  55697. * Generate a string containing the code declaration required to create an equivalent of this material
  55698. * @returns a string
  55699. */
  55700. generateCode(): string;
  55701. /**
  55702. * Serializes this material in a JSON representation
  55703. * @returns the serialized material object
  55704. */
  55705. serialize(): any;
  55706. private _restoreConnections;
  55707. /**
  55708. * Clear the current graph and load a new one from a serialization object
  55709. * @param source defines the JSON representation of the material
  55710. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55711. */
  55712. loadFromSerialization(source: any, rootUrl?: string): void;
  55713. /**
  55714. * Creates a node material from parsed material data
  55715. * @param source defines the JSON representation of the material
  55716. * @param scene defines the hosting scene
  55717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55718. * @returns a new node material
  55719. */
  55720. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55721. /**
  55722. * Creates a new node material set to default basic configuration
  55723. * @param name defines the name of the material
  55724. * @param scene defines the hosting scene
  55725. * @returns a new NodeMaterial
  55726. */
  55727. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55728. }
  55729. }
  55730. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55733. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55736. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55737. import { Effect } from "babylonjs/Materials/effect";
  55738. import { Mesh } from "babylonjs/Meshes/mesh";
  55739. import { Nullable } from "babylonjs/types";
  55740. import { Texture } from "babylonjs/Materials/Textures/texture";
  55741. import { Scene } from "babylonjs/scene";
  55742. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55743. /**
  55744. * Block used to read a texture from a sampler
  55745. */
  55746. export class TextureBlock extends NodeMaterialBlock {
  55747. private _defineName;
  55748. private _linearDefineName;
  55749. private _samplerName;
  55750. private _transformedUVName;
  55751. private _textureTransformName;
  55752. private _textureInfoName;
  55753. private _mainUVName;
  55754. private _mainUVDefineName;
  55755. /**
  55756. * Gets or sets the texture associated with the node
  55757. */
  55758. texture: Nullable<Texture>;
  55759. /**
  55760. * Create a new TextureBlock
  55761. * @param name defines the block name
  55762. */
  55763. constructor(name: string);
  55764. /**
  55765. * Gets the current class name
  55766. * @returns the class name
  55767. */
  55768. getClassName(): string;
  55769. /**
  55770. * Gets the uv input component
  55771. */
  55772. readonly uv: NodeMaterialConnectionPoint;
  55773. /**
  55774. * Gets the rgba output component
  55775. */
  55776. readonly rgba: NodeMaterialConnectionPoint;
  55777. /**
  55778. * Gets the rgb output component
  55779. */
  55780. readonly rgb: NodeMaterialConnectionPoint;
  55781. /**
  55782. * Gets the r output component
  55783. */
  55784. readonly r: NodeMaterialConnectionPoint;
  55785. /**
  55786. * Gets the g output component
  55787. */
  55788. readonly g: NodeMaterialConnectionPoint;
  55789. /**
  55790. * Gets the b output component
  55791. */
  55792. readonly b: NodeMaterialConnectionPoint;
  55793. /**
  55794. * Gets the a output component
  55795. */
  55796. readonly a: NodeMaterialConnectionPoint;
  55797. readonly target: NodeMaterialBlockTargets;
  55798. autoConfigure(material: NodeMaterial): void;
  55799. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55801. isReady(): boolean;
  55802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55803. private readonly _isMixed;
  55804. private _injectVertexCode;
  55805. private _writeOutput;
  55806. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55807. protected _dumpPropertiesCode(): string;
  55808. serialize(): any;
  55809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55810. }
  55811. }
  55812. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55815. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55816. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55817. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55818. import { Scene } from "babylonjs/scene";
  55819. /**
  55820. * Class used to store shared data between 2 NodeMaterialBuildState
  55821. */
  55822. export class NodeMaterialBuildStateSharedData {
  55823. /**
  55824. * Gets the list of emitted varyings
  55825. */
  55826. temps: string[];
  55827. /**
  55828. * Gets the list of emitted varyings
  55829. */
  55830. varyings: string[];
  55831. /**
  55832. * Gets the varying declaration string
  55833. */
  55834. varyingDeclaration: string;
  55835. /**
  55836. * Input blocks
  55837. */
  55838. inputBlocks: InputBlock[];
  55839. /**
  55840. * Input blocks
  55841. */
  55842. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55843. /**
  55844. * Bindable blocks (Blocks that need to set data to the effect)
  55845. */
  55846. bindableBlocks: NodeMaterialBlock[];
  55847. /**
  55848. * List of blocks that can provide a compilation fallback
  55849. */
  55850. blocksWithFallbacks: NodeMaterialBlock[];
  55851. /**
  55852. * List of blocks that can provide a define update
  55853. */
  55854. blocksWithDefines: NodeMaterialBlock[];
  55855. /**
  55856. * List of blocks that can provide a repeatable content
  55857. */
  55858. repeatableContentBlocks: NodeMaterialBlock[];
  55859. /**
  55860. * List of blocks that can provide a dynamic list of uniforms
  55861. */
  55862. dynamicUniformBlocks: NodeMaterialBlock[];
  55863. /**
  55864. * List of blocks that can block the isReady function for the material
  55865. */
  55866. blockingBlocks: NodeMaterialBlock[];
  55867. /**
  55868. * Gets the list of animated inputs
  55869. */
  55870. animatedInputs: InputBlock[];
  55871. /**
  55872. * Build Id used to avoid multiple recompilations
  55873. */
  55874. buildId: number;
  55875. /** List of emitted variables */
  55876. variableNames: {
  55877. [key: string]: number;
  55878. };
  55879. /** List of emitted defines */
  55880. defineNames: {
  55881. [key: string]: number;
  55882. };
  55883. /** Should emit comments? */
  55884. emitComments: boolean;
  55885. /** Emit build activity */
  55886. verbose: boolean;
  55887. /** Gets or sets the hosting scene */
  55888. scene: Scene;
  55889. /**
  55890. * Gets the compilation hints emitted at compilation time
  55891. */
  55892. hints: {
  55893. needWorldViewMatrix: boolean;
  55894. needWorldViewProjectionMatrix: boolean;
  55895. needAlphaBlending: boolean;
  55896. needAlphaTesting: boolean;
  55897. };
  55898. /**
  55899. * List of compilation checks
  55900. */
  55901. checks: {
  55902. emitVertex: boolean;
  55903. emitFragment: boolean;
  55904. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55905. };
  55906. /** Creates a new shared data */
  55907. constructor();
  55908. /**
  55909. * Emits console errors and exceptions if there is a failing check
  55910. */
  55911. emitErrors(): void;
  55912. }
  55913. }
  55914. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55915. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55916. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55917. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55918. /**
  55919. * Class used to store node based material build state
  55920. */
  55921. export class NodeMaterialBuildState {
  55922. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55923. supportUniformBuffers: boolean;
  55924. /**
  55925. * Gets the list of emitted attributes
  55926. */
  55927. attributes: string[];
  55928. /**
  55929. * Gets the list of emitted uniforms
  55930. */
  55931. uniforms: string[];
  55932. /**
  55933. * Gets the list of emitted constants
  55934. */
  55935. constants: string[];
  55936. /**
  55937. * Gets the list of emitted samplers
  55938. */
  55939. samplers: string[];
  55940. /**
  55941. * Gets the list of emitted functions
  55942. */
  55943. functions: {
  55944. [key: string]: string;
  55945. };
  55946. /**
  55947. * Gets the list of emitted extensions
  55948. */
  55949. extensions: {
  55950. [key: string]: string;
  55951. };
  55952. /**
  55953. * Gets the target of the compilation state
  55954. */
  55955. target: NodeMaterialBlockTargets;
  55956. /**
  55957. * Gets the list of emitted counters
  55958. */
  55959. counters: {
  55960. [key: string]: number;
  55961. };
  55962. /**
  55963. * Shared data between multiple NodeMaterialBuildState instances
  55964. */
  55965. sharedData: NodeMaterialBuildStateSharedData;
  55966. /** @hidden */
  55967. _vertexState: NodeMaterialBuildState;
  55968. /** @hidden */
  55969. _attributeDeclaration: string;
  55970. /** @hidden */
  55971. _uniformDeclaration: string;
  55972. /** @hidden */
  55973. _constantDeclaration: string;
  55974. /** @hidden */
  55975. _samplerDeclaration: string;
  55976. /** @hidden */
  55977. _varyingTransfer: string;
  55978. private _repeatableContentAnchorIndex;
  55979. /** @hidden */
  55980. _builtCompilationString: string;
  55981. /**
  55982. * Gets the emitted compilation strings
  55983. */
  55984. compilationString: string;
  55985. /**
  55986. * Finalize the compilation strings
  55987. * @param state defines the current compilation state
  55988. */
  55989. finalize(state: NodeMaterialBuildState): void;
  55990. /** @hidden */
  55991. readonly _repeatableContentAnchor: string;
  55992. /** @hidden */
  55993. _getFreeVariableName(prefix: string): string;
  55994. /** @hidden */
  55995. _getFreeDefineName(prefix: string): string;
  55996. /** @hidden */
  55997. _excludeVariableName(name: string): void;
  55998. /** @hidden */
  55999. _emit2DSampler(name: string): void;
  56000. /** @hidden */
  56001. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56002. /** @hidden */
  56003. _emitExtension(name: string, extension: string): void;
  56004. /** @hidden */
  56005. _emitFunction(name: string, code: string, comments: string): void;
  56006. /** @hidden */
  56007. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56008. replaceStrings?: {
  56009. search: RegExp;
  56010. replace: string;
  56011. }[];
  56012. repeatKey?: string;
  56013. }): string;
  56014. /** @hidden */
  56015. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56016. repeatKey?: string;
  56017. removeAttributes?: boolean;
  56018. removeUniforms?: boolean;
  56019. removeVaryings?: boolean;
  56020. removeIfDef?: boolean;
  56021. replaceStrings?: {
  56022. search: RegExp;
  56023. replace: string;
  56024. }[];
  56025. }, storeKey?: string): void;
  56026. /** @hidden */
  56027. _registerTempVariable(name: string): boolean;
  56028. /** @hidden */
  56029. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56030. /** @hidden */
  56031. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56032. /** @hidden */
  56033. _emitFloat(value: number): string;
  56034. }
  56035. }
  56036. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56037. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56039. import { Nullable } from "babylonjs/types";
  56040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56041. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56042. import { Effect } from "babylonjs/Materials/effect";
  56043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56044. import { Mesh } from "babylonjs/Meshes/mesh";
  56045. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56046. import { Scene } from "babylonjs/scene";
  56047. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56048. /**
  56049. * Defines a block that can be used inside a node based material
  56050. */
  56051. export class NodeMaterialBlock {
  56052. private _buildId;
  56053. private _buildTarget;
  56054. private _target;
  56055. private _isFinalMerger;
  56056. private _isInput;
  56057. /** @hidden */
  56058. _codeVariableName: string;
  56059. /** @hidden */
  56060. _inputs: NodeMaterialConnectionPoint[];
  56061. /** @hidden */
  56062. _outputs: NodeMaterialConnectionPoint[];
  56063. /** @hidden */
  56064. _preparationId: number;
  56065. /**
  56066. * Gets or sets the name of the block
  56067. */
  56068. name: string;
  56069. /**
  56070. * Gets or sets the unique id of the node
  56071. */
  56072. uniqueId: number;
  56073. /**
  56074. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56075. */
  56076. readonly isFinalMerger: boolean;
  56077. /**
  56078. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56079. */
  56080. readonly isInput: boolean;
  56081. /**
  56082. * Gets or sets the build Id
  56083. */
  56084. buildId: number;
  56085. /**
  56086. * Gets or sets the target of the block
  56087. */
  56088. target: NodeMaterialBlockTargets;
  56089. /**
  56090. * Gets the list of input points
  56091. */
  56092. readonly inputs: NodeMaterialConnectionPoint[];
  56093. /** Gets the list of output points */
  56094. readonly outputs: NodeMaterialConnectionPoint[];
  56095. /**
  56096. * Find an input by its name
  56097. * @param name defines the name of the input to look for
  56098. * @returns the input or null if not found
  56099. */
  56100. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56101. /**
  56102. * Find an output by its name
  56103. * @param name defines the name of the outputto look for
  56104. * @returns the output or null if not found
  56105. */
  56106. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56107. /**
  56108. * Creates a new NodeMaterialBlock
  56109. * @param name defines the block name
  56110. * @param target defines the target of that block (Vertex by default)
  56111. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56112. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56113. */
  56114. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56115. /**
  56116. * Initialize the block and prepare the context for build
  56117. * @param state defines the state that will be used for the build
  56118. */
  56119. initialize(state: NodeMaterialBuildState): void;
  56120. /**
  56121. * Bind data to effect. Will only be called for blocks with isBindable === true
  56122. * @param effect defines the effect to bind data to
  56123. * @param nodeMaterial defines the hosting NodeMaterial
  56124. * @param mesh defines the mesh that will be rendered
  56125. */
  56126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56127. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56128. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56129. protected _writeFloat(value: number): string;
  56130. /**
  56131. * Gets the current class name e.g. "NodeMaterialBlock"
  56132. * @returns the class name
  56133. */
  56134. getClassName(): string;
  56135. /**
  56136. * Register a new input. Must be called inside a block constructor
  56137. * @param name defines the connection point name
  56138. * @param type defines the connection point type
  56139. * @param isOptional defines a boolean indicating that this input can be omitted
  56140. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56141. * @returns the current block
  56142. */
  56143. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56144. /**
  56145. * Register a new output. Must be called inside a block constructor
  56146. * @param name defines the connection point name
  56147. * @param type defines the connection point type
  56148. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56149. * @returns the current block
  56150. */
  56151. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56152. /**
  56153. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56154. * @param forOutput defines an optional connection point to check compatibility with
  56155. * @returns the first available input or null
  56156. */
  56157. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56158. /**
  56159. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56160. * @param forBlock defines an optional block to check compatibility with
  56161. * @returns the first available input or null
  56162. */
  56163. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56164. /**
  56165. * Gets the sibling of the given output
  56166. * @param current defines the current output
  56167. * @returns the next output in the list or null
  56168. */
  56169. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56170. /**
  56171. * Connect current block with another block
  56172. * @param other defines the block to connect with
  56173. * @param options define the various options to help pick the right connections
  56174. * @returns the current block
  56175. */
  56176. connectTo(other: NodeMaterialBlock, options?: {
  56177. input?: string;
  56178. output?: string;
  56179. outputSwizzle?: string;
  56180. }): this | undefined;
  56181. protected _buildBlock(state: NodeMaterialBuildState): void;
  56182. /**
  56183. * Add uniforms, samplers and uniform buffers at compilation time
  56184. * @param state defines the state to update
  56185. * @param nodeMaterial defines the node material requesting the update
  56186. * @param defines defines the material defines to update
  56187. * @param uniformBuffers defines the list of uniform buffer names
  56188. */
  56189. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56190. /**
  56191. * Add potential fallbacks if shader compilation fails
  56192. * @param mesh defines the mesh to be rendered
  56193. * @param fallbacks defines the current prioritized list of fallbacks
  56194. */
  56195. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56196. /**
  56197. * Initialize defines for shader compilation
  56198. * @param mesh defines the mesh to be rendered
  56199. * @param nodeMaterial defines the node material requesting the update
  56200. * @param defines defines the material defines to update
  56201. * @param useInstances specifies that instances should be used
  56202. */
  56203. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56204. /**
  56205. * Update defines for shader compilation
  56206. * @param mesh defines the mesh to be rendered
  56207. * @param nodeMaterial defines the node material requesting the update
  56208. * @param defines defines the material defines to update
  56209. * @param useInstances specifies that instances should be used
  56210. */
  56211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56212. /**
  56213. * Lets the block try to connect some inputs automatically
  56214. * @param material defines the hosting NodeMaterial
  56215. */
  56216. autoConfigure(material: NodeMaterial): void;
  56217. /**
  56218. * Function called when a block is declared as repeatable content generator
  56219. * @param vertexShaderState defines the current compilation state for the vertex shader
  56220. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56221. * @param mesh defines the mesh to be rendered
  56222. * @param defines defines the material defines to update
  56223. */
  56224. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56225. /**
  56226. * Checks if the block is ready
  56227. * @param mesh defines the mesh to be rendered
  56228. * @param nodeMaterial defines the node material requesting the update
  56229. * @param defines defines the material defines to update
  56230. * @param useInstances specifies that instances should be used
  56231. * @returns true if the block is ready
  56232. */
  56233. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56234. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56235. private _processBuild;
  56236. /**
  56237. * Compile the current node and generate the shader code
  56238. * @param state defines the current compilation state (uniforms, samplers, current string)
  56239. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56240. * @returns true if already built
  56241. */
  56242. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56243. protected _inputRename(name: string): string;
  56244. protected _outputRename(name: string): string;
  56245. protected _dumpPropertiesCode(): string;
  56246. /** @hidden */
  56247. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56248. /**
  56249. * Clone the current block to a new identical block
  56250. * @param scene defines the hosting scene
  56251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56252. * @returns a copy of the current block
  56253. */
  56254. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56255. /**
  56256. * Serializes this block in a JSON representation
  56257. * @returns the serialized block object
  56258. */
  56259. serialize(): any;
  56260. /** @hidden */
  56261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56262. }
  56263. }
  56264. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56265. /**
  56266. * Enum defining the type of animations supported by InputBlock
  56267. */
  56268. export enum AnimatedInputBlockTypes {
  56269. /** No animation */
  56270. None = 0,
  56271. /** Time based animation. Will only work for floats */
  56272. Time = 1
  56273. }
  56274. }
  56275. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56277. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56278. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56279. import { Nullable } from "babylonjs/types";
  56280. import { Effect } from "babylonjs/Materials/effect";
  56281. import { Matrix } from "babylonjs/Maths/math.vector";
  56282. import { Scene } from "babylonjs/scene";
  56283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56286. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56287. /**
  56288. * Block used to expose an input value
  56289. */
  56290. export class InputBlock extends NodeMaterialBlock {
  56291. private _mode;
  56292. private _associatedVariableName;
  56293. private _storedValue;
  56294. private _valueCallback;
  56295. private _type;
  56296. private _animationType;
  56297. /** Gets or set a value used to limit the range of float values */
  56298. min: number;
  56299. /** Gets or set a value used to limit the range of float values */
  56300. max: number;
  56301. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56302. matrixMode: number;
  56303. /** @hidden */
  56304. _systemValue: Nullable<NodeMaterialSystemValues>;
  56305. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56306. visibleInInspector: boolean;
  56307. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56308. isConstant: boolean;
  56309. /**
  56310. * Gets or sets the connection point type (default is float)
  56311. */
  56312. readonly type: NodeMaterialBlockConnectionPointTypes;
  56313. /**
  56314. * Creates a new InputBlock
  56315. * @param name defines the block name
  56316. * @param target defines the target of that block (Vertex by default)
  56317. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56318. */
  56319. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56320. /**
  56321. * Gets the output component
  56322. */
  56323. readonly output: NodeMaterialConnectionPoint;
  56324. /**
  56325. * Set the source of this connection point to a vertex attribute
  56326. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56327. * @returns the current connection point
  56328. */
  56329. setAsAttribute(attributeName?: string): InputBlock;
  56330. /**
  56331. * Set the source of this connection point to a system value
  56332. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56333. * @returns the current connection point
  56334. */
  56335. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56336. /**
  56337. * Gets or sets the value of that point.
  56338. * Please note that this value will be ignored if valueCallback is defined
  56339. */
  56340. value: any;
  56341. /**
  56342. * Gets or sets a callback used to get the value of that point.
  56343. * Please note that setting this value will force the connection point to ignore the value property
  56344. */
  56345. valueCallback: () => any;
  56346. /**
  56347. * Gets or sets the associated variable name in the shader
  56348. */
  56349. associatedVariableName: string;
  56350. /** Gets or sets the type of animation applied to the input */
  56351. animationType: AnimatedInputBlockTypes;
  56352. /**
  56353. * Gets a boolean indicating that this connection point not defined yet
  56354. */
  56355. readonly isUndefined: boolean;
  56356. /**
  56357. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56358. * In this case the connection point name must be the name of the uniform to use.
  56359. * Can only be set on inputs
  56360. */
  56361. isUniform: boolean;
  56362. /**
  56363. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56364. * In this case the connection point name must be the name of the attribute to use
  56365. * Can only be set on inputs
  56366. */
  56367. isAttribute: boolean;
  56368. /**
  56369. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56370. * Can only be set on exit points
  56371. */
  56372. isVarying: boolean;
  56373. /**
  56374. * Gets a boolean indicating that the current connection point is a system value
  56375. */
  56376. readonly isSystemValue: boolean;
  56377. /**
  56378. * Gets or sets the current well known value or null if not defined as a system value
  56379. */
  56380. systemValue: Nullable<NodeMaterialSystemValues>;
  56381. /**
  56382. * Gets the current class name
  56383. * @returns the class name
  56384. */
  56385. getClassName(): string;
  56386. /**
  56387. * Animate the input if animationType !== None
  56388. * @param scene defines the rendering scene
  56389. */
  56390. animate(scene: Scene): void;
  56391. private _emitDefine;
  56392. initialize(state: NodeMaterialBuildState): void;
  56393. /**
  56394. * Set the input block to its default value (based on its type)
  56395. */
  56396. setDefaultValue(): void;
  56397. private _emitConstant;
  56398. private _emit;
  56399. /** @hidden */
  56400. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56401. /** @hidden */
  56402. _transmit(effect: Effect, scene: Scene): void;
  56403. protected _buildBlock(state: NodeMaterialBuildState): void;
  56404. protected _dumpPropertiesCode(): string;
  56405. serialize(): any;
  56406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56407. }
  56408. }
  56409. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56410. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56411. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56412. import { Nullable } from "babylonjs/types";
  56413. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56415. /**
  56416. * Defines a connection point for a block
  56417. */
  56418. export class NodeMaterialConnectionPoint {
  56419. /** @hidden */
  56420. _ownerBlock: NodeMaterialBlock;
  56421. /** @hidden */
  56422. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56423. private _endpoints;
  56424. private _associatedVariableName;
  56425. /** @hidden */
  56426. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56427. /** @hidden */
  56428. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56429. private _type;
  56430. /** @hidden */
  56431. _enforceAssociatedVariableName: boolean;
  56432. /**
  56433. * Gets or sets the additional types supported by this connection point
  56434. */
  56435. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56436. /**
  56437. * Gets or sets the additional types excluded by this connection point
  56438. */
  56439. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56440. /**
  56441. * Gets or sets the associated variable name in the shader
  56442. */
  56443. associatedVariableName: string;
  56444. /**
  56445. * Gets or sets the connection point type (default is float)
  56446. */
  56447. type: NodeMaterialBlockConnectionPointTypes;
  56448. /**
  56449. * Gets or sets the connection point name
  56450. */
  56451. name: string;
  56452. /**
  56453. * Gets or sets a boolean indicating that this connection point can be omitted
  56454. */
  56455. isOptional: boolean;
  56456. /**
  56457. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56458. */
  56459. define: string;
  56460. /** Gets or sets the target of that connection point */
  56461. target: NodeMaterialBlockTargets;
  56462. /**
  56463. * Gets a boolean indicating that the current point is connected
  56464. */
  56465. readonly isConnected: boolean;
  56466. /**
  56467. * Gets a boolean indicating that the current point is connected to an input block
  56468. */
  56469. readonly isConnectedToInputBlock: boolean;
  56470. /**
  56471. * Gets a the connected input block (if any)
  56472. */
  56473. readonly connectInputBlock: Nullable<InputBlock>;
  56474. /** Get the other side of the connection (if any) */
  56475. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56476. /** Get the block that owns this connection point */
  56477. readonly ownerBlock: NodeMaterialBlock;
  56478. /** Get the block connected on the other side of this connection (if any) */
  56479. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56480. /** Get the block connected on the endpoints of this connection (if any) */
  56481. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56482. /** Gets the list of connected endpoints */
  56483. readonly endpoints: NodeMaterialConnectionPoint[];
  56484. /** Gets a boolean indicating if that output point is connected to at least one input */
  56485. readonly hasEndpoints: boolean;
  56486. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56487. readonly isConnectedInVertexShader: boolean;
  56488. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56489. readonly isConnectedInFragmentShader: boolean;
  56490. /**
  56491. * Creates a new connection point
  56492. * @param name defines the connection point name
  56493. * @param ownerBlock defines the block hosting this connection point
  56494. */
  56495. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56496. /**
  56497. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56498. * @returns the class name
  56499. */
  56500. getClassName(): string;
  56501. /**
  56502. * Gets an boolean indicating if the current point can be connected to another point
  56503. * @param connectionPoint defines the other connection point
  56504. * @returns true if the connection is possible
  56505. */
  56506. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56507. /**
  56508. * Connect this point to another connection point
  56509. * @param connectionPoint defines the other connection point
  56510. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56511. * @returns the current connection point
  56512. */
  56513. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56514. /**
  56515. * Disconnect this point from one of his endpoint
  56516. * @param endpoint defines the other connection point
  56517. * @returns the current connection point
  56518. */
  56519. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56520. /**
  56521. * Serializes this point in a JSON representation
  56522. * @returns the serialized point object
  56523. */
  56524. serialize(): any;
  56525. }
  56526. }
  56527. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56531. import { Mesh } from "babylonjs/Meshes/mesh";
  56532. import { Effect } from "babylonjs/Materials/effect";
  56533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56535. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56537. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56538. /**
  56539. * Block used to add support for vertex skinning (bones)
  56540. */
  56541. export class BonesBlock extends NodeMaterialBlock {
  56542. /**
  56543. * Creates a new BonesBlock
  56544. * @param name defines the block name
  56545. */
  56546. constructor(name: string);
  56547. /**
  56548. * Initialize the block and prepare the context for build
  56549. * @param state defines the state that will be used for the build
  56550. */
  56551. initialize(state: NodeMaterialBuildState): void;
  56552. /**
  56553. * Gets the current class name
  56554. * @returns the class name
  56555. */
  56556. getClassName(): string;
  56557. /**
  56558. * Gets the matrix indices input component
  56559. */
  56560. readonly matricesIndices: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the matrix weights input component
  56563. */
  56564. readonly matricesWeights: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the extra matrix indices input component
  56567. */
  56568. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56569. /**
  56570. * Gets the extra matrix weights input component
  56571. */
  56572. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56573. /**
  56574. * Gets the world input component
  56575. */
  56576. readonly world: NodeMaterialConnectionPoint;
  56577. /**
  56578. * Gets the output component
  56579. */
  56580. readonly output: NodeMaterialConnectionPoint;
  56581. autoConfigure(material: NodeMaterial): void;
  56582. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56585. protected _buildBlock(state: NodeMaterialBuildState): this;
  56586. }
  56587. }
  56588. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56593. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56594. /**
  56595. * Block used to add support for instances
  56596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56597. */
  56598. export class InstancesBlock extends NodeMaterialBlock {
  56599. /**
  56600. * Creates a new InstancesBlock
  56601. * @param name defines the block name
  56602. */
  56603. constructor(name: string);
  56604. /**
  56605. * Gets the current class name
  56606. * @returns the class name
  56607. */
  56608. getClassName(): string;
  56609. /**
  56610. * Gets the first world row input component
  56611. */
  56612. readonly world0: NodeMaterialConnectionPoint;
  56613. /**
  56614. * Gets the second world row input component
  56615. */
  56616. readonly world1: NodeMaterialConnectionPoint;
  56617. /**
  56618. * Gets the third world row input component
  56619. */
  56620. readonly world2: NodeMaterialConnectionPoint;
  56621. /**
  56622. * Gets the forth world row input component
  56623. */
  56624. readonly world3: NodeMaterialConnectionPoint;
  56625. /**
  56626. * Gets the world input component
  56627. */
  56628. readonly world: NodeMaterialConnectionPoint;
  56629. /**
  56630. * Gets the output component
  56631. */
  56632. readonly output: NodeMaterialConnectionPoint;
  56633. autoConfigure(material: NodeMaterial): void;
  56634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56635. protected _buildBlock(state: NodeMaterialBuildState): this;
  56636. }
  56637. }
  56638. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56644. import { Effect } from "babylonjs/Materials/effect";
  56645. import { Mesh } from "babylonjs/Meshes/mesh";
  56646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56648. /**
  56649. * Block used to add morph targets support to vertex shader
  56650. */
  56651. export class MorphTargetsBlock extends NodeMaterialBlock {
  56652. private _repeatableContentAnchor;
  56653. private _repeatebleContentGenerated;
  56654. /**
  56655. * Create a new MorphTargetsBlock
  56656. * @param name defines the block name
  56657. */
  56658. constructor(name: string);
  56659. /**
  56660. * Gets the current class name
  56661. * @returns the class name
  56662. */
  56663. getClassName(): string;
  56664. /**
  56665. * Gets the position input component
  56666. */
  56667. readonly position: NodeMaterialConnectionPoint;
  56668. /**
  56669. * Gets the normal input component
  56670. */
  56671. readonly normal: NodeMaterialConnectionPoint;
  56672. /**
  56673. * Gets the tangent input component
  56674. */
  56675. readonly tangent: NodeMaterialConnectionPoint;
  56676. /**
  56677. * Gets the tangent input component
  56678. */
  56679. readonly uv: NodeMaterialConnectionPoint;
  56680. /**
  56681. * Gets the position output component
  56682. */
  56683. readonly positionOutput: NodeMaterialConnectionPoint;
  56684. /**
  56685. * Gets the normal output component
  56686. */
  56687. readonly normalOutput: NodeMaterialConnectionPoint;
  56688. /**
  56689. * Gets the tangent output component
  56690. */
  56691. readonly tangentOutput: NodeMaterialConnectionPoint;
  56692. /**
  56693. * Gets the tangent output component
  56694. */
  56695. readonly uvOutput: NodeMaterialConnectionPoint;
  56696. initialize(state: NodeMaterialBuildState): void;
  56697. autoConfigure(material: NodeMaterial): void;
  56698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56700. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56701. protected _buildBlock(state: NodeMaterialBuildState): this;
  56702. }
  56703. }
  56704. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56708. import { Nullable } from "babylonjs/types";
  56709. import { Scene } from "babylonjs/scene";
  56710. import { Effect } from "babylonjs/Materials/effect";
  56711. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56712. import { Mesh } from "babylonjs/Meshes/mesh";
  56713. import { Light } from "babylonjs/Lights/light";
  56714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56715. /**
  56716. * Block used to get data information from a light
  56717. */
  56718. export class LightInformationBlock extends NodeMaterialBlock {
  56719. private _lightDataUniformName;
  56720. private _lightColorUniformName;
  56721. private _lightTypeDefineName;
  56722. /**
  56723. * Gets or sets the light associated with this block
  56724. */
  56725. light: Nullable<Light>;
  56726. /**
  56727. * Creates a new LightInformationBlock
  56728. * @param name defines the block name
  56729. */
  56730. constructor(name: string);
  56731. /**
  56732. * Gets the current class name
  56733. * @returns the class name
  56734. */
  56735. getClassName(): string;
  56736. /**
  56737. * Gets the world position input component
  56738. */
  56739. readonly worldPosition: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the direction output component
  56742. */
  56743. readonly direction: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the direction output component
  56746. */
  56747. readonly color: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the direction output component
  56750. */
  56751. readonly intensity: NodeMaterialConnectionPoint;
  56752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56754. protected _buildBlock(state: NodeMaterialBuildState): this;
  56755. serialize(): any;
  56756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56757. }
  56758. }
  56759. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56760. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56761. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56762. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56763. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56764. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56765. }
  56766. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56771. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56772. import { Effect } from "babylonjs/Materials/effect";
  56773. import { Mesh } from "babylonjs/Meshes/mesh";
  56774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56776. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56777. /**
  56778. * Block used to add image processing support to fragment shader
  56779. */
  56780. export class ImageProcessingBlock extends NodeMaterialBlock {
  56781. /**
  56782. * Create a new ImageProcessingBlock
  56783. * @param name defines the block name
  56784. */
  56785. constructor(name: string);
  56786. /**
  56787. * Gets the current class name
  56788. * @returns the class name
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Gets the color input component
  56793. */
  56794. readonly color: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the output component
  56797. */
  56798. readonly output: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Initialize the block and prepare the context for build
  56801. * @param state defines the state that will be used for the build
  56802. */
  56803. initialize(state: NodeMaterialBuildState): void;
  56804. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56807. protected _buildBlock(state: NodeMaterialBuildState): this;
  56808. }
  56809. }
  56810. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56814. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56816. import { Effect } from "babylonjs/Materials/effect";
  56817. import { Mesh } from "babylonjs/Meshes/mesh";
  56818. import { Scene } from "babylonjs/scene";
  56819. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56820. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56821. /**
  56822. * Block used to pertub normals based on a normal map
  56823. */
  56824. export class PerturbNormalBlock extends NodeMaterialBlock {
  56825. private _tangentSpaceParameterName;
  56826. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56827. invertX: boolean;
  56828. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56829. invertY: boolean;
  56830. /**
  56831. * Create a new PerturbNormalBlock
  56832. * @param name defines the block name
  56833. */
  56834. constructor(name: string);
  56835. /**
  56836. * Gets the current class name
  56837. * @returns the class name
  56838. */
  56839. getClassName(): string;
  56840. /**
  56841. * Gets the world position input component
  56842. */
  56843. readonly worldPosition: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the world normal input component
  56846. */
  56847. readonly worldNormal: NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the uv input component
  56850. */
  56851. readonly uv: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the normal map color input component
  56854. */
  56855. readonly normalMapColor: NodeMaterialConnectionPoint;
  56856. /**
  56857. * Gets the strength input component
  56858. */
  56859. readonly strength: NodeMaterialConnectionPoint;
  56860. /**
  56861. * Gets the output component
  56862. */
  56863. readonly output: NodeMaterialConnectionPoint;
  56864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56866. autoConfigure(material: NodeMaterial): void;
  56867. protected _buildBlock(state: NodeMaterialBuildState): this;
  56868. protected _dumpPropertiesCode(): string;
  56869. serialize(): any;
  56870. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56871. }
  56872. }
  56873. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56877. /**
  56878. * Block used to discard a pixel if a value is smaller than a cutoff
  56879. */
  56880. export class DiscardBlock extends NodeMaterialBlock {
  56881. /**
  56882. * Create a new DiscardBlock
  56883. * @param name defines the block name
  56884. */
  56885. constructor(name: string);
  56886. /**
  56887. * Gets the current class name
  56888. * @returns the class name
  56889. */
  56890. getClassName(): string;
  56891. /**
  56892. * Gets the color input component
  56893. */
  56894. readonly value: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the cutoff input component
  56897. */
  56898. readonly cutoff: NodeMaterialConnectionPoint;
  56899. protected _buildBlock(state: NodeMaterialBuildState): this;
  56900. }
  56901. }
  56902. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56903. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56904. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56905. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56906. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56907. }
  56908. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56911. import { Mesh } from "babylonjs/Meshes/mesh";
  56912. import { Effect } from "babylonjs/Materials/effect";
  56913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56915. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56916. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56917. /**
  56918. * Block used to add support for scene fog
  56919. */
  56920. export class FogBlock extends NodeMaterialBlock {
  56921. private _fogDistanceName;
  56922. private _fogParameters;
  56923. /**
  56924. * Create a new FogBlock
  56925. * @param name defines the block name
  56926. */
  56927. constructor(name: string);
  56928. /**
  56929. * Gets the current class name
  56930. * @returns the class name
  56931. */
  56932. getClassName(): string;
  56933. /**
  56934. * Gets the world position input component
  56935. */
  56936. readonly worldPosition: NodeMaterialConnectionPoint;
  56937. /**
  56938. * Gets the view input component
  56939. */
  56940. readonly view: NodeMaterialConnectionPoint;
  56941. /**
  56942. * Gets the color input component
  56943. */
  56944. readonly input: NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the fog color input component
  56947. */
  56948. readonly fogColor: NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. readonly output: NodeMaterialConnectionPoint;
  56953. autoConfigure(material: NodeMaterial): void;
  56954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56956. protected _buildBlock(state: NodeMaterialBuildState): this;
  56957. }
  56958. }
  56959. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56964. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56965. import { Effect } from "babylonjs/Materials/effect";
  56966. import { Mesh } from "babylonjs/Meshes/mesh";
  56967. import { Light } from "babylonjs/Lights/light";
  56968. import { Nullable } from "babylonjs/types";
  56969. import { Scene } from "babylonjs/scene";
  56970. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56971. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56972. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56974. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56975. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56976. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56977. /**
  56978. * Block used to add light in the fragment shader
  56979. */
  56980. export class LightBlock extends NodeMaterialBlock {
  56981. private _lightId;
  56982. /**
  56983. * Gets or sets the light associated with this block
  56984. */
  56985. light: Nullable<Light>;
  56986. /**
  56987. * Create a new LightBlock
  56988. * @param name defines the block name
  56989. */
  56990. constructor(name: string);
  56991. /**
  56992. * Gets the current class name
  56993. * @returns the class name
  56994. */
  56995. getClassName(): string;
  56996. /**
  56997. * Gets the world position input component
  56998. */
  56999. readonly worldPosition: NodeMaterialConnectionPoint;
  57000. /**
  57001. * Gets the world normal input component
  57002. */
  57003. readonly worldNormal: NodeMaterialConnectionPoint;
  57004. /**
  57005. * Gets the camera (or eye) position component
  57006. */
  57007. readonly cameraPosition: NodeMaterialConnectionPoint;
  57008. /**
  57009. * Gets the glossiness component
  57010. */
  57011. readonly glossiness: NodeMaterialConnectionPoint;
  57012. /**
  57013. * Gets the glossinness power component
  57014. */
  57015. readonly glossPower: NodeMaterialConnectionPoint;
  57016. /**
  57017. * Gets the diffuse color component
  57018. */
  57019. readonly diffuseColor: NodeMaterialConnectionPoint;
  57020. /**
  57021. * Gets the specular color component
  57022. */
  57023. readonly specularColor: NodeMaterialConnectionPoint;
  57024. /**
  57025. * Gets the diffuse output component
  57026. */
  57027. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57028. /**
  57029. * Gets the specular output component
  57030. */
  57031. readonly specularOutput: NodeMaterialConnectionPoint;
  57032. autoConfigure(material: NodeMaterial): void;
  57033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57034. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57036. private _injectVertexCode;
  57037. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57038. serialize(): any;
  57039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57040. }
  57041. }
  57042. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57043. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57044. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57045. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57046. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57047. }
  57048. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57049. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57050. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57051. }
  57052. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57056. /**
  57057. * Block used to multiply 2 values
  57058. */
  57059. export class MultiplyBlock extends NodeMaterialBlock {
  57060. /**
  57061. * Creates a new MultiplyBlock
  57062. * @param name defines the block name
  57063. */
  57064. constructor(name: string);
  57065. /**
  57066. * Gets the current class name
  57067. * @returns the class name
  57068. */
  57069. getClassName(): string;
  57070. /**
  57071. * Gets the left operand input component
  57072. */
  57073. readonly left: NodeMaterialConnectionPoint;
  57074. /**
  57075. * Gets the right operand input component
  57076. */
  57077. readonly right: NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the output component
  57080. */
  57081. readonly output: NodeMaterialConnectionPoint;
  57082. protected _buildBlock(state: NodeMaterialBuildState): this;
  57083. }
  57084. }
  57085. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57089. /**
  57090. * Block used to add 2 vectors
  57091. */
  57092. export class AddBlock extends NodeMaterialBlock {
  57093. /**
  57094. * Creates a new AddBlock
  57095. * @param name defines the block name
  57096. */
  57097. constructor(name: string);
  57098. /**
  57099. * Gets the current class name
  57100. * @returns the class name
  57101. */
  57102. getClassName(): string;
  57103. /**
  57104. * Gets the left operand input component
  57105. */
  57106. readonly left: NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the right operand input component
  57109. */
  57110. readonly right: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the output component
  57113. */
  57114. readonly output: NodeMaterialConnectionPoint;
  57115. protected _buildBlock(state: NodeMaterialBuildState): this;
  57116. }
  57117. }
  57118. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57122. /**
  57123. * Block used to scale a vector by a float
  57124. */
  57125. export class ScaleBlock extends NodeMaterialBlock {
  57126. /**
  57127. * Creates a new ScaleBlock
  57128. * @param name defines the block name
  57129. */
  57130. constructor(name: string);
  57131. /**
  57132. * Gets the current class name
  57133. * @returns the class name
  57134. */
  57135. getClassName(): string;
  57136. /**
  57137. * Gets the input component
  57138. */
  57139. readonly input: NodeMaterialConnectionPoint;
  57140. /**
  57141. * Gets the factor input component
  57142. */
  57143. readonly factor: NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the output component
  57146. */
  57147. readonly output: NodeMaterialConnectionPoint;
  57148. protected _buildBlock(state: NodeMaterialBuildState): this;
  57149. }
  57150. }
  57151. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57155. import { Scene } from "babylonjs/scene";
  57156. /**
  57157. * Block used to clamp a float
  57158. */
  57159. export class ClampBlock extends NodeMaterialBlock {
  57160. /** Gets or sets the minimum range */
  57161. minimum: number;
  57162. /** Gets or sets the maximum range */
  57163. maximum: number;
  57164. /**
  57165. * Creates a new ClampBlock
  57166. * @param name defines the block name
  57167. */
  57168. constructor(name: string);
  57169. /**
  57170. * Gets the current class name
  57171. * @returns the class name
  57172. */
  57173. getClassName(): string;
  57174. /**
  57175. * Gets the value input component
  57176. */
  57177. readonly value: NodeMaterialConnectionPoint;
  57178. /**
  57179. * Gets the output component
  57180. */
  57181. readonly output: NodeMaterialConnectionPoint;
  57182. protected _buildBlock(state: NodeMaterialBuildState): this;
  57183. protected _dumpPropertiesCode(): string;
  57184. serialize(): any;
  57185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57186. }
  57187. }
  57188. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57192. /**
  57193. * Block used to apply a cross product between 2 vectors
  57194. */
  57195. export class CrossBlock extends NodeMaterialBlock {
  57196. /**
  57197. * Creates a new CrossBlock
  57198. * @param name defines the block name
  57199. */
  57200. constructor(name: string);
  57201. /**
  57202. * Gets the current class name
  57203. * @returns the class name
  57204. */
  57205. getClassName(): string;
  57206. /**
  57207. * Gets the left operand input component
  57208. */
  57209. readonly left: NodeMaterialConnectionPoint;
  57210. /**
  57211. * Gets the right operand input component
  57212. */
  57213. readonly right: NodeMaterialConnectionPoint;
  57214. /**
  57215. * Gets the output component
  57216. */
  57217. readonly output: NodeMaterialConnectionPoint;
  57218. protected _buildBlock(state: NodeMaterialBuildState): this;
  57219. }
  57220. }
  57221. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57225. /**
  57226. * Block used to apply a dot product between 2 vectors
  57227. */
  57228. export class DotBlock extends NodeMaterialBlock {
  57229. /**
  57230. * Creates a new DotBlock
  57231. * @param name defines the block name
  57232. */
  57233. constructor(name: string);
  57234. /**
  57235. * Gets the current class name
  57236. * @returns the class name
  57237. */
  57238. getClassName(): string;
  57239. /**
  57240. * Gets the left operand input component
  57241. */
  57242. readonly left: NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the right operand input component
  57245. */
  57246. readonly right: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the output component
  57249. */
  57250. readonly output: NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. }
  57253. }
  57254. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57258. import { Vector2 } from "babylonjs/Maths/math.vector";
  57259. import { Scene } from "babylonjs/scene";
  57260. /**
  57261. * Block used to remap a float from a range to a new one
  57262. */
  57263. export class RemapBlock extends NodeMaterialBlock {
  57264. /**
  57265. * Gets or sets the source range
  57266. */
  57267. sourceRange: Vector2;
  57268. /**
  57269. * Gets or sets the target range
  57270. */
  57271. targetRange: Vector2;
  57272. /**
  57273. * Creates a new RemapBlock
  57274. * @param name defines the block name
  57275. */
  57276. constructor(name: string);
  57277. /**
  57278. * Gets the current class name
  57279. * @returns the class name
  57280. */
  57281. getClassName(): string;
  57282. /**
  57283. * Gets the input component
  57284. */
  57285. readonly input: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the source min input component
  57288. */
  57289. readonly sourceMin: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the source max input component
  57292. */
  57293. readonly sourceMax: NodeMaterialConnectionPoint;
  57294. /**
  57295. * Gets the target min input component
  57296. */
  57297. readonly targetMin: NodeMaterialConnectionPoint;
  57298. /**
  57299. * Gets the target max input component
  57300. */
  57301. readonly targetMax: NodeMaterialConnectionPoint;
  57302. /**
  57303. * Gets the output component
  57304. */
  57305. readonly output: NodeMaterialConnectionPoint;
  57306. protected _buildBlock(state: NodeMaterialBuildState): this;
  57307. protected _dumpPropertiesCode(): string;
  57308. serialize(): any;
  57309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57310. }
  57311. }
  57312. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57316. /**
  57317. * Block used to normalize a vector
  57318. */
  57319. export class NormalizeBlock extends NodeMaterialBlock {
  57320. /**
  57321. * Creates a new NormalizeBlock
  57322. * @param name defines the block name
  57323. */
  57324. constructor(name: string);
  57325. /**
  57326. * Gets the current class name
  57327. * @returns the class name
  57328. */
  57329. getClassName(): string;
  57330. /**
  57331. * Gets the input component
  57332. */
  57333. readonly input: NodeMaterialConnectionPoint;
  57334. /**
  57335. * Gets the output component
  57336. */
  57337. readonly output: NodeMaterialConnectionPoint;
  57338. protected _buildBlock(state: NodeMaterialBuildState): this;
  57339. }
  57340. }
  57341. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57345. import { Scene } from "babylonjs/scene";
  57346. /**
  57347. * Operations supported by the Trigonometry block
  57348. */
  57349. export enum TrigonometryBlockOperations {
  57350. /** Cos */
  57351. Cos = 0,
  57352. /** Sin */
  57353. Sin = 1,
  57354. /** Abs */
  57355. Abs = 2,
  57356. /** Exp */
  57357. Exp = 3,
  57358. /** Exp2 */
  57359. Exp2 = 4,
  57360. /** Round */
  57361. Round = 5,
  57362. /** Floor */
  57363. Floor = 6,
  57364. /** Ceiling */
  57365. Ceiling = 7,
  57366. /** Square root */
  57367. Sqrt = 8,
  57368. /** Log */
  57369. Log = 9,
  57370. /** Tangent */
  57371. Tan = 10,
  57372. /** Arc tangent */
  57373. ArcTan = 11,
  57374. /** Arc cosinus */
  57375. ArcCos = 12,
  57376. /** Arc sinus */
  57377. ArcSin = 13,
  57378. /** Fraction */
  57379. Fract = 14,
  57380. /** Sign */
  57381. Sign = 15,
  57382. /** To radians (from degrees) */
  57383. Radians = 16,
  57384. /** To degrees (from radians) */
  57385. Degrees = 17
  57386. }
  57387. /**
  57388. * Block used to apply trigonometry operation to floats
  57389. */
  57390. export class TrigonometryBlock extends NodeMaterialBlock {
  57391. /**
  57392. * Gets or sets the operation applied by the block
  57393. */
  57394. operation: TrigonometryBlockOperations;
  57395. /**
  57396. * Creates a new TrigonometryBlock
  57397. * @param name defines the block name
  57398. */
  57399. constructor(name: string);
  57400. /**
  57401. * Gets the current class name
  57402. * @returns the class name
  57403. */
  57404. getClassName(): string;
  57405. /**
  57406. * Gets the input component
  57407. */
  57408. readonly input: NodeMaterialConnectionPoint;
  57409. /**
  57410. * Gets the output component
  57411. */
  57412. readonly output: NodeMaterialConnectionPoint;
  57413. protected _buildBlock(state: NodeMaterialBuildState): this;
  57414. serialize(): any;
  57415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57416. }
  57417. }
  57418. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57422. /**
  57423. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57424. */
  57425. export class ColorMergerBlock extends NodeMaterialBlock {
  57426. /**
  57427. * Create a new ColorMergerBlock
  57428. * @param name defines the block name
  57429. */
  57430. constructor(name: string);
  57431. /**
  57432. * Gets the current class name
  57433. * @returns the class name
  57434. */
  57435. getClassName(): string;
  57436. /**
  57437. * Gets the r component (input)
  57438. */
  57439. readonly r: NodeMaterialConnectionPoint;
  57440. /**
  57441. * Gets the g component (input)
  57442. */
  57443. readonly g: NodeMaterialConnectionPoint;
  57444. /**
  57445. * Gets the b component (input)
  57446. */
  57447. readonly b: NodeMaterialConnectionPoint;
  57448. /**
  57449. * Gets the a component (input)
  57450. */
  57451. readonly a: NodeMaterialConnectionPoint;
  57452. /**
  57453. * Gets the rgba component (output)
  57454. */
  57455. readonly rgba: NodeMaterialConnectionPoint;
  57456. /**
  57457. * Gets the rgb component (output)
  57458. */
  57459. readonly rgb: NodeMaterialConnectionPoint;
  57460. protected _buildBlock(state: NodeMaterialBuildState): this;
  57461. }
  57462. }
  57463. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57467. /**
  57468. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57469. */
  57470. export class VectorMergerBlock extends NodeMaterialBlock {
  57471. /**
  57472. * Create a new VectorMergerBlock
  57473. * @param name defines the block name
  57474. */
  57475. constructor(name: string);
  57476. /**
  57477. * Gets the current class name
  57478. * @returns the class name
  57479. */
  57480. getClassName(): string;
  57481. /**
  57482. * Gets the x component (input)
  57483. */
  57484. readonly x: NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the y component (input)
  57487. */
  57488. readonly y: NodeMaterialConnectionPoint;
  57489. /**
  57490. * Gets the z component (input)
  57491. */
  57492. readonly z: NodeMaterialConnectionPoint;
  57493. /**
  57494. * Gets the w component (input)
  57495. */
  57496. readonly w: NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the xyzw component (output)
  57499. */
  57500. readonly xyzw: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the xyz component (output)
  57503. */
  57504. readonly xyz: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the xy component (output)
  57507. */
  57508. readonly xy: NodeMaterialConnectionPoint;
  57509. protected _buildBlock(state: NodeMaterialBuildState): this;
  57510. }
  57511. }
  57512. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57516. /**
  57517. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57518. */
  57519. export class ColorSplitterBlock extends NodeMaterialBlock {
  57520. /**
  57521. * Create a new ColorSplitterBlock
  57522. * @param name defines the block name
  57523. */
  57524. constructor(name: string);
  57525. /**
  57526. * Gets the current class name
  57527. * @returns the class name
  57528. */
  57529. getClassName(): string;
  57530. /**
  57531. * Gets the rgba component (input)
  57532. */
  57533. readonly rgba: NodeMaterialConnectionPoint;
  57534. /**
  57535. * Gets the rgb component (input)
  57536. */
  57537. readonly rgbIn: NodeMaterialConnectionPoint;
  57538. /**
  57539. * Gets the rgb component (output)
  57540. */
  57541. readonly rgbOut: NodeMaterialConnectionPoint;
  57542. /**
  57543. * Gets the r component (output)
  57544. */
  57545. readonly r: NodeMaterialConnectionPoint;
  57546. /**
  57547. * Gets the g component (output)
  57548. */
  57549. readonly g: NodeMaterialConnectionPoint;
  57550. /**
  57551. * Gets the b component (output)
  57552. */
  57553. readonly b: NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the a component (output)
  57556. */
  57557. readonly a: NodeMaterialConnectionPoint;
  57558. protected _inputRename(name: string): string;
  57559. protected _outputRename(name: string): string;
  57560. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57561. }
  57562. }
  57563. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57567. /**
  57568. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57569. */
  57570. export class VectorSplitterBlock extends NodeMaterialBlock {
  57571. /**
  57572. * Create a new VectorSplitterBlock
  57573. * @param name defines the block name
  57574. */
  57575. constructor(name: string);
  57576. /**
  57577. * Gets the current class name
  57578. * @returns the class name
  57579. */
  57580. getClassName(): string;
  57581. /**
  57582. * Gets the xyzw component (input)
  57583. */
  57584. readonly xyzw: NodeMaterialConnectionPoint;
  57585. /**
  57586. * Gets the xyz component (input)
  57587. */
  57588. readonly xyzIn: NodeMaterialConnectionPoint;
  57589. /**
  57590. * Gets the xy component (input)
  57591. */
  57592. readonly xyIn: NodeMaterialConnectionPoint;
  57593. /**
  57594. * Gets the xyz component (output)
  57595. */
  57596. readonly xyzOut: NodeMaterialConnectionPoint;
  57597. /**
  57598. * Gets the xy component (output)
  57599. */
  57600. readonly xyOut: NodeMaterialConnectionPoint;
  57601. /**
  57602. * Gets the x component (output)
  57603. */
  57604. readonly x: NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the y component (output)
  57607. */
  57608. readonly y: NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the z component (output)
  57611. */
  57612. readonly z: NodeMaterialConnectionPoint;
  57613. /**
  57614. * Gets the w component (output)
  57615. */
  57616. readonly w: NodeMaterialConnectionPoint;
  57617. protected _inputRename(name: string): string;
  57618. protected _outputRename(name: string): string;
  57619. protected _buildBlock(state: NodeMaterialBuildState): this;
  57620. }
  57621. }
  57622. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57626. /**
  57627. * Block used to lerp between 2 values
  57628. */
  57629. export class LerpBlock extends NodeMaterialBlock {
  57630. /**
  57631. * Creates a new LerpBlock
  57632. * @param name defines the block name
  57633. */
  57634. constructor(name: string);
  57635. /**
  57636. * Gets the current class name
  57637. * @returns the class name
  57638. */
  57639. getClassName(): string;
  57640. /**
  57641. * Gets the left operand input component
  57642. */
  57643. readonly left: NodeMaterialConnectionPoint;
  57644. /**
  57645. * Gets the right operand input component
  57646. */
  57647. readonly right: NodeMaterialConnectionPoint;
  57648. /**
  57649. * Gets the gradient operand input component
  57650. */
  57651. readonly gradient: NodeMaterialConnectionPoint;
  57652. /**
  57653. * Gets the output component
  57654. */
  57655. readonly output: NodeMaterialConnectionPoint;
  57656. protected _buildBlock(state: NodeMaterialBuildState): this;
  57657. }
  57658. }
  57659. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57663. /**
  57664. * Block used to divide 2 vectors
  57665. */
  57666. export class DivideBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Creates a new DivideBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the left operand input component
  57679. */
  57680. readonly left: NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the right operand input component
  57683. */
  57684. readonly right: NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the output component
  57687. */
  57688. readonly output: NodeMaterialConnectionPoint;
  57689. protected _buildBlock(state: NodeMaterialBuildState): this;
  57690. }
  57691. }
  57692. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57696. /**
  57697. * Block used to subtract 2 vectors
  57698. */
  57699. export class SubtractBlock extends NodeMaterialBlock {
  57700. /**
  57701. * Creates a new SubtractBlock
  57702. * @param name defines the block name
  57703. */
  57704. constructor(name: string);
  57705. /**
  57706. * Gets the current class name
  57707. * @returns the class name
  57708. */
  57709. getClassName(): string;
  57710. /**
  57711. * Gets the left operand input component
  57712. */
  57713. readonly left: NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the right operand input component
  57716. */
  57717. readonly right: NodeMaterialConnectionPoint;
  57718. /**
  57719. * Gets the output component
  57720. */
  57721. readonly output: NodeMaterialConnectionPoint;
  57722. protected _buildBlock(state: NodeMaterialBuildState): this;
  57723. }
  57724. }
  57725. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57729. /**
  57730. * Block used to step a value
  57731. */
  57732. export class StepBlock extends NodeMaterialBlock {
  57733. /**
  57734. * Creates a new StepBlock
  57735. * @param name defines the block name
  57736. */
  57737. constructor(name: string);
  57738. /**
  57739. * Gets the current class name
  57740. * @returns the class name
  57741. */
  57742. getClassName(): string;
  57743. /**
  57744. * Gets the value operand input component
  57745. */
  57746. readonly value: NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the edge operand input component
  57749. */
  57750. readonly edge: NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the output component
  57753. */
  57754. readonly output: NodeMaterialConnectionPoint;
  57755. protected _buildBlock(state: NodeMaterialBuildState): this;
  57756. }
  57757. }
  57758. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57762. /**
  57763. * Block used to get the opposite (1 - x) of a value
  57764. */
  57765. export class OneMinusBlock extends NodeMaterialBlock {
  57766. /**
  57767. * Creates a new OneMinusBlock
  57768. * @param name defines the block name
  57769. */
  57770. constructor(name: string);
  57771. /**
  57772. * Gets the current class name
  57773. * @returns the class name
  57774. */
  57775. getClassName(): string;
  57776. /**
  57777. * Gets the input component
  57778. */
  57779. readonly input: NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the output component
  57782. */
  57783. readonly output: NodeMaterialConnectionPoint;
  57784. protected _buildBlock(state: NodeMaterialBuildState): this;
  57785. }
  57786. }
  57787. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  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 { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57792. /**
  57793. * Block used to get the view direction
  57794. */
  57795. export class ViewDirectionBlock extends NodeMaterialBlock {
  57796. /**
  57797. * Creates a new ViewDirectionBlock
  57798. * @param name defines the block name
  57799. */
  57800. constructor(name: string);
  57801. /**
  57802. * Gets the current class name
  57803. * @returns the class name
  57804. */
  57805. getClassName(): string;
  57806. /**
  57807. * Gets the world position component
  57808. */
  57809. readonly worldPosition: NodeMaterialConnectionPoint;
  57810. /**
  57811. * Gets the camera position component
  57812. */
  57813. readonly cameraPosition: NodeMaterialConnectionPoint;
  57814. /**
  57815. * Gets the output component
  57816. */
  57817. readonly output: NodeMaterialConnectionPoint;
  57818. autoConfigure(material: NodeMaterial): void;
  57819. protected _buildBlock(state: NodeMaterialBuildState): this;
  57820. }
  57821. }
  57822. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57826. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57827. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57828. /**
  57829. * Block used to compute fresnel value
  57830. */
  57831. export class FresnelBlock extends NodeMaterialBlock {
  57832. /**
  57833. * Create a new FresnelBlock
  57834. * @param name defines the block name
  57835. */
  57836. constructor(name: string);
  57837. /**
  57838. * Gets the current class name
  57839. * @returns the class name
  57840. */
  57841. getClassName(): string;
  57842. /**
  57843. * Gets the world normal input component
  57844. */
  57845. readonly worldNormal: NodeMaterialConnectionPoint;
  57846. /**
  57847. * Gets the view direction input component
  57848. */
  57849. readonly viewDirection: NodeMaterialConnectionPoint;
  57850. /**
  57851. * Gets the bias input component
  57852. */
  57853. readonly bias: NodeMaterialConnectionPoint;
  57854. /**
  57855. * Gets the camera (or eye) position component
  57856. */
  57857. readonly power: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the fresnel output component
  57860. */
  57861. readonly fresnel: NodeMaterialConnectionPoint;
  57862. autoConfigure(material: NodeMaterial): void;
  57863. protected _buildBlock(state: NodeMaterialBuildState): this;
  57864. }
  57865. }
  57866. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57870. /**
  57871. * Block used to get the max of 2 values
  57872. */
  57873. export class MaxBlock extends NodeMaterialBlock {
  57874. /**
  57875. * Creates a new MaxBlock
  57876. * @param name defines the block name
  57877. */
  57878. constructor(name: string);
  57879. /**
  57880. * Gets the current class name
  57881. * @returns the class name
  57882. */
  57883. getClassName(): string;
  57884. /**
  57885. * Gets the left operand input component
  57886. */
  57887. readonly left: NodeMaterialConnectionPoint;
  57888. /**
  57889. * Gets the right operand input component
  57890. */
  57891. readonly right: NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the output component
  57894. */
  57895. readonly output: NodeMaterialConnectionPoint;
  57896. protected _buildBlock(state: NodeMaterialBuildState): this;
  57897. }
  57898. }
  57899. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57903. /**
  57904. * Block used to get the min of 2 values
  57905. */
  57906. export class MinBlock extends NodeMaterialBlock {
  57907. /**
  57908. * Creates a new MinBlock
  57909. * @param name defines the block name
  57910. */
  57911. constructor(name: string);
  57912. /**
  57913. * Gets the current class name
  57914. * @returns the class name
  57915. */
  57916. getClassName(): string;
  57917. /**
  57918. * Gets the left operand input component
  57919. */
  57920. readonly left: NodeMaterialConnectionPoint;
  57921. /**
  57922. * Gets the right operand input component
  57923. */
  57924. readonly right: NodeMaterialConnectionPoint;
  57925. /**
  57926. * Gets the output component
  57927. */
  57928. readonly output: NodeMaterialConnectionPoint;
  57929. protected _buildBlock(state: NodeMaterialBuildState): this;
  57930. }
  57931. }
  57932. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57936. /**
  57937. * Block used to get the distance between 2 values
  57938. */
  57939. export class DistanceBlock extends NodeMaterialBlock {
  57940. /**
  57941. * Creates a new DistanceBlock
  57942. * @param name defines the block name
  57943. */
  57944. constructor(name: string);
  57945. /**
  57946. * Gets the current class name
  57947. * @returns the class name
  57948. */
  57949. getClassName(): string;
  57950. /**
  57951. * Gets the left operand input component
  57952. */
  57953. readonly left: NodeMaterialConnectionPoint;
  57954. /**
  57955. * Gets the right operand input component
  57956. */
  57957. readonly right: NodeMaterialConnectionPoint;
  57958. /**
  57959. * Gets the output component
  57960. */
  57961. readonly output: NodeMaterialConnectionPoint;
  57962. protected _buildBlock(state: NodeMaterialBuildState): this;
  57963. }
  57964. }
  57965. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57969. /**
  57970. * Block used to get the length of a vector
  57971. */
  57972. export class LengthBlock extends NodeMaterialBlock {
  57973. /**
  57974. * Creates a new LengthBlock
  57975. * @param name defines the block name
  57976. */
  57977. constructor(name: string);
  57978. /**
  57979. * Gets the current class name
  57980. * @returns the class name
  57981. */
  57982. getClassName(): string;
  57983. /**
  57984. * Gets the value input component
  57985. */
  57986. readonly value: NodeMaterialConnectionPoint;
  57987. /**
  57988. * Gets the output component
  57989. */
  57990. readonly output: NodeMaterialConnectionPoint;
  57991. protected _buildBlock(state: NodeMaterialBuildState): this;
  57992. }
  57993. }
  57994. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57998. /**
  57999. * Block used to get negative version of a value (i.e. x * -1)
  58000. */
  58001. export class NegateBlock extends NodeMaterialBlock {
  58002. /**
  58003. * Creates a new NegateBlock
  58004. * @param name defines the block name
  58005. */
  58006. constructor(name: string);
  58007. /**
  58008. * Gets the current class name
  58009. * @returns the class name
  58010. */
  58011. getClassName(): string;
  58012. /**
  58013. * Gets the value input component
  58014. */
  58015. readonly value: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the output component
  58018. */
  58019. readonly output: NodeMaterialConnectionPoint;
  58020. protected _buildBlock(state: NodeMaterialBuildState): this;
  58021. }
  58022. }
  58023. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58027. /**
  58028. * Block used to get the value of the first parameter raised to the power of the second
  58029. */
  58030. export class PowBlock extends NodeMaterialBlock {
  58031. /**
  58032. * Creates a new PowBlock
  58033. * @param name defines the block name
  58034. */
  58035. constructor(name: string);
  58036. /**
  58037. * Gets the current class name
  58038. * @returns the class name
  58039. */
  58040. getClassName(): string;
  58041. /**
  58042. * Gets the value operand input component
  58043. */
  58044. readonly value: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the power operand input component
  58047. */
  58048. readonly power: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the output component
  58051. */
  58052. readonly output: NodeMaterialConnectionPoint;
  58053. protected _buildBlock(state: NodeMaterialBuildState): this;
  58054. }
  58055. }
  58056. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58061. /**
  58062. * Block used to get a random number
  58063. */
  58064. export class RandomNumberBlock extends NodeMaterialBlock {
  58065. /**
  58066. * Creates a new RandomNumberBlock
  58067. * @param name defines the block name
  58068. */
  58069. constructor(name: string);
  58070. /**
  58071. * Gets the current class name
  58072. * @returns the class name
  58073. */
  58074. getClassName(): string;
  58075. /**
  58076. * Gets the seed input component
  58077. */
  58078. readonly seed: NodeMaterialConnectionPoint;
  58079. /**
  58080. * Gets the output component
  58081. */
  58082. readonly output: NodeMaterialConnectionPoint;
  58083. protected _buildBlock(state: NodeMaterialBuildState): this;
  58084. }
  58085. }
  58086. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58090. /**
  58091. * Block used to compute arc tangent of 2 values
  58092. */
  58093. export class ArcTan2Block extends NodeMaterialBlock {
  58094. /**
  58095. * Creates a new ArcTan2Block
  58096. * @param name defines the block name
  58097. */
  58098. constructor(name: string);
  58099. /**
  58100. * Gets the current class name
  58101. * @returns the class name
  58102. */
  58103. getClassName(): string;
  58104. /**
  58105. * Gets the x operand input component
  58106. */
  58107. readonly x: NodeMaterialConnectionPoint;
  58108. /**
  58109. * Gets the y operand input component
  58110. */
  58111. readonly y: NodeMaterialConnectionPoint;
  58112. /**
  58113. * Gets the output component
  58114. */
  58115. readonly output: NodeMaterialConnectionPoint;
  58116. protected _buildBlock(state: NodeMaterialBuildState): this;
  58117. }
  58118. }
  58119. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58123. /**
  58124. * Block used to smooth step a value
  58125. */
  58126. export class SmoothStepBlock extends NodeMaterialBlock {
  58127. /**
  58128. * Creates a new SmoothStepBlock
  58129. * @param name defines the block name
  58130. */
  58131. constructor(name: string);
  58132. /**
  58133. * Gets the current class name
  58134. * @returns the class name
  58135. */
  58136. getClassName(): string;
  58137. /**
  58138. * Gets the value operand input component
  58139. */
  58140. readonly value: NodeMaterialConnectionPoint;
  58141. /**
  58142. * Gets the first edge operand input component
  58143. */
  58144. readonly edge0: NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the second edge operand input component
  58147. */
  58148. readonly edge1: NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the output component
  58151. */
  58152. readonly output: NodeMaterialConnectionPoint;
  58153. protected _buildBlock(state: NodeMaterialBuildState): this;
  58154. }
  58155. }
  58156. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58160. /**
  58161. * Block used to get the reciprocal (1 / x) of a value
  58162. */
  58163. export class ReciprocalBlock extends NodeMaterialBlock {
  58164. /**
  58165. * Creates a new ReciprocalBlock
  58166. * @param name defines the block name
  58167. */
  58168. constructor(name: string);
  58169. /**
  58170. * Gets the current class name
  58171. * @returns the class name
  58172. */
  58173. getClassName(): string;
  58174. /**
  58175. * Gets the input component
  58176. */
  58177. readonly input: NodeMaterialConnectionPoint;
  58178. /**
  58179. * Gets the output component
  58180. */
  58181. readonly output: NodeMaterialConnectionPoint;
  58182. protected _buildBlock(state: NodeMaterialBuildState): this;
  58183. }
  58184. }
  58185. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58189. /**
  58190. * Block used to replace a color by another one
  58191. */
  58192. export class ReplaceColorBlock extends NodeMaterialBlock {
  58193. /**
  58194. * Creates a new ReplaceColorBlock
  58195. * @param name defines the block name
  58196. */
  58197. constructor(name: string);
  58198. /**
  58199. * Gets the current class name
  58200. * @returns the class name
  58201. */
  58202. getClassName(): string;
  58203. /**
  58204. * Gets the value input component
  58205. */
  58206. readonly value: NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the reference input component
  58209. */
  58210. readonly reference: NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the distance input component
  58213. */
  58214. readonly distance: NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the replacement input component
  58217. */
  58218. readonly replacement: NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the output component
  58221. */
  58222. readonly output: NodeMaterialConnectionPoint;
  58223. protected _buildBlock(state: NodeMaterialBuildState): this;
  58224. }
  58225. }
  58226. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58230. /**
  58231. * Block used to posterize a value
  58232. * @see https://en.wikipedia.org/wiki/Posterization
  58233. */
  58234. export class PosterizeBlock extends NodeMaterialBlock {
  58235. /**
  58236. * Creates a new PosterizeBlock
  58237. * @param name defines the block name
  58238. */
  58239. constructor(name: string);
  58240. /**
  58241. * Gets the current class name
  58242. * @returns the class name
  58243. */
  58244. getClassName(): string;
  58245. /**
  58246. * Gets the value input component
  58247. */
  58248. readonly value: NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the steps input component
  58251. */
  58252. readonly steps: NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the output component
  58255. */
  58256. readonly output: NodeMaterialConnectionPoint;
  58257. protected _buildBlock(state: NodeMaterialBuildState): this;
  58258. }
  58259. }
  58260. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58264. import { Scene } from "babylonjs/scene";
  58265. /**
  58266. * Operations supported by the Wave block
  58267. */
  58268. export enum WaveBlockKind {
  58269. /** SawTooth */
  58270. SawTooth = 0,
  58271. /** Square */
  58272. Square = 1,
  58273. /** Triangle */
  58274. Triangle = 2
  58275. }
  58276. /**
  58277. * Block used to apply wave operation to floats
  58278. */
  58279. export class WaveBlock extends NodeMaterialBlock {
  58280. /**
  58281. * Gets or sets the kibnd of wave to be applied by the block
  58282. */
  58283. kind: WaveBlockKind;
  58284. /**
  58285. * Creates a new WaveBlock
  58286. * @param name defines the block name
  58287. */
  58288. constructor(name: string);
  58289. /**
  58290. * Gets the current class name
  58291. * @returns the class name
  58292. */
  58293. getClassName(): string;
  58294. /**
  58295. * Gets the input component
  58296. */
  58297. readonly input: NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the output component
  58300. */
  58301. readonly output: NodeMaterialConnectionPoint;
  58302. protected _buildBlock(state: NodeMaterialBuildState): this;
  58303. serialize(): any;
  58304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58305. }
  58306. }
  58307. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58311. import { Color3 } from "babylonjs/Maths/math.color";
  58312. import { Scene } from "babylonjs/scene";
  58313. /**
  58314. * Class used to store a color step for the GradientBlock
  58315. */
  58316. export class GradientBlockColorStep {
  58317. /**
  58318. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58319. */
  58320. step: number;
  58321. /**
  58322. * Gets or sets the color associated with this step
  58323. */
  58324. color: Color3;
  58325. /**
  58326. * Creates a new GradientBlockColorStep
  58327. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58328. * @param color defines the color associated with this step
  58329. */
  58330. constructor(
  58331. /**
  58332. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58333. */
  58334. step: number,
  58335. /**
  58336. * Gets or sets the color associated with this step
  58337. */
  58338. color: Color3);
  58339. }
  58340. /**
  58341. * Block used to return a color from a gradient based on an input value between 0 and 1
  58342. */
  58343. export class GradientBlock extends NodeMaterialBlock {
  58344. /**
  58345. * Gets or sets the list of color steps
  58346. */
  58347. colorSteps: GradientBlockColorStep[];
  58348. /**
  58349. * Creates a new GradientBlock
  58350. * @param name defines the block name
  58351. */
  58352. constructor(name: string);
  58353. /**
  58354. * Gets the current class name
  58355. * @returns the class name
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * Gets the gradient input component
  58360. */
  58361. readonly gradient: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the output component
  58364. */
  58365. readonly output: NodeMaterialConnectionPoint;
  58366. private _writeColorConstant;
  58367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58368. serialize(): any;
  58369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58370. protected _dumpPropertiesCode(): string;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58377. /**
  58378. * Block used to normalize lerp between 2 values
  58379. */
  58380. export class NLerpBlock extends NodeMaterialBlock {
  58381. /**
  58382. * Creates a new NLerpBlock
  58383. * @param name defines the block name
  58384. */
  58385. constructor(name: string);
  58386. /**
  58387. * Gets the current class name
  58388. * @returns the class name
  58389. */
  58390. getClassName(): string;
  58391. /**
  58392. * Gets the left operand input component
  58393. */
  58394. readonly left: NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the right operand input component
  58397. */
  58398. readonly right: NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the gradient operand input component
  58401. */
  58402. readonly gradient: NodeMaterialConnectionPoint;
  58403. /**
  58404. * Gets the output component
  58405. */
  58406. readonly output: NodeMaterialConnectionPoint;
  58407. protected _buildBlock(state: NodeMaterialBuildState): this;
  58408. }
  58409. }
  58410. declare module "babylonjs/Materials/Node/Blocks/index" {
  58411. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58412. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58413. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58414. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58415. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58416. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58417. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58418. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58419. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58420. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58421. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58422. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58423. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58424. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58425. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58426. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58427. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58428. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58429. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58430. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58431. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58432. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58433. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58434. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58435. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58436. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58437. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58438. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58439. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58440. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58441. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58442. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58443. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58444. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58445. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58446. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58447. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58448. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58449. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58450. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58451. }
  58452. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58453. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58454. }
  58455. declare module "babylonjs/Materials/Node/index" {
  58456. export * from "babylonjs/Materials/Node/Enums/index";
  58457. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58458. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58459. export * from "babylonjs/Materials/Node/nodeMaterial";
  58460. export * from "babylonjs/Materials/Node/Blocks/index";
  58461. export * from "babylonjs/Materials/Node/Optimizers/index";
  58462. }
  58463. declare module "babylonjs/Materials/effectRenderer" {
  58464. import { Nullable } from "babylonjs/types";
  58465. import { Texture } from "babylonjs/Materials/Textures/texture";
  58466. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58467. import { Viewport } from "babylonjs/Maths/math.viewport";
  58468. import { Observable } from "babylonjs/Misc/observable";
  58469. import { Effect } from "babylonjs/Materials/effect";
  58470. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58471. import "babylonjs/Shaders/postprocess.vertex";
  58472. /**
  58473. * Effect Render Options
  58474. */
  58475. export interface IEffectRendererOptions {
  58476. /**
  58477. * Defines the vertices positions.
  58478. */
  58479. positions?: number[];
  58480. /**
  58481. * Defines the indices.
  58482. */
  58483. indices?: number[];
  58484. }
  58485. /**
  58486. * Helper class to render one or more effects
  58487. */
  58488. export class EffectRenderer {
  58489. private engine;
  58490. private static _DefaultOptions;
  58491. private _vertexBuffers;
  58492. private _indexBuffer;
  58493. private _ringBufferIndex;
  58494. private _ringScreenBuffer;
  58495. private _fullscreenViewport;
  58496. private _getNextFrameBuffer;
  58497. /**
  58498. * Creates an effect renderer
  58499. * @param engine the engine to use for rendering
  58500. * @param options defines the options of the effect renderer
  58501. */
  58502. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58503. /**
  58504. * Sets the current viewport in normalized coordinates 0-1
  58505. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58506. */
  58507. setViewport(viewport?: Viewport): void;
  58508. /**
  58509. * Binds the embedded attributes buffer to the effect.
  58510. * @param effect Defines the effect to bind the attributes for
  58511. */
  58512. bindBuffers(effect: Effect): void;
  58513. /**
  58514. * Sets the current effect wrapper to use during draw.
  58515. * The effect needs to be ready before calling this api.
  58516. * This also sets the default full screen position attribute.
  58517. * @param effectWrapper Defines the effect to draw with
  58518. */
  58519. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58520. /**
  58521. * Draws a full screen quad.
  58522. */
  58523. draw(): void;
  58524. /**
  58525. * renders one or more effects to a specified texture
  58526. * @param effectWrappers list of effects to renderer
  58527. * @param outputTexture texture to draw to, if null it will render to the screen
  58528. */
  58529. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58530. /**
  58531. * Disposes of the effect renderer
  58532. */
  58533. dispose(): void;
  58534. }
  58535. /**
  58536. * Options to create an EffectWrapper
  58537. */
  58538. interface EffectWrapperCreationOptions {
  58539. /**
  58540. * Engine to use to create the effect
  58541. */
  58542. engine: ThinEngine;
  58543. /**
  58544. * Fragment shader for the effect
  58545. */
  58546. fragmentShader: string;
  58547. /**
  58548. * Vertex shader for the effect
  58549. */
  58550. vertexShader?: string;
  58551. /**
  58552. * Attributes to use in the shader
  58553. */
  58554. attributeNames?: Array<string>;
  58555. /**
  58556. * Uniforms to use in the shader
  58557. */
  58558. uniformNames?: Array<string>;
  58559. /**
  58560. * Texture sampler names to use in the shader
  58561. */
  58562. samplerNames?: Array<string>;
  58563. /**
  58564. * The friendly name of the effect displayed in Spector.
  58565. */
  58566. name?: string;
  58567. }
  58568. /**
  58569. * Wraps an effect to be used for rendering
  58570. */
  58571. export class EffectWrapper {
  58572. /**
  58573. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58574. */
  58575. onApplyObservable: Observable<{}>;
  58576. /**
  58577. * The underlying effect
  58578. */
  58579. effect: Effect;
  58580. /**
  58581. * Creates an effect to be renderer
  58582. * @param creationOptions options to create the effect
  58583. */
  58584. constructor(creationOptions: EffectWrapperCreationOptions);
  58585. /**
  58586. * Disposes of the effect wrapper
  58587. */
  58588. dispose(): void;
  58589. }
  58590. }
  58591. declare module "babylonjs/Materials/index" {
  58592. export * from "babylonjs/Materials/Background/index";
  58593. export * from "babylonjs/Materials/colorCurves";
  58594. export * from "babylonjs/Materials/iEffectFallbacks";
  58595. export * from "babylonjs/Materials/effectFallbacks";
  58596. export * from "babylonjs/Materials/effect";
  58597. export * from "babylonjs/Materials/fresnelParameters";
  58598. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58599. export * from "babylonjs/Materials/material";
  58600. export * from "babylonjs/Materials/materialDefines";
  58601. export * from "babylonjs/Materials/materialHelper";
  58602. export * from "babylonjs/Materials/multiMaterial";
  58603. export * from "babylonjs/Materials/PBR/index";
  58604. export * from "babylonjs/Materials/pushMaterial";
  58605. export * from "babylonjs/Materials/shaderMaterial";
  58606. export * from "babylonjs/Materials/standardMaterial";
  58607. export * from "babylonjs/Materials/Textures/index";
  58608. export * from "babylonjs/Materials/uniformBuffer";
  58609. export * from "babylonjs/Materials/materialFlags";
  58610. export * from "babylonjs/Materials/Node/index";
  58611. export * from "babylonjs/Materials/effectRenderer";
  58612. }
  58613. declare module "babylonjs/Maths/index" {
  58614. export * from "babylonjs/Maths/math.scalar";
  58615. export * from "babylonjs/Maths/math";
  58616. export * from "babylonjs/Maths/sphericalPolynomial";
  58617. }
  58618. declare module "babylonjs/Misc/workerPool" {
  58619. import { IDisposable } from "babylonjs/scene";
  58620. /**
  58621. * Helper class to push actions to a pool of workers.
  58622. */
  58623. export class WorkerPool implements IDisposable {
  58624. private _workerInfos;
  58625. private _pendingActions;
  58626. /**
  58627. * Constructor
  58628. * @param workers Array of workers to use for actions
  58629. */
  58630. constructor(workers: Array<Worker>);
  58631. /**
  58632. * Terminates all workers and clears any pending actions.
  58633. */
  58634. dispose(): void;
  58635. /**
  58636. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58637. * pended until a worker has completed its action.
  58638. * @param action The action to perform. Call onComplete when the action is complete.
  58639. */
  58640. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58641. private _execute;
  58642. }
  58643. }
  58644. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58645. import { IDisposable } from "babylonjs/scene";
  58646. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58647. /**
  58648. * Configuration for Draco compression
  58649. */
  58650. export interface IDracoCompressionConfiguration {
  58651. /**
  58652. * Configuration for the decoder.
  58653. */
  58654. decoder: {
  58655. /**
  58656. * The url to the WebAssembly module.
  58657. */
  58658. wasmUrl?: string;
  58659. /**
  58660. * The url to the WebAssembly binary.
  58661. */
  58662. wasmBinaryUrl?: string;
  58663. /**
  58664. * The url to the fallback JavaScript module.
  58665. */
  58666. fallbackUrl?: string;
  58667. };
  58668. }
  58669. /**
  58670. * Draco compression (https://google.github.io/draco/)
  58671. *
  58672. * This class wraps the Draco module.
  58673. *
  58674. * **Encoder**
  58675. *
  58676. * The encoder is not currently implemented.
  58677. *
  58678. * **Decoder**
  58679. *
  58680. * 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.
  58681. *
  58682. * To update the configuration, use the following code:
  58683. * ```javascript
  58684. * DracoCompression.Configuration = {
  58685. * decoder: {
  58686. * wasmUrl: "<url to the WebAssembly library>",
  58687. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58688. * fallbackUrl: "<url to the fallback JavaScript library>",
  58689. * }
  58690. * };
  58691. * ```
  58692. *
  58693. * 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.
  58694. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58695. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58696. *
  58697. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58698. * ```javascript
  58699. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58700. * ```
  58701. *
  58702. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58703. */
  58704. export class DracoCompression implements IDisposable {
  58705. private _workerPoolPromise?;
  58706. private _decoderModulePromise?;
  58707. /**
  58708. * The configuration. Defaults to the following urls:
  58709. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58710. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58711. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58712. */
  58713. static Configuration: IDracoCompressionConfiguration;
  58714. /**
  58715. * Returns true if the decoder configuration is available.
  58716. */
  58717. static readonly DecoderAvailable: boolean;
  58718. /**
  58719. * Default number of workers to create when creating the draco compression object.
  58720. */
  58721. static DefaultNumWorkers: number;
  58722. private static GetDefaultNumWorkers;
  58723. private static _Default;
  58724. /**
  58725. * Default instance for the draco compression object.
  58726. */
  58727. static readonly Default: DracoCompression;
  58728. /**
  58729. * Constructor
  58730. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58731. */
  58732. constructor(numWorkers?: number);
  58733. /**
  58734. * Stop all async operations and release resources.
  58735. */
  58736. dispose(): void;
  58737. /**
  58738. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58739. * @returns a promise that resolves when ready
  58740. */
  58741. whenReadyAsync(): Promise<void>;
  58742. /**
  58743. * Decode Draco compressed mesh data to vertex data.
  58744. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58745. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58746. * @returns A promise that resolves with the decoded vertex data
  58747. */
  58748. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58749. [kind: string]: number;
  58750. }): Promise<VertexData>;
  58751. }
  58752. }
  58753. declare module "babylonjs/Meshes/Compression/index" {
  58754. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58755. }
  58756. declare module "babylonjs/Meshes/csg" {
  58757. import { Nullable } from "babylonjs/types";
  58758. import { Scene } from "babylonjs/scene";
  58759. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58760. import { Mesh } from "babylonjs/Meshes/mesh";
  58761. import { Material } from "babylonjs/Materials/material";
  58762. /**
  58763. * Class for building Constructive Solid Geometry
  58764. */
  58765. export class CSG {
  58766. private polygons;
  58767. /**
  58768. * The world matrix
  58769. */
  58770. matrix: Matrix;
  58771. /**
  58772. * Stores the position
  58773. */
  58774. position: Vector3;
  58775. /**
  58776. * Stores the rotation
  58777. */
  58778. rotation: Vector3;
  58779. /**
  58780. * Stores the rotation quaternion
  58781. */
  58782. rotationQuaternion: Nullable<Quaternion>;
  58783. /**
  58784. * Stores the scaling vector
  58785. */
  58786. scaling: Vector3;
  58787. /**
  58788. * Convert the Mesh to CSG
  58789. * @param mesh The Mesh to convert to CSG
  58790. * @returns A new CSG from the Mesh
  58791. */
  58792. static FromMesh(mesh: Mesh): CSG;
  58793. /**
  58794. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58795. * @param polygons Polygons used to construct a CSG solid
  58796. */
  58797. private static FromPolygons;
  58798. /**
  58799. * Clones, or makes a deep copy, of the CSG
  58800. * @returns A new CSG
  58801. */
  58802. clone(): CSG;
  58803. /**
  58804. * Unions this CSG with another CSG
  58805. * @param csg The CSG to union against this CSG
  58806. * @returns The unioned CSG
  58807. */
  58808. union(csg: CSG): CSG;
  58809. /**
  58810. * Unions this CSG with another CSG in place
  58811. * @param csg The CSG to union against this CSG
  58812. */
  58813. unionInPlace(csg: CSG): void;
  58814. /**
  58815. * Subtracts this CSG with another CSG
  58816. * @param csg The CSG to subtract against this CSG
  58817. * @returns A new CSG
  58818. */
  58819. subtract(csg: CSG): CSG;
  58820. /**
  58821. * Subtracts this CSG with another CSG in place
  58822. * @param csg The CSG to subtact against this CSG
  58823. */
  58824. subtractInPlace(csg: CSG): void;
  58825. /**
  58826. * Intersect this CSG with another CSG
  58827. * @param csg The CSG to intersect against this CSG
  58828. * @returns A new CSG
  58829. */
  58830. intersect(csg: CSG): CSG;
  58831. /**
  58832. * Intersects this CSG with another CSG in place
  58833. * @param csg The CSG to intersect against this CSG
  58834. */
  58835. intersectInPlace(csg: CSG): void;
  58836. /**
  58837. * Return a new CSG solid with solid and empty space switched. This solid is
  58838. * not modified.
  58839. * @returns A new CSG solid with solid and empty space switched
  58840. */
  58841. inverse(): CSG;
  58842. /**
  58843. * Inverses the CSG in place
  58844. */
  58845. inverseInPlace(): void;
  58846. /**
  58847. * This is used to keep meshes transformations so they can be restored
  58848. * when we build back a Babylon Mesh
  58849. * NB : All CSG operations are performed in world coordinates
  58850. * @param csg The CSG to copy the transform attributes from
  58851. * @returns This CSG
  58852. */
  58853. copyTransformAttributes(csg: CSG): CSG;
  58854. /**
  58855. * Build Raw mesh from CSG
  58856. * Coordinates here are in world space
  58857. * @param name The name of the mesh geometry
  58858. * @param scene The Scene
  58859. * @param keepSubMeshes Specifies if the submeshes should be kept
  58860. * @returns A new Mesh
  58861. */
  58862. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58863. /**
  58864. * Build Mesh from CSG taking material and transforms into account
  58865. * @param name The name of the Mesh
  58866. * @param material The material of the Mesh
  58867. * @param scene The Scene
  58868. * @param keepSubMeshes Specifies if submeshes should be kept
  58869. * @returns The new Mesh
  58870. */
  58871. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58872. }
  58873. }
  58874. declare module "babylonjs/Meshes/trailMesh" {
  58875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58876. import { Mesh } from "babylonjs/Meshes/mesh";
  58877. import { Scene } from "babylonjs/scene";
  58878. /**
  58879. * Class used to create a trail following a mesh
  58880. */
  58881. export class TrailMesh extends Mesh {
  58882. private _generator;
  58883. private _autoStart;
  58884. private _running;
  58885. private _diameter;
  58886. private _length;
  58887. private _sectionPolygonPointsCount;
  58888. private _sectionVectors;
  58889. private _sectionNormalVectors;
  58890. private _beforeRenderObserver;
  58891. /**
  58892. * @constructor
  58893. * @param name The value used by scene.getMeshByName() to do a lookup.
  58894. * @param generator The mesh to generate a trail.
  58895. * @param scene The scene to add this mesh to.
  58896. * @param diameter Diameter of trailing mesh. Default is 1.
  58897. * @param length Length of trailing mesh. Default is 60.
  58898. * @param autoStart Automatically start trailing mesh. Default true.
  58899. */
  58900. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58901. /**
  58902. * "TrailMesh"
  58903. * @returns "TrailMesh"
  58904. */
  58905. getClassName(): string;
  58906. private _createMesh;
  58907. /**
  58908. * Start trailing mesh.
  58909. */
  58910. start(): void;
  58911. /**
  58912. * Stop trailing mesh.
  58913. */
  58914. stop(): void;
  58915. /**
  58916. * Update trailing mesh geometry.
  58917. */
  58918. update(): void;
  58919. /**
  58920. * Returns a new TrailMesh object.
  58921. * @param name is a string, the name given to the new mesh
  58922. * @param newGenerator use new generator object for cloned trail mesh
  58923. * @returns a new mesh
  58924. */
  58925. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58926. /**
  58927. * Serializes this trail mesh
  58928. * @param serializationObject object to write serialization to
  58929. */
  58930. serialize(serializationObject: any): void;
  58931. /**
  58932. * Parses a serialized trail mesh
  58933. * @param parsedMesh the serialized mesh
  58934. * @param scene the scene to create the trail mesh in
  58935. * @returns the created trail mesh
  58936. */
  58937. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58938. }
  58939. }
  58940. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58941. import { Nullable } from "babylonjs/types";
  58942. import { Scene } from "babylonjs/scene";
  58943. import { Vector4 } from "babylonjs/Maths/math.vector";
  58944. import { Color4 } from "babylonjs/Maths/math.color";
  58945. import { Mesh } from "babylonjs/Meshes/mesh";
  58946. /**
  58947. * Class containing static functions to help procedurally build meshes
  58948. */
  58949. export class TiledBoxBuilder {
  58950. /**
  58951. * Creates a box mesh
  58952. * 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)
  58953. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58957. * @param name defines the name of the mesh
  58958. * @param options defines the options used to create the mesh
  58959. * @param scene defines the hosting scene
  58960. * @returns the box mesh
  58961. */
  58962. static CreateTiledBox(name: string, options: {
  58963. pattern?: number;
  58964. width?: number;
  58965. height?: number;
  58966. depth?: number;
  58967. tileSize?: number;
  58968. tileWidth?: number;
  58969. tileHeight?: number;
  58970. alignHorizontal?: number;
  58971. alignVertical?: number;
  58972. faceUV?: Vector4[];
  58973. faceColors?: Color4[];
  58974. sideOrientation?: number;
  58975. updatable?: boolean;
  58976. }, scene?: Nullable<Scene>): Mesh;
  58977. }
  58978. }
  58979. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58980. import { Vector4 } from "babylonjs/Maths/math.vector";
  58981. import { Mesh } from "babylonjs/Meshes/mesh";
  58982. /**
  58983. * Class containing static functions to help procedurally build meshes
  58984. */
  58985. export class TorusKnotBuilder {
  58986. /**
  58987. * Creates a torus knot mesh
  58988. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58989. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58990. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58991. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58995. * @param name defines the name of the mesh
  58996. * @param options defines the options used to create the mesh
  58997. * @param scene defines the hosting scene
  58998. * @returns the torus knot mesh
  58999. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59000. */
  59001. static CreateTorusKnot(name: string, options: {
  59002. radius?: number;
  59003. tube?: number;
  59004. radialSegments?: number;
  59005. tubularSegments?: number;
  59006. p?: number;
  59007. q?: number;
  59008. updatable?: boolean;
  59009. sideOrientation?: number;
  59010. frontUVs?: Vector4;
  59011. backUVs?: Vector4;
  59012. }, scene: any): Mesh;
  59013. }
  59014. }
  59015. declare module "babylonjs/Meshes/polygonMesh" {
  59016. import { Scene } from "babylonjs/scene";
  59017. import { Vector2 } from "babylonjs/Maths/math.vector";
  59018. import { Mesh } from "babylonjs/Meshes/mesh";
  59019. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59020. import { Path2 } from "babylonjs/Maths/math.path";
  59021. /**
  59022. * Polygon
  59023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59024. */
  59025. export class Polygon {
  59026. /**
  59027. * Creates a rectangle
  59028. * @param xmin bottom X coord
  59029. * @param ymin bottom Y coord
  59030. * @param xmax top X coord
  59031. * @param ymax top Y coord
  59032. * @returns points that make the resulting rectation
  59033. */
  59034. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59035. /**
  59036. * Creates a circle
  59037. * @param radius radius of circle
  59038. * @param cx scale in x
  59039. * @param cy scale in y
  59040. * @param numberOfSides number of sides that make up the circle
  59041. * @returns points that make the resulting circle
  59042. */
  59043. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59044. /**
  59045. * Creates a polygon from input string
  59046. * @param input Input polygon data
  59047. * @returns the parsed points
  59048. */
  59049. static Parse(input: string): Vector2[];
  59050. /**
  59051. * Starts building a polygon from x and y coordinates
  59052. * @param x x coordinate
  59053. * @param y y coordinate
  59054. * @returns the started path2
  59055. */
  59056. static StartingAt(x: number, y: number): Path2;
  59057. }
  59058. /**
  59059. * Builds a polygon
  59060. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59061. */
  59062. export class PolygonMeshBuilder {
  59063. private _points;
  59064. private _outlinepoints;
  59065. private _holes;
  59066. private _name;
  59067. private _scene;
  59068. private _epoints;
  59069. private _eholes;
  59070. private _addToepoint;
  59071. /**
  59072. * Babylon reference to the earcut plugin.
  59073. */
  59074. bjsEarcut: any;
  59075. /**
  59076. * Creates a PolygonMeshBuilder
  59077. * @param name name of the builder
  59078. * @param contours Path of the polygon
  59079. * @param scene scene to add to when creating the mesh
  59080. * @param earcutInjection can be used to inject your own earcut reference
  59081. */
  59082. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59083. /**
  59084. * Adds a whole within the polygon
  59085. * @param hole Array of points defining the hole
  59086. * @returns this
  59087. */
  59088. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59089. /**
  59090. * Creates the polygon
  59091. * @param updatable If the mesh should be updatable
  59092. * @param depth The depth of the mesh created
  59093. * @returns the created mesh
  59094. */
  59095. build(updatable?: boolean, depth?: number): Mesh;
  59096. /**
  59097. * Creates the polygon
  59098. * @param depth The depth of the mesh created
  59099. * @returns the created VertexData
  59100. */
  59101. buildVertexData(depth?: number): VertexData;
  59102. /**
  59103. * Adds a side to the polygon
  59104. * @param positions points that make the polygon
  59105. * @param normals normals of the polygon
  59106. * @param uvs uvs of the polygon
  59107. * @param indices indices of the polygon
  59108. * @param bounds bounds of the polygon
  59109. * @param points points of the polygon
  59110. * @param depth depth of the polygon
  59111. * @param flip flip of the polygon
  59112. */
  59113. private addSide;
  59114. }
  59115. }
  59116. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59117. import { Scene } from "babylonjs/scene";
  59118. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59119. import { Color4 } from "babylonjs/Maths/math.color";
  59120. import { Mesh } from "babylonjs/Meshes/mesh";
  59121. import { Nullable } from "babylonjs/types";
  59122. /**
  59123. * Class containing static functions to help procedurally build meshes
  59124. */
  59125. export class PolygonBuilder {
  59126. /**
  59127. * Creates a polygon mesh
  59128. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59129. * * 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
  59130. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59133. * * Remember you can only change the shape positions, not their number when updating a polygon
  59134. * @param name defines the name of the mesh
  59135. * @param options defines the options used to create the mesh
  59136. * @param scene defines the hosting scene
  59137. * @param earcutInjection can be used to inject your own earcut reference
  59138. * @returns the polygon mesh
  59139. */
  59140. static CreatePolygon(name: string, options: {
  59141. shape: Vector3[];
  59142. holes?: Vector3[][];
  59143. depth?: number;
  59144. faceUV?: Vector4[];
  59145. faceColors?: Color4[];
  59146. updatable?: boolean;
  59147. sideOrientation?: number;
  59148. frontUVs?: Vector4;
  59149. backUVs?: Vector4;
  59150. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59151. /**
  59152. * Creates an extruded polygon mesh, with depth in the Y direction.
  59153. * * 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)
  59154. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59155. * @param name defines the name of the mesh
  59156. * @param options defines the options used to create the mesh
  59157. * @param scene defines the hosting scene
  59158. * @param earcutInjection can be used to inject your own earcut reference
  59159. * @returns the polygon mesh
  59160. */
  59161. static ExtrudePolygon(name: string, options: {
  59162. shape: Vector3[];
  59163. holes?: Vector3[][];
  59164. depth?: number;
  59165. faceUV?: Vector4[];
  59166. faceColors?: Color4[];
  59167. updatable?: boolean;
  59168. sideOrientation?: number;
  59169. frontUVs?: Vector4;
  59170. backUVs?: Vector4;
  59171. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59172. }
  59173. }
  59174. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59175. import { Scene } from "babylonjs/scene";
  59176. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59177. import { Mesh } from "babylonjs/Meshes/mesh";
  59178. import { Nullable } from "babylonjs/types";
  59179. /**
  59180. * Class containing static functions to help procedurally build meshes
  59181. */
  59182. export class LatheBuilder {
  59183. /**
  59184. * Creates lathe mesh.
  59185. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59186. * * 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
  59187. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59188. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59189. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59190. * * 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
  59191. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59192. * * 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
  59193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59197. * @param name defines the name of the mesh
  59198. * @param options defines the options used to create the mesh
  59199. * @param scene defines the hosting scene
  59200. * @returns the lathe mesh
  59201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59202. */
  59203. static CreateLathe(name: string, options: {
  59204. shape: Vector3[];
  59205. radius?: number;
  59206. tessellation?: number;
  59207. clip?: number;
  59208. arc?: number;
  59209. closed?: boolean;
  59210. updatable?: boolean;
  59211. sideOrientation?: number;
  59212. frontUVs?: Vector4;
  59213. backUVs?: Vector4;
  59214. cap?: number;
  59215. invertUV?: boolean;
  59216. }, scene?: Nullable<Scene>): Mesh;
  59217. }
  59218. }
  59219. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59220. import { Nullable } from "babylonjs/types";
  59221. import { Scene } from "babylonjs/scene";
  59222. import { Vector4 } from "babylonjs/Maths/math.vector";
  59223. import { Mesh } from "babylonjs/Meshes/mesh";
  59224. /**
  59225. * Class containing static functions to help procedurally build meshes
  59226. */
  59227. export class TiledPlaneBuilder {
  59228. /**
  59229. * Creates a tiled plane mesh
  59230. * * The parameter `pattern` will, depending on value, do nothing or
  59231. * * * flip (reflect about central vertical) alternate tiles across and up
  59232. * * * flip every tile on alternate rows
  59233. * * * rotate (180 degs) alternate tiles across and up
  59234. * * * rotate every tile on alternate rows
  59235. * * * flip and rotate alternate tiles across and up
  59236. * * * flip and rotate every tile on alternate rows
  59237. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59238. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59241. * * 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)
  59242. * * 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)
  59243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59244. * @param name defines the name of the mesh
  59245. * @param options defines the options used to create the mesh
  59246. * @param scene defines the hosting scene
  59247. * @returns the box mesh
  59248. */
  59249. static CreateTiledPlane(name: string, options: {
  59250. pattern?: number;
  59251. tileSize?: number;
  59252. tileWidth?: number;
  59253. tileHeight?: number;
  59254. size?: number;
  59255. width?: number;
  59256. height?: number;
  59257. alignHorizontal?: number;
  59258. alignVertical?: number;
  59259. sideOrientation?: number;
  59260. frontUVs?: Vector4;
  59261. backUVs?: Vector4;
  59262. updatable?: boolean;
  59263. }, scene?: Nullable<Scene>): Mesh;
  59264. }
  59265. }
  59266. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59267. import { Nullable } from "babylonjs/types";
  59268. import { Scene } from "babylonjs/scene";
  59269. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59270. import { Mesh } from "babylonjs/Meshes/mesh";
  59271. /**
  59272. * Class containing static functions to help procedurally build meshes
  59273. */
  59274. export class TubeBuilder {
  59275. /**
  59276. * Creates a tube mesh.
  59277. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59278. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59279. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59280. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59281. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59282. * * 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)
  59283. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59284. * * 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
  59285. * * 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
  59286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59288. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59290. * @param name defines the name of the mesh
  59291. * @param options defines the options used to create the mesh
  59292. * @param scene defines the hosting scene
  59293. * @returns the tube mesh
  59294. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59295. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59296. */
  59297. static CreateTube(name: string, options: {
  59298. path: Vector3[];
  59299. radius?: number;
  59300. tessellation?: number;
  59301. radiusFunction?: {
  59302. (i: number, distance: number): number;
  59303. };
  59304. cap?: number;
  59305. arc?: number;
  59306. updatable?: boolean;
  59307. sideOrientation?: number;
  59308. frontUVs?: Vector4;
  59309. backUVs?: Vector4;
  59310. instance?: Mesh;
  59311. invertUV?: boolean;
  59312. }, scene?: Nullable<Scene>): Mesh;
  59313. }
  59314. }
  59315. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59316. import { Scene } from "babylonjs/scene";
  59317. import { Vector4 } from "babylonjs/Maths/math.vector";
  59318. import { Mesh } from "babylonjs/Meshes/mesh";
  59319. import { Nullable } from "babylonjs/types";
  59320. /**
  59321. * Class containing static functions to help procedurally build meshes
  59322. */
  59323. export class IcoSphereBuilder {
  59324. /**
  59325. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59326. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59327. * * 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`)
  59328. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59329. * * 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
  59330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59333. * @param name defines the name of the mesh
  59334. * @param options defines the options used to create the mesh
  59335. * @param scene defines the hosting scene
  59336. * @returns the icosahedron mesh
  59337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59338. */
  59339. static CreateIcoSphere(name: string, options: {
  59340. radius?: number;
  59341. radiusX?: number;
  59342. radiusY?: number;
  59343. radiusZ?: number;
  59344. flat?: boolean;
  59345. subdivisions?: number;
  59346. sideOrientation?: number;
  59347. frontUVs?: Vector4;
  59348. backUVs?: Vector4;
  59349. updatable?: boolean;
  59350. }, scene?: Nullable<Scene>): Mesh;
  59351. }
  59352. }
  59353. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59354. import { Vector3 } from "babylonjs/Maths/math.vector";
  59355. import { Mesh } from "babylonjs/Meshes/mesh";
  59356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59357. /**
  59358. * Class containing static functions to help procedurally build meshes
  59359. */
  59360. export class DecalBuilder {
  59361. /**
  59362. * Creates a decal mesh.
  59363. * 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
  59364. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59365. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59366. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59367. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59368. * @param name defines the name of the mesh
  59369. * @param sourceMesh defines the mesh where the decal must be applied
  59370. * @param options defines the options used to create the mesh
  59371. * @param scene defines the hosting scene
  59372. * @returns the decal mesh
  59373. * @see https://doc.babylonjs.com/how_to/decals
  59374. */
  59375. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59376. position?: Vector3;
  59377. normal?: Vector3;
  59378. size?: Vector3;
  59379. angle?: number;
  59380. }): Mesh;
  59381. }
  59382. }
  59383. declare module "babylonjs/Meshes/meshBuilder" {
  59384. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59385. import { Nullable } from "babylonjs/types";
  59386. import { Scene } from "babylonjs/scene";
  59387. import { Mesh } from "babylonjs/Meshes/mesh";
  59388. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59389. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59391. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59392. import { Plane } from "babylonjs/Maths/math.plane";
  59393. /**
  59394. * Class containing static functions to help procedurally build meshes
  59395. */
  59396. export class MeshBuilder {
  59397. /**
  59398. * Creates a box mesh
  59399. * * The parameter `size` sets the size (float) of each box side (default 1)
  59400. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59401. * * 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)
  59402. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59406. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59407. * @param name defines the name of the mesh
  59408. * @param options defines the options used to create the mesh
  59409. * @param scene defines the hosting scene
  59410. * @returns the box mesh
  59411. */
  59412. static CreateBox(name: string, options: {
  59413. size?: number;
  59414. width?: number;
  59415. height?: number;
  59416. depth?: number;
  59417. faceUV?: Vector4[];
  59418. faceColors?: Color4[];
  59419. sideOrientation?: number;
  59420. frontUVs?: Vector4;
  59421. backUVs?: Vector4;
  59422. updatable?: boolean;
  59423. }, scene?: Nullable<Scene>): Mesh;
  59424. /**
  59425. * Creates a tiled box mesh
  59426. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59428. * @param name defines the name of the mesh
  59429. * @param options defines the options used to create the mesh
  59430. * @param scene defines the hosting scene
  59431. * @returns the tiled box mesh
  59432. */
  59433. static CreateTiledBox(name: string, options: {
  59434. pattern?: number;
  59435. size?: number;
  59436. width?: number;
  59437. height?: number;
  59438. depth: number;
  59439. tileSize?: number;
  59440. tileWidth?: number;
  59441. tileHeight?: number;
  59442. faceUV?: Vector4[];
  59443. faceColors?: Color4[];
  59444. alignHorizontal?: number;
  59445. alignVertical?: number;
  59446. sideOrientation?: number;
  59447. updatable?: boolean;
  59448. }, scene?: Nullable<Scene>): Mesh;
  59449. /**
  59450. * Creates a sphere mesh
  59451. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59452. * * 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`)
  59453. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59454. * * 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
  59455. * * 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)
  59456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59459. * @param name defines the name of the mesh
  59460. * @param options defines the options used to create the mesh
  59461. * @param scene defines the hosting scene
  59462. * @returns the sphere mesh
  59463. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59464. */
  59465. static CreateSphere(name: string, options: {
  59466. segments?: number;
  59467. diameter?: number;
  59468. diameterX?: number;
  59469. diameterY?: number;
  59470. diameterZ?: number;
  59471. arc?: number;
  59472. slice?: number;
  59473. sideOrientation?: number;
  59474. frontUVs?: Vector4;
  59475. backUVs?: Vector4;
  59476. updatable?: boolean;
  59477. }, scene?: Nullable<Scene>): Mesh;
  59478. /**
  59479. * Creates a plane polygonal mesh. By default, this is a disc
  59480. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59481. * * 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
  59482. * * 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
  59483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59486. * @param name defines the name of the mesh
  59487. * @param options defines the options used to create the mesh
  59488. * @param scene defines the hosting scene
  59489. * @returns the plane polygonal mesh
  59490. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59491. */
  59492. static CreateDisc(name: string, options: {
  59493. radius?: number;
  59494. tessellation?: number;
  59495. arc?: number;
  59496. updatable?: boolean;
  59497. sideOrientation?: number;
  59498. frontUVs?: Vector4;
  59499. backUVs?: Vector4;
  59500. }, scene?: Nullable<Scene>): Mesh;
  59501. /**
  59502. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59503. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59504. * * 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`)
  59505. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59506. * * 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
  59507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59510. * @param name defines the name of the mesh
  59511. * @param options defines the options used to create the mesh
  59512. * @param scene defines the hosting scene
  59513. * @returns the icosahedron mesh
  59514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59515. */
  59516. static CreateIcoSphere(name: string, options: {
  59517. radius?: number;
  59518. radiusX?: number;
  59519. radiusY?: number;
  59520. radiusZ?: number;
  59521. flat?: boolean;
  59522. subdivisions?: number;
  59523. sideOrientation?: number;
  59524. frontUVs?: Vector4;
  59525. backUVs?: Vector4;
  59526. updatable?: boolean;
  59527. }, scene?: Nullable<Scene>): Mesh;
  59528. /**
  59529. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59530. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59531. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59532. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59533. * * 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
  59534. * * 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
  59535. * * 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
  59536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59539. * * 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
  59540. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59541. * * 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
  59542. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59544. * @param name defines the name of the mesh
  59545. * @param options defines the options used to create the mesh
  59546. * @param scene defines the hosting scene
  59547. * @returns the ribbon mesh
  59548. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59550. */
  59551. static CreateRibbon(name: string, options: {
  59552. pathArray: Vector3[][];
  59553. closeArray?: boolean;
  59554. closePath?: boolean;
  59555. offset?: number;
  59556. updatable?: boolean;
  59557. sideOrientation?: number;
  59558. frontUVs?: Vector4;
  59559. backUVs?: Vector4;
  59560. instance?: Mesh;
  59561. invertUV?: boolean;
  59562. uvs?: Vector2[];
  59563. colors?: Color4[];
  59564. }, scene?: Nullable<Scene>): Mesh;
  59565. /**
  59566. * Creates a cylinder or a cone mesh
  59567. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59568. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59569. * * 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.
  59570. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59571. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59572. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59573. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59574. * * 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).
  59575. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59576. * * 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).
  59577. * * 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
  59578. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59579. * * 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
  59580. * * 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.
  59581. * * If `enclose` is false, a ring surface is one element.
  59582. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59583. * * 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
  59584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59587. * @param name defines the name of the mesh
  59588. * @param options defines the options used to create the mesh
  59589. * @param scene defines the hosting scene
  59590. * @returns the cylinder mesh
  59591. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59592. */
  59593. static CreateCylinder(name: string, options: {
  59594. height?: number;
  59595. diameterTop?: number;
  59596. diameterBottom?: number;
  59597. diameter?: number;
  59598. tessellation?: number;
  59599. subdivisions?: number;
  59600. arc?: number;
  59601. faceColors?: Color4[];
  59602. faceUV?: Vector4[];
  59603. updatable?: boolean;
  59604. hasRings?: boolean;
  59605. enclose?: boolean;
  59606. cap?: number;
  59607. sideOrientation?: number;
  59608. frontUVs?: Vector4;
  59609. backUVs?: Vector4;
  59610. }, scene?: Nullable<Scene>): Mesh;
  59611. /**
  59612. * Creates a torus mesh
  59613. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59614. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59615. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59619. * @param name defines the name of the mesh
  59620. * @param options defines the options used to create the mesh
  59621. * @param scene defines the hosting scene
  59622. * @returns the torus mesh
  59623. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59624. */
  59625. static CreateTorus(name: string, options: {
  59626. diameter?: number;
  59627. thickness?: number;
  59628. tessellation?: number;
  59629. updatable?: boolean;
  59630. sideOrientation?: number;
  59631. frontUVs?: Vector4;
  59632. backUVs?: Vector4;
  59633. }, scene?: Nullable<Scene>): Mesh;
  59634. /**
  59635. * Creates a torus knot mesh
  59636. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59637. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59638. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59639. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59643. * @param name defines the name of the mesh
  59644. * @param options defines the options used to create the mesh
  59645. * @param scene defines the hosting scene
  59646. * @returns the torus knot mesh
  59647. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59648. */
  59649. static CreateTorusKnot(name: string, options: {
  59650. radius?: number;
  59651. tube?: number;
  59652. radialSegments?: number;
  59653. tubularSegments?: number;
  59654. p?: number;
  59655. q?: number;
  59656. updatable?: boolean;
  59657. sideOrientation?: number;
  59658. frontUVs?: Vector4;
  59659. backUVs?: Vector4;
  59660. }, scene?: Nullable<Scene>): Mesh;
  59661. /**
  59662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59663. * * 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
  59664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59669. * * 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
  59670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59673. * @param name defines the name of the new line system
  59674. * @param options defines the options used to create the line system
  59675. * @param scene defines the hosting scene
  59676. * @returns a new line system mesh
  59677. */
  59678. static CreateLineSystem(name: string, options: {
  59679. lines: Vector3[][];
  59680. updatable?: boolean;
  59681. instance?: Nullable<LinesMesh>;
  59682. colors?: Nullable<Color4[][]>;
  59683. useVertexAlpha?: boolean;
  59684. }, scene: Nullable<Scene>): LinesMesh;
  59685. /**
  59686. * Creates a line mesh
  59687. * 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
  59688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59689. * * The parameter `points` is an array successive Vector3
  59690. * * 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
  59691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59693. * * When updating an instance, remember that only point positions can change, not the number of points
  59694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59696. * @param name defines the name of the new line system
  59697. * @param options defines the options used to create the line system
  59698. * @param scene defines the hosting scene
  59699. * @returns a new line mesh
  59700. */
  59701. static CreateLines(name: string, options: {
  59702. points: Vector3[];
  59703. updatable?: boolean;
  59704. instance?: Nullable<LinesMesh>;
  59705. colors?: Color4[];
  59706. useVertexAlpha?: boolean;
  59707. }, scene?: Nullable<Scene>): LinesMesh;
  59708. /**
  59709. * Creates a dashed line mesh
  59710. * * 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
  59711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59712. * * The parameter `points` is an array successive Vector3
  59713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59716. * * 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
  59717. * * When updating an instance, remember that only point positions can change, not the number of points
  59718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59719. * @param name defines the name of the mesh
  59720. * @param options defines the options used to create the mesh
  59721. * @param scene defines the hosting scene
  59722. * @returns the dashed line mesh
  59723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59724. */
  59725. static CreateDashedLines(name: string, options: {
  59726. points: Vector3[];
  59727. dashSize?: number;
  59728. gapSize?: number;
  59729. dashNb?: number;
  59730. updatable?: boolean;
  59731. instance?: LinesMesh;
  59732. }, scene?: Nullable<Scene>): LinesMesh;
  59733. /**
  59734. * 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.
  59735. * * 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.
  59736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59737. * * 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.
  59738. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59739. * * 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
  59740. * * 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
  59741. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59746. * @param name defines the name of the mesh
  59747. * @param options defines the options used to create the mesh
  59748. * @param scene defines the hosting scene
  59749. * @returns the extruded shape mesh
  59750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59752. */
  59753. static ExtrudeShape(name: string, options: {
  59754. shape: Vector3[];
  59755. path: Vector3[];
  59756. scale?: number;
  59757. rotation?: number;
  59758. cap?: number;
  59759. updatable?: boolean;
  59760. sideOrientation?: number;
  59761. frontUVs?: Vector4;
  59762. backUVs?: Vector4;
  59763. instance?: Mesh;
  59764. invertUV?: boolean;
  59765. }, scene?: Nullable<Scene>): Mesh;
  59766. /**
  59767. * Creates an custom extruded shape mesh.
  59768. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59769. * * 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.
  59770. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59771. * * 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
  59772. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59773. * * 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
  59774. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59775. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59776. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59777. * * 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
  59778. * * 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
  59779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59784. * @param name defines the name of the mesh
  59785. * @param options defines the options used to create the mesh
  59786. * @param scene defines the hosting scene
  59787. * @returns the custom extruded shape mesh
  59788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59791. */
  59792. static ExtrudeShapeCustom(name: string, options: {
  59793. shape: Vector3[];
  59794. path: Vector3[];
  59795. scaleFunction?: any;
  59796. rotationFunction?: any;
  59797. ribbonCloseArray?: boolean;
  59798. ribbonClosePath?: boolean;
  59799. cap?: number;
  59800. updatable?: boolean;
  59801. sideOrientation?: number;
  59802. frontUVs?: Vector4;
  59803. backUVs?: Vector4;
  59804. instance?: Mesh;
  59805. invertUV?: boolean;
  59806. }, scene?: Nullable<Scene>): Mesh;
  59807. /**
  59808. * Creates lathe mesh.
  59809. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59810. * * 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
  59811. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59812. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59813. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59814. * * 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
  59815. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59816. * * 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
  59817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59821. * @param name defines the name of the mesh
  59822. * @param options defines the options used to create the mesh
  59823. * @param scene defines the hosting scene
  59824. * @returns the lathe mesh
  59825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59826. */
  59827. static CreateLathe(name: string, options: {
  59828. shape: Vector3[];
  59829. radius?: number;
  59830. tessellation?: number;
  59831. clip?: number;
  59832. arc?: number;
  59833. closed?: boolean;
  59834. updatable?: boolean;
  59835. sideOrientation?: number;
  59836. frontUVs?: Vector4;
  59837. backUVs?: Vector4;
  59838. cap?: number;
  59839. invertUV?: boolean;
  59840. }, scene?: Nullable<Scene>): Mesh;
  59841. /**
  59842. * Creates a tiled plane mesh
  59843. * * You can set a limited pattern arrangement with the tiles
  59844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59847. * @param name defines the name of the mesh
  59848. * @param options defines the options used to create the mesh
  59849. * @param scene defines the hosting scene
  59850. * @returns the plane mesh
  59851. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59852. */
  59853. static CreateTiledPlane(name: string, options: {
  59854. pattern?: number;
  59855. tileSize?: number;
  59856. tileWidth?: number;
  59857. tileHeight?: number;
  59858. size?: number;
  59859. width?: number;
  59860. height?: number;
  59861. alignHorizontal?: number;
  59862. alignVertical?: number;
  59863. sideOrientation?: number;
  59864. frontUVs?: Vector4;
  59865. backUVs?: Vector4;
  59866. updatable?: boolean;
  59867. }, scene?: Nullable<Scene>): Mesh;
  59868. /**
  59869. * Creates a plane mesh
  59870. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59871. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59872. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59876. * @param name defines the name of the mesh
  59877. * @param options defines the options used to create the mesh
  59878. * @param scene defines the hosting scene
  59879. * @returns the plane mesh
  59880. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59881. */
  59882. static CreatePlane(name: string, options: {
  59883. size?: number;
  59884. width?: number;
  59885. height?: number;
  59886. sideOrientation?: number;
  59887. frontUVs?: Vector4;
  59888. backUVs?: Vector4;
  59889. updatable?: boolean;
  59890. sourcePlane?: Plane;
  59891. }, scene?: Nullable<Scene>): Mesh;
  59892. /**
  59893. * Creates a ground mesh
  59894. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59895. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59897. * @param name defines the name of the mesh
  59898. * @param options defines the options used to create the mesh
  59899. * @param scene defines the hosting scene
  59900. * @returns the ground mesh
  59901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59902. */
  59903. static CreateGround(name: string, options: {
  59904. width?: number;
  59905. height?: number;
  59906. subdivisions?: number;
  59907. subdivisionsX?: number;
  59908. subdivisionsY?: number;
  59909. updatable?: boolean;
  59910. }, scene?: Nullable<Scene>): Mesh;
  59911. /**
  59912. * Creates a tiled ground mesh
  59913. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59914. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59915. * * 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
  59916. * * 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
  59917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59918. * @param name defines the name of the mesh
  59919. * @param options defines the options used to create the mesh
  59920. * @param scene defines the hosting scene
  59921. * @returns the tiled ground mesh
  59922. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59923. */
  59924. static CreateTiledGround(name: string, options: {
  59925. xmin: number;
  59926. zmin: number;
  59927. xmax: number;
  59928. zmax: number;
  59929. subdivisions?: {
  59930. w: number;
  59931. h: number;
  59932. };
  59933. precision?: {
  59934. w: number;
  59935. h: number;
  59936. };
  59937. updatable?: boolean;
  59938. }, scene?: Nullable<Scene>): Mesh;
  59939. /**
  59940. * Creates a ground mesh from a height map
  59941. * * The parameter `url` sets the URL of the height map image resource.
  59942. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59943. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59944. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59945. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59946. * * 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.
  59947. * * 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).
  59948. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59950. * @param name defines the name of the mesh
  59951. * @param url defines the url to the height map
  59952. * @param options defines the options used to create the mesh
  59953. * @param scene defines the hosting scene
  59954. * @returns the ground mesh
  59955. * @see https://doc.babylonjs.com/babylon101/height_map
  59956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59957. */
  59958. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59959. width?: number;
  59960. height?: number;
  59961. subdivisions?: number;
  59962. minHeight?: number;
  59963. maxHeight?: number;
  59964. colorFilter?: Color3;
  59965. alphaFilter?: number;
  59966. updatable?: boolean;
  59967. onReady?: (mesh: GroundMesh) => void;
  59968. }, scene?: Nullable<Scene>): GroundMesh;
  59969. /**
  59970. * Creates a polygon mesh
  59971. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59972. * * 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
  59973. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59976. * * Remember you can only change the shape positions, not their number when updating a polygon
  59977. * @param name defines the name of the mesh
  59978. * @param options defines the options used to create the mesh
  59979. * @param scene defines the hosting scene
  59980. * @param earcutInjection can be used to inject your own earcut reference
  59981. * @returns the polygon mesh
  59982. */
  59983. static CreatePolygon(name: string, options: {
  59984. shape: Vector3[];
  59985. holes?: Vector3[][];
  59986. depth?: number;
  59987. faceUV?: Vector4[];
  59988. faceColors?: Color4[];
  59989. updatable?: boolean;
  59990. sideOrientation?: number;
  59991. frontUVs?: Vector4;
  59992. backUVs?: Vector4;
  59993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59994. /**
  59995. * Creates an extruded polygon mesh, with depth in the Y direction.
  59996. * * 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)
  59997. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59998. * @param name defines the name of the mesh
  59999. * @param options defines the options used to create the mesh
  60000. * @param scene defines the hosting scene
  60001. * @param earcutInjection can be used to inject your own earcut reference
  60002. * @returns the polygon mesh
  60003. */
  60004. static ExtrudePolygon(name: string, options: {
  60005. shape: Vector3[];
  60006. holes?: Vector3[][];
  60007. depth?: number;
  60008. faceUV?: Vector4[];
  60009. faceColors?: Color4[];
  60010. updatable?: boolean;
  60011. sideOrientation?: number;
  60012. frontUVs?: Vector4;
  60013. backUVs?: Vector4;
  60014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60015. /**
  60016. * Creates a tube mesh.
  60017. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60018. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60019. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60020. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60021. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60022. * * 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)
  60023. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60024. * * 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
  60025. * * 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
  60026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60030. * @param name defines the name of the mesh
  60031. * @param options defines the options used to create the mesh
  60032. * @param scene defines the hosting scene
  60033. * @returns the tube mesh
  60034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60035. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60036. */
  60037. static CreateTube(name: string, options: {
  60038. path: Vector3[];
  60039. radius?: number;
  60040. tessellation?: number;
  60041. radiusFunction?: {
  60042. (i: number, distance: number): number;
  60043. };
  60044. cap?: number;
  60045. arc?: number;
  60046. updatable?: boolean;
  60047. sideOrientation?: number;
  60048. frontUVs?: Vector4;
  60049. backUVs?: Vector4;
  60050. instance?: Mesh;
  60051. invertUV?: boolean;
  60052. }, scene?: Nullable<Scene>): Mesh;
  60053. /**
  60054. * Creates a polyhedron mesh
  60055. * * 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
  60056. * * The parameter `size` (positive float, default 1) sets the polygon size
  60057. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60058. * * 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`
  60059. * * 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
  60060. * * 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)`)
  60061. * * 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
  60062. * * 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
  60063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60066. * @param name defines the name of the mesh
  60067. * @param options defines the options used to create the mesh
  60068. * @param scene defines the hosting scene
  60069. * @returns the polyhedron mesh
  60070. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60071. */
  60072. static CreatePolyhedron(name: string, options: {
  60073. type?: number;
  60074. size?: number;
  60075. sizeX?: number;
  60076. sizeY?: number;
  60077. sizeZ?: number;
  60078. custom?: any;
  60079. faceUV?: Vector4[];
  60080. faceColors?: Color4[];
  60081. flat?: boolean;
  60082. updatable?: boolean;
  60083. sideOrientation?: number;
  60084. frontUVs?: Vector4;
  60085. backUVs?: Vector4;
  60086. }, scene?: Nullable<Scene>): Mesh;
  60087. /**
  60088. * Creates a decal mesh.
  60089. * 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
  60090. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60091. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60092. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60093. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60094. * @param name defines the name of the mesh
  60095. * @param sourceMesh defines the mesh where the decal must be applied
  60096. * @param options defines the options used to create the mesh
  60097. * @param scene defines the hosting scene
  60098. * @returns the decal mesh
  60099. * @see https://doc.babylonjs.com/how_to/decals
  60100. */
  60101. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60102. position?: Vector3;
  60103. normal?: Vector3;
  60104. size?: Vector3;
  60105. angle?: number;
  60106. }): Mesh;
  60107. }
  60108. }
  60109. declare module "babylonjs/Meshes/meshSimplification" {
  60110. import { Mesh } from "babylonjs/Meshes/mesh";
  60111. /**
  60112. * A simplifier interface for future simplification implementations
  60113. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60114. */
  60115. export interface ISimplifier {
  60116. /**
  60117. * Simplification of a given mesh according to the given settings.
  60118. * Since this requires computation, it is assumed that the function runs async.
  60119. * @param settings The settings of the simplification, including quality and distance
  60120. * @param successCallback A callback that will be called after the mesh was simplified.
  60121. * @param errorCallback in case of an error, this callback will be called. optional.
  60122. */
  60123. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60124. }
  60125. /**
  60126. * Expected simplification settings.
  60127. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60129. */
  60130. export interface ISimplificationSettings {
  60131. /**
  60132. * Gets or sets the expected quality
  60133. */
  60134. quality: number;
  60135. /**
  60136. * Gets or sets the distance when this optimized version should be used
  60137. */
  60138. distance: number;
  60139. /**
  60140. * Gets an already optimized mesh
  60141. */
  60142. optimizeMesh?: boolean;
  60143. }
  60144. /**
  60145. * Class used to specify simplification options
  60146. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60147. */
  60148. export class SimplificationSettings implements ISimplificationSettings {
  60149. /** expected quality */
  60150. quality: number;
  60151. /** distance when this optimized version should be used */
  60152. distance: number;
  60153. /** already optimized mesh */
  60154. optimizeMesh?: boolean | undefined;
  60155. /**
  60156. * Creates a SimplificationSettings
  60157. * @param quality expected quality
  60158. * @param distance distance when this optimized version should be used
  60159. * @param optimizeMesh already optimized mesh
  60160. */
  60161. constructor(
  60162. /** expected quality */
  60163. quality: number,
  60164. /** distance when this optimized version should be used */
  60165. distance: number,
  60166. /** already optimized mesh */
  60167. optimizeMesh?: boolean | undefined);
  60168. }
  60169. /**
  60170. * Interface used to define a simplification task
  60171. */
  60172. export interface ISimplificationTask {
  60173. /**
  60174. * Array of settings
  60175. */
  60176. settings: Array<ISimplificationSettings>;
  60177. /**
  60178. * Simplification type
  60179. */
  60180. simplificationType: SimplificationType;
  60181. /**
  60182. * Mesh to simplify
  60183. */
  60184. mesh: Mesh;
  60185. /**
  60186. * Callback called on success
  60187. */
  60188. successCallback?: () => void;
  60189. /**
  60190. * Defines if parallel processing can be used
  60191. */
  60192. parallelProcessing: boolean;
  60193. }
  60194. /**
  60195. * Queue used to order the simplification tasks
  60196. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60197. */
  60198. export class SimplificationQueue {
  60199. private _simplificationArray;
  60200. /**
  60201. * Gets a boolean indicating that the process is still running
  60202. */
  60203. running: boolean;
  60204. /**
  60205. * Creates a new queue
  60206. */
  60207. constructor();
  60208. /**
  60209. * Adds a new simplification task
  60210. * @param task defines a task to add
  60211. */
  60212. addTask(task: ISimplificationTask): void;
  60213. /**
  60214. * Execute next task
  60215. */
  60216. executeNext(): void;
  60217. /**
  60218. * Execute a simplification task
  60219. * @param task defines the task to run
  60220. */
  60221. runSimplification(task: ISimplificationTask): void;
  60222. private getSimplifier;
  60223. }
  60224. /**
  60225. * The implemented types of simplification
  60226. * At the moment only Quadratic Error Decimation is implemented
  60227. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60228. */
  60229. export enum SimplificationType {
  60230. /** Quadratic error decimation */
  60231. QUADRATIC = 0
  60232. }
  60233. }
  60234. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60235. import { Scene } from "babylonjs/scene";
  60236. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60237. import { ISceneComponent } from "babylonjs/sceneComponent";
  60238. module "babylonjs/scene" {
  60239. interface Scene {
  60240. /** @hidden (Backing field) */
  60241. _simplificationQueue: SimplificationQueue;
  60242. /**
  60243. * Gets or sets the simplification queue attached to the scene
  60244. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60245. */
  60246. simplificationQueue: SimplificationQueue;
  60247. }
  60248. }
  60249. module "babylonjs/Meshes/mesh" {
  60250. interface Mesh {
  60251. /**
  60252. * Simplify the mesh according to the given array of settings.
  60253. * Function will return immediately and will simplify async
  60254. * @param settings a collection of simplification settings
  60255. * @param parallelProcessing should all levels calculate parallel or one after the other
  60256. * @param simplificationType the type of simplification to run
  60257. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60258. * @returns the current mesh
  60259. */
  60260. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60261. }
  60262. }
  60263. /**
  60264. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60265. * created in a scene
  60266. */
  60267. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60268. /**
  60269. * The component name helpfull to identify the component in the list of scene components.
  60270. */
  60271. readonly name: string;
  60272. /**
  60273. * The scene the component belongs to.
  60274. */
  60275. scene: Scene;
  60276. /**
  60277. * Creates a new instance of the component for the given scene
  60278. * @param scene Defines the scene to register the component in
  60279. */
  60280. constructor(scene: Scene);
  60281. /**
  60282. * Registers the component in a given scene
  60283. */
  60284. register(): void;
  60285. /**
  60286. * Rebuilds the elements related to this component in case of
  60287. * context lost for instance.
  60288. */
  60289. rebuild(): void;
  60290. /**
  60291. * Disposes the component and the associated ressources
  60292. */
  60293. dispose(): void;
  60294. private _beforeCameraUpdate;
  60295. }
  60296. }
  60297. declare module "babylonjs/Meshes/Builders/index" {
  60298. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60299. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60300. export * from "babylonjs/Meshes/Builders/discBuilder";
  60301. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60302. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60303. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60304. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60305. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60306. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60307. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60308. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60309. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60310. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60311. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60312. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60313. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60314. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60315. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60316. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60317. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60318. }
  60319. declare module "babylonjs/Meshes/index" {
  60320. export * from "babylonjs/Meshes/abstractMesh";
  60321. export * from "babylonjs/Meshes/buffer";
  60322. export * from "babylonjs/Meshes/Compression/index";
  60323. export * from "babylonjs/Meshes/csg";
  60324. export * from "babylonjs/Meshes/geometry";
  60325. export * from "babylonjs/Meshes/groundMesh";
  60326. export * from "babylonjs/Meshes/trailMesh";
  60327. export * from "babylonjs/Meshes/instancedMesh";
  60328. export * from "babylonjs/Meshes/linesMesh";
  60329. export * from "babylonjs/Meshes/mesh";
  60330. export * from "babylonjs/Meshes/mesh.vertexData";
  60331. export * from "babylonjs/Meshes/meshBuilder";
  60332. export * from "babylonjs/Meshes/meshSimplification";
  60333. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60334. export * from "babylonjs/Meshes/polygonMesh";
  60335. export * from "babylonjs/Meshes/subMesh";
  60336. export * from "babylonjs/Meshes/meshLODLevel";
  60337. export * from "babylonjs/Meshes/transformNode";
  60338. export * from "babylonjs/Meshes/Builders/index";
  60339. export * from "babylonjs/Meshes/dataBuffer";
  60340. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60341. }
  60342. declare module "babylonjs/Morph/index" {
  60343. export * from "babylonjs/Morph/morphTarget";
  60344. export * from "babylonjs/Morph/morphTargetManager";
  60345. }
  60346. declare module "babylonjs/Navigation/INavigationEngine" {
  60347. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60348. import { Vector3 } from "babylonjs/Maths/math";
  60349. import { Mesh } from "babylonjs/Meshes/mesh";
  60350. import { Scene } from "babylonjs/scene";
  60351. /**
  60352. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60353. */
  60354. export interface INavigationEnginePlugin {
  60355. /**
  60356. * plugin name
  60357. */
  60358. name: string;
  60359. /**
  60360. * Creates a navigation mesh
  60361. * @param meshes array of all the geometry used to compute the navigatio mesh
  60362. * @param parameters bunch of parameters used to filter geometry
  60363. */
  60364. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60365. /**
  60366. * Create a navigation mesh debug mesh
  60367. * @param scene is where the mesh will be added
  60368. * @returns debug display mesh
  60369. */
  60370. createDebugNavMesh(scene: Scene): Mesh;
  60371. /**
  60372. * Get a navigation mesh constrained position, closest to the parameter position
  60373. * @param position world position
  60374. * @returns the closest point to position constrained by the navigation mesh
  60375. */
  60376. getClosestPoint(position: Vector3): Vector3;
  60377. /**
  60378. * Get a navigation mesh constrained position, within a particular radius
  60379. * @param position world position
  60380. * @param maxRadius the maximum distance to the constrained world position
  60381. * @returns the closest point to position constrained by the navigation mesh
  60382. */
  60383. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60384. /**
  60385. * Compute the final position from a segment made of destination-position
  60386. * @param position world position
  60387. * @param destination world position
  60388. * @returns the resulting point along the navmesh
  60389. */
  60390. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60391. /**
  60392. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60393. * @param start world position
  60394. * @param end world position
  60395. * @returns array containing world position composing the path
  60396. */
  60397. computePath(start: Vector3, end: Vector3): Vector3[];
  60398. /**
  60399. * If this plugin is supported
  60400. * @returns true if plugin is supported
  60401. */
  60402. isSupported(): boolean;
  60403. /**
  60404. * Create a new Crowd so you can add agents
  60405. * @param maxAgents the maximum agent count in the crowd
  60406. * @param maxAgentRadius the maximum radius an agent can have
  60407. * @param scene to attach the crowd to
  60408. * @returns the crowd you can add agents to
  60409. */
  60410. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60411. /**
  60412. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60413. * The queries will try to find a solution within those bounds
  60414. * default is (1,1,1)
  60415. * @param extent x,y,z value that define the extent around the queries point of reference
  60416. */
  60417. setDefaultQueryExtent(extent: Vector3): void;
  60418. /**
  60419. * Get the Bounding box extent specified by setDefaultQueryExtent
  60420. * @returns the box extent values
  60421. */
  60422. getDefaultQueryExtent(): Vector3;
  60423. /**
  60424. * Release all resources
  60425. */
  60426. dispose(): void;
  60427. }
  60428. /**
  60429. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60430. */
  60431. export interface ICrowd {
  60432. /**
  60433. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60434. * You can attach anything to that node. The node position is updated in the scene update tick.
  60435. * @param pos world position that will be constrained by the navigation mesh
  60436. * @param parameters agent parameters
  60437. * @param transform hooked to the agent that will be update by the scene
  60438. * @returns agent index
  60439. */
  60440. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60441. /**
  60442. * Returns the agent position in world space
  60443. * @param index agent index returned by addAgent
  60444. * @returns world space position
  60445. */
  60446. getAgentPosition(index: number): Vector3;
  60447. /**
  60448. * Gets the agent velocity in world space
  60449. * @param index agent index returned by addAgent
  60450. * @returns world space velocity
  60451. */
  60452. getAgentVelocity(index: number): Vector3;
  60453. /**
  60454. * remove a particular agent previously created
  60455. * @param index agent index returned by addAgent
  60456. */
  60457. removeAgent(index: number): void;
  60458. /**
  60459. * get the list of all agents attached to this crowd
  60460. * @returns list of agent indices
  60461. */
  60462. getAgents(): number[];
  60463. /**
  60464. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60465. * @param deltaTime in seconds
  60466. */
  60467. update(deltaTime: number): void;
  60468. /**
  60469. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60470. * @param index agent index returned by addAgent
  60471. * @param destination targeted world position
  60472. */
  60473. agentGoto(index: number, destination: Vector3): void;
  60474. /**
  60475. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60476. * The queries will try to find a solution within those bounds
  60477. * default is (1,1,1)
  60478. * @param extent x,y,z value that define the extent around the queries point of reference
  60479. */
  60480. setDefaultQueryExtent(extent: Vector3): void;
  60481. /**
  60482. * Get the Bounding box extent specified by setDefaultQueryExtent
  60483. * @returns the box extent values
  60484. */
  60485. getDefaultQueryExtent(): Vector3;
  60486. /**
  60487. * Release all resources
  60488. */
  60489. dispose(): void;
  60490. }
  60491. /**
  60492. * Configures an agent
  60493. */
  60494. export interface IAgentParameters {
  60495. /**
  60496. * Agent radius. [Limit: >= 0]
  60497. */
  60498. radius: number;
  60499. /**
  60500. * Agent height. [Limit: > 0]
  60501. */
  60502. height: number;
  60503. /**
  60504. * Maximum allowed acceleration. [Limit: >= 0]
  60505. */
  60506. maxAcceleration: number;
  60507. /**
  60508. * Maximum allowed speed. [Limit: >= 0]
  60509. */
  60510. maxSpeed: number;
  60511. /**
  60512. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60513. */
  60514. collisionQueryRange: number;
  60515. /**
  60516. * The path visibility optimization range. [Limit: > 0]
  60517. */
  60518. pathOptimizationRange: number;
  60519. /**
  60520. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60521. */
  60522. separationWeight: number;
  60523. }
  60524. /**
  60525. * Configures the navigation mesh creation
  60526. */
  60527. export interface INavMeshParameters {
  60528. /**
  60529. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60530. */
  60531. cs: number;
  60532. /**
  60533. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60534. */
  60535. ch: number;
  60536. /**
  60537. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60538. */
  60539. walkableSlopeAngle: number;
  60540. /**
  60541. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60542. * be considered walkable. [Limit: >= 3] [Units: vx]
  60543. */
  60544. walkableHeight: number;
  60545. /**
  60546. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60547. */
  60548. walkableClimb: number;
  60549. /**
  60550. * The distance to erode/shrink the walkable area of the heightfield away from
  60551. * obstructions. [Limit: >=0] [Units: vx]
  60552. */
  60553. walkableRadius: number;
  60554. /**
  60555. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60556. */
  60557. maxEdgeLen: number;
  60558. /**
  60559. * The maximum distance a simplfied contour's border edges should deviate
  60560. * the original raw contour. [Limit: >=0] [Units: vx]
  60561. */
  60562. maxSimplificationError: number;
  60563. /**
  60564. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60565. */
  60566. minRegionArea: number;
  60567. /**
  60568. * Any regions with a span count smaller than this value will, if possible,
  60569. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60570. */
  60571. mergeRegionArea: number;
  60572. /**
  60573. * The maximum number of vertices allowed for polygons generated during the
  60574. * contour to polygon conversion process. [Limit: >= 3]
  60575. */
  60576. maxVertsPerPoly: number;
  60577. /**
  60578. * Sets the sampling distance to use when generating the detail mesh.
  60579. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60580. */
  60581. detailSampleDist: number;
  60582. /**
  60583. * The maximum distance the detail mesh surface should deviate from heightfield
  60584. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60585. */
  60586. detailSampleMaxError: number;
  60587. }
  60588. }
  60589. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60590. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60591. import { Mesh } from "babylonjs/Meshes/mesh";
  60592. import { Scene } from "babylonjs/scene";
  60593. import { Vector3 } from "babylonjs/Maths/math";
  60594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60595. /**
  60596. * RecastJS navigation plugin
  60597. */
  60598. export class RecastJSPlugin implements INavigationEnginePlugin {
  60599. /**
  60600. * Reference to the Recast library
  60601. */
  60602. bjsRECAST: any;
  60603. /**
  60604. * plugin name
  60605. */
  60606. name: string;
  60607. /**
  60608. * the first navmesh created. We might extend this to support multiple navmeshes
  60609. */
  60610. navMesh: any;
  60611. /**
  60612. * Initializes the recastJS plugin
  60613. * @param recastInjection can be used to inject your own recast reference
  60614. */
  60615. constructor(recastInjection?: any);
  60616. /**
  60617. * Creates a navigation mesh
  60618. * @param meshes array of all the geometry used to compute the navigatio mesh
  60619. * @param parameters bunch of parameters used to filter geometry
  60620. */
  60621. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60622. /**
  60623. * Create a navigation mesh debug mesh
  60624. * @param scene is where the mesh will be added
  60625. * @returns debug display mesh
  60626. */
  60627. createDebugNavMesh(scene: Scene): Mesh;
  60628. /**
  60629. * Get a navigation mesh constrained position, closest to the parameter position
  60630. * @param position world position
  60631. * @returns the closest point to position constrained by the navigation mesh
  60632. */
  60633. getClosestPoint(position: Vector3): Vector3;
  60634. /**
  60635. * Get a navigation mesh constrained position, within a particular radius
  60636. * @param position world position
  60637. * @param maxRadius the maximum distance to the constrained world position
  60638. * @returns the closest point to position constrained by the navigation mesh
  60639. */
  60640. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60641. /**
  60642. * Compute the final position from a segment made of destination-position
  60643. * @param position world position
  60644. * @param destination world position
  60645. * @returns the resulting point along the navmesh
  60646. */
  60647. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60648. /**
  60649. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60650. * @param start world position
  60651. * @param end world position
  60652. * @returns array containing world position composing the path
  60653. */
  60654. computePath(start: Vector3, end: Vector3): Vector3[];
  60655. /**
  60656. * Create a new Crowd so you can add agents
  60657. * @param maxAgents the maximum agent count in the crowd
  60658. * @param maxAgentRadius the maximum radius an agent can have
  60659. * @param scene to attach the crowd to
  60660. * @returns the crowd you can add agents to
  60661. */
  60662. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60663. /**
  60664. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60665. * The queries will try to find a solution within those bounds
  60666. * default is (1,1,1)
  60667. * @param extent x,y,z value that define the extent around the queries point of reference
  60668. */
  60669. setDefaultQueryExtent(extent: Vector3): void;
  60670. /**
  60671. * Get the Bounding box extent specified by setDefaultQueryExtent
  60672. * @returns the box extent values
  60673. */
  60674. getDefaultQueryExtent(): Vector3;
  60675. /**
  60676. * Disposes
  60677. */
  60678. dispose(): void;
  60679. /**
  60680. * If this plugin is supported
  60681. * @returns true if plugin is supported
  60682. */
  60683. isSupported(): boolean;
  60684. }
  60685. /**
  60686. * Recast detour crowd implementation
  60687. */
  60688. export class RecastJSCrowd implements ICrowd {
  60689. /**
  60690. * Recast/detour plugin
  60691. */
  60692. bjsRECASTPlugin: RecastJSPlugin;
  60693. /**
  60694. * Link to the detour crowd
  60695. */
  60696. recastCrowd: any;
  60697. /**
  60698. * One transform per agent
  60699. */
  60700. transforms: TransformNode[];
  60701. /**
  60702. * All agents created
  60703. */
  60704. agents: number[];
  60705. /**
  60706. * Link to the scene is kept to unregister the crowd from the scene
  60707. */
  60708. private _scene;
  60709. /**
  60710. * Observer for crowd updates
  60711. */
  60712. private _onBeforeAnimationsObserver;
  60713. /**
  60714. * Constructor
  60715. * @param plugin recastJS plugin
  60716. * @param maxAgents the maximum agent count in the crowd
  60717. * @param maxAgentRadius the maximum radius an agent can have
  60718. * @param scene to attach the crowd to
  60719. * @returns the crowd you can add agents to
  60720. */
  60721. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60722. /**
  60723. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60724. * You can attach anything to that node. The node position is updated in the scene update tick.
  60725. * @param pos world position that will be constrained by the navigation mesh
  60726. * @param parameters agent parameters
  60727. * @param transform hooked to the agent that will be update by the scene
  60728. * @returns agent index
  60729. */
  60730. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60731. /**
  60732. * Returns the agent position in world space
  60733. * @param index agent index returned by addAgent
  60734. * @returns world space position
  60735. */
  60736. getAgentPosition(index: number): Vector3;
  60737. /**
  60738. * Returns the agent velocity in world space
  60739. * @param index agent index returned by addAgent
  60740. * @returns world space velocity
  60741. */
  60742. getAgentVelocity(index: number): Vector3;
  60743. /**
  60744. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60745. * @param index agent index returned by addAgent
  60746. * @param destination targeted world position
  60747. */
  60748. agentGoto(index: number, destination: Vector3): void;
  60749. /**
  60750. * remove a particular agent previously created
  60751. * @param index agent index returned by addAgent
  60752. */
  60753. removeAgent(index: number): void;
  60754. /**
  60755. * get the list of all agents attached to this crowd
  60756. * @returns list of agent indices
  60757. */
  60758. getAgents(): number[];
  60759. /**
  60760. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60761. * @param deltaTime in seconds
  60762. */
  60763. update(deltaTime: number): void;
  60764. /**
  60765. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60766. * The queries will try to find a solution within those bounds
  60767. * default is (1,1,1)
  60768. * @param extent x,y,z value that define the extent around the queries point of reference
  60769. */
  60770. setDefaultQueryExtent(extent: Vector3): void;
  60771. /**
  60772. * Get the Bounding box extent specified by setDefaultQueryExtent
  60773. * @returns the box extent values
  60774. */
  60775. getDefaultQueryExtent(): Vector3;
  60776. /**
  60777. * Release all resources
  60778. */
  60779. dispose(): void;
  60780. }
  60781. }
  60782. declare module "babylonjs/Navigation/Plugins/index" {
  60783. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60784. }
  60785. declare module "babylonjs/Navigation/index" {
  60786. export * from "babylonjs/Navigation/INavigationEngine";
  60787. export * from "babylonjs/Navigation/Plugins/index";
  60788. }
  60789. declare module "babylonjs/Offline/database" {
  60790. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60791. /**
  60792. * Class used to enable access to IndexedDB
  60793. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60794. */
  60795. export class Database implements IOfflineProvider {
  60796. private _callbackManifestChecked;
  60797. private _currentSceneUrl;
  60798. private _db;
  60799. private _enableSceneOffline;
  60800. private _enableTexturesOffline;
  60801. private _manifestVersionFound;
  60802. private _mustUpdateRessources;
  60803. private _hasReachedQuota;
  60804. private _isSupported;
  60805. private _idbFactory;
  60806. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60807. private static IsUASupportingBlobStorage;
  60808. /**
  60809. * Gets a boolean indicating if Database storate is enabled (off by default)
  60810. */
  60811. static IDBStorageEnabled: boolean;
  60812. /**
  60813. * Gets a boolean indicating if scene must be saved in the database
  60814. */
  60815. readonly enableSceneOffline: boolean;
  60816. /**
  60817. * Gets a boolean indicating if textures must be saved in the database
  60818. */
  60819. readonly enableTexturesOffline: boolean;
  60820. /**
  60821. * Creates a new Database
  60822. * @param urlToScene defines the url to load the scene
  60823. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60824. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60825. */
  60826. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60827. private static _ParseURL;
  60828. private static _ReturnFullUrlLocation;
  60829. private _checkManifestFile;
  60830. /**
  60831. * Open the database and make it available
  60832. * @param successCallback defines the callback to call on success
  60833. * @param errorCallback defines the callback to call on error
  60834. */
  60835. open(successCallback: () => void, errorCallback: () => void): void;
  60836. /**
  60837. * Loads an image from the database
  60838. * @param url defines the url to load from
  60839. * @param image defines the target DOM image
  60840. */
  60841. loadImage(url: string, image: HTMLImageElement): void;
  60842. private _loadImageFromDBAsync;
  60843. private _saveImageIntoDBAsync;
  60844. private _checkVersionFromDB;
  60845. private _loadVersionFromDBAsync;
  60846. private _saveVersionIntoDBAsync;
  60847. /**
  60848. * Loads a file from database
  60849. * @param url defines the URL to load from
  60850. * @param sceneLoaded defines a callback to call on success
  60851. * @param progressCallBack defines a callback to call when progress changed
  60852. * @param errorCallback defines a callback to call on error
  60853. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60854. */
  60855. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60856. private _loadFileAsync;
  60857. private _saveFileAsync;
  60858. /**
  60859. * Validates if xhr data is correct
  60860. * @param xhr defines the request to validate
  60861. * @param dataType defines the expected data type
  60862. * @returns true if data is correct
  60863. */
  60864. private static _ValidateXHRData;
  60865. }
  60866. }
  60867. declare module "babylonjs/Offline/index" {
  60868. export * from "babylonjs/Offline/database";
  60869. export * from "babylonjs/Offline/IOfflineProvider";
  60870. }
  60871. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60872. /** @hidden */
  60873. export var gpuUpdateParticlesPixelShader: {
  60874. name: string;
  60875. shader: string;
  60876. };
  60877. }
  60878. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60879. /** @hidden */
  60880. export var gpuUpdateParticlesVertexShader: {
  60881. name: string;
  60882. shader: string;
  60883. };
  60884. }
  60885. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60886. /** @hidden */
  60887. export var clipPlaneFragmentDeclaration2: {
  60888. name: string;
  60889. shader: string;
  60890. };
  60891. }
  60892. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60893. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60894. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60896. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60898. /** @hidden */
  60899. export var gpuRenderParticlesPixelShader: {
  60900. name: string;
  60901. shader: string;
  60902. };
  60903. }
  60904. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60905. /** @hidden */
  60906. export var clipPlaneVertexDeclaration2: {
  60907. name: string;
  60908. shader: string;
  60909. };
  60910. }
  60911. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60912. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60913. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60914. /** @hidden */
  60915. export var gpuRenderParticlesVertexShader: {
  60916. name: string;
  60917. shader: string;
  60918. };
  60919. }
  60920. declare module "babylonjs/Particles/gpuParticleSystem" {
  60921. import { Nullable } from "babylonjs/types";
  60922. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60923. import { Observable } from "babylonjs/Misc/observable";
  60924. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60925. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60926. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60927. import { Scene, IDisposable } from "babylonjs/scene";
  60928. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60929. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60930. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60931. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60932. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60933. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60934. /**
  60935. * This represents a GPU particle system in Babylon
  60936. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60937. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60938. */
  60939. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60940. /**
  60941. * The layer mask we are rendering the particles through.
  60942. */
  60943. layerMask: number;
  60944. private _capacity;
  60945. private _activeCount;
  60946. private _currentActiveCount;
  60947. private _accumulatedCount;
  60948. private _renderEffect;
  60949. private _updateEffect;
  60950. private _buffer0;
  60951. private _buffer1;
  60952. private _spriteBuffer;
  60953. private _updateVAO;
  60954. private _renderVAO;
  60955. private _targetIndex;
  60956. private _sourceBuffer;
  60957. private _targetBuffer;
  60958. private _engine;
  60959. private _currentRenderId;
  60960. private _started;
  60961. private _stopped;
  60962. private _timeDelta;
  60963. private _randomTexture;
  60964. private _randomTexture2;
  60965. private _attributesStrideSize;
  60966. private _updateEffectOptions;
  60967. private _randomTextureSize;
  60968. private _actualFrame;
  60969. private readonly _rawTextureWidth;
  60970. /**
  60971. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60972. */
  60973. static readonly IsSupported: boolean;
  60974. /**
  60975. * An event triggered when the system is disposed.
  60976. */
  60977. onDisposeObservable: Observable<GPUParticleSystem>;
  60978. /**
  60979. * Gets the maximum number of particles active at the same time.
  60980. * @returns The max number of active particles.
  60981. */
  60982. getCapacity(): number;
  60983. /**
  60984. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60985. * to override the particles.
  60986. */
  60987. forceDepthWrite: boolean;
  60988. /**
  60989. * Gets or set the number of active particles
  60990. */
  60991. activeParticleCount: number;
  60992. private _preWarmDone;
  60993. /**
  60994. * Is this system ready to be used/rendered
  60995. * @return true if the system is ready
  60996. */
  60997. isReady(): boolean;
  60998. /**
  60999. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61000. * @returns True if it has been started, otherwise false.
  61001. */
  61002. isStarted(): boolean;
  61003. /**
  61004. * Starts the particle system and begins to emit
  61005. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61006. */
  61007. start(delay?: number): void;
  61008. /**
  61009. * Stops the particle system.
  61010. */
  61011. stop(): void;
  61012. /**
  61013. * Remove all active particles
  61014. */
  61015. reset(): void;
  61016. /**
  61017. * Returns the string "GPUParticleSystem"
  61018. * @returns a string containing the class name
  61019. */
  61020. getClassName(): string;
  61021. private _colorGradientsTexture;
  61022. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61023. /**
  61024. * Adds a new color gradient
  61025. * @param gradient defines the gradient to use (between 0 and 1)
  61026. * @param color1 defines the color to affect to the specified gradient
  61027. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61028. * @returns the current particle system
  61029. */
  61030. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61031. /**
  61032. * Remove a specific color gradient
  61033. * @param gradient defines the gradient to remove
  61034. * @returns the current particle system
  61035. */
  61036. removeColorGradient(gradient: number): GPUParticleSystem;
  61037. private _angularSpeedGradientsTexture;
  61038. private _sizeGradientsTexture;
  61039. private _velocityGradientsTexture;
  61040. private _limitVelocityGradientsTexture;
  61041. private _dragGradientsTexture;
  61042. private _addFactorGradient;
  61043. /**
  61044. * Adds a new size gradient
  61045. * @param gradient defines the gradient to use (between 0 and 1)
  61046. * @param factor defines the size factor to affect to the specified gradient
  61047. * @returns the current particle system
  61048. */
  61049. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61050. /**
  61051. * Remove a specific size gradient
  61052. * @param gradient defines the gradient to remove
  61053. * @returns the current particle system
  61054. */
  61055. removeSizeGradient(gradient: number): GPUParticleSystem;
  61056. /**
  61057. * Adds a new angular speed gradient
  61058. * @param gradient defines the gradient to use (between 0 and 1)
  61059. * @param factor defines the angular speed to affect to the specified gradient
  61060. * @returns the current particle system
  61061. */
  61062. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61063. /**
  61064. * Remove a specific angular speed gradient
  61065. * @param gradient defines the gradient to remove
  61066. * @returns the current particle system
  61067. */
  61068. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61069. /**
  61070. * Adds a new velocity gradient
  61071. * @param gradient defines the gradient to use (between 0 and 1)
  61072. * @param factor defines the velocity to affect to the specified gradient
  61073. * @returns the current particle system
  61074. */
  61075. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61076. /**
  61077. * Remove a specific velocity gradient
  61078. * @param gradient defines the gradient to remove
  61079. * @returns the current particle system
  61080. */
  61081. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61082. /**
  61083. * Adds a new limit velocity gradient
  61084. * @param gradient defines the gradient to use (between 0 and 1)
  61085. * @param factor defines the limit velocity value to affect to the specified gradient
  61086. * @returns the current particle system
  61087. */
  61088. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61089. /**
  61090. * Remove a specific limit velocity gradient
  61091. * @param gradient defines the gradient to remove
  61092. * @returns the current particle system
  61093. */
  61094. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61095. /**
  61096. * Adds a new drag gradient
  61097. * @param gradient defines the gradient to use (between 0 and 1)
  61098. * @param factor defines the drag value to affect to the specified gradient
  61099. * @returns the current particle system
  61100. */
  61101. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61102. /**
  61103. * Remove a specific drag gradient
  61104. * @param gradient defines the gradient to remove
  61105. * @returns the current particle system
  61106. */
  61107. removeDragGradient(gradient: number): GPUParticleSystem;
  61108. /**
  61109. * Not supported by GPUParticleSystem
  61110. * @param gradient defines the gradient to use (between 0 and 1)
  61111. * @param factor defines the emit rate value to affect to the specified gradient
  61112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61113. * @returns the current particle system
  61114. */
  61115. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61116. /**
  61117. * Not supported by GPUParticleSystem
  61118. * @param gradient defines the gradient to remove
  61119. * @returns the current particle system
  61120. */
  61121. removeEmitRateGradient(gradient: number): IParticleSystem;
  61122. /**
  61123. * Not supported by GPUParticleSystem
  61124. * @param gradient defines the gradient to use (between 0 and 1)
  61125. * @param factor defines the start size value to affect to the specified gradient
  61126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61127. * @returns the current particle system
  61128. */
  61129. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61130. /**
  61131. * Not supported by GPUParticleSystem
  61132. * @param gradient defines the gradient to remove
  61133. * @returns the current particle system
  61134. */
  61135. removeStartSizeGradient(gradient: number): IParticleSystem;
  61136. /**
  61137. * Not supported by GPUParticleSystem
  61138. * @param gradient defines the gradient to use (between 0 and 1)
  61139. * @param min defines the color remap minimal range
  61140. * @param max defines the color remap maximal range
  61141. * @returns the current particle system
  61142. */
  61143. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61144. /**
  61145. * Not supported by GPUParticleSystem
  61146. * @param gradient defines the gradient to remove
  61147. * @returns the current particle system
  61148. */
  61149. removeColorRemapGradient(): IParticleSystem;
  61150. /**
  61151. * Not supported by GPUParticleSystem
  61152. * @param gradient defines the gradient to use (between 0 and 1)
  61153. * @param min defines the alpha remap minimal range
  61154. * @param max defines the alpha remap maximal range
  61155. * @returns the current particle system
  61156. */
  61157. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61158. /**
  61159. * Not supported by GPUParticleSystem
  61160. * @param gradient defines the gradient to remove
  61161. * @returns the current particle system
  61162. */
  61163. removeAlphaRemapGradient(): IParticleSystem;
  61164. /**
  61165. * Not supported by GPUParticleSystem
  61166. * @param gradient defines the gradient to use (between 0 and 1)
  61167. * @param color defines the color to affect to the specified gradient
  61168. * @returns the current particle system
  61169. */
  61170. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61171. /**
  61172. * Not supported by GPUParticleSystem
  61173. * @param gradient defines the gradient to remove
  61174. * @returns the current particle system
  61175. */
  61176. removeRampGradient(): IParticleSystem;
  61177. /**
  61178. * Not supported by GPUParticleSystem
  61179. * @returns the list of ramp gradients
  61180. */
  61181. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61182. /**
  61183. * Not supported by GPUParticleSystem
  61184. * Gets or sets a boolean indicating that ramp gradients must be used
  61185. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61186. */
  61187. useRampGradients: boolean;
  61188. /**
  61189. * Not supported by GPUParticleSystem
  61190. * @param gradient defines the gradient to use (between 0 and 1)
  61191. * @param factor defines the life time factor to affect to the specified gradient
  61192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61193. * @returns the current particle system
  61194. */
  61195. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61196. /**
  61197. * Not supported by GPUParticleSystem
  61198. * @param gradient defines the gradient to remove
  61199. * @returns the current particle system
  61200. */
  61201. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61202. /**
  61203. * Instantiates a GPU particle system.
  61204. * 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.
  61205. * @param name The name of the particle system
  61206. * @param options The options used to create the system
  61207. * @param scene The scene the particle system belongs to
  61208. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61209. */
  61210. constructor(name: string, options: Partial<{
  61211. capacity: number;
  61212. randomTextureSize: number;
  61213. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61214. protected _reset(): void;
  61215. private _createUpdateVAO;
  61216. private _createRenderVAO;
  61217. private _initialize;
  61218. /** @hidden */
  61219. _recreateUpdateEffect(): void;
  61220. /** @hidden */
  61221. _recreateRenderEffect(): void;
  61222. /**
  61223. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61224. * @param preWarm defines if we are in the pre-warmimg phase
  61225. */
  61226. animate(preWarm?: boolean): void;
  61227. private _createFactorGradientTexture;
  61228. private _createSizeGradientTexture;
  61229. private _createAngularSpeedGradientTexture;
  61230. private _createVelocityGradientTexture;
  61231. private _createLimitVelocityGradientTexture;
  61232. private _createDragGradientTexture;
  61233. private _createColorGradientTexture;
  61234. /**
  61235. * Renders the particle system in its current state
  61236. * @param preWarm defines if the system should only update the particles but not render them
  61237. * @returns the current number of particles
  61238. */
  61239. render(preWarm?: boolean): number;
  61240. /**
  61241. * Rebuilds the particle system
  61242. */
  61243. rebuild(): void;
  61244. private _releaseBuffers;
  61245. private _releaseVAOs;
  61246. /**
  61247. * Disposes the particle system and free the associated resources
  61248. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61249. */
  61250. dispose(disposeTexture?: boolean): void;
  61251. /**
  61252. * Clones the particle system.
  61253. * @param name The name of the cloned object
  61254. * @param newEmitter The new emitter to use
  61255. * @returns the cloned particle system
  61256. */
  61257. clone(name: string, newEmitter: any): GPUParticleSystem;
  61258. /**
  61259. * Serializes the particle system to a JSON object.
  61260. * @returns the JSON object
  61261. */
  61262. serialize(): any;
  61263. /**
  61264. * Parses a JSON object to create a GPU particle system.
  61265. * @param parsedParticleSystem The JSON object to parse
  61266. * @param scene The scene to create the particle system in
  61267. * @param rootUrl The root url to use to load external dependencies like texture
  61268. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61269. * @returns the parsed GPU particle system
  61270. */
  61271. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61272. }
  61273. }
  61274. declare module "babylonjs/Particles/particleSystemSet" {
  61275. import { Nullable } from "babylonjs/types";
  61276. import { Color3 } from "babylonjs/Maths/math.color";
  61277. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61279. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61280. import { Scene, IDisposable } from "babylonjs/scene";
  61281. /**
  61282. * Represents a set of particle systems working together to create a specific effect
  61283. */
  61284. export class ParticleSystemSet implements IDisposable {
  61285. /**
  61286. * Gets or sets base Assets URL
  61287. */
  61288. static BaseAssetsUrl: string;
  61289. private _emitterCreationOptions;
  61290. private _emitterNode;
  61291. /**
  61292. * Gets the particle system list
  61293. */
  61294. systems: IParticleSystem[];
  61295. /**
  61296. * Gets the emitter node used with this set
  61297. */
  61298. readonly emitterNode: Nullable<TransformNode>;
  61299. /**
  61300. * Creates a new emitter mesh as a sphere
  61301. * @param options defines the options used to create the sphere
  61302. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61303. * @param scene defines the hosting scene
  61304. */
  61305. setEmitterAsSphere(options: {
  61306. diameter: number;
  61307. segments: number;
  61308. color: Color3;
  61309. }, renderingGroupId: number, scene: Scene): void;
  61310. /**
  61311. * Starts all particle systems of the set
  61312. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61313. */
  61314. start(emitter?: AbstractMesh): void;
  61315. /**
  61316. * Release all associated resources
  61317. */
  61318. dispose(): void;
  61319. /**
  61320. * Serialize the set into a JSON compatible object
  61321. * @returns a JSON compatible representation of the set
  61322. */
  61323. serialize(): any;
  61324. /**
  61325. * Parse a new ParticleSystemSet from a serialized source
  61326. * @param data defines a JSON compatible representation of the set
  61327. * @param scene defines the hosting scene
  61328. * @param gpu defines if we want GPU particles or CPU particles
  61329. * @returns a new ParticleSystemSet
  61330. */
  61331. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61332. }
  61333. }
  61334. declare module "babylonjs/Particles/particleHelper" {
  61335. import { Nullable } from "babylonjs/types";
  61336. import { Scene } from "babylonjs/scene";
  61337. import { Vector3 } from "babylonjs/Maths/math.vector";
  61338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61339. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61340. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61341. /**
  61342. * This class is made for on one-liner static method to help creating particle system set.
  61343. */
  61344. export class ParticleHelper {
  61345. /**
  61346. * Gets or sets base Assets URL
  61347. */
  61348. static BaseAssetsUrl: string;
  61349. /**
  61350. * Create a default particle system that you can tweak
  61351. * @param emitter defines the emitter to use
  61352. * @param capacity defines the system capacity (default is 500 particles)
  61353. * @param scene defines the hosting scene
  61354. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61355. * @returns the new Particle system
  61356. */
  61357. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61358. /**
  61359. * This is the main static method (one-liner) of this helper to create different particle systems
  61360. * @param type This string represents the type to the particle system to create
  61361. * @param scene The scene where the particle system should live
  61362. * @param gpu If the system will use gpu
  61363. * @returns the ParticleSystemSet created
  61364. */
  61365. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61366. /**
  61367. * Static function used to export a particle system to a ParticleSystemSet variable.
  61368. * Please note that the emitter shape is not exported
  61369. * @param systems defines the particle systems to export
  61370. * @returns the created particle system set
  61371. */
  61372. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61373. }
  61374. }
  61375. declare module "babylonjs/Particles/particleSystemComponent" {
  61376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61377. import { Effect } from "babylonjs/Materials/effect";
  61378. import "babylonjs/Shaders/particles.vertex";
  61379. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61380. module "babylonjs/Engines/engine" {
  61381. interface Engine {
  61382. /**
  61383. * Create an effect to use with particle systems.
  61384. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61385. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61386. * @param uniformsNames defines a list of attribute names
  61387. * @param samplers defines an array of string used to represent textures
  61388. * @param defines defines the string containing the defines to use to compile the shaders
  61389. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61390. * @param onCompiled defines a function to call when the effect creation is successful
  61391. * @param onError defines a function to call when the effect creation has failed
  61392. * @returns the new Effect
  61393. */
  61394. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61395. }
  61396. }
  61397. module "babylonjs/Meshes/mesh" {
  61398. interface Mesh {
  61399. /**
  61400. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61401. * @returns an array of IParticleSystem
  61402. */
  61403. getEmittedParticleSystems(): IParticleSystem[];
  61404. /**
  61405. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61406. * @returns an array of IParticleSystem
  61407. */
  61408. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61409. }
  61410. }
  61411. /**
  61412. * @hidden
  61413. */
  61414. export var _IDoNeedToBeInTheBuild: number;
  61415. }
  61416. declare module "babylonjs/Particles/pointsCloudSystem" {
  61417. import { Color4 } from "babylonjs/Maths/math";
  61418. import { Mesh } from "babylonjs/Meshes/mesh";
  61419. import { Scene, IDisposable } from "babylonjs/scene";
  61420. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61421. /** Defines the 4 color options */
  61422. export enum PointColor {
  61423. /** color value */
  61424. Color = 2,
  61425. /** uv value */
  61426. UV = 1,
  61427. /** random value */
  61428. Random = 0,
  61429. /** stated value */
  61430. Stated = 3
  61431. }
  61432. /**
  61433. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61434. * 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.
  61435. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61436. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61437. *
  61438. * Full documentation here : TO BE ENTERED
  61439. */
  61440. export class PointsCloudSystem implements IDisposable {
  61441. /**
  61442. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61443. * Example : var p = SPS.particles[i];
  61444. */
  61445. particles: CloudPoint[];
  61446. /**
  61447. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61448. */
  61449. nbParticles: number;
  61450. /**
  61451. * This a counter for your own usage. It's not set by any SPS functions.
  61452. */
  61453. counter: number;
  61454. /**
  61455. * The PCS name. This name is also given to the underlying mesh.
  61456. */
  61457. name: string;
  61458. /**
  61459. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61460. */
  61461. mesh: Mesh;
  61462. /**
  61463. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61464. * Please read :
  61465. */
  61466. vars: any;
  61467. /**
  61468. * @hidden
  61469. */
  61470. _size: number;
  61471. private _scene;
  61472. private _promises;
  61473. private _positions;
  61474. private _indices;
  61475. private _normals;
  61476. private _colors;
  61477. private _uvs;
  61478. private _indices32;
  61479. private _positions32;
  61480. private _colors32;
  61481. private _uvs32;
  61482. private _updatable;
  61483. private _isVisibilityBoxLocked;
  61484. private _alwaysVisible;
  61485. private _groups;
  61486. private _groupCounter;
  61487. private _computeParticleColor;
  61488. private _computeParticleTexture;
  61489. private _computeParticleRotation;
  61490. private _computeBoundingBox;
  61491. private _isReady;
  61492. /**
  61493. * Creates a PCS (Points Cloud System) object
  61494. * @param name (String) is the PCS name, this will be the underlying mesh name
  61495. * @param pointSize (number) is the size for each point
  61496. * @param scene (Scene) is the scene in which the PCS is added
  61497. * @param options defines the options of the PCS e.g.
  61498. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61499. */
  61500. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61501. updatable?: boolean;
  61502. });
  61503. /**
  61504. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61505. * If no points were added to the PCS, the returned mesh is just a single point.
  61506. * @returns a promise for the created mesh
  61507. */
  61508. buildMeshAsync(): Promise<Mesh>;
  61509. /**
  61510. * @hidden
  61511. */
  61512. private _buildMesh;
  61513. private _addParticle;
  61514. private _randomUnitVector;
  61515. private _getColorIndicesForCoord;
  61516. private _setPointsColorOrUV;
  61517. private _colorFromTexture;
  61518. private _calculateDensity;
  61519. /**
  61520. * Adds points to the PCS in random positions within a unit sphere
  61521. * @param nb (positive integer) the number of particles to be created from this model
  61522. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61523. * @returns the number of groups in the system
  61524. */
  61525. addPoints(nb: number, pointFunction?: any): number;
  61526. /**
  61527. * Adds points to the PCS from the surface of the model shape
  61528. * @param mesh is any Mesh object that will be used as a surface model for the points
  61529. * @param nb (positive integer) the number of particles to be created from this model
  61530. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61531. * @param color (color3) to be used when colorWith is stated
  61532. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61533. * @returns the number of groups in the system
  61534. */
  61535. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61536. /**
  61537. * Adds points to the PCS inside the model shape
  61538. * @param mesh is any Mesh object that will be used as a surface model for the points
  61539. * @param nb (positive integer) the number of particles to be created from this model
  61540. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61541. * @param color (color4) to be used when colorWith is stated
  61542. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61543. * @returns the number of groups in the system
  61544. */
  61545. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61546. /**
  61547. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61548. * This method calls `updateParticle()` for each particle of the SPS.
  61549. * For an animated SPS, it is usually called within the render loop.
  61550. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61551. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61552. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61553. * @returns the PCS.
  61554. */
  61555. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61556. /**
  61557. * Disposes the PCS.
  61558. */
  61559. dispose(): void;
  61560. /**
  61561. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61562. * doc :
  61563. * @returns the PCS.
  61564. */
  61565. refreshVisibleSize(): PointsCloudSystem;
  61566. /**
  61567. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61568. * @param size the size (float) of the visibility box
  61569. * note : this doesn't lock the PCS mesh bounding box.
  61570. * doc :
  61571. */
  61572. setVisibilityBox(size: number): void;
  61573. /**
  61574. * Gets whether the PCS is always visible or not
  61575. * doc :
  61576. */
  61577. /**
  61578. * Sets the PCS as always visible or not
  61579. * doc :
  61580. */
  61581. isAlwaysVisible: boolean;
  61582. /**
  61583. * Tells to `setParticles()` to compute the particle rotations or not
  61584. * Default value : false. The PCS is faster when it's set to false
  61585. * Note : particle rotations are only applied to parent particles
  61586. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61587. */
  61588. computeParticleRotation: boolean;
  61589. /**
  61590. * Tells to `setParticles()` to compute the particle colors or not.
  61591. * Default value : true. The PCS is faster when it's set to false.
  61592. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61593. */
  61594. /**
  61595. * Gets if `setParticles()` computes the particle colors or not.
  61596. * Default value : false. The PCS is faster when it's set to false.
  61597. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61598. */
  61599. computeParticleColor: boolean;
  61600. /**
  61601. * Gets if `setParticles()` computes the particle textures or not.
  61602. * Default value : false. The PCS is faster when it's set to false.
  61603. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61604. */
  61605. computeParticleTexture: boolean;
  61606. /**
  61607. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61608. */
  61609. /**
  61610. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61611. */
  61612. computeBoundingBox: boolean;
  61613. /**
  61614. * This function does nothing. It may be overwritten to set all the particle first values.
  61615. * The PCS doesn't call this function, you may have to call it by your own.
  61616. * doc :
  61617. */
  61618. initParticles(): void;
  61619. /**
  61620. * This function does nothing. It may be overwritten to recycle a particle
  61621. * The PCS doesn't call this function, you can to call it
  61622. * doc :
  61623. * @param particle The particle to recycle
  61624. * @returns the recycled particle
  61625. */
  61626. recycleParticle(particle: CloudPoint): CloudPoint;
  61627. /**
  61628. * Updates a particle : this function should be overwritten by the user.
  61629. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61630. * doc :
  61631. * @example : just set a particle position or velocity and recycle conditions
  61632. * @param particle The particle to update
  61633. * @returns the updated particle
  61634. */
  61635. updateParticle(particle: CloudPoint): CloudPoint;
  61636. /**
  61637. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61638. * This does nothing and may be overwritten by the user.
  61639. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61640. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61641. * @param update the boolean update value actually passed to setParticles()
  61642. */
  61643. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61644. /**
  61645. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61646. * This will be passed three parameters.
  61647. * This does nothing and may be overwritten by the user.
  61648. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61649. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61650. * @param update the boolean update value actually passed to setParticles()
  61651. */
  61652. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61653. }
  61654. }
  61655. declare module "babylonjs/Particles/cloudPoint" {
  61656. import { Nullable } from "babylonjs/types";
  61657. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61658. import { Mesh } from "babylonjs/Meshes/mesh";
  61659. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61660. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61661. /**
  61662. * Represents one particle of a points cloud system.
  61663. */
  61664. export class CloudPoint {
  61665. /**
  61666. * particle global index
  61667. */
  61668. idx: number;
  61669. /**
  61670. * The color of the particle
  61671. */
  61672. color: Nullable<Color4>;
  61673. /**
  61674. * The world space position of the particle.
  61675. */
  61676. position: Vector3;
  61677. /**
  61678. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61679. */
  61680. rotation: Vector3;
  61681. /**
  61682. * The world space rotation quaternion of the particle.
  61683. */
  61684. rotationQuaternion: Nullable<Quaternion>;
  61685. /**
  61686. * The uv of the particle.
  61687. */
  61688. uv: Nullable<Vector2>;
  61689. /**
  61690. * The current speed of the particle.
  61691. */
  61692. velocity: Vector3;
  61693. /**
  61694. * The pivot point in the particle local space.
  61695. */
  61696. pivot: Vector3;
  61697. /**
  61698. * Must the particle be translated from its pivot point in its local space ?
  61699. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61700. * Default : false
  61701. */
  61702. translateFromPivot: boolean;
  61703. /**
  61704. * Index of this particle in the global "positions" array (Internal use)
  61705. * @hidden
  61706. */
  61707. _pos: number;
  61708. /**
  61709. * @hidden Index of this particle in the global "indices" array (Internal use)
  61710. */
  61711. _ind: number;
  61712. /**
  61713. * Group this particle belongs to
  61714. */
  61715. _group: PointsGroup;
  61716. /**
  61717. * Group id of this particle
  61718. */
  61719. groupId: number;
  61720. /**
  61721. * Index of the particle in its group id (Internal use)
  61722. */
  61723. idxInGroup: number;
  61724. /**
  61725. * @hidden Particle BoundingInfo object (Internal use)
  61726. */
  61727. _boundingInfo: BoundingInfo;
  61728. /**
  61729. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61730. */
  61731. _pcs: PointsCloudSystem;
  61732. /**
  61733. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61734. */
  61735. _stillInvisible: boolean;
  61736. /**
  61737. * @hidden Last computed particle rotation matrix
  61738. */
  61739. _rotationMatrix: number[];
  61740. /**
  61741. * Parent particle Id, if any.
  61742. * Default null.
  61743. */
  61744. parentId: Nullable<number>;
  61745. /**
  61746. * @hidden Internal global position in the PCS.
  61747. */
  61748. _globalPosition: Vector3;
  61749. /**
  61750. * Creates a Point Cloud object.
  61751. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61752. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61753. * @param group (PointsGroup) is the group the particle belongs to
  61754. * @param groupId (integer) is the group identifier in the PCS.
  61755. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61756. * @param pcs defines the PCS it is associated to
  61757. */
  61758. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61759. /**
  61760. * get point size
  61761. */
  61762. /**
  61763. * Set point size
  61764. */
  61765. size: Vector3;
  61766. /**
  61767. * Legacy support, changed quaternion to rotationQuaternion
  61768. */
  61769. /**
  61770. * Legacy support, changed quaternion to rotationQuaternion
  61771. */
  61772. quaternion: Nullable<Quaternion>;
  61773. /**
  61774. * Returns a boolean. True if the particle intersects a mesh, else false
  61775. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61776. * @param target is the object (point or mesh) what the intersection is computed against
  61777. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61778. * @returns true if it intersects
  61779. */
  61780. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61781. /**
  61782. * get the rotation matrix of the particle
  61783. * @hidden
  61784. */
  61785. getRotationMatrix(m: Matrix): void;
  61786. }
  61787. /**
  61788. * Represents a group of points in a points cloud system
  61789. * * PCS internal tool, don't use it manually.
  61790. */
  61791. export class PointsGroup {
  61792. /**
  61793. * The group id
  61794. * @hidden
  61795. */
  61796. groupID: number;
  61797. /**
  61798. * image data for group (internal use)
  61799. * @hidden
  61800. */
  61801. _groupImageData: Nullable<ArrayBufferView>;
  61802. /**
  61803. * Image Width (internal use)
  61804. * @hidden
  61805. */
  61806. _groupImgWidth: number;
  61807. /**
  61808. * Image Height (internal use)
  61809. * @hidden
  61810. */
  61811. _groupImgHeight: number;
  61812. /**
  61813. * Custom position function (internal use)
  61814. * @hidden
  61815. */
  61816. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61817. /**
  61818. * density per facet for surface points
  61819. * @hidden
  61820. */
  61821. _groupDensity: number[];
  61822. /**
  61823. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61824. * PCS internal tool, don't use it manually.
  61825. * @hidden
  61826. */
  61827. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61828. }
  61829. }
  61830. declare module "babylonjs/Particles/index" {
  61831. export * from "babylonjs/Particles/baseParticleSystem";
  61832. export * from "babylonjs/Particles/EmitterTypes/index";
  61833. export * from "babylonjs/Particles/gpuParticleSystem";
  61834. export * from "babylonjs/Particles/IParticleSystem";
  61835. export * from "babylonjs/Particles/particle";
  61836. export * from "babylonjs/Particles/particleHelper";
  61837. export * from "babylonjs/Particles/particleSystem";
  61838. export * from "babylonjs/Particles/particleSystemComponent";
  61839. export * from "babylonjs/Particles/particleSystemSet";
  61840. export * from "babylonjs/Particles/solidParticle";
  61841. export * from "babylonjs/Particles/solidParticleSystem";
  61842. export * from "babylonjs/Particles/cloudPoint";
  61843. export * from "babylonjs/Particles/pointsCloudSystem";
  61844. export * from "babylonjs/Particles/subEmitter";
  61845. }
  61846. declare module "babylonjs/Physics/physicsEngineComponent" {
  61847. import { Nullable } from "babylonjs/types";
  61848. import { Observable, Observer } from "babylonjs/Misc/observable";
  61849. import { Vector3 } from "babylonjs/Maths/math.vector";
  61850. import { Mesh } from "babylonjs/Meshes/mesh";
  61851. import { ISceneComponent } from "babylonjs/sceneComponent";
  61852. import { Scene } from "babylonjs/scene";
  61853. import { Node } from "babylonjs/node";
  61854. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61855. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61856. module "babylonjs/scene" {
  61857. interface Scene {
  61858. /** @hidden (Backing field) */
  61859. _physicsEngine: Nullable<IPhysicsEngine>;
  61860. /**
  61861. * Gets the current physics engine
  61862. * @returns a IPhysicsEngine or null if none attached
  61863. */
  61864. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61865. /**
  61866. * Enables physics to the current scene
  61867. * @param gravity defines the scene's gravity for the physics engine
  61868. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61869. * @return a boolean indicating if the physics engine was initialized
  61870. */
  61871. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61872. /**
  61873. * Disables and disposes the physics engine associated with the scene
  61874. */
  61875. disablePhysicsEngine(): void;
  61876. /**
  61877. * Gets a boolean indicating if there is an active physics engine
  61878. * @returns a boolean indicating if there is an active physics engine
  61879. */
  61880. isPhysicsEnabled(): boolean;
  61881. /**
  61882. * Deletes a physics compound impostor
  61883. * @param compound defines the compound to delete
  61884. */
  61885. deleteCompoundImpostor(compound: any): void;
  61886. /**
  61887. * An event triggered when physic simulation is about to be run
  61888. */
  61889. onBeforePhysicsObservable: Observable<Scene>;
  61890. /**
  61891. * An event triggered when physic simulation has been done
  61892. */
  61893. onAfterPhysicsObservable: Observable<Scene>;
  61894. }
  61895. }
  61896. module "babylonjs/Meshes/abstractMesh" {
  61897. interface AbstractMesh {
  61898. /** @hidden */
  61899. _physicsImpostor: Nullable<PhysicsImpostor>;
  61900. /**
  61901. * Gets or sets impostor used for physic simulation
  61902. * @see http://doc.babylonjs.com/features/physics_engine
  61903. */
  61904. physicsImpostor: Nullable<PhysicsImpostor>;
  61905. /**
  61906. * Gets the current physics impostor
  61907. * @see http://doc.babylonjs.com/features/physics_engine
  61908. * @returns a physics impostor or null
  61909. */
  61910. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61911. /** Apply a physic impulse to the mesh
  61912. * @param force defines the force to apply
  61913. * @param contactPoint defines where to apply the force
  61914. * @returns the current mesh
  61915. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61916. */
  61917. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61918. /**
  61919. * Creates a physic joint between two meshes
  61920. * @param otherMesh defines the other mesh to use
  61921. * @param pivot1 defines the pivot to use on this mesh
  61922. * @param pivot2 defines the pivot to use on the other mesh
  61923. * @param options defines additional options (can be plugin dependent)
  61924. * @returns the current mesh
  61925. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61926. */
  61927. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61928. /** @hidden */
  61929. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61930. }
  61931. }
  61932. /**
  61933. * Defines the physics engine scene component responsible to manage a physics engine
  61934. */
  61935. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61936. /**
  61937. * The component name helpful to identify the component in the list of scene components.
  61938. */
  61939. readonly name: string;
  61940. /**
  61941. * The scene the component belongs to.
  61942. */
  61943. scene: Scene;
  61944. /**
  61945. * Creates a new instance of the component for the given scene
  61946. * @param scene Defines the scene to register the component in
  61947. */
  61948. constructor(scene: Scene);
  61949. /**
  61950. * Registers the component in a given scene
  61951. */
  61952. register(): void;
  61953. /**
  61954. * Rebuilds the elements related to this component in case of
  61955. * context lost for instance.
  61956. */
  61957. rebuild(): void;
  61958. /**
  61959. * Disposes the component and the associated ressources
  61960. */
  61961. dispose(): void;
  61962. }
  61963. }
  61964. declare module "babylonjs/Physics/physicsHelper" {
  61965. import { Nullable } from "babylonjs/types";
  61966. import { Vector3 } from "babylonjs/Maths/math.vector";
  61967. import { Mesh } from "babylonjs/Meshes/mesh";
  61968. import { Scene } from "babylonjs/scene";
  61969. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61970. /**
  61971. * A helper for physics simulations
  61972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61973. */
  61974. export class PhysicsHelper {
  61975. private _scene;
  61976. private _physicsEngine;
  61977. /**
  61978. * Initializes the Physics helper
  61979. * @param scene Babylon.js scene
  61980. */
  61981. constructor(scene: Scene);
  61982. /**
  61983. * Applies a radial explosion impulse
  61984. * @param origin the origin of the explosion
  61985. * @param radiusOrEventOptions the radius or the options of radial explosion
  61986. * @param strength the explosion strength
  61987. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61988. * @returns A physics radial explosion event, or null
  61989. */
  61990. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61991. /**
  61992. * Applies a radial explosion force
  61993. * @param origin the origin of the explosion
  61994. * @param radiusOrEventOptions the radius or the options of radial explosion
  61995. * @param strength the explosion strength
  61996. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61997. * @returns A physics radial explosion event, or null
  61998. */
  61999. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62000. /**
  62001. * Creates a gravitational field
  62002. * @param origin the origin of the explosion
  62003. * @param radiusOrEventOptions the radius or the options of radial explosion
  62004. * @param strength the explosion strength
  62005. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62006. * @returns A physics gravitational field event, or null
  62007. */
  62008. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62009. /**
  62010. * Creates a physics updraft event
  62011. * @param origin the origin of the updraft
  62012. * @param radiusOrEventOptions the radius or the options of the updraft
  62013. * @param strength the strength of the updraft
  62014. * @param height the height of the updraft
  62015. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62016. * @returns A physics updraft event, or null
  62017. */
  62018. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62019. /**
  62020. * Creates a physics vortex event
  62021. * @param origin the of the vortex
  62022. * @param radiusOrEventOptions the radius or the options of the vortex
  62023. * @param strength the strength of the vortex
  62024. * @param height the height of the vortex
  62025. * @returns a Physics vortex event, or null
  62026. * A physics vortex event or null
  62027. */
  62028. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62029. }
  62030. /**
  62031. * Represents a physics radial explosion event
  62032. */
  62033. class PhysicsRadialExplosionEvent {
  62034. private _scene;
  62035. private _options;
  62036. private _sphere;
  62037. private _dataFetched;
  62038. /**
  62039. * Initializes a radial explosioin event
  62040. * @param _scene BabylonJS scene
  62041. * @param _options The options for the vortex event
  62042. */
  62043. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62044. /**
  62045. * Returns the data related to the radial explosion event (sphere).
  62046. * @returns The radial explosion event data
  62047. */
  62048. getData(): PhysicsRadialExplosionEventData;
  62049. /**
  62050. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62051. * @param impostor A physics imposter
  62052. * @param origin the origin of the explosion
  62053. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62054. */
  62055. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62056. /**
  62057. * Triggers affecterd impostors callbacks
  62058. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62059. */
  62060. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62061. /**
  62062. * Disposes the sphere.
  62063. * @param force Specifies if the sphere should be disposed by force
  62064. */
  62065. dispose(force?: boolean): void;
  62066. /*** Helpers ***/
  62067. private _prepareSphere;
  62068. private _intersectsWithSphere;
  62069. }
  62070. /**
  62071. * Represents a gravitational field event
  62072. */
  62073. class PhysicsGravitationalFieldEvent {
  62074. private _physicsHelper;
  62075. private _scene;
  62076. private _origin;
  62077. private _options;
  62078. private _tickCallback;
  62079. private _sphere;
  62080. private _dataFetched;
  62081. /**
  62082. * Initializes the physics gravitational field event
  62083. * @param _physicsHelper A physics helper
  62084. * @param _scene BabylonJS scene
  62085. * @param _origin The origin position of the gravitational field event
  62086. * @param _options The options for the vortex event
  62087. */
  62088. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62089. /**
  62090. * Returns the data related to the gravitational field event (sphere).
  62091. * @returns A gravitational field event
  62092. */
  62093. getData(): PhysicsGravitationalFieldEventData;
  62094. /**
  62095. * Enables the gravitational field.
  62096. */
  62097. enable(): void;
  62098. /**
  62099. * Disables the gravitational field.
  62100. */
  62101. disable(): void;
  62102. /**
  62103. * Disposes the sphere.
  62104. * @param force The force to dispose from the gravitational field event
  62105. */
  62106. dispose(force?: boolean): void;
  62107. private _tick;
  62108. }
  62109. /**
  62110. * Represents a physics updraft event
  62111. */
  62112. class PhysicsUpdraftEvent {
  62113. private _scene;
  62114. private _origin;
  62115. private _options;
  62116. private _physicsEngine;
  62117. private _originTop;
  62118. private _originDirection;
  62119. private _tickCallback;
  62120. private _cylinder;
  62121. private _cylinderPosition;
  62122. private _dataFetched;
  62123. /**
  62124. * Initializes the physics updraft event
  62125. * @param _scene BabylonJS scene
  62126. * @param _origin The origin position of the updraft
  62127. * @param _options The options for the updraft event
  62128. */
  62129. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62130. /**
  62131. * Returns the data related to the updraft event (cylinder).
  62132. * @returns A physics updraft event
  62133. */
  62134. getData(): PhysicsUpdraftEventData;
  62135. /**
  62136. * Enables the updraft.
  62137. */
  62138. enable(): void;
  62139. /**
  62140. * Disables the updraft.
  62141. */
  62142. disable(): void;
  62143. /**
  62144. * Disposes the cylinder.
  62145. * @param force Specifies if the updraft should be disposed by force
  62146. */
  62147. dispose(force?: boolean): void;
  62148. private getImpostorHitData;
  62149. private _tick;
  62150. /*** Helpers ***/
  62151. private _prepareCylinder;
  62152. private _intersectsWithCylinder;
  62153. }
  62154. /**
  62155. * Represents a physics vortex event
  62156. */
  62157. class PhysicsVortexEvent {
  62158. private _scene;
  62159. private _origin;
  62160. private _options;
  62161. private _physicsEngine;
  62162. private _originTop;
  62163. private _tickCallback;
  62164. private _cylinder;
  62165. private _cylinderPosition;
  62166. private _dataFetched;
  62167. /**
  62168. * Initializes the physics vortex event
  62169. * @param _scene The BabylonJS scene
  62170. * @param _origin The origin position of the vortex
  62171. * @param _options The options for the vortex event
  62172. */
  62173. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62174. /**
  62175. * Returns the data related to the vortex event (cylinder).
  62176. * @returns The physics vortex event data
  62177. */
  62178. getData(): PhysicsVortexEventData;
  62179. /**
  62180. * Enables the vortex.
  62181. */
  62182. enable(): void;
  62183. /**
  62184. * Disables the cortex.
  62185. */
  62186. disable(): void;
  62187. /**
  62188. * Disposes the sphere.
  62189. * @param force
  62190. */
  62191. dispose(force?: boolean): void;
  62192. private getImpostorHitData;
  62193. private _tick;
  62194. /*** Helpers ***/
  62195. private _prepareCylinder;
  62196. private _intersectsWithCylinder;
  62197. }
  62198. /**
  62199. * Options fot the radial explosion event
  62200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62201. */
  62202. export class PhysicsRadialExplosionEventOptions {
  62203. /**
  62204. * The radius of the sphere for the radial explosion.
  62205. */
  62206. radius: number;
  62207. /**
  62208. * The strenth of the explosion.
  62209. */
  62210. strength: number;
  62211. /**
  62212. * The strenght of the force in correspondence to the distance of the affected object
  62213. */
  62214. falloff: PhysicsRadialImpulseFalloff;
  62215. /**
  62216. * Sphere options for the radial explosion.
  62217. */
  62218. sphere: {
  62219. segments: number;
  62220. diameter: number;
  62221. };
  62222. /**
  62223. * Sphere options for the radial explosion.
  62224. */
  62225. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62226. }
  62227. /**
  62228. * Options fot the updraft event
  62229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62230. */
  62231. export class PhysicsUpdraftEventOptions {
  62232. /**
  62233. * The radius of the cylinder for the vortex
  62234. */
  62235. radius: number;
  62236. /**
  62237. * The strenth of the updraft.
  62238. */
  62239. strength: number;
  62240. /**
  62241. * The height of the cylinder for the updraft.
  62242. */
  62243. height: number;
  62244. /**
  62245. * The mode for the the updraft.
  62246. */
  62247. updraftMode: PhysicsUpdraftMode;
  62248. }
  62249. /**
  62250. * Options fot the vortex event
  62251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62252. */
  62253. export class PhysicsVortexEventOptions {
  62254. /**
  62255. * The radius of the cylinder for the vortex
  62256. */
  62257. radius: number;
  62258. /**
  62259. * The strenth of the vortex.
  62260. */
  62261. strength: number;
  62262. /**
  62263. * The height of the cylinder for the vortex.
  62264. */
  62265. height: number;
  62266. /**
  62267. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62268. */
  62269. centripetalForceThreshold: number;
  62270. /**
  62271. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62272. */
  62273. centripetalForceMultiplier: number;
  62274. /**
  62275. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62276. */
  62277. centrifugalForceMultiplier: number;
  62278. /**
  62279. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62280. */
  62281. updraftForceMultiplier: number;
  62282. }
  62283. /**
  62284. * The strenght of the force in correspondence to the distance of the affected object
  62285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62286. */
  62287. export enum PhysicsRadialImpulseFalloff {
  62288. /** Defines that impulse is constant in strength across it's whole radius */
  62289. Constant = 0,
  62290. /** Defines that impulse gets weaker if it's further from the origin */
  62291. Linear = 1
  62292. }
  62293. /**
  62294. * The strength of the force in correspondence to the distance of the affected object
  62295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62296. */
  62297. export enum PhysicsUpdraftMode {
  62298. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62299. Center = 0,
  62300. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62301. Perpendicular = 1
  62302. }
  62303. /**
  62304. * Interface for a physics hit data
  62305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62306. */
  62307. export interface PhysicsHitData {
  62308. /**
  62309. * The force applied at the contact point
  62310. */
  62311. force: Vector3;
  62312. /**
  62313. * The contact point
  62314. */
  62315. contactPoint: Vector3;
  62316. /**
  62317. * The distance from the origin to the contact point
  62318. */
  62319. distanceFromOrigin: number;
  62320. }
  62321. /**
  62322. * Interface for radial explosion event data
  62323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62324. */
  62325. export interface PhysicsRadialExplosionEventData {
  62326. /**
  62327. * A sphere used for the radial explosion event
  62328. */
  62329. sphere: Mesh;
  62330. }
  62331. /**
  62332. * Interface for gravitational field event data
  62333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62334. */
  62335. export interface PhysicsGravitationalFieldEventData {
  62336. /**
  62337. * A sphere mesh used for the gravitational field event
  62338. */
  62339. sphere: Mesh;
  62340. }
  62341. /**
  62342. * Interface for updraft event data
  62343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62344. */
  62345. export interface PhysicsUpdraftEventData {
  62346. /**
  62347. * A cylinder used for the updraft event
  62348. */
  62349. cylinder: Mesh;
  62350. }
  62351. /**
  62352. * Interface for vortex event data
  62353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62354. */
  62355. export interface PhysicsVortexEventData {
  62356. /**
  62357. * A cylinder used for the vortex event
  62358. */
  62359. cylinder: Mesh;
  62360. }
  62361. /**
  62362. * Interface for an affected physics impostor
  62363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62364. */
  62365. export interface PhysicsAffectedImpostorWithData {
  62366. /**
  62367. * The impostor affected by the effect
  62368. */
  62369. impostor: PhysicsImpostor;
  62370. /**
  62371. * The data about the hit/horce from the explosion
  62372. */
  62373. hitData: PhysicsHitData;
  62374. }
  62375. }
  62376. declare module "babylonjs/Physics/Plugins/index" {
  62377. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62378. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62379. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62380. }
  62381. declare module "babylonjs/Physics/index" {
  62382. export * from "babylonjs/Physics/IPhysicsEngine";
  62383. export * from "babylonjs/Physics/physicsEngine";
  62384. export * from "babylonjs/Physics/physicsEngineComponent";
  62385. export * from "babylonjs/Physics/physicsHelper";
  62386. export * from "babylonjs/Physics/physicsImpostor";
  62387. export * from "babylonjs/Physics/physicsJoint";
  62388. export * from "babylonjs/Physics/Plugins/index";
  62389. }
  62390. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62391. /** @hidden */
  62392. export var blackAndWhitePixelShader: {
  62393. name: string;
  62394. shader: string;
  62395. };
  62396. }
  62397. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62399. import { Camera } from "babylonjs/Cameras/camera";
  62400. import { Engine } from "babylonjs/Engines/engine";
  62401. import "babylonjs/Shaders/blackAndWhite.fragment";
  62402. /**
  62403. * Post process used to render in black and white
  62404. */
  62405. export class BlackAndWhitePostProcess extends PostProcess {
  62406. /**
  62407. * Linear about to convert he result to black and white (default: 1)
  62408. */
  62409. degree: number;
  62410. /**
  62411. * Creates a black and white post process
  62412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62413. * @param name The name of the effect.
  62414. * @param options The required width/height ratio to downsize to before computing the render pass.
  62415. * @param camera The camera to apply the render pass to.
  62416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62417. * @param engine The engine which the post process will be applied. (default: current engine)
  62418. * @param reusable If the post process can be reused on the same frame. (default: false)
  62419. */
  62420. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62421. }
  62422. }
  62423. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62424. import { Nullable } from "babylonjs/types";
  62425. import { Camera } from "babylonjs/Cameras/camera";
  62426. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62427. import { Engine } from "babylonjs/Engines/engine";
  62428. /**
  62429. * This represents a set of one or more post processes in Babylon.
  62430. * A post process can be used to apply a shader to a texture after it is rendered.
  62431. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62432. */
  62433. export class PostProcessRenderEffect {
  62434. private _postProcesses;
  62435. private _getPostProcesses;
  62436. private _singleInstance;
  62437. private _cameras;
  62438. private _indicesForCamera;
  62439. /**
  62440. * Name of the effect
  62441. * @hidden
  62442. */
  62443. _name: string;
  62444. /**
  62445. * Instantiates a post process render effect.
  62446. * A post process can be used to apply a shader to a texture after it is rendered.
  62447. * @param engine The engine the effect is tied to
  62448. * @param name The name of the effect
  62449. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62450. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62451. */
  62452. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62453. /**
  62454. * Checks if all the post processes in the effect are supported.
  62455. */
  62456. readonly isSupported: boolean;
  62457. /**
  62458. * Updates the current state of the effect
  62459. * @hidden
  62460. */
  62461. _update(): void;
  62462. /**
  62463. * Attaches the effect on cameras
  62464. * @param cameras The camera to attach to.
  62465. * @hidden
  62466. */
  62467. _attachCameras(cameras: Camera): void;
  62468. /**
  62469. * Attaches the effect on cameras
  62470. * @param cameras The camera to attach to.
  62471. * @hidden
  62472. */
  62473. _attachCameras(cameras: Camera[]): void;
  62474. /**
  62475. * Detaches the effect on cameras
  62476. * @param cameras The camera to detatch from.
  62477. * @hidden
  62478. */
  62479. _detachCameras(cameras: Camera): void;
  62480. /**
  62481. * Detatches the effect on cameras
  62482. * @param cameras The camera to detatch from.
  62483. * @hidden
  62484. */
  62485. _detachCameras(cameras: Camera[]): void;
  62486. /**
  62487. * Enables the effect on given cameras
  62488. * @param cameras The camera to enable.
  62489. * @hidden
  62490. */
  62491. _enable(cameras: Camera): void;
  62492. /**
  62493. * Enables the effect on given cameras
  62494. * @param cameras The camera to enable.
  62495. * @hidden
  62496. */
  62497. _enable(cameras: Nullable<Camera[]>): void;
  62498. /**
  62499. * Disables the effect on the given cameras
  62500. * @param cameras The camera to disable.
  62501. * @hidden
  62502. */
  62503. _disable(cameras: Camera): void;
  62504. /**
  62505. * Disables the effect on the given cameras
  62506. * @param cameras The camera to disable.
  62507. * @hidden
  62508. */
  62509. _disable(cameras: Nullable<Camera[]>): void;
  62510. /**
  62511. * Gets a list of the post processes contained in the effect.
  62512. * @param camera The camera to get the post processes on.
  62513. * @returns The list of the post processes in the effect.
  62514. */
  62515. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62516. }
  62517. }
  62518. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62520. /** @hidden */
  62521. export var extractHighlightsPixelShader: {
  62522. name: string;
  62523. shader: string;
  62524. };
  62525. }
  62526. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62527. import { Nullable } from "babylonjs/types";
  62528. import { Camera } from "babylonjs/Cameras/camera";
  62529. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62530. import { Engine } from "babylonjs/Engines/engine";
  62531. import "babylonjs/Shaders/extractHighlights.fragment";
  62532. /**
  62533. * 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.
  62534. */
  62535. export class ExtractHighlightsPostProcess extends PostProcess {
  62536. /**
  62537. * The luminance threshold, pixels below this value will be set to black.
  62538. */
  62539. threshold: number;
  62540. /** @hidden */
  62541. _exposure: number;
  62542. /**
  62543. * Post process which has the input texture to be used when performing highlight extraction
  62544. * @hidden
  62545. */
  62546. _inputPostProcess: Nullable<PostProcess>;
  62547. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62548. }
  62549. }
  62550. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62551. /** @hidden */
  62552. export var bloomMergePixelShader: {
  62553. name: string;
  62554. shader: string;
  62555. };
  62556. }
  62557. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62559. import { Nullable } from "babylonjs/types";
  62560. import { Engine } from "babylonjs/Engines/engine";
  62561. import { Camera } from "babylonjs/Cameras/camera";
  62562. import "babylonjs/Shaders/bloomMerge.fragment";
  62563. /**
  62564. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62565. */
  62566. export class BloomMergePostProcess extends PostProcess {
  62567. /** Weight of the bloom to be added to the original input. */
  62568. weight: number;
  62569. /**
  62570. * Creates a new instance of @see BloomMergePostProcess
  62571. * @param name The name of the effect.
  62572. * @param originalFromInput Post process which's input will be used for the merge.
  62573. * @param blurred Blurred highlights post process which's output will be used.
  62574. * @param weight Weight of the bloom to be added to the original input.
  62575. * @param options The required width/height ratio to downsize to before computing the render pass.
  62576. * @param camera The camera to apply the render pass to.
  62577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62578. * @param engine The engine which the post process will be applied. (default: current engine)
  62579. * @param reusable If the post process can be reused on the same frame. (default: false)
  62580. * @param textureType Type of textures used when performing the post process. (default: 0)
  62581. * @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)
  62582. */
  62583. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62584. /** Weight of the bloom to be added to the original input. */
  62585. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62586. }
  62587. }
  62588. declare module "babylonjs/PostProcesses/bloomEffect" {
  62589. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62590. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62591. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62592. import { Camera } from "babylonjs/Cameras/camera";
  62593. import { Scene } from "babylonjs/scene";
  62594. /**
  62595. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62596. */
  62597. export class BloomEffect extends PostProcessRenderEffect {
  62598. private bloomScale;
  62599. /**
  62600. * @hidden Internal
  62601. */
  62602. _effects: Array<PostProcess>;
  62603. /**
  62604. * @hidden Internal
  62605. */
  62606. _downscale: ExtractHighlightsPostProcess;
  62607. private _blurX;
  62608. private _blurY;
  62609. private _merge;
  62610. /**
  62611. * The luminance threshold to find bright areas of the image to bloom.
  62612. */
  62613. threshold: number;
  62614. /**
  62615. * The strength of the bloom.
  62616. */
  62617. weight: number;
  62618. /**
  62619. * Specifies the size of the bloom blur kernel, relative to the final output size
  62620. */
  62621. kernel: number;
  62622. /**
  62623. * Creates a new instance of @see BloomEffect
  62624. * @param scene The scene the effect belongs to.
  62625. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62626. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62627. * @param bloomWeight The the strength of bloom.
  62628. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62629. * @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)
  62630. */
  62631. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62632. /**
  62633. * Disposes each of the internal effects for a given camera.
  62634. * @param camera The camera to dispose the effect on.
  62635. */
  62636. disposeEffects(camera: Camera): void;
  62637. /**
  62638. * @hidden Internal
  62639. */
  62640. _updateEffects(): void;
  62641. /**
  62642. * Internal
  62643. * @returns if all the contained post processes are ready.
  62644. * @hidden
  62645. */
  62646. _isReady(): boolean;
  62647. }
  62648. }
  62649. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62650. /** @hidden */
  62651. export var chromaticAberrationPixelShader: {
  62652. name: string;
  62653. shader: string;
  62654. };
  62655. }
  62656. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62657. import { Vector2 } from "babylonjs/Maths/math.vector";
  62658. import { Nullable } from "babylonjs/types";
  62659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62660. import { Camera } from "babylonjs/Cameras/camera";
  62661. import { Engine } from "babylonjs/Engines/engine";
  62662. import "babylonjs/Shaders/chromaticAberration.fragment";
  62663. /**
  62664. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62665. */
  62666. export class ChromaticAberrationPostProcess extends PostProcess {
  62667. /**
  62668. * The amount of seperation of rgb channels (default: 30)
  62669. */
  62670. aberrationAmount: number;
  62671. /**
  62672. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62673. */
  62674. radialIntensity: number;
  62675. /**
  62676. * 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))
  62677. */
  62678. direction: Vector2;
  62679. /**
  62680. * 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))
  62681. */
  62682. centerPosition: Vector2;
  62683. /**
  62684. * Creates a new instance ChromaticAberrationPostProcess
  62685. * @param name The name of the effect.
  62686. * @param screenWidth The width of the screen to apply the effect on.
  62687. * @param screenHeight The height of the screen to apply the effect on.
  62688. * @param options The required width/height ratio to downsize to before computing the render pass.
  62689. * @param camera The camera to apply the render pass to.
  62690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62691. * @param engine The engine which the post process will be applied. (default: current engine)
  62692. * @param reusable If the post process can be reused on the same frame. (default: false)
  62693. * @param textureType Type of textures used when performing the post process. (default: 0)
  62694. * @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)
  62695. */
  62696. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62697. }
  62698. }
  62699. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62700. /** @hidden */
  62701. export var circleOfConfusionPixelShader: {
  62702. name: string;
  62703. shader: string;
  62704. };
  62705. }
  62706. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62707. import { Nullable } from "babylonjs/types";
  62708. import { Engine } from "babylonjs/Engines/engine";
  62709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62711. import { Camera } from "babylonjs/Cameras/camera";
  62712. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62713. /**
  62714. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62715. */
  62716. export class CircleOfConfusionPostProcess extends PostProcess {
  62717. /**
  62718. * 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.
  62719. */
  62720. lensSize: number;
  62721. /**
  62722. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62723. */
  62724. fStop: number;
  62725. /**
  62726. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62727. */
  62728. focusDistance: number;
  62729. /**
  62730. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62731. */
  62732. focalLength: number;
  62733. private _depthTexture;
  62734. /**
  62735. * Creates a new instance CircleOfConfusionPostProcess
  62736. * @param name The name of the effect.
  62737. * @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.
  62738. * @param options The required width/height ratio to downsize to before computing the render pass.
  62739. * @param camera The camera to apply the render pass to.
  62740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62741. * @param engine The engine which the post process will be applied. (default: current engine)
  62742. * @param reusable If the post process can be reused on the same frame. (default: false)
  62743. * @param textureType Type of textures used when performing the post process. (default: 0)
  62744. * @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)
  62745. */
  62746. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62747. /**
  62748. * 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.
  62749. */
  62750. depthTexture: RenderTargetTexture;
  62751. }
  62752. }
  62753. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62754. /** @hidden */
  62755. export var colorCorrectionPixelShader: {
  62756. name: string;
  62757. shader: string;
  62758. };
  62759. }
  62760. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62762. import { Engine } from "babylonjs/Engines/engine";
  62763. import { Camera } from "babylonjs/Cameras/camera";
  62764. import "babylonjs/Shaders/colorCorrection.fragment";
  62765. /**
  62766. *
  62767. * This post-process allows the modification of rendered colors by using
  62768. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62769. *
  62770. * The object needs to be provided an url to a texture containing the color
  62771. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62772. * Use an image editing software to tweak the LUT to match your needs.
  62773. *
  62774. * For an example of a color LUT, see here:
  62775. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62776. * For explanations on color grading, see here:
  62777. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62778. *
  62779. */
  62780. export class ColorCorrectionPostProcess extends PostProcess {
  62781. private _colorTableTexture;
  62782. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62783. }
  62784. }
  62785. declare module "babylonjs/Shaders/convolution.fragment" {
  62786. /** @hidden */
  62787. export var convolutionPixelShader: {
  62788. name: string;
  62789. shader: string;
  62790. };
  62791. }
  62792. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62794. import { Nullable } from "babylonjs/types";
  62795. import { Camera } from "babylonjs/Cameras/camera";
  62796. import { Engine } from "babylonjs/Engines/engine";
  62797. import "babylonjs/Shaders/convolution.fragment";
  62798. /**
  62799. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62800. * input texture to perform effects such as edge detection or sharpening
  62801. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62802. */
  62803. export class ConvolutionPostProcess extends PostProcess {
  62804. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62805. kernel: number[];
  62806. /**
  62807. * Creates a new instance ConvolutionPostProcess
  62808. * @param name The name of the effect.
  62809. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62810. * @param options The required width/height ratio to downsize to before computing the render pass.
  62811. * @param camera The camera to apply the render pass to.
  62812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62813. * @param engine The engine which the post process will be applied. (default: current engine)
  62814. * @param reusable If the post process can be reused on the same frame. (default: false)
  62815. * @param textureType Type of textures used when performing the post process. (default: 0)
  62816. */
  62817. constructor(name: string,
  62818. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62819. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62820. /**
  62821. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62822. */
  62823. static EdgeDetect0Kernel: number[];
  62824. /**
  62825. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62826. */
  62827. static EdgeDetect1Kernel: number[];
  62828. /**
  62829. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62830. */
  62831. static EdgeDetect2Kernel: number[];
  62832. /**
  62833. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62834. */
  62835. static SharpenKernel: number[];
  62836. /**
  62837. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62838. */
  62839. static EmbossKernel: number[];
  62840. /**
  62841. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62842. */
  62843. static GaussianKernel: number[];
  62844. }
  62845. }
  62846. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62847. import { Nullable } from "babylonjs/types";
  62848. import { Vector2 } from "babylonjs/Maths/math.vector";
  62849. import { Camera } from "babylonjs/Cameras/camera";
  62850. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62851. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62852. import { Engine } from "babylonjs/Engines/engine";
  62853. import { Scene } from "babylonjs/scene";
  62854. /**
  62855. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62856. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62857. * based on samples that have a large difference in distance than the center pixel.
  62858. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62859. */
  62860. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62861. direction: Vector2;
  62862. /**
  62863. * Creates a new instance CircleOfConfusionPostProcess
  62864. * @param name The name of the effect.
  62865. * @param scene The scene the effect belongs to.
  62866. * @param direction The direction the blur should be applied.
  62867. * @param kernel The size of the kernel used to blur.
  62868. * @param options The required width/height ratio to downsize to before computing the render pass.
  62869. * @param camera The camera to apply the render pass to.
  62870. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62871. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62873. * @param engine The engine which the post process will be applied. (default: current engine)
  62874. * @param reusable If the post process can be reused on the same frame. (default: false)
  62875. * @param textureType Type of textures used when performing the post process. (default: 0)
  62876. * @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)
  62877. */
  62878. 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);
  62879. }
  62880. }
  62881. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62882. /** @hidden */
  62883. export var depthOfFieldMergePixelShader: {
  62884. name: string;
  62885. shader: string;
  62886. };
  62887. }
  62888. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62889. import { Nullable } from "babylonjs/types";
  62890. import { Camera } from "babylonjs/Cameras/camera";
  62891. import { Effect } from "babylonjs/Materials/effect";
  62892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62893. import { Engine } from "babylonjs/Engines/engine";
  62894. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62895. /**
  62896. * Options to be set when merging outputs from the default pipeline.
  62897. */
  62898. export class DepthOfFieldMergePostProcessOptions {
  62899. /**
  62900. * The original image to merge on top of
  62901. */
  62902. originalFromInput: PostProcess;
  62903. /**
  62904. * Parameters to perform the merge of the depth of field effect
  62905. */
  62906. depthOfField?: {
  62907. circleOfConfusion: PostProcess;
  62908. blurSteps: Array<PostProcess>;
  62909. };
  62910. /**
  62911. * Parameters to perform the merge of bloom effect
  62912. */
  62913. bloom?: {
  62914. blurred: PostProcess;
  62915. weight: number;
  62916. };
  62917. }
  62918. /**
  62919. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62920. */
  62921. export class DepthOfFieldMergePostProcess extends PostProcess {
  62922. private blurSteps;
  62923. /**
  62924. * Creates a new instance of DepthOfFieldMergePostProcess
  62925. * @param name The name of the effect.
  62926. * @param originalFromInput Post process which's input will be used for the merge.
  62927. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62928. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62929. * @param options The required width/height ratio to downsize to before computing the render pass.
  62930. * @param camera The camera to apply the render pass to.
  62931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62932. * @param engine The engine which the post process will be applied. (default: current engine)
  62933. * @param reusable If the post process can be reused on the same frame. (default: false)
  62934. * @param textureType Type of textures used when performing the post process. (default: 0)
  62935. * @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)
  62936. */
  62937. 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);
  62938. /**
  62939. * Updates the effect with the current post process compile time values and recompiles the shader.
  62940. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62941. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62942. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62943. * @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
  62944. * @param onCompiled Called when the shader has been compiled.
  62945. * @param onError Called if there is an error when compiling a shader.
  62946. */
  62947. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62948. }
  62949. }
  62950. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62951. import { Nullable } from "babylonjs/types";
  62952. import { Camera } from "babylonjs/Cameras/camera";
  62953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62954. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62955. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62956. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62957. import { Scene } from "babylonjs/scene";
  62958. /**
  62959. * Specifies the level of max blur that should be applied when using the depth of field effect
  62960. */
  62961. export enum DepthOfFieldEffectBlurLevel {
  62962. /**
  62963. * Subtle blur
  62964. */
  62965. Low = 0,
  62966. /**
  62967. * Medium blur
  62968. */
  62969. Medium = 1,
  62970. /**
  62971. * Large blur
  62972. */
  62973. High = 2
  62974. }
  62975. /**
  62976. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62977. */
  62978. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62979. private _circleOfConfusion;
  62980. /**
  62981. * @hidden Internal, blurs from high to low
  62982. */
  62983. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62984. private _depthOfFieldBlurY;
  62985. private _dofMerge;
  62986. /**
  62987. * @hidden Internal post processes in depth of field effect
  62988. */
  62989. _effects: Array<PostProcess>;
  62990. /**
  62991. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62992. */
  62993. focalLength: number;
  62994. /**
  62995. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62996. */
  62997. fStop: number;
  62998. /**
  62999. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63000. */
  63001. focusDistance: number;
  63002. /**
  63003. * 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.
  63004. */
  63005. lensSize: number;
  63006. /**
  63007. * Creates a new instance DepthOfFieldEffect
  63008. * @param scene The scene the effect belongs to.
  63009. * @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.
  63010. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63011. * @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)
  63012. */
  63013. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63014. /**
  63015. * Get the current class name of the current effet
  63016. * @returns "DepthOfFieldEffect"
  63017. */
  63018. getClassName(): string;
  63019. /**
  63020. * 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.
  63021. */
  63022. depthTexture: RenderTargetTexture;
  63023. /**
  63024. * Disposes each of the internal effects for a given camera.
  63025. * @param camera The camera to dispose the effect on.
  63026. */
  63027. disposeEffects(camera: Camera): void;
  63028. /**
  63029. * @hidden Internal
  63030. */
  63031. _updateEffects(): void;
  63032. /**
  63033. * Internal
  63034. * @returns if all the contained post processes are ready.
  63035. * @hidden
  63036. */
  63037. _isReady(): boolean;
  63038. }
  63039. }
  63040. declare module "babylonjs/Shaders/displayPass.fragment" {
  63041. /** @hidden */
  63042. export var displayPassPixelShader: {
  63043. name: string;
  63044. shader: string;
  63045. };
  63046. }
  63047. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63048. import { Nullable } from "babylonjs/types";
  63049. import { Camera } from "babylonjs/Cameras/camera";
  63050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63051. import { Engine } from "babylonjs/Engines/engine";
  63052. import "babylonjs/Shaders/displayPass.fragment";
  63053. /**
  63054. * DisplayPassPostProcess which produces an output the same as it's input
  63055. */
  63056. export class DisplayPassPostProcess extends PostProcess {
  63057. /**
  63058. * Creates the DisplayPassPostProcess
  63059. * @param name The name of the effect.
  63060. * @param options The required width/height ratio to downsize to before computing the render pass.
  63061. * @param camera The camera to apply the render pass to.
  63062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63063. * @param engine The engine which the post process will be applied. (default: current engine)
  63064. * @param reusable If the post process can be reused on the same frame. (default: false)
  63065. */
  63066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63067. }
  63068. }
  63069. declare module "babylonjs/Shaders/filter.fragment" {
  63070. /** @hidden */
  63071. export var filterPixelShader: {
  63072. name: string;
  63073. shader: string;
  63074. };
  63075. }
  63076. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63077. import { Nullable } from "babylonjs/types";
  63078. import { Matrix } from "babylonjs/Maths/math.vector";
  63079. import { Camera } from "babylonjs/Cameras/camera";
  63080. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63081. import { Engine } from "babylonjs/Engines/engine";
  63082. import "babylonjs/Shaders/filter.fragment";
  63083. /**
  63084. * Applies a kernel filter to the image
  63085. */
  63086. export class FilterPostProcess extends PostProcess {
  63087. /** The matrix to be applied to the image */
  63088. kernelMatrix: Matrix;
  63089. /**
  63090. *
  63091. * @param name The name of the effect.
  63092. * @param kernelMatrix The matrix to be applied to the image
  63093. * @param options The required width/height ratio to downsize to before computing the render pass.
  63094. * @param camera The camera to apply the render pass to.
  63095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63096. * @param engine The engine which the post process will be applied. (default: current engine)
  63097. * @param reusable If the post process can be reused on the same frame. (default: false)
  63098. */
  63099. constructor(name: string,
  63100. /** The matrix to be applied to the image */
  63101. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63102. }
  63103. }
  63104. declare module "babylonjs/Shaders/fxaa.fragment" {
  63105. /** @hidden */
  63106. export var fxaaPixelShader: {
  63107. name: string;
  63108. shader: string;
  63109. };
  63110. }
  63111. declare module "babylonjs/Shaders/fxaa.vertex" {
  63112. /** @hidden */
  63113. export var fxaaVertexShader: {
  63114. name: string;
  63115. shader: string;
  63116. };
  63117. }
  63118. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63119. import { Nullable } from "babylonjs/types";
  63120. import { Camera } from "babylonjs/Cameras/camera";
  63121. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63122. import { Engine } from "babylonjs/Engines/engine";
  63123. import "babylonjs/Shaders/fxaa.fragment";
  63124. import "babylonjs/Shaders/fxaa.vertex";
  63125. /**
  63126. * Fxaa post process
  63127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63128. */
  63129. export class FxaaPostProcess extends PostProcess {
  63130. /** @hidden */
  63131. texelWidth: number;
  63132. /** @hidden */
  63133. texelHeight: number;
  63134. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63135. private _getDefines;
  63136. }
  63137. }
  63138. declare module "babylonjs/Shaders/grain.fragment" {
  63139. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63140. /** @hidden */
  63141. export var grainPixelShader: {
  63142. name: string;
  63143. shader: string;
  63144. };
  63145. }
  63146. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63147. import { Nullable } from "babylonjs/types";
  63148. import { Camera } from "babylonjs/Cameras/camera";
  63149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63150. import { Engine } from "babylonjs/Engines/engine";
  63151. import "babylonjs/Shaders/grain.fragment";
  63152. /**
  63153. * The GrainPostProcess adds noise to the image at mid luminance levels
  63154. */
  63155. export class GrainPostProcess extends PostProcess {
  63156. /**
  63157. * The intensity of the grain added (default: 30)
  63158. */
  63159. intensity: number;
  63160. /**
  63161. * If the grain should be randomized on every frame
  63162. */
  63163. animated: boolean;
  63164. /**
  63165. * Creates a new instance of @see GrainPostProcess
  63166. * @param name The name of the effect.
  63167. * @param options The required width/height ratio to downsize to before computing the render pass.
  63168. * @param camera The camera to apply the render pass to.
  63169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63170. * @param engine The engine which the post process will be applied. (default: current engine)
  63171. * @param reusable If the post process can be reused on the same frame. (default: false)
  63172. * @param textureType Type of textures used when performing the post process. (default: 0)
  63173. * @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)
  63174. */
  63175. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63176. }
  63177. }
  63178. declare module "babylonjs/Shaders/highlights.fragment" {
  63179. /** @hidden */
  63180. export var highlightsPixelShader: {
  63181. name: string;
  63182. shader: string;
  63183. };
  63184. }
  63185. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63186. import { Nullable } from "babylonjs/types";
  63187. import { Camera } from "babylonjs/Cameras/camera";
  63188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63189. import { Engine } from "babylonjs/Engines/engine";
  63190. import "babylonjs/Shaders/highlights.fragment";
  63191. /**
  63192. * Extracts highlights from the image
  63193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63194. */
  63195. export class HighlightsPostProcess extends PostProcess {
  63196. /**
  63197. * Extracts highlights from the image
  63198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63199. * @param name The name of the effect.
  63200. * @param options The required width/height ratio to downsize to before computing the render pass.
  63201. * @param camera The camera to apply the render pass to.
  63202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63203. * @param engine The engine which the post process will be applied. (default: current engine)
  63204. * @param reusable If the post process can be reused on the same frame. (default: false)
  63205. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63206. */
  63207. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63208. }
  63209. }
  63210. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63211. /** @hidden */
  63212. export var mrtFragmentDeclaration: {
  63213. name: string;
  63214. shader: string;
  63215. };
  63216. }
  63217. declare module "babylonjs/Shaders/geometry.fragment" {
  63218. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63219. /** @hidden */
  63220. export var geometryPixelShader: {
  63221. name: string;
  63222. shader: string;
  63223. };
  63224. }
  63225. declare module "babylonjs/Shaders/geometry.vertex" {
  63226. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63229. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63231. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63232. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63233. /** @hidden */
  63234. export var geometryVertexShader: {
  63235. name: string;
  63236. shader: string;
  63237. };
  63238. }
  63239. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63240. import { Matrix } from "babylonjs/Maths/math.vector";
  63241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63242. import { Mesh } from "babylonjs/Meshes/mesh";
  63243. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63244. import { Effect } from "babylonjs/Materials/effect";
  63245. import { Scene } from "babylonjs/scene";
  63246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63247. import "babylonjs/Shaders/geometry.fragment";
  63248. import "babylonjs/Shaders/geometry.vertex";
  63249. /** @hidden */
  63250. interface ISavedTransformationMatrix {
  63251. world: Matrix;
  63252. viewProjection: Matrix;
  63253. }
  63254. /**
  63255. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63256. */
  63257. export class GeometryBufferRenderer {
  63258. /**
  63259. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63260. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63261. */
  63262. static readonly POSITION_TEXTURE_TYPE: number;
  63263. /**
  63264. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63265. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63266. */
  63267. static readonly VELOCITY_TEXTURE_TYPE: number;
  63268. /**
  63269. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63270. * in order to compute objects velocities when enableVelocity is set to "true"
  63271. * @hidden
  63272. */
  63273. _previousTransformationMatrices: {
  63274. [index: number]: ISavedTransformationMatrix;
  63275. };
  63276. /**
  63277. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63278. * in order to compute objects velocities when enableVelocity is set to "true"
  63279. * @hidden
  63280. */
  63281. _previousBonesTransformationMatrices: {
  63282. [index: number]: Float32Array;
  63283. };
  63284. /**
  63285. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63286. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63287. */
  63288. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63289. private _scene;
  63290. private _multiRenderTarget;
  63291. private _ratio;
  63292. private _enablePosition;
  63293. private _enableVelocity;
  63294. private _positionIndex;
  63295. private _velocityIndex;
  63296. protected _effect: Effect;
  63297. protected _cachedDefines: string;
  63298. /**
  63299. * Set the render list (meshes to be rendered) used in the G buffer.
  63300. */
  63301. renderList: Mesh[];
  63302. /**
  63303. * Gets wether or not G buffer are supported by the running hardware.
  63304. * This requires draw buffer supports
  63305. */
  63306. readonly isSupported: boolean;
  63307. /**
  63308. * Returns the index of the given texture type in the G-Buffer textures array
  63309. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63310. * @returns the index of the given texture type in the G-Buffer textures array
  63311. */
  63312. getTextureIndex(textureType: number): number;
  63313. /**
  63314. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63315. */
  63316. /**
  63317. * Sets whether or not objects positions are enabled for the G buffer.
  63318. */
  63319. enablePosition: boolean;
  63320. /**
  63321. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63322. */
  63323. /**
  63324. * Sets wether or not objects velocities are enabled for the G buffer.
  63325. */
  63326. enableVelocity: boolean;
  63327. /**
  63328. * Gets the scene associated with the buffer.
  63329. */
  63330. readonly scene: Scene;
  63331. /**
  63332. * Gets the ratio used by the buffer during its creation.
  63333. * How big is the buffer related to the main canvas.
  63334. */
  63335. readonly ratio: number;
  63336. /** @hidden */
  63337. static _SceneComponentInitialization: (scene: Scene) => void;
  63338. /**
  63339. * Creates a new G Buffer for the scene
  63340. * @param scene The scene the buffer belongs to
  63341. * @param ratio How big is the buffer related to the main canvas.
  63342. */
  63343. constructor(scene: Scene, ratio?: number);
  63344. /**
  63345. * Checks wether everything is ready to render a submesh to the G buffer.
  63346. * @param subMesh the submesh to check readiness for
  63347. * @param useInstances is the mesh drawn using instance or not
  63348. * @returns true if ready otherwise false
  63349. */
  63350. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63351. /**
  63352. * Gets the current underlying G Buffer.
  63353. * @returns the buffer
  63354. */
  63355. getGBuffer(): MultiRenderTarget;
  63356. /**
  63357. * Gets the number of samples used to render the buffer (anti aliasing).
  63358. */
  63359. /**
  63360. * Sets the number of samples used to render the buffer (anti aliasing).
  63361. */
  63362. samples: number;
  63363. /**
  63364. * Disposes the renderer and frees up associated resources.
  63365. */
  63366. dispose(): void;
  63367. protected _createRenderTargets(): void;
  63368. private _copyBonesTransformationMatrices;
  63369. }
  63370. }
  63371. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63372. import { Nullable } from "babylonjs/types";
  63373. import { Scene } from "babylonjs/scene";
  63374. import { ISceneComponent } from "babylonjs/sceneComponent";
  63375. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63376. module "babylonjs/scene" {
  63377. interface Scene {
  63378. /** @hidden (Backing field) */
  63379. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63380. /**
  63381. * Gets or Sets the current geometry buffer associated to the scene.
  63382. */
  63383. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63384. /**
  63385. * Enables a GeometryBufferRender and associates it with the scene
  63386. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63387. * @returns the GeometryBufferRenderer
  63388. */
  63389. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63390. /**
  63391. * Disables the GeometryBufferRender associated with the scene
  63392. */
  63393. disableGeometryBufferRenderer(): void;
  63394. }
  63395. }
  63396. /**
  63397. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63398. * in several rendering techniques.
  63399. */
  63400. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63401. /**
  63402. * The component name helpful to identify the component in the list of scene components.
  63403. */
  63404. readonly name: string;
  63405. /**
  63406. * The scene the component belongs to.
  63407. */
  63408. scene: Scene;
  63409. /**
  63410. * Creates a new instance of the component for the given scene
  63411. * @param scene Defines the scene to register the component in
  63412. */
  63413. constructor(scene: Scene);
  63414. /**
  63415. * Registers the component in a given scene
  63416. */
  63417. register(): void;
  63418. /**
  63419. * Rebuilds the elements related to this component in case of
  63420. * context lost for instance.
  63421. */
  63422. rebuild(): void;
  63423. /**
  63424. * Disposes the component and the associated ressources
  63425. */
  63426. dispose(): void;
  63427. private _gatherRenderTargets;
  63428. }
  63429. }
  63430. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63431. /** @hidden */
  63432. export var motionBlurPixelShader: {
  63433. name: string;
  63434. shader: string;
  63435. };
  63436. }
  63437. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63438. import { Nullable } from "babylonjs/types";
  63439. import { Camera } from "babylonjs/Cameras/camera";
  63440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63441. import { Scene } from "babylonjs/scene";
  63442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63443. import "babylonjs/Animations/animatable";
  63444. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63445. import "babylonjs/Shaders/motionBlur.fragment";
  63446. import { Engine } from "babylonjs/Engines/engine";
  63447. /**
  63448. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63449. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63450. * As an example, all you have to do is to create the post-process:
  63451. * var mb = new BABYLON.MotionBlurPostProcess(
  63452. * 'mb', // The name of the effect.
  63453. * scene, // The scene containing the objects to blur according to their velocity.
  63454. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63455. * camera // The camera to apply the render pass to.
  63456. * );
  63457. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63458. */
  63459. export class MotionBlurPostProcess extends PostProcess {
  63460. /**
  63461. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63462. */
  63463. motionStrength: number;
  63464. /**
  63465. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63466. */
  63467. /**
  63468. * Sets the number of iterations to be used for motion blur quality
  63469. */
  63470. motionBlurSamples: number;
  63471. private _motionBlurSamples;
  63472. private _geometryBufferRenderer;
  63473. /**
  63474. * Creates a new instance MotionBlurPostProcess
  63475. * @param name The name of the effect.
  63476. * @param scene The scene containing the objects to blur according to their velocity.
  63477. * @param options The required width/height ratio to downsize to before computing the render pass.
  63478. * @param camera The camera to apply the render pass to.
  63479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63480. * @param engine The engine which the post process will be applied. (default: current engine)
  63481. * @param reusable If the post process can be reused on the same frame. (default: false)
  63482. * @param textureType Type of textures used when performing the post process. (default: 0)
  63483. * @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)
  63484. */
  63485. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63486. /**
  63487. * Excludes the given skinned mesh from computing bones velocities.
  63488. * 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.
  63489. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63490. */
  63491. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63492. /**
  63493. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63494. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63495. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63496. */
  63497. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63498. /**
  63499. * Disposes the post process.
  63500. * @param camera The camera to dispose the post process on.
  63501. */
  63502. dispose(camera?: Camera): void;
  63503. }
  63504. }
  63505. declare module "babylonjs/Shaders/refraction.fragment" {
  63506. /** @hidden */
  63507. export var refractionPixelShader: {
  63508. name: string;
  63509. shader: string;
  63510. };
  63511. }
  63512. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63513. import { Color3 } from "babylonjs/Maths/math.color";
  63514. import { Camera } from "babylonjs/Cameras/camera";
  63515. import { Texture } from "babylonjs/Materials/Textures/texture";
  63516. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63517. import { Engine } from "babylonjs/Engines/engine";
  63518. import "babylonjs/Shaders/refraction.fragment";
  63519. /**
  63520. * Post process which applies a refractin texture
  63521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63522. */
  63523. export class RefractionPostProcess extends PostProcess {
  63524. /** the base color of the refraction (used to taint the rendering) */
  63525. color: Color3;
  63526. /** simulated refraction depth */
  63527. depth: number;
  63528. /** the coefficient of the base color (0 to remove base color tainting) */
  63529. colorLevel: number;
  63530. private _refTexture;
  63531. private _ownRefractionTexture;
  63532. /**
  63533. * Gets or sets the refraction texture
  63534. * Please note that you are responsible for disposing the texture if you set it manually
  63535. */
  63536. refractionTexture: Texture;
  63537. /**
  63538. * Initializes the RefractionPostProcess
  63539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63540. * @param name The name of the effect.
  63541. * @param refractionTextureUrl Url of the refraction texture to use
  63542. * @param color the base color of the refraction (used to taint the rendering)
  63543. * @param depth simulated refraction depth
  63544. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63545. * @param camera The camera to apply the render pass to.
  63546. * @param options The required width/height ratio to downsize to before computing the render pass.
  63547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63548. * @param engine The engine which the post process will be applied. (default: current engine)
  63549. * @param reusable If the post process can be reused on the same frame. (default: false)
  63550. */
  63551. constructor(name: string, refractionTextureUrl: string,
  63552. /** the base color of the refraction (used to taint the rendering) */
  63553. color: Color3,
  63554. /** simulated refraction depth */
  63555. depth: number,
  63556. /** the coefficient of the base color (0 to remove base color tainting) */
  63557. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63558. /**
  63559. * Disposes of the post process
  63560. * @param camera Camera to dispose post process on
  63561. */
  63562. dispose(camera: Camera): void;
  63563. }
  63564. }
  63565. declare module "babylonjs/Shaders/sharpen.fragment" {
  63566. /** @hidden */
  63567. export var sharpenPixelShader: {
  63568. name: string;
  63569. shader: string;
  63570. };
  63571. }
  63572. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63573. import { Nullable } from "babylonjs/types";
  63574. import { Camera } from "babylonjs/Cameras/camera";
  63575. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63576. import "babylonjs/Shaders/sharpen.fragment";
  63577. import { Engine } from "babylonjs/Engines/engine";
  63578. /**
  63579. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63580. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63581. */
  63582. export class SharpenPostProcess extends PostProcess {
  63583. /**
  63584. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63585. */
  63586. colorAmount: number;
  63587. /**
  63588. * How much sharpness should be applied (default: 0.3)
  63589. */
  63590. edgeAmount: number;
  63591. /**
  63592. * Creates a new instance ConvolutionPostProcess
  63593. * @param name The name of the effect.
  63594. * @param options The required width/height ratio to downsize to before computing the render pass.
  63595. * @param camera The camera to apply the render pass to.
  63596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63597. * @param engine The engine which the post process will be applied. (default: current engine)
  63598. * @param reusable If the post process can be reused on the same frame. (default: false)
  63599. * @param textureType Type of textures used when performing the post process. (default: 0)
  63600. * @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)
  63601. */
  63602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63603. }
  63604. }
  63605. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63606. import { Nullable } from "babylonjs/types";
  63607. import { Camera } from "babylonjs/Cameras/camera";
  63608. import { Engine } from "babylonjs/Engines/engine";
  63609. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63610. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63611. /**
  63612. * PostProcessRenderPipeline
  63613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63614. */
  63615. export class PostProcessRenderPipeline {
  63616. private engine;
  63617. private _renderEffects;
  63618. private _renderEffectsForIsolatedPass;
  63619. /**
  63620. * List of inspectable custom properties (used by the Inspector)
  63621. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63622. */
  63623. inspectableCustomProperties: IInspectable[];
  63624. /**
  63625. * @hidden
  63626. */
  63627. protected _cameras: Camera[];
  63628. /** @hidden */
  63629. _name: string;
  63630. /**
  63631. * Gets pipeline name
  63632. */
  63633. readonly name: string;
  63634. /**
  63635. * Initializes a PostProcessRenderPipeline
  63636. * @param engine engine to add the pipeline to
  63637. * @param name name of the pipeline
  63638. */
  63639. constructor(engine: Engine, name: string);
  63640. /**
  63641. * Gets the class name
  63642. * @returns "PostProcessRenderPipeline"
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * If all the render effects in the pipeline are supported
  63647. */
  63648. readonly isSupported: boolean;
  63649. /**
  63650. * Adds an effect to the pipeline
  63651. * @param renderEffect the effect to add
  63652. */
  63653. addEffect(renderEffect: PostProcessRenderEffect): void;
  63654. /** @hidden */
  63655. _rebuild(): void;
  63656. /** @hidden */
  63657. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63658. /** @hidden */
  63659. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63660. /** @hidden */
  63661. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63662. /** @hidden */
  63663. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63664. /** @hidden */
  63665. _attachCameras(cameras: Camera, unique: boolean): void;
  63666. /** @hidden */
  63667. _attachCameras(cameras: Camera[], unique: boolean): void;
  63668. /** @hidden */
  63669. _detachCameras(cameras: Camera): void;
  63670. /** @hidden */
  63671. _detachCameras(cameras: Nullable<Camera[]>): void;
  63672. /** @hidden */
  63673. _update(): void;
  63674. /** @hidden */
  63675. _reset(): void;
  63676. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63677. /**
  63678. * Disposes of the pipeline
  63679. */
  63680. dispose(): void;
  63681. }
  63682. }
  63683. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63684. import { Camera } from "babylonjs/Cameras/camera";
  63685. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63686. /**
  63687. * PostProcessRenderPipelineManager class
  63688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63689. */
  63690. export class PostProcessRenderPipelineManager {
  63691. private _renderPipelines;
  63692. /**
  63693. * Initializes a PostProcessRenderPipelineManager
  63694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63695. */
  63696. constructor();
  63697. /**
  63698. * Gets the list of supported render pipelines
  63699. */
  63700. readonly supportedPipelines: PostProcessRenderPipeline[];
  63701. /**
  63702. * Adds a pipeline to the manager
  63703. * @param renderPipeline The pipeline to add
  63704. */
  63705. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63706. /**
  63707. * Attaches a camera to the pipeline
  63708. * @param renderPipelineName The name of the pipeline to attach to
  63709. * @param cameras the camera to attach
  63710. * @param unique if the camera can be attached multiple times to the pipeline
  63711. */
  63712. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63713. /**
  63714. * Detaches a camera from the pipeline
  63715. * @param renderPipelineName The name of the pipeline to detach from
  63716. * @param cameras the camera to detach
  63717. */
  63718. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63719. /**
  63720. * Enables an effect by name on a pipeline
  63721. * @param renderPipelineName the name of the pipeline to enable the effect in
  63722. * @param renderEffectName the name of the effect to enable
  63723. * @param cameras the cameras that the effect should be enabled on
  63724. */
  63725. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63726. /**
  63727. * Disables an effect by name on a pipeline
  63728. * @param renderPipelineName the name of the pipeline to disable the effect in
  63729. * @param renderEffectName the name of the effect to disable
  63730. * @param cameras the cameras that the effect should be disabled on
  63731. */
  63732. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63733. /**
  63734. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63735. */
  63736. update(): void;
  63737. /** @hidden */
  63738. _rebuild(): void;
  63739. /**
  63740. * Disposes of the manager and pipelines
  63741. */
  63742. dispose(): void;
  63743. }
  63744. }
  63745. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63746. import { ISceneComponent } from "babylonjs/sceneComponent";
  63747. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63748. import { Scene } from "babylonjs/scene";
  63749. module "babylonjs/scene" {
  63750. interface Scene {
  63751. /** @hidden (Backing field) */
  63752. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63753. /**
  63754. * Gets the postprocess render pipeline manager
  63755. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63756. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63757. */
  63758. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63759. }
  63760. }
  63761. /**
  63762. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63763. */
  63764. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63765. /**
  63766. * The component name helpfull to identify the component in the list of scene components.
  63767. */
  63768. readonly name: string;
  63769. /**
  63770. * The scene the component belongs to.
  63771. */
  63772. scene: Scene;
  63773. /**
  63774. * Creates a new instance of the component for the given scene
  63775. * @param scene Defines the scene to register the component in
  63776. */
  63777. constructor(scene: Scene);
  63778. /**
  63779. * Registers the component in a given scene
  63780. */
  63781. register(): void;
  63782. /**
  63783. * Rebuilds the elements related to this component in case of
  63784. * context lost for instance.
  63785. */
  63786. rebuild(): void;
  63787. /**
  63788. * Disposes the component and the associated ressources
  63789. */
  63790. dispose(): void;
  63791. private _gatherRenderTargets;
  63792. }
  63793. }
  63794. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63795. import { Nullable } from "babylonjs/types";
  63796. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63797. import { Camera } from "babylonjs/Cameras/camera";
  63798. import { IDisposable } from "babylonjs/scene";
  63799. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63800. import { Scene } from "babylonjs/scene";
  63801. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63802. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63803. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63804. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63805. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63806. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63807. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63808. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63809. import { Animation } from "babylonjs/Animations/animation";
  63810. /**
  63811. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63812. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63813. */
  63814. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63815. private _scene;
  63816. private _camerasToBeAttached;
  63817. /**
  63818. * ID of the sharpen post process,
  63819. */
  63820. private readonly SharpenPostProcessId;
  63821. /**
  63822. * @ignore
  63823. * ID of the image processing post process;
  63824. */
  63825. readonly ImageProcessingPostProcessId: string;
  63826. /**
  63827. * @ignore
  63828. * ID of the Fast Approximate Anti-Aliasing post process;
  63829. */
  63830. readonly FxaaPostProcessId: string;
  63831. /**
  63832. * ID of the chromatic aberration post process,
  63833. */
  63834. private readonly ChromaticAberrationPostProcessId;
  63835. /**
  63836. * ID of the grain post process
  63837. */
  63838. private readonly GrainPostProcessId;
  63839. /**
  63840. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63841. */
  63842. sharpen: SharpenPostProcess;
  63843. private _sharpenEffect;
  63844. private bloom;
  63845. /**
  63846. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63847. */
  63848. depthOfField: DepthOfFieldEffect;
  63849. /**
  63850. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63851. */
  63852. fxaa: FxaaPostProcess;
  63853. /**
  63854. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63855. */
  63856. imageProcessing: ImageProcessingPostProcess;
  63857. /**
  63858. * Chromatic aberration post process which will shift rgb colors in the image
  63859. */
  63860. chromaticAberration: ChromaticAberrationPostProcess;
  63861. private _chromaticAberrationEffect;
  63862. /**
  63863. * Grain post process which add noise to the image
  63864. */
  63865. grain: GrainPostProcess;
  63866. private _grainEffect;
  63867. /**
  63868. * Glow post process which adds a glow to emissive areas of the image
  63869. */
  63870. private _glowLayer;
  63871. /**
  63872. * Animations which can be used to tweak settings over a period of time
  63873. */
  63874. animations: Animation[];
  63875. private _imageProcessingConfigurationObserver;
  63876. private _sharpenEnabled;
  63877. private _bloomEnabled;
  63878. private _depthOfFieldEnabled;
  63879. private _depthOfFieldBlurLevel;
  63880. private _fxaaEnabled;
  63881. private _imageProcessingEnabled;
  63882. private _defaultPipelineTextureType;
  63883. private _bloomScale;
  63884. private _chromaticAberrationEnabled;
  63885. private _grainEnabled;
  63886. private _buildAllowed;
  63887. /**
  63888. * Gets active scene
  63889. */
  63890. readonly scene: Scene;
  63891. /**
  63892. * Enable or disable the sharpen process from the pipeline
  63893. */
  63894. sharpenEnabled: boolean;
  63895. private _resizeObserver;
  63896. private _hardwareScaleLevel;
  63897. private _bloomKernel;
  63898. /**
  63899. * Specifies the size of the bloom blur kernel, relative to the final output size
  63900. */
  63901. bloomKernel: number;
  63902. /**
  63903. * Specifies the weight of the bloom in the final rendering
  63904. */
  63905. private _bloomWeight;
  63906. /**
  63907. * Specifies the luma threshold for the area that will be blurred by the bloom
  63908. */
  63909. private _bloomThreshold;
  63910. private _hdr;
  63911. /**
  63912. * The strength of the bloom.
  63913. */
  63914. bloomWeight: number;
  63915. /**
  63916. * The strength of the bloom.
  63917. */
  63918. bloomThreshold: number;
  63919. /**
  63920. * The scale of the bloom, lower value will provide better performance.
  63921. */
  63922. bloomScale: number;
  63923. /**
  63924. * Enable or disable the bloom from the pipeline
  63925. */
  63926. bloomEnabled: boolean;
  63927. private _rebuildBloom;
  63928. /**
  63929. * If the depth of field is enabled.
  63930. */
  63931. depthOfFieldEnabled: boolean;
  63932. /**
  63933. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63934. */
  63935. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63936. /**
  63937. * If the anti aliasing is enabled.
  63938. */
  63939. fxaaEnabled: boolean;
  63940. private _samples;
  63941. /**
  63942. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63943. */
  63944. samples: number;
  63945. /**
  63946. * If image processing is enabled.
  63947. */
  63948. imageProcessingEnabled: boolean;
  63949. /**
  63950. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63951. */
  63952. glowLayerEnabled: boolean;
  63953. /**
  63954. * Gets the glow layer (or null if not defined)
  63955. */
  63956. readonly glowLayer: Nullable<GlowLayer>;
  63957. /**
  63958. * Enable or disable the chromaticAberration process from the pipeline
  63959. */
  63960. chromaticAberrationEnabled: boolean;
  63961. /**
  63962. * Enable or disable the grain process from the pipeline
  63963. */
  63964. grainEnabled: boolean;
  63965. /**
  63966. * @constructor
  63967. * @param name - The rendering pipeline name (default: "")
  63968. * @param hdr - If high dynamic range textures should be used (default: true)
  63969. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63970. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63971. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63972. */
  63973. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63974. /**
  63975. * Get the class name
  63976. * @returns "DefaultRenderingPipeline"
  63977. */
  63978. getClassName(): string;
  63979. /**
  63980. * Force the compilation of the entire pipeline.
  63981. */
  63982. prepare(): void;
  63983. private _hasCleared;
  63984. private _prevPostProcess;
  63985. private _prevPrevPostProcess;
  63986. private _setAutoClearAndTextureSharing;
  63987. private _depthOfFieldSceneObserver;
  63988. private _buildPipeline;
  63989. private _disposePostProcesses;
  63990. /**
  63991. * Adds a camera to the pipeline
  63992. * @param camera the camera to be added
  63993. */
  63994. addCamera(camera: Camera): void;
  63995. /**
  63996. * Removes a camera from the pipeline
  63997. * @param camera the camera to remove
  63998. */
  63999. removeCamera(camera: Camera): void;
  64000. /**
  64001. * Dispose of the pipeline and stop all post processes
  64002. */
  64003. dispose(): void;
  64004. /**
  64005. * Serialize the rendering pipeline (Used when exporting)
  64006. * @returns the serialized object
  64007. */
  64008. serialize(): any;
  64009. /**
  64010. * Parse the serialized pipeline
  64011. * @param source Source pipeline.
  64012. * @param scene The scene to load the pipeline to.
  64013. * @param rootUrl The URL of the serialized pipeline.
  64014. * @returns An instantiated pipeline from the serialized object.
  64015. */
  64016. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64017. }
  64018. }
  64019. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64020. /** @hidden */
  64021. export var lensHighlightsPixelShader: {
  64022. name: string;
  64023. shader: string;
  64024. };
  64025. }
  64026. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64027. /** @hidden */
  64028. export var depthOfFieldPixelShader: {
  64029. name: string;
  64030. shader: string;
  64031. };
  64032. }
  64033. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64034. import { Camera } from "babylonjs/Cameras/camera";
  64035. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64036. import { Scene } from "babylonjs/scene";
  64037. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64038. import "babylonjs/Shaders/chromaticAberration.fragment";
  64039. import "babylonjs/Shaders/lensHighlights.fragment";
  64040. import "babylonjs/Shaders/depthOfField.fragment";
  64041. /**
  64042. * BABYLON.JS Chromatic Aberration GLSL Shader
  64043. * Author: Olivier Guyot
  64044. * Separates very slightly R, G and B colors on the edges of the screen
  64045. * Inspired by Francois Tarlier & Martins Upitis
  64046. */
  64047. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64048. /**
  64049. * @ignore
  64050. * The chromatic aberration PostProcess id in the pipeline
  64051. */
  64052. LensChromaticAberrationEffect: string;
  64053. /**
  64054. * @ignore
  64055. * The highlights enhancing PostProcess id in the pipeline
  64056. */
  64057. HighlightsEnhancingEffect: string;
  64058. /**
  64059. * @ignore
  64060. * The depth-of-field PostProcess id in the pipeline
  64061. */
  64062. LensDepthOfFieldEffect: string;
  64063. private _scene;
  64064. private _depthTexture;
  64065. private _grainTexture;
  64066. private _chromaticAberrationPostProcess;
  64067. private _highlightsPostProcess;
  64068. private _depthOfFieldPostProcess;
  64069. private _edgeBlur;
  64070. private _grainAmount;
  64071. private _chromaticAberration;
  64072. private _distortion;
  64073. private _highlightsGain;
  64074. private _highlightsThreshold;
  64075. private _dofDistance;
  64076. private _dofAperture;
  64077. private _dofDarken;
  64078. private _dofPentagon;
  64079. private _blurNoise;
  64080. /**
  64081. * @constructor
  64082. *
  64083. * Effect parameters are as follow:
  64084. * {
  64085. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64086. * edge_blur: number; // from 0 to x (1 for realism)
  64087. * distortion: number; // from 0 to x (1 for realism)
  64088. * grain_amount: number; // from 0 to 1
  64089. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64090. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64091. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64092. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64093. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64094. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64095. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64096. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64097. * }
  64098. * Note: if an effect parameter is unset, effect is disabled
  64099. *
  64100. * @param name The rendering pipeline name
  64101. * @param parameters - An object containing all parameters (see above)
  64102. * @param scene The scene linked to this pipeline
  64103. * @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)
  64104. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64105. */
  64106. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64107. /**
  64108. * Get the class name
  64109. * @returns "LensRenderingPipeline"
  64110. */
  64111. getClassName(): string;
  64112. /**
  64113. * Gets associated scene
  64114. */
  64115. readonly scene: Scene;
  64116. /**
  64117. * Gets or sets the edge blur
  64118. */
  64119. edgeBlur: number;
  64120. /**
  64121. * Gets or sets the grain amount
  64122. */
  64123. grainAmount: number;
  64124. /**
  64125. * Gets or sets the chromatic aberration amount
  64126. */
  64127. chromaticAberration: number;
  64128. /**
  64129. * Gets or sets the depth of field aperture
  64130. */
  64131. dofAperture: number;
  64132. /**
  64133. * Gets or sets the edge distortion
  64134. */
  64135. edgeDistortion: number;
  64136. /**
  64137. * Gets or sets the depth of field distortion
  64138. */
  64139. dofDistortion: number;
  64140. /**
  64141. * Gets or sets the darken out of focus amount
  64142. */
  64143. darkenOutOfFocus: number;
  64144. /**
  64145. * Gets or sets a boolean indicating if blur noise is enabled
  64146. */
  64147. blurNoise: boolean;
  64148. /**
  64149. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64150. */
  64151. pentagonBokeh: boolean;
  64152. /**
  64153. * Gets or sets the highlight grain amount
  64154. */
  64155. highlightsGain: number;
  64156. /**
  64157. * Gets or sets the highlight threshold
  64158. */
  64159. highlightsThreshold: number;
  64160. /**
  64161. * Sets the amount of blur at the edges
  64162. * @param amount blur amount
  64163. */
  64164. setEdgeBlur(amount: number): void;
  64165. /**
  64166. * Sets edge blur to 0
  64167. */
  64168. disableEdgeBlur(): void;
  64169. /**
  64170. * Sets the amout of grain
  64171. * @param amount Amount of grain
  64172. */
  64173. setGrainAmount(amount: number): void;
  64174. /**
  64175. * Set grain amount to 0
  64176. */
  64177. disableGrain(): void;
  64178. /**
  64179. * Sets the chromatic aberration amount
  64180. * @param amount amount of chromatic aberration
  64181. */
  64182. setChromaticAberration(amount: number): void;
  64183. /**
  64184. * Sets chromatic aberration amount to 0
  64185. */
  64186. disableChromaticAberration(): void;
  64187. /**
  64188. * Sets the EdgeDistortion amount
  64189. * @param amount amount of EdgeDistortion
  64190. */
  64191. setEdgeDistortion(amount: number): void;
  64192. /**
  64193. * Sets edge distortion to 0
  64194. */
  64195. disableEdgeDistortion(): void;
  64196. /**
  64197. * Sets the FocusDistance amount
  64198. * @param amount amount of FocusDistance
  64199. */
  64200. setFocusDistance(amount: number): void;
  64201. /**
  64202. * Disables depth of field
  64203. */
  64204. disableDepthOfField(): void;
  64205. /**
  64206. * Sets the Aperture amount
  64207. * @param amount amount of Aperture
  64208. */
  64209. setAperture(amount: number): void;
  64210. /**
  64211. * Sets the DarkenOutOfFocus amount
  64212. * @param amount amount of DarkenOutOfFocus
  64213. */
  64214. setDarkenOutOfFocus(amount: number): void;
  64215. private _pentagonBokehIsEnabled;
  64216. /**
  64217. * Creates a pentagon bokeh effect
  64218. */
  64219. enablePentagonBokeh(): void;
  64220. /**
  64221. * Disables the pentagon bokeh effect
  64222. */
  64223. disablePentagonBokeh(): void;
  64224. /**
  64225. * Enables noise blur
  64226. */
  64227. enableNoiseBlur(): void;
  64228. /**
  64229. * Disables noise blur
  64230. */
  64231. disableNoiseBlur(): void;
  64232. /**
  64233. * Sets the HighlightsGain amount
  64234. * @param amount amount of HighlightsGain
  64235. */
  64236. setHighlightsGain(amount: number): void;
  64237. /**
  64238. * Sets the HighlightsThreshold amount
  64239. * @param amount amount of HighlightsThreshold
  64240. */
  64241. setHighlightsThreshold(amount: number): void;
  64242. /**
  64243. * Disables highlights
  64244. */
  64245. disableHighlights(): void;
  64246. /**
  64247. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64248. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64249. */
  64250. dispose(disableDepthRender?: boolean): void;
  64251. private _createChromaticAberrationPostProcess;
  64252. private _createHighlightsPostProcess;
  64253. private _createDepthOfFieldPostProcess;
  64254. private _createGrainTexture;
  64255. }
  64256. }
  64257. declare module "babylonjs/Shaders/ssao2.fragment" {
  64258. /** @hidden */
  64259. export var ssao2PixelShader: {
  64260. name: string;
  64261. shader: string;
  64262. };
  64263. }
  64264. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64265. /** @hidden */
  64266. export var ssaoCombinePixelShader: {
  64267. name: string;
  64268. shader: string;
  64269. };
  64270. }
  64271. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64272. import { Camera } from "babylonjs/Cameras/camera";
  64273. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64274. import { Scene } from "babylonjs/scene";
  64275. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64276. import "babylonjs/Shaders/ssao2.fragment";
  64277. import "babylonjs/Shaders/ssaoCombine.fragment";
  64278. /**
  64279. * Render pipeline to produce ssao effect
  64280. */
  64281. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64282. /**
  64283. * @ignore
  64284. * The PassPostProcess id in the pipeline that contains the original scene color
  64285. */
  64286. SSAOOriginalSceneColorEffect: string;
  64287. /**
  64288. * @ignore
  64289. * The SSAO PostProcess id in the pipeline
  64290. */
  64291. SSAORenderEffect: string;
  64292. /**
  64293. * @ignore
  64294. * The horizontal blur PostProcess id in the pipeline
  64295. */
  64296. SSAOBlurHRenderEffect: string;
  64297. /**
  64298. * @ignore
  64299. * The vertical blur PostProcess id in the pipeline
  64300. */
  64301. SSAOBlurVRenderEffect: string;
  64302. /**
  64303. * @ignore
  64304. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64305. */
  64306. SSAOCombineRenderEffect: string;
  64307. /**
  64308. * The output strength of the SSAO post-process. Default value is 1.0.
  64309. */
  64310. totalStrength: number;
  64311. /**
  64312. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64313. */
  64314. maxZ: number;
  64315. /**
  64316. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64317. */
  64318. minZAspect: number;
  64319. private _samples;
  64320. /**
  64321. * Number of samples used for the SSAO calculations. Default value is 8
  64322. */
  64323. samples: number;
  64324. private _textureSamples;
  64325. /**
  64326. * Number of samples to use for antialiasing
  64327. */
  64328. textureSamples: number;
  64329. /**
  64330. * Ratio object used for SSAO ratio and blur ratio
  64331. */
  64332. private _ratio;
  64333. /**
  64334. * Dynamically generated sphere sampler.
  64335. */
  64336. private _sampleSphere;
  64337. /**
  64338. * Blur filter offsets
  64339. */
  64340. private _samplerOffsets;
  64341. private _expensiveBlur;
  64342. /**
  64343. * If bilateral blur should be used
  64344. */
  64345. expensiveBlur: boolean;
  64346. /**
  64347. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64348. */
  64349. radius: number;
  64350. /**
  64351. * The base color of the SSAO post-process
  64352. * The final result is "base + ssao" between [0, 1]
  64353. */
  64354. base: number;
  64355. /**
  64356. * Support test.
  64357. */
  64358. static readonly IsSupported: boolean;
  64359. private _scene;
  64360. private _depthTexture;
  64361. private _normalTexture;
  64362. private _randomTexture;
  64363. private _originalColorPostProcess;
  64364. private _ssaoPostProcess;
  64365. private _blurHPostProcess;
  64366. private _blurVPostProcess;
  64367. private _ssaoCombinePostProcess;
  64368. private _firstUpdate;
  64369. /**
  64370. * Gets active scene
  64371. */
  64372. readonly scene: Scene;
  64373. /**
  64374. * @constructor
  64375. * @param name The rendering pipeline name
  64376. * @param scene The scene linked to this pipeline
  64377. * @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 }
  64378. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64379. */
  64380. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64381. /**
  64382. * Get the class name
  64383. * @returns "SSAO2RenderingPipeline"
  64384. */
  64385. getClassName(): string;
  64386. /**
  64387. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64388. */
  64389. dispose(disableGeometryBufferRenderer?: boolean): void;
  64390. private _createBlurPostProcess;
  64391. /** @hidden */
  64392. _rebuild(): void;
  64393. private _bits;
  64394. private _radicalInverse_VdC;
  64395. private _hammersley;
  64396. private _hemisphereSample_uniform;
  64397. private _generateHemisphere;
  64398. private _createSSAOPostProcess;
  64399. private _createSSAOCombinePostProcess;
  64400. private _createRandomTexture;
  64401. /**
  64402. * Serialize the rendering pipeline (Used when exporting)
  64403. * @returns the serialized object
  64404. */
  64405. serialize(): any;
  64406. /**
  64407. * Parse the serialized pipeline
  64408. * @param source Source pipeline.
  64409. * @param scene The scene to load the pipeline to.
  64410. * @param rootUrl The URL of the serialized pipeline.
  64411. * @returns An instantiated pipeline from the serialized object.
  64412. */
  64413. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64414. }
  64415. }
  64416. declare module "babylonjs/Shaders/ssao.fragment" {
  64417. /** @hidden */
  64418. export var ssaoPixelShader: {
  64419. name: string;
  64420. shader: string;
  64421. };
  64422. }
  64423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64424. import { Camera } from "babylonjs/Cameras/camera";
  64425. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64426. import { Scene } from "babylonjs/scene";
  64427. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64428. import "babylonjs/Shaders/ssao.fragment";
  64429. import "babylonjs/Shaders/ssaoCombine.fragment";
  64430. /**
  64431. * Render pipeline to produce ssao effect
  64432. */
  64433. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64434. /**
  64435. * @ignore
  64436. * The PassPostProcess id in the pipeline that contains the original scene color
  64437. */
  64438. SSAOOriginalSceneColorEffect: string;
  64439. /**
  64440. * @ignore
  64441. * The SSAO PostProcess id in the pipeline
  64442. */
  64443. SSAORenderEffect: string;
  64444. /**
  64445. * @ignore
  64446. * The horizontal blur PostProcess id in the pipeline
  64447. */
  64448. SSAOBlurHRenderEffect: string;
  64449. /**
  64450. * @ignore
  64451. * The vertical blur PostProcess id in the pipeline
  64452. */
  64453. SSAOBlurVRenderEffect: string;
  64454. /**
  64455. * @ignore
  64456. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64457. */
  64458. SSAOCombineRenderEffect: string;
  64459. /**
  64460. * The output strength of the SSAO post-process. Default value is 1.0.
  64461. */
  64462. totalStrength: number;
  64463. /**
  64464. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64465. */
  64466. radius: number;
  64467. /**
  64468. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64469. * Must not be equal to fallOff and superior to fallOff.
  64470. * Default value is 0.0075
  64471. */
  64472. area: number;
  64473. /**
  64474. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64475. * Must not be equal to area and inferior to area.
  64476. * Default value is 0.000001
  64477. */
  64478. fallOff: number;
  64479. /**
  64480. * The base color of the SSAO post-process
  64481. * The final result is "base + ssao" between [0, 1]
  64482. */
  64483. base: number;
  64484. private _scene;
  64485. private _depthTexture;
  64486. private _randomTexture;
  64487. private _originalColorPostProcess;
  64488. private _ssaoPostProcess;
  64489. private _blurHPostProcess;
  64490. private _blurVPostProcess;
  64491. private _ssaoCombinePostProcess;
  64492. private _firstUpdate;
  64493. /**
  64494. * Gets active scene
  64495. */
  64496. readonly scene: Scene;
  64497. /**
  64498. * @constructor
  64499. * @param name - The rendering pipeline name
  64500. * @param scene - The scene linked to this pipeline
  64501. * @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 }
  64502. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64503. */
  64504. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64505. /**
  64506. * Get the class name
  64507. * @returns "SSAORenderingPipeline"
  64508. */
  64509. getClassName(): string;
  64510. /**
  64511. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64512. */
  64513. dispose(disableDepthRender?: boolean): void;
  64514. private _createBlurPostProcess;
  64515. /** @hidden */
  64516. _rebuild(): void;
  64517. private _createSSAOPostProcess;
  64518. private _createSSAOCombinePostProcess;
  64519. private _createRandomTexture;
  64520. }
  64521. }
  64522. declare module "babylonjs/Shaders/standard.fragment" {
  64523. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64524. /** @hidden */
  64525. export var standardPixelShader: {
  64526. name: string;
  64527. shader: string;
  64528. };
  64529. }
  64530. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64531. import { Nullable } from "babylonjs/types";
  64532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64533. import { Camera } from "babylonjs/Cameras/camera";
  64534. import { Texture } from "babylonjs/Materials/Textures/texture";
  64535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64536. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64537. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64538. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64539. import { IDisposable } from "babylonjs/scene";
  64540. import { SpotLight } from "babylonjs/Lights/spotLight";
  64541. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64542. import { Scene } from "babylonjs/scene";
  64543. import { Animation } from "babylonjs/Animations/animation";
  64544. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64545. import "babylonjs/Shaders/standard.fragment";
  64546. /**
  64547. * Standard rendering pipeline
  64548. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64549. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64550. */
  64551. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64552. /**
  64553. * Public members
  64554. */
  64555. /**
  64556. * Post-process which contains the original scene color before the pipeline applies all the effects
  64557. */
  64558. originalPostProcess: Nullable<PostProcess>;
  64559. /**
  64560. * Post-process used to down scale an image x4
  64561. */
  64562. downSampleX4PostProcess: Nullable<PostProcess>;
  64563. /**
  64564. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64565. */
  64566. brightPassPostProcess: Nullable<PostProcess>;
  64567. /**
  64568. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64569. */
  64570. blurHPostProcesses: PostProcess[];
  64571. /**
  64572. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64573. */
  64574. blurVPostProcesses: PostProcess[];
  64575. /**
  64576. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64577. */
  64578. textureAdderPostProcess: Nullable<PostProcess>;
  64579. /**
  64580. * Post-process used to create volumetric lighting effect
  64581. */
  64582. volumetricLightPostProcess: Nullable<PostProcess>;
  64583. /**
  64584. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64585. */
  64586. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64587. /**
  64588. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64589. */
  64590. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64591. /**
  64592. * Post-process used to merge the volumetric light effect and the real scene color
  64593. */
  64594. volumetricLightMergePostProces: Nullable<PostProcess>;
  64595. /**
  64596. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64597. */
  64598. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64599. /**
  64600. * Base post-process used to calculate the average luminance of the final image for HDR
  64601. */
  64602. luminancePostProcess: Nullable<PostProcess>;
  64603. /**
  64604. * Post-processes used to create down sample post-processes in order to get
  64605. * the average luminance of the final image for HDR
  64606. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64607. */
  64608. luminanceDownSamplePostProcesses: PostProcess[];
  64609. /**
  64610. * Post-process used to create a HDR effect (light adaptation)
  64611. */
  64612. hdrPostProcess: Nullable<PostProcess>;
  64613. /**
  64614. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64615. */
  64616. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64617. /**
  64618. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64619. */
  64620. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64621. /**
  64622. * Post-process used to merge the final HDR post-process and the real scene color
  64623. */
  64624. hdrFinalPostProcess: Nullable<PostProcess>;
  64625. /**
  64626. * Post-process used to create a lens flare effect
  64627. */
  64628. lensFlarePostProcess: Nullable<PostProcess>;
  64629. /**
  64630. * Post-process that merges the result of the lens flare post-process and the real scene color
  64631. */
  64632. lensFlareComposePostProcess: Nullable<PostProcess>;
  64633. /**
  64634. * Post-process used to create a motion blur effect
  64635. */
  64636. motionBlurPostProcess: Nullable<PostProcess>;
  64637. /**
  64638. * Post-process used to create a depth of field effect
  64639. */
  64640. depthOfFieldPostProcess: Nullable<PostProcess>;
  64641. /**
  64642. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64643. */
  64644. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64645. /**
  64646. * Represents the brightness threshold in order to configure the illuminated surfaces
  64647. */
  64648. brightThreshold: number;
  64649. /**
  64650. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64651. */
  64652. blurWidth: number;
  64653. /**
  64654. * Sets if the blur for highlighted surfaces must be only horizontal
  64655. */
  64656. horizontalBlur: boolean;
  64657. /**
  64658. * Gets the overall exposure used by the pipeline
  64659. */
  64660. /**
  64661. * Sets the overall exposure used by the pipeline
  64662. */
  64663. exposure: number;
  64664. /**
  64665. * Texture used typically to simulate "dirty" on camera lens
  64666. */
  64667. lensTexture: Nullable<Texture>;
  64668. /**
  64669. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64670. */
  64671. volumetricLightCoefficient: number;
  64672. /**
  64673. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64674. */
  64675. volumetricLightPower: number;
  64676. /**
  64677. * Used the set the blur intensity to smooth the volumetric lights
  64678. */
  64679. volumetricLightBlurScale: number;
  64680. /**
  64681. * Light (spot or directional) used to generate the volumetric lights rays
  64682. * The source light must have a shadow generate so the pipeline can get its
  64683. * depth map
  64684. */
  64685. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64686. /**
  64687. * For eye adaptation, represents the minimum luminance the eye can see
  64688. */
  64689. hdrMinimumLuminance: number;
  64690. /**
  64691. * For eye adaptation, represents the decrease luminance speed
  64692. */
  64693. hdrDecreaseRate: number;
  64694. /**
  64695. * For eye adaptation, represents the increase luminance speed
  64696. */
  64697. hdrIncreaseRate: number;
  64698. /**
  64699. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64700. */
  64701. /**
  64702. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64703. */
  64704. hdrAutoExposure: boolean;
  64705. /**
  64706. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64707. */
  64708. lensColorTexture: Nullable<Texture>;
  64709. /**
  64710. * The overall strengh for the lens flare effect
  64711. */
  64712. lensFlareStrength: number;
  64713. /**
  64714. * Dispersion coefficient for lens flare ghosts
  64715. */
  64716. lensFlareGhostDispersal: number;
  64717. /**
  64718. * Main lens flare halo width
  64719. */
  64720. lensFlareHaloWidth: number;
  64721. /**
  64722. * Based on the lens distortion effect, defines how much the lens flare result
  64723. * is distorted
  64724. */
  64725. lensFlareDistortionStrength: number;
  64726. /**
  64727. * Configures the blur intensity used for for lens flare (halo)
  64728. */
  64729. lensFlareBlurWidth: number;
  64730. /**
  64731. * Lens star texture must be used to simulate rays on the flares and is available
  64732. * in the documentation
  64733. */
  64734. lensStarTexture: Nullable<Texture>;
  64735. /**
  64736. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64737. * flare effect by taking account of the dirt texture
  64738. */
  64739. lensFlareDirtTexture: Nullable<Texture>;
  64740. /**
  64741. * Represents the focal length for the depth of field effect
  64742. */
  64743. depthOfFieldDistance: number;
  64744. /**
  64745. * Represents the blur intensity for the blurred part of the depth of field effect
  64746. */
  64747. depthOfFieldBlurWidth: number;
  64748. /**
  64749. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64750. */
  64751. /**
  64752. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64753. */
  64754. motionStrength: number;
  64755. /**
  64756. * Gets wether or not the motion blur post-process is object based or screen based.
  64757. */
  64758. /**
  64759. * Sets wether or not the motion blur post-process should be object based or screen based
  64760. */
  64761. objectBasedMotionBlur: boolean;
  64762. /**
  64763. * List of animations for the pipeline (IAnimatable implementation)
  64764. */
  64765. animations: Animation[];
  64766. /**
  64767. * Private members
  64768. */
  64769. private _scene;
  64770. private _currentDepthOfFieldSource;
  64771. private _basePostProcess;
  64772. private _fixedExposure;
  64773. private _currentExposure;
  64774. private _hdrAutoExposure;
  64775. private _hdrCurrentLuminance;
  64776. private _motionStrength;
  64777. private _isObjectBasedMotionBlur;
  64778. private _floatTextureType;
  64779. private _camerasToBeAttached;
  64780. private _ratio;
  64781. private _bloomEnabled;
  64782. private _depthOfFieldEnabled;
  64783. private _vlsEnabled;
  64784. private _lensFlareEnabled;
  64785. private _hdrEnabled;
  64786. private _motionBlurEnabled;
  64787. private _fxaaEnabled;
  64788. private _motionBlurSamples;
  64789. private _volumetricLightStepsCount;
  64790. private _samples;
  64791. /**
  64792. * @ignore
  64793. * Specifies if the bloom pipeline is enabled
  64794. */
  64795. BloomEnabled: boolean;
  64796. /**
  64797. * @ignore
  64798. * Specifies if the depth of field pipeline is enabed
  64799. */
  64800. DepthOfFieldEnabled: boolean;
  64801. /**
  64802. * @ignore
  64803. * Specifies if the lens flare pipeline is enabed
  64804. */
  64805. LensFlareEnabled: boolean;
  64806. /**
  64807. * @ignore
  64808. * Specifies if the HDR pipeline is enabled
  64809. */
  64810. HDREnabled: boolean;
  64811. /**
  64812. * @ignore
  64813. * Specifies if the volumetric lights scattering effect is enabled
  64814. */
  64815. VLSEnabled: boolean;
  64816. /**
  64817. * @ignore
  64818. * Specifies if the motion blur effect is enabled
  64819. */
  64820. MotionBlurEnabled: boolean;
  64821. /**
  64822. * Specifies if anti-aliasing is enabled
  64823. */
  64824. fxaaEnabled: boolean;
  64825. /**
  64826. * Specifies the number of steps used to calculate the volumetric lights
  64827. * Typically in interval [50, 200]
  64828. */
  64829. volumetricLightStepsCount: number;
  64830. /**
  64831. * Specifies the number of samples used for the motion blur effect
  64832. * Typically in interval [16, 64]
  64833. */
  64834. motionBlurSamples: number;
  64835. /**
  64836. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64837. */
  64838. samples: number;
  64839. /**
  64840. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64841. * @constructor
  64842. * @param name The rendering pipeline name
  64843. * @param scene The scene linked to this pipeline
  64844. * @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)
  64845. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64846. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64847. */
  64848. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64849. private _buildPipeline;
  64850. private _createDownSampleX4PostProcess;
  64851. private _createBrightPassPostProcess;
  64852. private _createBlurPostProcesses;
  64853. private _createTextureAdderPostProcess;
  64854. private _createVolumetricLightPostProcess;
  64855. private _createLuminancePostProcesses;
  64856. private _createHdrPostProcess;
  64857. private _createLensFlarePostProcess;
  64858. private _createDepthOfFieldPostProcess;
  64859. private _createMotionBlurPostProcess;
  64860. private _getDepthTexture;
  64861. private _disposePostProcesses;
  64862. /**
  64863. * Dispose of the pipeline and stop all post processes
  64864. */
  64865. dispose(): void;
  64866. /**
  64867. * Serialize the rendering pipeline (Used when exporting)
  64868. * @returns the serialized object
  64869. */
  64870. serialize(): any;
  64871. /**
  64872. * Parse the serialized pipeline
  64873. * @param source Source pipeline.
  64874. * @param scene The scene to load the pipeline to.
  64875. * @param rootUrl The URL of the serialized pipeline.
  64876. * @returns An instantiated pipeline from the serialized object.
  64877. */
  64878. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64879. /**
  64880. * Luminance steps
  64881. */
  64882. static LuminanceSteps: number;
  64883. }
  64884. }
  64885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64886. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64887. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64888. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64889. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64890. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64891. }
  64892. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64893. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64894. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64895. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64896. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64897. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64898. }
  64899. declare module "babylonjs/Shaders/tonemap.fragment" {
  64900. /** @hidden */
  64901. export var tonemapPixelShader: {
  64902. name: string;
  64903. shader: string;
  64904. };
  64905. }
  64906. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64907. import { Camera } from "babylonjs/Cameras/camera";
  64908. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64909. import "babylonjs/Shaders/tonemap.fragment";
  64910. import { Engine } from "babylonjs/Engines/engine";
  64911. /** Defines operator used for tonemapping */
  64912. export enum TonemappingOperator {
  64913. /** Hable */
  64914. Hable = 0,
  64915. /** Reinhard */
  64916. Reinhard = 1,
  64917. /** HejiDawson */
  64918. HejiDawson = 2,
  64919. /** Photographic */
  64920. Photographic = 3
  64921. }
  64922. /**
  64923. * Defines a post process to apply tone mapping
  64924. */
  64925. export class TonemapPostProcess extends PostProcess {
  64926. private _operator;
  64927. /** Defines the required exposure adjustement */
  64928. exposureAdjustment: number;
  64929. /**
  64930. * Creates a new TonemapPostProcess
  64931. * @param name defines the name of the postprocess
  64932. * @param _operator defines the operator to use
  64933. * @param exposureAdjustment defines the required exposure adjustement
  64934. * @param camera defines the camera to use (can be null)
  64935. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64936. * @param engine defines the hosting engine (can be ignore if camera is set)
  64937. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64938. */
  64939. constructor(name: string, _operator: TonemappingOperator,
  64940. /** Defines the required exposure adjustement */
  64941. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64942. }
  64943. }
  64944. declare module "babylonjs/Shaders/depth.vertex" {
  64945. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64950. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64951. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64952. /** @hidden */
  64953. export var depthVertexShader: {
  64954. name: string;
  64955. shader: string;
  64956. };
  64957. }
  64958. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64959. /** @hidden */
  64960. export var volumetricLightScatteringPixelShader: {
  64961. name: string;
  64962. shader: string;
  64963. };
  64964. }
  64965. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64966. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64967. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64968. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64969. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64971. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64972. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64973. /** @hidden */
  64974. export var volumetricLightScatteringPassVertexShader: {
  64975. name: string;
  64976. shader: string;
  64977. };
  64978. }
  64979. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64980. /** @hidden */
  64981. export var volumetricLightScatteringPassPixelShader: {
  64982. name: string;
  64983. shader: string;
  64984. };
  64985. }
  64986. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64987. import { Vector3 } from "babylonjs/Maths/math.vector";
  64988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64989. import { Mesh } from "babylonjs/Meshes/mesh";
  64990. import { Camera } from "babylonjs/Cameras/camera";
  64991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64993. import { Scene } from "babylonjs/scene";
  64994. import "babylonjs/Meshes/Builders/planeBuilder";
  64995. import "babylonjs/Shaders/depth.vertex";
  64996. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64997. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64998. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64999. import { Engine } from "babylonjs/Engines/engine";
  65000. /**
  65001. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65002. */
  65003. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65004. private _volumetricLightScatteringPass;
  65005. private _volumetricLightScatteringRTT;
  65006. private _viewPort;
  65007. private _screenCoordinates;
  65008. private _cachedDefines;
  65009. /**
  65010. * If not undefined, the mesh position is computed from the attached node position
  65011. */
  65012. attachedNode: {
  65013. position: Vector3;
  65014. };
  65015. /**
  65016. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65017. */
  65018. customMeshPosition: Vector3;
  65019. /**
  65020. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65021. */
  65022. useCustomMeshPosition: boolean;
  65023. /**
  65024. * If the post-process should inverse the light scattering direction
  65025. */
  65026. invert: boolean;
  65027. /**
  65028. * The internal mesh used by the post-process
  65029. */
  65030. mesh: Mesh;
  65031. /**
  65032. * @hidden
  65033. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65034. */
  65035. useDiffuseColor: boolean;
  65036. /**
  65037. * Array containing the excluded meshes not rendered in the internal pass
  65038. */
  65039. excludedMeshes: AbstractMesh[];
  65040. /**
  65041. * Controls the overall intensity of the post-process
  65042. */
  65043. exposure: number;
  65044. /**
  65045. * Dissipates each sample's contribution in range [0, 1]
  65046. */
  65047. decay: number;
  65048. /**
  65049. * Controls the overall intensity of each sample
  65050. */
  65051. weight: number;
  65052. /**
  65053. * Controls the density of each sample
  65054. */
  65055. density: number;
  65056. /**
  65057. * @constructor
  65058. * @param name The post-process name
  65059. * @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)
  65060. * @param camera The camera that the post-process will be attached to
  65061. * @param mesh The mesh used to create the light scattering
  65062. * @param samples The post-process quality, default 100
  65063. * @param samplingModeThe post-process filtering mode
  65064. * @param engine The babylon engine
  65065. * @param reusable If the post-process is reusable
  65066. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65067. */
  65068. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65069. /**
  65070. * Returns the string "VolumetricLightScatteringPostProcess"
  65071. * @returns "VolumetricLightScatteringPostProcess"
  65072. */
  65073. getClassName(): string;
  65074. private _isReady;
  65075. /**
  65076. * Sets the new light position for light scattering effect
  65077. * @param position The new custom light position
  65078. */
  65079. setCustomMeshPosition(position: Vector3): void;
  65080. /**
  65081. * Returns the light position for light scattering effect
  65082. * @return Vector3 The custom light position
  65083. */
  65084. getCustomMeshPosition(): Vector3;
  65085. /**
  65086. * Disposes the internal assets and detaches the post-process from the camera
  65087. */
  65088. dispose(camera: Camera): void;
  65089. /**
  65090. * Returns the render target texture used by the post-process
  65091. * @return the render target texture used by the post-process
  65092. */
  65093. getPass(): RenderTargetTexture;
  65094. private _meshExcluded;
  65095. private _createPass;
  65096. private _updateMeshScreenCoordinates;
  65097. /**
  65098. * Creates a default mesh for the Volumeric Light Scattering post-process
  65099. * @param name The mesh name
  65100. * @param scene The scene where to create the mesh
  65101. * @return the default mesh
  65102. */
  65103. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65104. }
  65105. }
  65106. declare module "babylonjs/PostProcesses/index" {
  65107. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65108. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65109. export * from "babylonjs/PostProcesses/bloomEffect";
  65110. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65111. export * from "babylonjs/PostProcesses/blurPostProcess";
  65112. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65113. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65114. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65115. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65116. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65117. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65118. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65119. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65120. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65121. export * from "babylonjs/PostProcesses/filterPostProcess";
  65122. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65123. export * from "babylonjs/PostProcesses/grainPostProcess";
  65124. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65125. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65126. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65127. export * from "babylonjs/PostProcesses/passPostProcess";
  65128. export * from "babylonjs/PostProcesses/postProcess";
  65129. export * from "babylonjs/PostProcesses/postProcessManager";
  65130. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65131. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65132. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65133. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65134. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65135. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65136. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65137. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65138. }
  65139. declare module "babylonjs/Probes/index" {
  65140. export * from "babylonjs/Probes/reflectionProbe";
  65141. }
  65142. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65143. import { Scene } from "babylonjs/scene";
  65144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65145. import { SmartArray } from "babylonjs/Misc/smartArray";
  65146. import { ISceneComponent } from "babylonjs/sceneComponent";
  65147. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65148. import "babylonjs/Meshes/Builders/boxBuilder";
  65149. import "babylonjs/Shaders/color.fragment";
  65150. import "babylonjs/Shaders/color.vertex";
  65151. import { Color3 } from "babylonjs/Maths/math.color";
  65152. module "babylonjs/scene" {
  65153. interface Scene {
  65154. /** @hidden (Backing field) */
  65155. _boundingBoxRenderer: BoundingBoxRenderer;
  65156. /** @hidden (Backing field) */
  65157. _forceShowBoundingBoxes: boolean;
  65158. /**
  65159. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65160. */
  65161. forceShowBoundingBoxes: boolean;
  65162. /**
  65163. * Gets the bounding box renderer associated with the scene
  65164. * @returns a BoundingBoxRenderer
  65165. */
  65166. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65167. }
  65168. }
  65169. module "babylonjs/Meshes/abstractMesh" {
  65170. interface AbstractMesh {
  65171. /** @hidden (Backing field) */
  65172. _showBoundingBox: boolean;
  65173. /**
  65174. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65175. */
  65176. showBoundingBox: boolean;
  65177. }
  65178. }
  65179. /**
  65180. * Component responsible of rendering the bounding box of the meshes in a scene.
  65181. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65182. */
  65183. export class BoundingBoxRenderer implements ISceneComponent {
  65184. /**
  65185. * The component name helpfull to identify the component in the list of scene components.
  65186. */
  65187. readonly name: string;
  65188. /**
  65189. * The scene the component belongs to.
  65190. */
  65191. scene: Scene;
  65192. /**
  65193. * Color of the bounding box lines placed in front of an object
  65194. */
  65195. frontColor: Color3;
  65196. /**
  65197. * Color of the bounding box lines placed behind an object
  65198. */
  65199. backColor: Color3;
  65200. /**
  65201. * Defines if the renderer should show the back lines or not
  65202. */
  65203. showBackLines: boolean;
  65204. /**
  65205. * @hidden
  65206. */
  65207. renderList: SmartArray<BoundingBox>;
  65208. private _colorShader;
  65209. private _vertexBuffers;
  65210. private _indexBuffer;
  65211. private _fillIndexBuffer;
  65212. private _fillIndexData;
  65213. /**
  65214. * Instantiates a new bounding box renderer in a scene.
  65215. * @param scene the scene the renderer renders in
  65216. */
  65217. constructor(scene: Scene);
  65218. /**
  65219. * Registers the component in a given scene
  65220. */
  65221. register(): void;
  65222. private _evaluateSubMesh;
  65223. private _activeMesh;
  65224. private _prepareRessources;
  65225. private _createIndexBuffer;
  65226. /**
  65227. * Rebuilds the elements related to this component in case of
  65228. * context lost for instance.
  65229. */
  65230. rebuild(): void;
  65231. /**
  65232. * @hidden
  65233. */
  65234. reset(): void;
  65235. /**
  65236. * Render the bounding boxes of a specific rendering group
  65237. * @param renderingGroupId defines the rendering group to render
  65238. */
  65239. render(renderingGroupId: number): void;
  65240. /**
  65241. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65242. * @param mesh Define the mesh to render the occlusion bounding box for
  65243. */
  65244. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65245. /**
  65246. * Dispose and release the resources attached to this renderer.
  65247. */
  65248. dispose(): void;
  65249. }
  65250. }
  65251. declare module "babylonjs/Shaders/depth.fragment" {
  65252. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65253. /** @hidden */
  65254. export var depthPixelShader: {
  65255. name: string;
  65256. shader: string;
  65257. };
  65258. }
  65259. declare module "babylonjs/Rendering/depthRenderer" {
  65260. import { Nullable } from "babylonjs/types";
  65261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65262. import { Scene } from "babylonjs/scene";
  65263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65264. import { Camera } from "babylonjs/Cameras/camera";
  65265. import "babylonjs/Shaders/depth.fragment";
  65266. import "babylonjs/Shaders/depth.vertex";
  65267. /**
  65268. * This represents a depth renderer in Babylon.
  65269. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65270. */
  65271. export class DepthRenderer {
  65272. private _scene;
  65273. private _depthMap;
  65274. private _effect;
  65275. private readonly _storeNonLinearDepth;
  65276. private readonly _clearColor;
  65277. /** Get if the depth renderer is using packed depth or not */
  65278. readonly isPacked: boolean;
  65279. private _cachedDefines;
  65280. private _camera;
  65281. /**
  65282. * Specifiess that the depth renderer will only be used within
  65283. * the camera it is created for.
  65284. * This can help forcing its rendering during the camera processing.
  65285. */
  65286. useOnlyInActiveCamera: boolean;
  65287. /** @hidden */
  65288. static _SceneComponentInitialization: (scene: Scene) => void;
  65289. /**
  65290. * Instantiates a depth renderer
  65291. * @param scene The scene the renderer belongs to
  65292. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65293. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65294. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65295. */
  65296. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65297. /**
  65298. * Creates the depth rendering effect and checks if the effect is ready.
  65299. * @param subMesh The submesh to be used to render the depth map of
  65300. * @param useInstances If multiple world instances should be used
  65301. * @returns if the depth renderer is ready to render the depth map
  65302. */
  65303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65304. /**
  65305. * Gets the texture which the depth map will be written to.
  65306. * @returns The depth map texture
  65307. */
  65308. getDepthMap(): RenderTargetTexture;
  65309. /**
  65310. * Disposes of the depth renderer.
  65311. */
  65312. dispose(): void;
  65313. }
  65314. }
  65315. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65316. import { Nullable } from "babylonjs/types";
  65317. import { Scene } from "babylonjs/scene";
  65318. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65319. import { Camera } from "babylonjs/Cameras/camera";
  65320. import { ISceneComponent } from "babylonjs/sceneComponent";
  65321. module "babylonjs/scene" {
  65322. interface Scene {
  65323. /** @hidden (Backing field) */
  65324. _depthRenderer: {
  65325. [id: string]: DepthRenderer;
  65326. };
  65327. /**
  65328. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65329. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65330. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65331. * @returns the created depth renderer
  65332. */
  65333. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65334. /**
  65335. * Disables a depth renderer for a given camera
  65336. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65337. */
  65338. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65339. }
  65340. }
  65341. /**
  65342. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65343. * in several rendering techniques.
  65344. */
  65345. export class DepthRendererSceneComponent implements ISceneComponent {
  65346. /**
  65347. * The component name helpfull to identify the component in the list of scene components.
  65348. */
  65349. readonly name: string;
  65350. /**
  65351. * The scene the component belongs to.
  65352. */
  65353. scene: Scene;
  65354. /**
  65355. * Creates a new instance of the component for the given scene
  65356. * @param scene Defines the scene to register the component in
  65357. */
  65358. constructor(scene: Scene);
  65359. /**
  65360. * Registers the component in a given scene
  65361. */
  65362. register(): void;
  65363. /**
  65364. * Rebuilds the elements related to this component in case of
  65365. * context lost for instance.
  65366. */
  65367. rebuild(): void;
  65368. /**
  65369. * Disposes the component and the associated ressources
  65370. */
  65371. dispose(): void;
  65372. private _gatherRenderTargets;
  65373. private _gatherActiveCameraRenderTargets;
  65374. }
  65375. }
  65376. declare module "babylonjs/Shaders/outline.fragment" {
  65377. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65378. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65379. /** @hidden */
  65380. export var outlinePixelShader: {
  65381. name: string;
  65382. shader: string;
  65383. };
  65384. }
  65385. declare module "babylonjs/Shaders/outline.vertex" {
  65386. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65390. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65392. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65393. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65394. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65395. /** @hidden */
  65396. export var outlineVertexShader: {
  65397. name: string;
  65398. shader: string;
  65399. };
  65400. }
  65401. declare module "babylonjs/Rendering/outlineRenderer" {
  65402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65403. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65404. import { Scene } from "babylonjs/scene";
  65405. import { ISceneComponent } from "babylonjs/sceneComponent";
  65406. import "babylonjs/Shaders/outline.fragment";
  65407. import "babylonjs/Shaders/outline.vertex";
  65408. module "babylonjs/scene" {
  65409. interface Scene {
  65410. /** @hidden */
  65411. _outlineRenderer: OutlineRenderer;
  65412. /**
  65413. * Gets the outline renderer associated with the scene
  65414. * @returns a OutlineRenderer
  65415. */
  65416. getOutlineRenderer(): OutlineRenderer;
  65417. }
  65418. }
  65419. module "babylonjs/Meshes/abstractMesh" {
  65420. interface AbstractMesh {
  65421. /** @hidden (Backing field) */
  65422. _renderOutline: boolean;
  65423. /**
  65424. * Gets or sets a boolean indicating if the outline must be rendered as well
  65425. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65426. */
  65427. renderOutline: boolean;
  65428. /** @hidden (Backing field) */
  65429. _renderOverlay: boolean;
  65430. /**
  65431. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65432. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65433. */
  65434. renderOverlay: boolean;
  65435. }
  65436. }
  65437. /**
  65438. * This class is responsible to draw bothe outline/overlay of meshes.
  65439. * It should not be used directly but through the available method on mesh.
  65440. */
  65441. export class OutlineRenderer implements ISceneComponent {
  65442. /**
  65443. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65444. */
  65445. private static _StencilReference;
  65446. /**
  65447. * The name of the component. Each component must have a unique name.
  65448. */
  65449. name: string;
  65450. /**
  65451. * The scene the component belongs to.
  65452. */
  65453. scene: Scene;
  65454. /**
  65455. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65456. */
  65457. zOffset: number;
  65458. private _engine;
  65459. private _effect;
  65460. private _cachedDefines;
  65461. private _savedDepthWrite;
  65462. /**
  65463. * Instantiates a new outline renderer. (There could be only one per scene).
  65464. * @param scene Defines the scene it belongs to
  65465. */
  65466. constructor(scene: Scene);
  65467. /**
  65468. * Register the component to one instance of a scene.
  65469. */
  65470. register(): void;
  65471. /**
  65472. * Rebuilds the elements related to this component in case of
  65473. * context lost for instance.
  65474. */
  65475. rebuild(): void;
  65476. /**
  65477. * Disposes the component and the associated ressources.
  65478. */
  65479. dispose(): void;
  65480. /**
  65481. * Renders the outline in the canvas.
  65482. * @param subMesh Defines the sumesh to render
  65483. * @param batch Defines the batch of meshes in case of instances
  65484. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65485. */
  65486. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65487. /**
  65488. * Returns whether or not the outline renderer is ready for a given submesh.
  65489. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65490. * @param subMesh Defines the submesh to check readyness for
  65491. * @param useInstances Defines wheter wee are trying to render instances or not
  65492. * @returns true if ready otherwise false
  65493. */
  65494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65495. private _beforeRenderingMesh;
  65496. private _afterRenderingMesh;
  65497. }
  65498. }
  65499. declare module "babylonjs/Rendering/index" {
  65500. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65501. export * from "babylonjs/Rendering/depthRenderer";
  65502. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65503. export * from "babylonjs/Rendering/edgesRenderer";
  65504. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65505. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65506. export * from "babylonjs/Rendering/outlineRenderer";
  65507. export * from "babylonjs/Rendering/renderingGroup";
  65508. export * from "babylonjs/Rendering/renderingManager";
  65509. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65510. }
  65511. declare module "babylonjs/Sprites/spritePackedManager" {
  65512. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65513. import { Scene } from "babylonjs/scene";
  65514. /**
  65515. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65516. * @see http://doc.babylonjs.com/babylon101/sprites
  65517. */
  65518. export class SpritePackedManager extends SpriteManager {
  65519. /** defines the packed manager's name */
  65520. name: string;
  65521. /**
  65522. * Creates a new sprite manager from a packed sprite sheet
  65523. * @param name defines the manager's name
  65524. * @param imgUrl defines the sprite sheet url
  65525. * @param capacity defines the maximum allowed number of sprites
  65526. * @param scene defines the hosting scene
  65527. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65528. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65529. * @param samplingMode defines the smapling mode to use with spritesheet
  65530. * @param fromPacked set to true; do not alter
  65531. */
  65532. constructor(
  65533. /** defines the packed manager's name */
  65534. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65535. }
  65536. }
  65537. declare module "babylonjs/Sprites/index" {
  65538. export * from "babylonjs/Sprites/sprite";
  65539. export * from "babylonjs/Sprites/spriteManager";
  65540. export * from "babylonjs/Sprites/spritePackedManager";
  65541. export * from "babylonjs/Sprites/spriteSceneComponent";
  65542. }
  65543. declare module "babylonjs/States/index" {
  65544. export * from "babylonjs/States/alphaCullingState";
  65545. export * from "babylonjs/States/depthCullingState";
  65546. export * from "babylonjs/States/stencilState";
  65547. }
  65548. declare module "babylonjs/Misc/assetsManager" {
  65549. import { Scene } from "babylonjs/scene";
  65550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65551. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65552. import { Skeleton } from "babylonjs/Bones/skeleton";
  65553. import { Observable } from "babylonjs/Misc/observable";
  65554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65555. import { Texture } from "babylonjs/Materials/Textures/texture";
  65556. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65557. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65558. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65559. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65560. /**
  65561. * Defines the list of states available for a task inside a AssetsManager
  65562. */
  65563. export enum AssetTaskState {
  65564. /**
  65565. * Initialization
  65566. */
  65567. INIT = 0,
  65568. /**
  65569. * Running
  65570. */
  65571. RUNNING = 1,
  65572. /**
  65573. * Done
  65574. */
  65575. DONE = 2,
  65576. /**
  65577. * Error
  65578. */
  65579. ERROR = 3
  65580. }
  65581. /**
  65582. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65583. */
  65584. export abstract class AbstractAssetTask {
  65585. /**
  65586. * Task name
  65587. */ name: string;
  65588. /**
  65589. * Callback called when the task is successful
  65590. */
  65591. onSuccess: (task: any) => void;
  65592. /**
  65593. * Callback called when the task is not successful
  65594. */
  65595. onError: (task: any, message?: string, exception?: any) => void;
  65596. /**
  65597. * Creates a new AssetsManager
  65598. * @param name defines the name of the task
  65599. */
  65600. constructor(
  65601. /**
  65602. * Task name
  65603. */ name: string);
  65604. private _isCompleted;
  65605. private _taskState;
  65606. private _errorObject;
  65607. /**
  65608. * Get if the task is completed
  65609. */
  65610. readonly isCompleted: boolean;
  65611. /**
  65612. * Gets the current state of the task
  65613. */
  65614. readonly taskState: AssetTaskState;
  65615. /**
  65616. * Gets the current error object (if task is in error)
  65617. */
  65618. readonly errorObject: {
  65619. message?: string;
  65620. exception?: any;
  65621. };
  65622. /**
  65623. * Internal only
  65624. * @hidden
  65625. */
  65626. _setErrorObject(message?: string, exception?: any): void;
  65627. /**
  65628. * Execute the current task
  65629. * @param scene defines the scene where you want your assets to be loaded
  65630. * @param onSuccess is a callback called when the task is successfully executed
  65631. * @param onError is a callback called if an error occurs
  65632. */
  65633. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65634. /**
  65635. * Execute the current task
  65636. * @param scene defines the scene where you want your assets to be loaded
  65637. * @param onSuccess is a callback called when the task is successfully executed
  65638. * @param onError is a callback called if an error occurs
  65639. */
  65640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65641. /**
  65642. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65643. * This can be used with failed tasks that have the reason for failure fixed.
  65644. */
  65645. reset(): void;
  65646. private onErrorCallback;
  65647. private onDoneCallback;
  65648. }
  65649. /**
  65650. * Define the interface used by progress events raised during assets loading
  65651. */
  65652. export interface IAssetsProgressEvent {
  65653. /**
  65654. * Defines the number of remaining tasks to process
  65655. */
  65656. remainingCount: number;
  65657. /**
  65658. * Defines the total number of tasks
  65659. */
  65660. totalCount: number;
  65661. /**
  65662. * Defines the task that was just processed
  65663. */
  65664. task: AbstractAssetTask;
  65665. }
  65666. /**
  65667. * Class used to share progress information about assets loading
  65668. */
  65669. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65670. /**
  65671. * Defines the number of remaining tasks to process
  65672. */
  65673. remainingCount: number;
  65674. /**
  65675. * Defines the total number of tasks
  65676. */
  65677. totalCount: number;
  65678. /**
  65679. * Defines the task that was just processed
  65680. */
  65681. task: AbstractAssetTask;
  65682. /**
  65683. * Creates a AssetsProgressEvent
  65684. * @param remainingCount defines the number of remaining tasks to process
  65685. * @param totalCount defines the total number of tasks
  65686. * @param task defines the task that was just processed
  65687. */
  65688. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65689. }
  65690. /**
  65691. * Define a task used by AssetsManager to load meshes
  65692. */
  65693. export class MeshAssetTask extends AbstractAssetTask {
  65694. /**
  65695. * Defines the name of the task
  65696. */
  65697. name: string;
  65698. /**
  65699. * Defines the list of mesh's names you want to load
  65700. */
  65701. meshesNames: any;
  65702. /**
  65703. * Defines the root url to use as a base to load your meshes and associated resources
  65704. */
  65705. rootUrl: string;
  65706. /**
  65707. * Defines the filename of the scene to load from
  65708. */
  65709. sceneFilename: string;
  65710. /**
  65711. * Gets the list of loaded meshes
  65712. */
  65713. loadedMeshes: Array<AbstractMesh>;
  65714. /**
  65715. * Gets the list of loaded particle systems
  65716. */
  65717. loadedParticleSystems: Array<IParticleSystem>;
  65718. /**
  65719. * Gets the list of loaded skeletons
  65720. */
  65721. loadedSkeletons: Array<Skeleton>;
  65722. /**
  65723. * Gets the list of loaded animation groups
  65724. */
  65725. loadedAnimationGroups: Array<AnimationGroup>;
  65726. /**
  65727. * Callback called when the task is successful
  65728. */
  65729. onSuccess: (task: MeshAssetTask) => void;
  65730. /**
  65731. * Callback called when the task is successful
  65732. */
  65733. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65734. /**
  65735. * Creates a new MeshAssetTask
  65736. * @param name defines the name of the task
  65737. * @param meshesNames defines the list of mesh's names you want to load
  65738. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65739. * @param sceneFilename defines the filename of the scene to load from
  65740. */
  65741. constructor(
  65742. /**
  65743. * Defines the name of the task
  65744. */
  65745. name: string,
  65746. /**
  65747. * Defines the list of mesh's names you want to load
  65748. */
  65749. meshesNames: any,
  65750. /**
  65751. * Defines the root url to use as a base to load your meshes and associated resources
  65752. */
  65753. rootUrl: string,
  65754. /**
  65755. * Defines the filename of the scene to load from
  65756. */
  65757. sceneFilename: string);
  65758. /**
  65759. * Execute the current task
  65760. * @param scene defines the scene where you want your assets to be loaded
  65761. * @param onSuccess is a callback called when the task is successfully executed
  65762. * @param onError is a callback called if an error occurs
  65763. */
  65764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65765. }
  65766. /**
  65767. * Define a task used by AssetsManager to load text content
  65768. */
  65769. export class TextFileAssetTask extends AbstractAssetTask {
  65770. /**
  65771. * Defines the name of the task
  65772. */
  65773. name: string;
  65774. /**
  65775. * Defines the location of the file to load
  65776. */
  65777. url: string;
  65778. /**
  65779. * Gets the loaded text string
  65780. */
  65781. text: string;
  65782. /**
  65783. * Callback called when the task is successful
  65784. */
  65785. onSuccess: (task: TextFileAssetTask) => void;
  65786. /**
  65787. * Callback called when the task is successful
  65788. */
  65789. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65790. /**
  65791. * Creates a new TextFileAssetTask object
  65792. * @param name defines the name of the task
  65793. * @param url defines the location of the file to load
  65794. */
  65795. constructor(
  65796. /**
  65797. * Defines the name of the task
  65798. */
  65799. name: string,
  65800. /**
  65801. * Defines the location of the file to load
  65802. */
  65803. url: string);
  65804. /**
  65805. * Execute the current task
  65806. * @param scene defines the scene where you want your assets to be loaded
  65807. * @param onSuccess is a callback called when the task is successfully executed
  65808. * @param onError is a callback called if an error occurs
  65809. */
  65810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65811. }
  65812. /**
  65813. * Define a task used by AssetsManager to load binary data
  65814. */
  65815. export class BinaryFileAssetTask extends AbstractAssetTask {
  65816. /**
  65817. * Defines the name of the task
  65818. */
  65819. name: string;
  65820. /**
  65821. * Defines the location of the file to load
  65822. */
  65823. url: string;
  65824. /**
  65825. * Gets the lodaded data (as an array buffer)
  65826. */
  65827. data: ArrayBuffer;
  65828. /**
  65829. * Callback called when the task is successful
  65830. */
  65831. onSuccess: (task: BinaryFileAssetTask) => void;
  65832. /**
  65833. * Callback called when the task is successful
  65834. */
  65835. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65836. /**
  65837. * Creates a new BinaryFileAssetTask object
  65838. * @param name defines the name of the new task
  65839. * @param url defines the location of the file to load
  65840. */
  65841. constructor(
  65842. /**
  65843. * Defines the name of the task
  65844. */
  65845. name: string,
  65846. /**
  65847. * Defines the location of the file to load
  65848. */
  65849. url: string);
  65850. /**
  65851. * Execute the current task
  65852. * @param scene defines the scene where you want your assets to be loaded
  65853. * @param onSuccess is a callback called when the task is successfully executed
  65854. * @param onError is a callback called if an error occurs
  65855. */
  65856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65857. }
  65858. /**
  65859. * Define a task used by AssetsManager to load images
  65860. */
  65861. export class ImageAssetTask extends AbstractAssetTask {
  65862. /**
  65863. * Defines the name of the task
  65864. */
  65865. name: string;
  65866. /**
  65867. * Defines the location of the image to load
  65868. */
  65869. url: string;
  65870. /**
  65871. * Gets the loaded images
  65872. */
  65873. image: HTMLImageElement;
  65874. /**
  65875. * Callback called when the task is successful
  65876. */
  65877. onSuccess: (task: ImageAssetTask) => void;
  65878. /**
  65879. * Callback called when the task is successful
  65880. */
  65881. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65882. /**
  65883. * Creates a new ImageAssetTask
  65884. * @param name defines the name of the task
  65885. * @param url defines the location of the image to load
  65886. */
  65887. constructor(
  65888. /**
  65889. * Defines the name of the task
  65890. */
  65891. name: string,
  65892. /**
  65893. * Defines the location of the image to load
  65894. */
  65895. url: string);
  65896. /**
  65897. * Execute the current task
  65898. * @param scene defines the scene where you want your assets to be loaded
  65899. * @param onSuccess is a callback called when the task is successfully executed
  65900. * @param onError is a callback called if an error occurs
  65901. */
  65902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65903. }
  65904. /**
  65905. * Defines the interface used by texture loading tasks
  65906. */
  65907. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65908. /**
  65909. * Gets the loaded texture
  65910. */
  65911. texture: TEX;
  65912. }
  65913. /**
  65914. * Define a task used by AssetsManager to load 2D textures
  65915. */
  65916. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65917. /**
  65918. * Defines the name of the task
  65919. */
  65920. name: string;
  65921. /**
  65922. * Defines the location of the file to load
  65923. */
  65924. url: string;
  65925. /**
  65926. * Defines if mipmap should not be generated (default is false)
  65927. */
  65928. noMipmap?: boolean | undefined;
  65929. /**
  65930. * Defines if texture must be inverted on Y axis (default is false)
  65931. */
  65932. invertY?: boolean | undefined;
  65933. /**
  65934. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65935. */
  65936. samplingMode: number;
  65937. /**
  65938. * Gets the loaded texture
  65939. */
  65940. texture: Texture;
  65941. /**
  65942. * Callback called when the task is successful
  65943. */
  65944. onSuccess: (task: TextureAssetTask) => void;
  65945. /**
  65946. * Callback called when the task is successful
  65947. */
  65948. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65949. /**
  65950. * Creates a new TextureAssetTask object
  65951. * @param name defines the name of the task
  65952. * @param url defines the location of the file to load
  65953. * @param noMipmap defines if mipmap should not be generated (default is false)
  65954. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65955. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65956. */
  65957. constructor(
  65958. /**
  65959. * Defines the name of the task
  65960. */
  65961. name: string,
  65962. /**
  65963. * Defines the location of the file to load
  65964. */
  65965. url: string,
  65966. /**
  65967. * Defines if mipmap should not be generated (default is false)
  65968. */
  65969. noMipmap?: boolean | undefined,
  65970. /**
  65971. * Defines if texture must be inverted on Y axis (default is false)
  65972. */
  65973. invertY?: boolean | undefined,
  65974. /**
  65975. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65976. */
  65977. samplingMode?: number);
  65978. /**
  65979. * Execute the current task
  65980. * @param scene defines the scene where you want your assets to be loaded
  65981. * @param onSuccess is a callback called when the task is successfully executed
  65982. * @param onError is a callback called if an error occurs
  65983. */
  65984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65985. }
  65986. /**
  65987. * Define a task used by AssetsManager to load cube textures
  65988. */
  65989. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65990. /**
  65991. * Defines the name of the task
  65992. */
  65993. name: string;
  65994. /**
  65995. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65996. */
  65997. url: string;
  65998. /**
  65999. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66000. */
  66001. extensions?: string[] | undefined;
  66002. /**
  66003. * Defines if mipmaps should not be generated (default is false)
  66004. */
  66005. noMipmap?: boolean | undefined;
  66006. /**
  66007. * Defines the explicit list of files (undefined by default)
  66008. */
  66009. files?: string[] | undefined;
  66010. /**
  66011. * Gets the loaded texture
  66012. */
  66013. texture: CubeTexture;
  66014. /**
  66015. * Callback called when the task is successful
  66016. */
  66017. onSuccess: (task: CubeTextureAssetTask) => void;
  66018. /**
  66019. * Callback called when the task is successful
  66020. */
  66021. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66022. /**
  66023. * Creates a new CubeTextureAssetTask
  66024. * @param name defines the name of the task
  66025. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66026. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66027. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66028. * @param files defines the explicit list of files (undefined by default)
  66029. */
  66030. constructor(
  66031. /**
  66032. * Defines the name of the task
  66033. */
  66034. name: string,
  66035. /**
  66036. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66037. */
  66038. url: string,
  66039. /**
  66040. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66041. */
  66042. extensions?: string[] | undefined,
  66043. /**
  66044. * Defines if mipmaps should not be generated (default is false)
  66045. */
  66046. noMipmap?: boolean | undefined,
  66047. /**
  66048. * Defines the explicit list of files (undefined by default)
  66049. */
  66050. files?: string[] | undefined);
  66051. /**
  66052. * Execute the current task
  66053. * @param scene defines the scene where you want your assets to be loaded
  66054. * @param onSuccess is a callback called when the task is successfully executed
  66055. * @param onError is a callback called if an error occurs
  66056. */
  66057. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66058. }
  66059. /**
  66060. * Define a task used by AssetsManager to load HDR cube textures
  66061. */
  66062. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66063. /**
  66064. * Defines the name of the task
  66065. */
  66066. name: string;
  66067. /**
  66068. * Defines the location of the file to load
  66069. */
  66070. url: string;
  66071. /**
  66072. * Defines the desired size (the more it increases the longer the generation will be)
  66073. */
  66074. size: number;
  66075. /**
  66076. * Defines if mipmaps should not be generated (default is false)
  66077. */
  66078. noMipmap: boolean;
  66079. /**
  66080. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66081. */
  66082. generateHarmonics: boolean;
  66083. /**
  66084. * 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)
  66085. */
  66086. gammaSpace: boolean;
  66087. /**
  66088. * Internal Use Only
  66089. */
  66090. reserved: boolean;
  66091. /**
  66092. * Gets the loaded texture
  66093. */
  66094. texture: HDRCubeTexture;
  66095. /**
  66096. * Callback called when the task is successful
  66097. */
  66098. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66099. /**
  66100. * Callback called when the task is successful
  66101. */
  66102. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66103. /**
  66104. * Creates a new HDRCubeTextureAssetTask object
  66105. * @param name defines the name of the task
  66106. * @param url defines the location of the file to load
  66107. * @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.
  66108. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66109. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66110. * @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)
  66111. * @param reserved Internal use only
  66112. */
  66113. constructor(
  66114. /**
  66115. * Defines the name of the task
  66116. */
  66117. name: string,
  66118. /**
  66119. * Defines the location of the file to load
  66120. */
  66121. url: string,
  66122. /**
  66123. * Defines the desired size (the more it increases the longer the generation will be)
  66124. */
  66125. size: number,
  66126. /**
  66127. * Defines if mipmaps should not be generated (default is false)
  66128. */
  66129. noMipmap?: boolean,
  66130. /**
  66131. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66132. */
  66133. generateHarmonics?: boolean,
  66134. /**
  66135. * 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)
  66136. */
  66137. gammaSpace?: boolean,
  66138. /**
  66139. * Internal Use Only
  66140. */
  66141. reserved?: boolean);
  66142. /**
  66143. * Execute the current task
  66144. * @param scene defines the scene where you want your assets to be loaded
  66145. * @param onSuccess is a callback called when the task is successfully executed
  66146. * @param onError is a callback called if an error occurs
  66147. */
  66148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66149. }
  66150. /**
  66151. * Define a task used by AssetsManager to load Equirectangular cube textures
  66152. */
  66153. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66154. /**
  66155. * Defines the name of the task
  66156. */
  66157. name: string;
  66158. /**
  66159. * Defines the location of the file to load
  66160. */
  66161. url: string;
  66162. /**
  66163. * Defines the desired size (the more it increases the longer the generation will be)
  66164. */
  66165. size: number;
  66166. /**
  66167. * Defines if mipmaps should not be generated (default is false)
  66168. */
  66169. noMipmap: boolean;
  66170. /**
  66171. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66172. * but the standard material would require them in Gamma space) (default is true)
  66173. */
  66174. gammaSpace: boolean;
  66175. /**
  66176. * Gets the loaded texture
  66177. */
  66178. texture: EquiRectangularCubeTexture;
  66179. /**
  66180. * Callback called when the task is successful
  66181. */
  66182. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66183. /**
  66184. * Callback called when the task is successful
  66185. */
  66186. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66187. /**
  66188. * Creates a new EquiRectangularCubeTextureAssetTask object
  66189. * @param name defines the name of the task
  66190. * @param url defines the location of the file to load
  66191. * @param size defines the desired size (the more it increases the longer the generation will be)
  66192. * If the size is omitted this implies you are using a preprocessed cubemap.
  66193. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66194. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66195. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66196. * (default is true)
  66197. */
  66198. constructor(
  66199. /**
  66200. * Defines the name of the task
  66201. */
  66202. name: string,
  66203. /**
  66204. * Defines the location of the file to load
  66205. */
  66206. url: string,
  66207. /**
  66208. * Defines the desired size (the more it increases the longer the generation will be)
  66209. */
  66210. size: number,
  66211. /**
  66212. * Defines if mipmaps should not be generated (default is false)
  66213. */
  66214. noMipmap?: boolean,
  66215. /**
  66216. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66217. * but the standard material would require them in Gamma space) (default is true)
  66218. */
  66219. gammaSpace?: boolean);
  66220. /**
  66221. * Execute the current task
  66222. * @param scene defines the scene where you want your assets to be loaded
  66223. * @param onSuccess is a callback called when the task is successfully executed
  66224. * @param onError is a callback called if an error occurs
  66225. */
  66226. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66227. }
  66228. /**
  66229. * This class can be used to easily import assets into a scene
  66230. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66231. */
  66232. export class AssetsManager {
  66233. private _scene;
  66234. private _isLoading;
  66235. protected _tasks: AbstractAssetTask[];
  66236. protected _waitingTasksCount: number;
  66237. protected _totalTasksCount: number;
  66238. /**
  66239. * Callback called when all tasks are processed
  66240. */
  66241. onFinish: (tasks: AbstractAssetTask[]) => void;
  66242. /**
  66243. * Callback called when a task is successful
  66244. */
  66245. onTaskSuccess: (task: AbstractAssetTask) => void;
  66246. /**
  66247. * Callback called when a task had an error
  66248. */
  66249. onTaskError: (task: AbstractAssetTask) => void;
  66250. /**
  66251. * Callback called when a task is done (whatever the result is)
  66252. */
  66253. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66254. /**
  66255. * Observable called when all tasks are processed
  66256. */
  66257. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66258. /**
  66259. * Observable called when a task had an error
  66260. */
  66261. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66262. /**
  66263. * Observable called when all tasks were executed
  66264. */
  66265. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66266. /**
  66267. * Observable called when a task is done (whatever the result is)
  66268. */
  66269. onProgressObservable: Observable<IAssetsProgressEvent>;
  66270. /**
  66271. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66273. */
  66274. useDefaultLoadingScreen: boolean;
  66275. /**
  66276. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66277. * when all assets have been downloaded.
  66278. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66279. */
  66280. autoHideLoadingUI: boolean;
  66281. /**
  66282. * Creates a new AssetsManager
  66283. * @param scene defines the scene to work on
  66284. */
  66285. constructor(scene: Scene);
  66286. /**
  66287. * Add a MeshAssetTask to the list of active tasks
  66288. * @param taskName defines the name of the new task
  66289. * @param meshesNames defines the name of meshes to load
  66290. * @param rootUrl defines the root url to use to locate files
  66291. * @param sceneFilename defines the filename of the scene file
  66292. * @returns a new MeshAssetTask object
  66293. */
  66294. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66295. /**
  66296. * Add a TextFileAssetTask to the list of active tasks
  66297. * @param taskName defines the name of the new task
  66298. * @param url defines the url of the file to load
  66299. * @returns a new TextFileAssetTask object
  66300. */
  66301. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66302. /**
  66303. * Add a BinaryFileAssetTask to the list of active tasks
  66304. * @param taskName defines the name of the new task
  66305. * @param url defines the url of the file to load
  66306. * @returns a new BinaryFileAssetTask object
  66307. */
  66308. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66309. /**
  66310. * Add a ImageAssetTask to the list of active tasks
  66311. * @param taskName defines the name of the new task
  66312. * @param url defines the url of the file to load
  66313. * @returns a new ImageAssetTask object
  66314. */
  66315. addImageTask(taskName: string, url: string): ImageAssetTask;
  66316. /**
  66317. * Add a TextureAssetTask to the list of active tasks
  66318. * @param taskName defines the name of the new task
  66319. * @param url defines the url of the file to load
  66320. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66321. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66322. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66323. * @returns a new TextureAssetTask object
  66324. */
  66325. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66326. /**
  66327. * Add a CubeTextureAssetTask to the list of active tasks
  66328. * @param taskName defines the name of the new task
  66329. * @param url defines the url of the file to load
  66330. * @param extensions defines the extension to use to load the cube map (can be null)
  66331. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66332. * @param files defines the list of files to load (can be null)
  66333. * @returns a new CubeTextureAssetTask object
  66334. */
  66335. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66336. /**
  66337. *
  66338. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66339. * @param taskName defines the name of the new task
  66340. * @param url defines the url of the file to load
  66341. * @param size defines the size you want for the cubemap (can be null)
  66342. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66343. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66344. * @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)
  66345. * @param reserved Internal use only
  66346. * @returns a new HDRCubeTextureAssetTask object
  66347. */
  66348. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66349. /**
  66350. *
  66351. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66352. * @param taskName defines the name of the new task
  66353. * @param url defines the url of the file to load
  66354. * @param size defines the size you want for the cubemap (can be null)
  66355. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66356. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66357. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66358. * @returns a new EquiRectangularCubeTextureAssetTask object
  66359. */
  66360. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66361. /**
  66362. * Remove a task from the assets manager.
  66363. * @param task the task to remove
  66364. */
  66365. removeTask(task: AbstractAssetTask): void;
  66366. private _decreaseWaitingTasksCount;
  66367. private _runTask;
  66368. /**
  66369. * Reset the AssetsManager and remove all tasks
  66370. * @return the current instance of the AssetsManager
  66371. */
  66372. reset(): AssetsManager;
  66373. /**
  66374. * Start the loading process
  66375. * @return the current instance of the AssetsManager
  66376. */
  66377. load(): AssetsManager;
  66378. /**
  66379. * Start the loading process as an async operation
  66380. * @return a promise returning the list of failed tasks
  66381. */
  66382. loadAsync(): Promise<void>;
  66383. }
  66384. }
  66385. declare module "babylonjs/Misc/deferred" {
  66386. /**
  66387. * Wrapper class for promise with external resolve and reject.
  66388. */
  66389. export class Deferred<T> {
  66390. /**
  66391. * The promise associated with this deferred object.
  66392. */
  66393. readonly promise: Promise<T>;
  66394. private _resolve;
  66395. private _reject;
  66396. /**
  66397. * The resolve method of the promise associated with this deferred object.
  66398. */
  66399. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66400. /**
  66401. * The reject method of the promise associated with this deferred object.
  66402. */
  66403. readonly reject: (reason?: any) => void;
  66404. /**
  66405. * Constructor for this deferred object.
  66406. */
  66407. constructor();
  66408. }
  66409. }
  66410. declare module "babylonjs/Misc/meshExploder" {
  66411. import { Mesh } from "babylonjs/Meshes/mesh";
  66412. /**
  66413. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66414. */
  66415. export class MeshExploder {
  66416. private _centerMesh;
  66417. private _meshes;
  66418. private _meshesOrigins;
  66419. private _toCenterVectors;
  66420. private _scaledDirection;
  66421. private _newPosition;
  66422. private _centerPosition;
  66423. /**
  66424. * Explodes meshes from a center mesh.
  66425. * @param meshes The meshes to explode.
  66426. * @param centerMesh The mesh to be center of explosion.
  66427. */
  66428. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66429. private _setCenterMesh;
  66430. /**
  66431. * Get class name
  66432. * @returns "MeshExploder"
  66433. */
  66434. getClassName(): string;
  66435. /**
  66436. * "Exploded meshes"
  66437. * @returns Array of meshes with the centerMesh at index 0.
  66438. */
  66439. getMeshes(): Array<Mesh>;
  66440. /**
  66441. * Explodes meshes giving a specific direction
  66442. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66443. */
  66444. explode(direction?: number): void;
  66445. }
  66446. }
  66447. declare module "babylonjs/Misc/filesInput" {
  66448. import { Engine } from "babylonjs/Engines/engine";
  66449. import { Scene } from "babylonjs/scene";
  66450. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66451. /**
  66452. * Class used to help managing file picking and drag'n'drop
  66453. */
  66454. export class FilesInput {
  66455. /**
  66456. * List of files ready to be loaded
  66457. */
  66458. static readonly FilesToLoad: {
  66459. [key: string]: File;
  66460. };
  66461. /**
  66462. * Callback called when a file is processed
  66463. */
  66464. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66465. private _engine;
  66466. private _currentScene;
  66467. private _sceneLoadedCallback;
  66468. private _progressCallback;
  66469. private _additionalRenderLoopLogicCallback;
  66470. private _textureLoadingCallback;
  66471. private _startingProcessingFilesCallback;
  66472. private _onReloadCallback;
  66473. private _errorCallback;
  66474. private _elementToMonitor;
  66475. private _sceneFileToLoad;
  66476. private _filesToLoad;
  66477. /**
  66478. * Creates a new FilesInput
  66479. * @param engine defines the rendering engine
  66480. * @param scene defines the hosting scene
  66481. * @param sceneLoadedCallback callback called when scene is loaded
  66482. * @param progressCallback callback called to track progress
  66483. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66484. * @param textureLoadingCallback callback called when a texture is loading
  66485. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66486. * @param onReloadCallback callback called when a reload is requested
  66487. * @param errorCallback callback call if an error occurs
  66488. */
  66489. 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);
  66490. private _dragEnterHandler;
  66491. private _dragOverHandler;
  66492. private _dropHandler;
  66493. /**
  66494. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66495. * @param elementToMonitor defines the DOM element to track
  66496. */
  66497. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66498. /**
  66499. * Release all associated resources
  66500. */
  66501. dispose(): void;
  66502. private renderFunction;
  66503. private drag;
  66504. private drop;
  66505. private _traverseFolder;
  66506. private _processFiles;
  66507. /**
  66508. * Load files from a drop event
  66509. * @param event defines the drop event to use as source
  66510. */
  66511. loadFiles(event: any): void;
  66512. private _processReload;
  66513. /**
  66514. * Reload the current scene from the loaded files
  66515. */
  66516. reload(): void;
  66517. }
  66518. }
  66519. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66520. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66521. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66522. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66523. }
  66524. declare module "babylonjs/Misc/sceneOptimizer" {
  66525. import { Scene, IDisposable } from "babylonjs/scene";
  66526. import { Observable } from "babylonjs/Misc/observable";
  66527. /**
  66528. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66530. */
  66531. export class SceneOptimization {
  66532. /**
  66533. * Defines the priority of this optimization (0 by default which means first in the list)
  66534. */
  66535. priority: number;
  66536. /**
  66537. * Gets a string describing the action executed by the current optimization
  66538. * @returns description string
  66539. */
  66540. getDescription(): string;
  66541. /**
  66542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66543. * @param scene defines the current scene where to apply this optimization
  66544. * @param optimizer defines the current optimizer
  66545. * @returns true if everything that can be done was applied
  66546. */
  66547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66548. /**
  66549. * Creates the SceneOptimization object
  66550. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66551. * @param desc defines the description associated with the optimization
  66552. */
  66553. constructor(
  66554. /**
  66555. * Defines the priority of this optimization (0 by default which means first in the list)
  66556. */
  66557. priority?: number);
  66558. }
  66559. /**
  66560. * Defines an optimization used to reduce the size of render target textures
  66561. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66562. */
  66563. export class TextureOptimization extends SceneOptimization {
  66564. /**
  66565. * Defines the priority of this optimization (0 by default which means first in the list)
  66566. */
  66567. priority: number;
  66568. /**
  66569. * 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
  66570. */
  66571. maximumSize: number;
  66572. /**
  66573. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66574. */
  66575. step: number;
  66576. /**
  66577. * Gets a string describing the action executed by the current optimization
  66578. * @returns description string
  66579. */
  66580. getDescription(): string;
  66581. /**
  66582. * Creates the TextureOptimization object
  66583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66584. * @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
  66585. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66586. */
  66587. constructor(
  66588. /**
  66589. * Defines the priority of this optimization (0 by default which means first in the list)
  66590. */
  66591. priority?: number,
  66592. /**
  66593. * 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
  66594. */
  66595. maximumSize?: number,
  66596. /**
  66597. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66598. */
  66599. step?: number);
  66600. /**
  66601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66602. * @param scene defines the current scene where to apply this optimization
  66603. * @param optimizer defines the current optimizer
  66604. * @returns true if everything that can be done was applied
  66605. */
  66606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66607. }
  66608. /**
  66609. * Defines an optimization used to increase or decrease the rendering resolution
  66610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66611. */
  66612. export class HardwareScalingOptimization extends SceneOptimization {
  66613. /**
  66614. * Defines the priority of this optimization (0 by default which means first in the list)
  66615. */
  66616. priority: number;
  66617. /**
  66618. * Defines the maximum scale to use (2 by default)
  66619. */
  66620. maximumScale: number;
  66621. /**
  66622. * Defines the step to use between two passes (0.5 by default)
  66623. */
  66624. step: number;
  66625. private _currentScale;
  66626. private _directionOffset;
  66627. /**
  66628. * Gets a string describing the action executed by the current optimization
  66629. * @return description string
  66630. */
  66631. getDescription(): string;
  66632. /**
  66633. * Creates the HardwareScalingOptimization object
  66634. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66635. * @param maximumScale defines the maximum scale to use (2 by default)
  66636. * @param step defines the step to use between two passes (0.5 by default)
  66637. */
  66638. constructor(
  66639. /**
  66640. * Defines the priority of this optimization (0 by default which means first in the list)
  66641. */
  66642. priority?: number,
  66643. /**
  66644. * Defines the maximum scale to use (2 by default)
  66645. */
  66646. maximumScale?: number,
  66647. /**
  66648. * Defines the step to use between two passes (0.5 by default)
  66649. */
  66650. step?: number);
  66651. /**
  66652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66653. * @param scene defines the current scene where to apply this optimization
  66654. * @param optimizer defines the current optimizer
  66655. * @returns true if everything that can be done was applied
  66656. */
  66657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66658. }
  66659. /**
  66660. * Defines an optimization used to remove shadows
  66661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66662. */
  66663. export class ShadowsOptimization extends SceneOptimization {
  66664. /**
  66665. * Gets a string describing the action executed by the current optimization
  66666. * @return description string
  66667. */
  66668. getDescription(): string;
  66669. /**
  66670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66671. * @param scene defines the current scene where to apply this optimization
  66672. * @param optimizer defines the current optimizer
  66673. * @returns true if everything that can be done was applied
  66674. */
  66675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66676. }
  66677. /**
  66678. * Defines an optimization used to turn post-processes off
  66679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66680. */
  66681. export class PostProcessesOptimization extends SceneOptimization {
  66682. /**
  66683. * Gets a string describing the action executed by the current optimization
  66684. * @return description string
  66685. */
  66686. getDescription(): string;
  66687. /**
  66688. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66689. * @param scene defines the current scene where to apply this optimization
  66690. * @param optimizer defines the current optimizer
  66691. * @returns true if everything that can be done was applied
  66692. */
  66693. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66694. }
  66695. /**
  66696. * Defines an optimization used to turn lens flares off
  66697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66698. */
  66699. export class LensFlaresOptimization extends SceneOptimization {
  66700. /**
  66701. * Gets a string describing the action executed by the current optimization
  66702. * @return description string
  66703. */
  66704. getDescription(): string;
  66705. /**
  66706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66707. * @param scene defines the current scene where to apply this optimization
  66708. * @param optimizer defines the current optimizer
  66709. * @returns true if everything that can be done was applied
  66710. */
  66711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66712. }
  66713. /**
  66714. * Defines an optimization based on user defined callback.
  66715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66716. */
  66717. export class CustomOptimization extends SceneOptimization {
  66718. /**
  66719. * Callback called to apply the custom optimization.
  66720. */
  66721. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66722. /**
  66723. * Callback called to get custom description
  66724. */
  66725. onGetDescription: () => string;
  66726. /**
  66727. * Gets a string describing the action executed by the current optimization
  66728. * @returns description string
  66729. */
  66730. getDescription(): string;
  66731. /**
  66732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66733. * @param scene defines the current scene where to apply this optimization
  66734. * @param optimizer defines the current optimizer
  66735. * @returns true if everything that can be done was applied
  66736. */
  66737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66738. }
  66739. /**
  66740. * Defines an optimization used to turn particles off
  66741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66742. */
  66743. export class ParticlesOptimization extends SceneOptimization {
  66744. /**
  66745. * Gets a string describing the action executed by the current optimization
  66746. * @return description string
  66747. */
  66748. getDescription(): string;
  66749. /**
  66750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66751. * @param scene defines the current scene where to apply this optimization
  66752. * @param optimizer defines the current optimizer
  66753. * @returns true if everything that can be done was applied
  66754. */
  66755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66756. }
  66757. /**
  66758. * Defines an optimization used to turn render targets off
  66759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66760. */
  66761. export class RenderTargetsOptimization extends SceneOptimization {
  66762. /**
  66763. * Gets a string describing the action executed by the current optimization
  66764. * @return description string
  66765. */
  66766. getDescription(): string;
  66767. /**
  66768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66769. * @param scene defines the current scene where to apply this optimization
  66770. * @param optimizer defines the current optimizer
  66771. * @returns true if everything that can be done was applied
  66772. */
  66773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66774. }
  66775. /**
  66776. * Defines an optimization used to merge meshes with compatible materials
  66777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66778. */
  66779. export class MergeMeshesOptimization extends SceneOptimization {
  66780. private static _UpdateSelectionTree;
  66781. /**
  66782. * Gets or sets a boolean which defines if optimization octree has to be updated
  66783. */
  66784. /**
  66785. * Gets or sets a boolean which defines if optimization octree has to be updated
  66786. */
  66787. static UpdateSelectionTree: boolean;
  66788. /**
  66789. * Gets a string describing the action executed by the current optimization
  66790. * @return description string
  66791. */
  66792. getDescription(): string;
  66793. private _canBeMerged;
  66794. /**
  66795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66796. * @param scene defines the current scene where to apply this optimization
  66797. * @param optimizer defines the current optimizer
  66798. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66799. * @returns true if everything that can be done was applied
  66800. */
  66801. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66802. }
  66803. /**
  66804. * Defines a list of options used by SceneOptimizer
  66805. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66806. */
  66807. export class SceneOptimizerOptions {
  66808. /**
  66809. * Defines the target frame rate to reach (60 by default)
  66810. */
  66811. targetFrameRate: number;
  66812. /**
  66813. * Defines the interval between two checkes (2000ms by default)
  66814. */
  66815. trackerDuration: number;
  66816. /**
  66817. * Gets the list of optimizations to apply
  66818. */
  66819. optimizations: SceneOptimization[];
  66820. /**
  66821. * Creates a new list of options used by SceneOptimizer
  66822. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66823. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66824. */
  66825. constructor(
  66826. /**
  66827. * Defines the target frame rate to reach (60 by default)
  66828. */
  66829. targetFrameRate?: number,
  66830. /**
  66831. * Defines the interval between two checkes (2000ms by default)
  66832. */
  66833. trackerDuration?: number);
  66834. /**
  66835. * Add a new optimization
  66836. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66837. * @returns the current SceneOptimizerOptions
  66838. */
  66839. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66840. /**
  66841. * Add a new custom optimization
  66842. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66843. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66844. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66845. * @returns the current SceneOptimizerOptions
  66846. */
  66847. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66848. /**
  66849. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66850. * @param targetFrameRate defines the target frame rate (60 by default)
  66851. * @returns a SceneOptimizerOptions object
  66852. */
  66853. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66854. /**
  66855. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66856. * @param targetFrameRate defines the target frame rate (60 by default)
  66857. * @returns a SceneOptimizerOptions object
  66858. */
  66859. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66860. /**
  66861. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66862. * @param targetFrameRate defines the target frame rate (60 by default)
  66863. * @returns a SceneOptimizerOptions object
  66864. */
  66865. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66866. }
  66867. /**
  66868. * Class used to run optimizations in order to reach a target frame rate
  66869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66870. */
  66871. export class SceneOptimizer implements IDisposable {
  66872. private _isRunning;
  66873. private _options;
  66874. private _scene;
  66875. private _currentPriorityLevel;
  66876. private _targetFrameRate;
  66877. private _trackerDuration;
  66878. private _currentFrameRate;
  66879. private _sceneDisposeObserver;
  66880. private _improvementMode;
  66881. /**
  66882. * Defines an observable called when the optimizer reaches the target frame rate
  66883. */
  66884. onSuccessObservable: Observable<SceneOptimizer>;
  66885. /**
  66886. * Defines an observable called when the optimizer enables an optimization
  66887. */
  66888. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66889. /**
  66890. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66891. */
  66892. onFailureObservable: Observable<SceneOptimizer>;
  66893. /**
  66894. * Gets a boolean indicating if the optimizer is in improvement mode
  66895. */
  66896. readonly isInImprovementMode: boolean;
  66897. /**
  66898. * Gets the current priority level (0 at start)
  66899. */
  66900. readonly currentPriorityLevel: number;
  66901. /**
  66902. * Gets the current frame rate checked by the SceneOptimizer
  66903. */
  66904. readonly currentFrameRate: number;
  66905. /**
  66906. * Gets or sets the current target frame rate (60 by default)
  66907. */
  66908. /**
  66909. * Gets or sets the current target frame rate (60 by default)
  66910. */
  66911. targetFrameRate: number;
  66912. /**
  66913. * Gets or sets the current interval between two checks (every 2000ms by default)
  66914. */
  66915. /**
  66916. * Gets or sets the current interval between two checks (every 2000ms by default)
  66917. */
  66918. trackerDuration: number;
  66919. /**
  66920. * Gets the list of active optimizations
  66921. */
  66922. readonly optimizations: SceneOptimization[];
  66923. /**
  66924. * Creates a new SceneOptimizer
  66925. * @param scene defines the scene to work on
  66926. * @param options defines the options to use with the SceneOptimizer
  66927. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66928. * @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)
  66929. */
  66930. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66931. /**
  66932. * Stops the current optimizer
  66933. */
  66934. stop(): void;
  66935. /**
  66936. * Reset the optimizer to initial step (current priority level = 0)
  66937. */
  66938. reset(): void;
  66939. /**
  66940. * Start the optimizer. By default it will try to reach a specific framerate
  66941. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66942. */
  66943. start(): void;
  66944. private _checkCurrentState;
  66945. /**
  66946. * Release all resources
  66947. */
  66948. dispose(): void;
  66949. /**
  66950. * Helper function to create a SceneOptimizer with one single line of code
  66951. * @param scene defines the scene to work on
  66952. * @param options defines the options to use with the SceneOptimizer
  66953. * @param onSuccess defines a callback to call on success
  66954. * @param onFailure defines a callback to call on failure
  66955. * @returns the new SceneOptimizer object
  66956. */
  66957. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66958. }
  66959. }
  66960. declare module "babylonjs/Misc/sceneSerializer" {
  66961. import { Scene } from "babylonjs/scene";
  66962. /**
  66963. * Class used to serialize a scene into a string
  66964. */
  66965. export class SceneSerializer {
  66966. /**
  66967. * Clear cache used by a previous serialization
  66968. */
  66969. static ClearCache(): void;
  66970. /**
  66971. * Serialize a scene into a JSON compatible object
  66972. * @param scene defines the scene to serialize
  66973. * @returns a JSON compatible object
  66974. */
  66975. static Serialize(scene: Scene): any;
  66976. /**
  66977. * Serialize a mesh into a JSON compatible object
  66978. * @param toSerialize defines the mesh to serialize
  66979. * @param withParents defines if parents must be serialized as well
  66980. * @param withChildren defines if children must be serialized as well
  66981. * @returns a JSON compatible object
  66982. */
  66983. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66984. }
  66985. }
  66986. declare module "babylonjs/Misc/textureTools" {
  66987. import { Texture } from "babylonjs/Materials/Textures/texture";
  66988. /**
  66989. * Class used to host texture specific utilities
  66990. */
  66991. export class TextureTools {
  66992. /**
  66993. * Uses the GPU to create a copy texture rescaled at a given size
  66994. * @param texture Texture to copy from
  66995. * @param width defines the desired width
  66996. * @param height defines the desired height
  66997. * @param useBilinearMode defines if bilinear mode has to be used
  66998. * @return the generated texture
  66999. */
  67000. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67001. }
  67002. }
  67003. declare module "babylonjs/Misc/videoRecorder" {
  67004. import { Nullable } from "babylonjs/types";
  67005. import { Engine } from "babylonjs/Engines/engine";
  67006. /**
  67007. * This represents the different options available for the video capture.
  67008. */
  67009. export interface VideoRecorderOptions {
  67010. /** Defines the mime type of the video. */
  67011. mimeType: string;
  67012. /** Defines the FPS the video should be recorded at. */
  67013. fps: number;
  67014. /** Defines the chunk size for the recording data. */
  67015. recordChunckSize: number;
  67016. /** The audio tracks to attach to the recording. */
  67017. audioTracks?: MediaStreamTrack[];
  67018. }
  67019. /**
  67020. * This can help with recording videos from BabylonJS.
  67021. * This is based on the available WebRTC functionalities of the browser.
  67022. *
  67023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67024. */
  67025. export class VideoRecorder {
  67026. private static readonly _defaultOptions;
  67027. /**
  67028. * Returns whether or not the VideoRecorder is available in your browser.
  67029. * @param engine Defines the Babylon Engine.
  67030. * @returns true if supported otherwise false.
  67031. */
  67032. static IsSupported(engine: Engine): boolean;
  67033. private readonly _options;
  67034. private _canvas;
  67035. private _mediaRecorder;
  67036. private _recordedChunks;
  67037. private _fileName;
  67038. private _resolve;
  67039. private _reject;
  67040. /**
  67041. * True when a recording is already in progress.
  67042. */
  67043. readonly isRecording: boolean;
  67044. /**
  67045. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67046. * @param engine Defines the BabylonJS Engine you wish to record.
  67047. * @param options Defines options that can be used to customize the capture.
  67048. */
  67049. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67050. /**
  67051. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67052. */
  67053. stopRecording(): void;
  67054. /**
  67055. * Starts recording the canvas for a max duration specified in parameters.
  67056. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67057. * If null no automatic download will start and you can rely on the promise to get the data back.
  67058. * @param maxDuration Defines the maximum recording time in seconds.
  67059. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67060. * @return A promise callback at the end of the recording with the video data in Blob.
  67061. */
  67062. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67063. /**
  67064. * Releases internal resources used during the recording.
  67065. */
  67066. dispose(): void;
  67067. private _handleDataAvailable;
  67068. private _handleError;
  67069. private _handleStop;
  67070. }
  67071. }
  67072. declare module "babylonjs/Misc/screenshotTools" {
  67073. import { Camera } from "babylonjs/Cameras/camera";
  67074. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67075. import { Engine } from "babylonjs/Engines/engine";
  67076. /**
  67077. * Class containing a set of static utilities functions for screenshots
  67078. */
  67079. export class ScreenshotTools {
  67080. /**
  67081. * Captures a screenshot of the current rendering
  67082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67083. * @param engine defines the rendering engine
  67084. * @param camera defines the source camera
  67085. * @param size This parameter can be set to a single number or to an object with the
  67086. * following (optional) properties: precision, width, height. If a single number is passed,
  67087. * it will be used for both width and height. If an object is passed, the screenshot size
  67088. * will be derived from the parameters. The precision property is a multiplier allowing
  67089. * rendering at a higher or lower resolution
  67090. * @param successCallback defines the callback receives a single parameter which contains the
  67091. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67092. * src parameter of an <img> to display it
  67093. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67094. * Check your browser for supported MIME types
  67095. */
  67096. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67097. /**
  67098. * Captures a screenshot of the current rendering
  67099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67100. * @param engine defines the rendering engine
  67101. * @param camera defines the source camera
  67102. * @param size This parameter can be set to a single number or to an object with the
  67103. * following (optional) properties: precision, width, height. If a single number is passed,
  67104. * it will be used for both width and height. If an object is passed, the screenshot size
  67105. * will be derived from the parameters. The precision property is a multiplier allowing
  67106. * rendering at a higher or lower resolution
  67107. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67108. * Check your browser for supported MIME types
  67109. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67110. * to the src parameter of an <img> to display it
  67111. */
  67112. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67113. /**
  67114. * Generates an image screenshot from the specified camera.
  67115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67116. * @param engine The engine to use for rendering
  67117. * @param camera The camera to use for rendering
  67118. * @param size This parameter can be set to a single number or to an object with the
  67119. * following (optional) properties: precision, width, height. If a single number is passed,
  67120. * it will be used for both width and height. If an object is passed, the screenshot size
  67121. * will be derived from the parameters. The precision property is a multiplier allowing
  67122. * rendering at a higher or lower resolution
  67123. * @param successCallback The callback receives a single parameter which contains the
  67124. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67125. * src parameter of an <img> to display it
  67126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67127. * Check your browser for supported MIME types
  67128. * @param samples Texture samples (default: 1)
  67129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67130. * @param fileName A name for for the downloaded file.
  67131. */
  67132. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67133. /**
  67134. * Generates an image screenshot from the specified camera.
  67135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67136. * @param engine The engine to use for rendering
  67137. * @param camera The camera to use for rendering
  67138. * @param size This parameter can be set to a single number or to an object with the
  67139. * following (optional) properties: precision, width, height. If a single number is passed,
  67140. * it will be used for both width and height. If an object is passed, the screenshot size
  67141. * will be derived from the parameters. The precision property is a multiplier allowing
  67142. * rendering at a higher or lower resolution
  67143. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67144. * Check your browser for supported MIME types
  67145. * @param samples Texture samples (default: 1)
  67146. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67147. * @param fileName A name for for the downloaded file.
  67148. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67149. * to the src parameter of an <img> to display it
  67150. */
  67151. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67152. /**
  67153. * Gets height and width for screenshot size
  67154. * @private
  67155. */
  67156. private static _getScreenshotSize;
  67157. }
  67158. }
  67159. declare module "babylonjs/Misc/index" {
  67160. export * from "babylonjs/Misc/andOrNotEvaluator";
  67161. export * from "babylonjs/Misc/assetsManager";
  67162. export * from "babylonjs/Misc/dds";
  67163. export * from "babylonjs/Misc/decorators";
  67164. export * from "babylonjs/Misc/deferred";
  67165. export * from "babylonjs/Misc/environmentTextureTools";
  67166. export * from "babylonjs/Misc/meshExploder";
  67167. export * from "babylonjs/Misc/filesInput";
  67168. export * from "babylonjs/Misc/HighDynamicRange/index";
  67169. export * from "babylonjs/Misc/khronosTextureContainer";
  67170. export * from "babylonjs/Misc/observable";
  67171. export * from "babylonjs/Misc/performanceMonitor";
  67172. export * from "babylonjs/Misc/promise";
  67173. export * from "babylonjs/Misc/sceneOptimizer";
  67174. export * from "babylonjs/Misc/sceneSerializer";
  67175. export * from "babylonjs/Misc/smartArray";
  67176. export * from "babylonjs/Misc/stringDictionary";
  67177. export * from "babylonjs/Misc/tags";
  67178. export * from "babylonjs/Misc/textureTools";
  67179. export * from "babylonjs/Misc/tga";
  67180. export * from "babylonjs/Misc/tools";
  67181. export * from "babylonjs/Misc/videoRecorder";
  67182. export * from "babylonjs/Misc/virtualJoystick";
  67183. export * from "babylonjs/Misc/workerPool";
  67184. export * from "babylonjs/Misc/logger";
  67185. export * from "babylonjs/Misc/typeStore";
  67186. export * from "babylonjs/Misc/filesInputStore";
  67187. export * from "babylonjs/Misc/deepCopier";
  67188. export * from "babylonjs/Misc/pivotTools";
  67189. export * from "babylonjs/Misc/precisionDate";
  67190. export * from "babylonjs/Misc/screenshotTools";
  67191. export * from "babylonjs/Misc/typeStore";
  67192. export * from "babylonjs/Misc/webRequest";
  67193. export * from "babylonjs/Misc/iInspectable";
  67194. export * from "babylonjs/Misc/brdfTextureTools";
  67195. export * from "babylonjs/Misc/rgbdTextureTools";
  67196. export * from "babylonjs/Misc/gradients";
  67197. export * from "babylonjs/Misc/perfCounter";
  67198. export * from "babylonjs/Misc/fileRequest";
  67199. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67200. export * from "babylonjs/Misc/retryStrategy";
  67201. export * from "babylonjs/Misc/loadFileError";
  67202. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67203. export * from "babylonjs/Misc/canvasGenerator";
  67204. }
  67205. declare module "babylonjs/index" {
  67206. export * from "babylonjs/abstractScene";
  67207. export * from "babylonjs/Actions/index";
  67208. export * from "babylonjs/Animations/index";
  67209. export * from "babylonjs/assetContainer";
  67210. export * from "babylonjs/Audio/index";
  67211. export * from "babylonjs/Behaviors/index";
  67212. export * from "babylonjs/Bones/index";
  67213. export * from "babylonjs/Cameras/index";
  67214. export * from "babylonjs/Collisions/index";
  67215. export * from "babylonjs/Culling/index";
  67216. export * from "babylonjs/Debug/index";
  67217. export * from "babylonjs/Engines/index";
  67218. export * from "babylonjs/Events/index";
  67219. export * from "babylonjs/Gamepads/index";
  67220. export * from "babylonjs/Gizmos/index";
  67221. export * from "babylonjs/Helpers/index";
  67222. export * from "babylonjs/Instrumentation/index";
  67223. export * from "babylonjs/Layers/index";
  67224. export * from "babylonjs/LensFlares/index";
  67225. export * from "babylonjs/Lights/index";
  67226. export * from "babylonjs/Loading/index";
  67227. export * from "babylonjs/Materials/index";
  67228. export * from "babylonjs/Maths/index";
  67229. export * from "babylonjs/Meshes/index";
  67230. export * from "babylonjs/Morph/index";
  67231. export * from "babylonjs/Navigation/index";
  67232. export * from "babylonjs/node";
  67233. export * from "babylonjs/Offline/index";
  67234. export * from "babylonjs/Particles/index";
  67235. export * from "babylonjs/Physics/index";
  67236. export * from "babylonjs/PostProcesses/index";
  67237. export * from "babylonjs/Probes/index";
  67238. export * from "babylonjs/Rendering/index";
  67239. export * from "babylonjs/scene";
  67240. export * from "babylonjs/sceneComponent";
  67241. export * from "babylonjs/Sprites/index";
  67242. export * from "babylonjs/States/index";
  67243. export * from "babylonjs/Misc/index";
  67244. export * from "babylonjs/types";
  67245. }
  67246. declare module "babylonjs/Animations/pathCursor" {
  67247. import { Vector3 } from "babylonjs/Maths/math.vector";
  67248. import { Path2 } from "babylonjs/Maths/math.path";
  67249. /**
  67250. * A cursor which tracks a point on a path
  67251. */
  67252. export class PathCursor {
  67253. private path;
  67254. /**
  67255. * Stores path cursor callbacks for when an onchange event is triggered
  67256. */
  67257. private _onchange;
  67258. /**
  67259. * The value of the path cursor
  67260. */
  67261. value: number;
  67262. /**
  67263. * The animation array of the path cursor
  67264. */
  67265. animations: Animation[];
  67266. /**
  67267. * Initializes the path cursor
  67268. * @param path The path to track
  67269. */
  67270. constructor(path: Path2);
  67271. /**
  67272. * Gets the cursor point on the path
  67273. * @returns A point on the path cursor at the cursor location
  67274. */
  67275. getPoint(): Vector3;
  67276. /**
  67277. * Moves the cursor ahead by the step amount
  67278. * @param step The amount to move the cursor forward
  67279. * @returns This path cursor
  67280. */
  67281. moveAhead(step?: number): PathCursor;
  67282. /**
  67283. * Moves the cursor behind by the step amount
  67284. * @param step The amount to move the cursor back
  67285. * @returns This path cursor
  67286. */
  67287. moveBack(step?: number): PathCursor;
  67288. /**
  67289. * Moves the cursor by the step amount
  67290. * If the step amount is greater than one, an exception is thrown
  67291. * @param step The amount to move the cursor
  67292. * @returns This path cursor
  67293. */
  67294. move(step: number): PathCursor;
  67295. /**
  67296. * Ensures that the value is limited between zero and one
  67297. * @returns This path cursor
  67298. */
  67299. private ensureLimits;
  67300. /**
  67301. * Runs onchange callbacks on change (used by the animation engine)
  67302. * @returns This path cursor
  67303. */
  67304. private raiseOnChange;
  67305. /**
  67306. * Executes a function on change
  67307. * @param f A path cursor onchange callback
  67308. * @returns This path cursor
  67309. */
  67310. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67311. }
  67312. }
  67313. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67314. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67315. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67316. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67317. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67318. }
  67319. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67320. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67321. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67322. }
  67323. declare module "babylonjs/Engines/Processors/index" {
  67324. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67325. export * from "babylonjs/Engines/Processors/Expressions/index";
  67326. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67327. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67328. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67329. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67330. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67331. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67332. }
  67333. declare module "babylonjs/Legacy/legacy" {
  67334. import * as Babylon from "babylonjs/index";
  67335. export * from "babylonjs/index";
  67336. }
  67337. declare module "babylonjs/Shaders/blur.fragment" {
  67338. /** @hidden */
  67339. export var blurPixelShader: {
  67340. name: string;
  67341. shader: string;
  67342. };
  67343. }
  67344. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67345. /** @hidden */
  67346. export var pointCloudVertexDeclaration: {
  67347. name: string;
  67348. shader: string;
  67349. };
  67350. }
  67351. declare module "babylonjs" {
  67352. export * from "babylonjs/Legacy/legacy";
  67353. }
  67354. declare module BABYLON {
  67355. /** Alias type for value that can be null */
  67356. export type Nullable<T> = T | null;
  67357. /**
  67358. * Alias type for number that are floats
  67359. * @ignorenaming
  67360. */
  67361. export type float = number;
  67362. /**
  67363. * Alias type for number that are doubles.
  67364. * @ignorenaming
  67365. */
  67366. export type double = number;
  67367. /**
  67368. * Alias type for number that are integer
  67369. * @ignorenaming
  67370. */
  67371. export type int = number;
  67372. /** Alias type for number array or Float32Array */
  67373. export type FloatArray = number[] | Float32Array;
  67374. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67375. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67376. /**
  67377. * Alias for types that can be used by a Buffer or VertexBuffer.
  67378. */
  67379. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67380. /**
  67381. * Alias type for primitive types
  67382. * @ignorenaming
  67383. */
  67384. type Primitive = undefined | null | boolean | string | number | Function;
  67385. /**
  67386. * Type modifier to make all the properties of an object Readonly
  67387. */
  67388. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67389. /**
  67390. * Type modifier to make all the properties of an object Readonly recursively
  67391. */
  67392. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67393. /**
  67394. * Type modifier to make object properties readonly.
  67395. */
  67396. export type DeepImmutableObject<T> = {
  67397. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67398. };
  67399. /** @hidden */
  67400. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67401. }
  67402. }
  67403. declare module BABYLON {
  67404. /**
  67405. * A class serves as a medium between the observable and its observers
  67406. */
  67407. export class EventState {
  67408. /**
  67409. * Create a new EventState
  67410. * @param mask defines the mask associated with this state
  67411. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67412. * @param target defines the original target of the state
  67413. * @param currentTarget defines the current target of the state
  67414. */
  67415. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67416. /**
  67417. * Initialize the current event state
  67418. * @param mask defines the mask associated with this state
  67419. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67420. * @param target defines the original target of the state
  67421. * @param currentTarget defines the current target of the state
  67422. * @returns the current event state
  67423. */
  67424. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67425. /**
  67426. * An Observer can set this property to true to prevent subsequent observers of being notified
  67427. */
  67428. skipNextObservers: boolean;
  67429. /**
  67430. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67431. */
  67432. mask: number;
  67433. /**
  67434. * The object that originally notified the event
  67435. */
  67436. target?: any;
  67437. /**
  67438. * The current object in the bubbling phase
  67439. */
  67440. currentTarget?: any;
  67441. /**
  67442. * This will be populated with the return value of the last function that was executed.
  67443. * If it is the first function in the callback chain it will be the event data.
  67444. */
  67445. lastReturnValue?: any;
  67446. }
  67447. /**
  67448. * Represent an Observer registered to a given Observable object.
  67449. */
  67450. export class Observer<T> {
  67451. /**
  67452. * Defines the callback to call when the observer is notified
  67453. */
  67454. callback: (eventData: T, eventState: EventState) => void;
  67455. /**
  67456. * Defines the mask of the observer (used to filter notifications)
  67457. */
  67458. mask: number;
  67459. /**
  67460. * Defines the current scope used to restore the JS context
  67461. */
  67462. scope: any;
  67463. /** @hidden */
  67464. _willBeUnregistered: boolean;
  67465. /**
  67466. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67467. */
  67468. unregisterOnNextCall: boolean;
  67469. /**
  67470. * Creates a new observer
  67471. * @param callback defines the callback to call when the observer is notified
  67472. * @param mask defines the mask of the observer (used to filter notifications)
  67473. * @param scope defines the current scope used to restore the JS context
  67474. */
  67475. constructor(
  67476. /**
  67477. * Defines the callback to call when the observer is notified
  67478. */
  67479. callback: (eventData: T, eventState: EventState) => void,
  67480. /**
  67481. * Defines the mask of the observer (used to filter notifications)
  67482. */
  67483. mask: number,
  67484. /**
  67485. * Defines the current scope used to restore the JS context
  67486. */
  67487. scope?: any);
  67488. }
  67489. /**
  67490. * Represent a list of observers registered to multiple Observables object.
  67491. */
  67492. export class MultiObserver<T> {
  67493. private _observers;
  67494. private _observables;
  67495. /**
  67496. * Release associated resources
  67497. */
  67498. dispose(): void;
  67499. /**
  67500. * Raise a callback when one of the observable will notify
  67501. * @param observables defines a list of observables to watch
  67502. * @param callback defines the callback to call on notification
  67503. * @param mask defines the mask used to filter notifications
  67504. * @param scope defines the current scope used to restore the JS context
  67505. * @returns the new MultiObserver
  67506. */
  67507. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67508. }
  67509. /**
  67510. * The Observable class is a simple implementation of the Observable pattern.
  67511. *
  67512. * 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.
  67513. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67514. * 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).
  67515. * 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.
  67516. */
  67517. export class Observable<T> {
  67518. private _observers;
  67519. private _eventState;
  67520. private _onObserverAdded;
  67521. /**
  67522. * Gets the list of observers
  67523. */
  67524. readonly observers: Array<Observer<T>>;
  67525. /**
  67526. * Creates a new observable
  67527. * @param onObserverAdded defines a callback to call when a new observer is added
  67528. */
  67529. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67530. /**
  67531. * Create a new Observer with the specified callback
  67532. * @param callback the callback that will be executed for that Observer
  67533. * @param mask the mask used to filter observers
  67534. * @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.
  67535. * @param scope optional scope for the callback to be called from
  67536. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67537. * @returns the new observer created for the callback
  67538. */
  67539. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67540. /**
  67541. * Create a new Observer with the specified callback and unregisters after the next notification
  67542. * @param callback the callback that will be executed for that Observer
  67543. * @returns the new observer created for the callback
  67544. */
  67545. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67546. /**
  67547. * Remove an Observer from the Observable object
  67548. * @param observer the instance of the Observer to remove
  67549. * @returns false if it doesn't belong to this Observable
  67550. */
  67551. remove(observer: Nullable<Observer<T>>): boolean;
  67552. /**
  67553. * Remove a callback from the Observable object
  67554. * @param callback the callback to remove
  67555. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67556. * @returns false if it doesn't belong to this Observable
  67557. */
  67558. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67559. private _deferUnregister;
  67560. private _remove;
  67561. /**
  67562. * Moves the observable to the top of the observer list making it get called first when notified
  67563. * @param observer the observer to move
  67564. */
  67565. makeObserverTopPriority(observer: Observer<T>): void;
  67566. /**
  67567. * Moves the observable to the bottom of the observer list making it get called last when notified
  67568. * @param observer the observer to move
  67569. */
  67570. makeObserverBottomPriority(observer: Observer<T>): void;
  67571. /**
  67572. * Notify all Observers by calling their respective callback with the given data
  67573. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67574. * @param eventData defines the data to send to all observers
  67575. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67576. * @param target defines the original target of the state
  67577. * @param currentTarget defines the current target of the state
  67578. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67579. */
  67580. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67581. /**
  67582. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67583. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67584. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67585. * and it is crucial that all callbacks will be executed.
  67586. * The order of the callbacks is kept, callbacks are not executed parallel.
  67587. *
  67588. * @param eventData The data to be sent to each callback
  67589. * @param mask is used to filter observers defaults to -1
  67590. * @param target defines the callback target (see EventState)
  67591. * @param currentTarget defines he current object in the bubbling phase
  67592. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67593. */
  67594. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67595. /**
  67596. * Notify a specific observer
  67597. * @param observer defines the observer to notify
  67598. * @param eventData defines the data to be sent to each callback
  67599. * @param mask is used to filter observers defaults to -1
  67600. */
  67601. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67602. /**
  67603. * Gets a boolean indicating if the observable has at least one observer
  67604. * @returns true is the Observable has at least one Observer registered
  67605. */
  67606. hasObservers(): boolean;
  67607. /**
  67608. * Clear the list of observers
  67609. */
  67610. clear(): void;
  67611. /**
  67612. * Clone the current observable
  67613. * @returns a new observable
  67614. */
  67615. clone(): Observable<T>;
  67616. /**
  67617. * Does this observable handles observer registered with a given mask
  67618. * @param mask defines the mask to be tested
  67619. * @return whether or not one observer registered with the given mask is handeled
  67620. **/
  67621. hasSpecificMask(mask?: number): boolean;
  67622. }
  67623. }
  67624. declare module BABYLON {
  67625. /**
  67626. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67627. * Babylon.js
  67628. */
  67629. export class DomManagement {
  67630. /**
  67631. * Checks if the window object exists
  67632. * @returns true if the window object exists
  67633. */
  67634. static IsWindowObjectExist(): boolean;
  67635. /**
  67636. * Checks if the navigator object exists
  67637. * @returns true if the navigator object exists
  67638. */
  67639. static IsNavigatorAvailable(): boolean;
  67640. /**
  67641. * Extracts text content from a DOM element hierarchy
  67642. * @param element defines the root element
  67643. * @returns a string
  67644. */
  67645. static GetDOMTextContent(element: HTMLElement): string;
  67646. }
  67647. }
  67648. declare module BABYLON {
  67649. /**
  67650. * Logger used througouht the application to allow configuration of
  67651. * the log level required for the messages.
  67652. */
  67653. export class Logger {
  67654. /**
  67655. * No log
  67656. */
  67657. static readonly NoneLogLevel: number;
  67658. /**
  67659. * Only message logs
  67660. */
  67661. static readonly MessageLogLevel: number;
  67662. /**
  67663. * Only warning logs
  67664. */
  67665. static readonly WarningLogLevel: number;
  67666. /**
  67667. * Only error logs
  67668. */
  67669. static readonly ErrorLogLevel: number;
  67670. /**
  67671. * All logs
  67672. */
  67673. static readonly AllLogLevel: number;
  67674. private static _LogCache;
  67675. /**
  67676. * Gets a value indicating the number of loading errors
  67677. * @ignorenaming
  67678. */
  67679. static errorsCount: number;
  67680. /**
  67681. * Callback called when a new log is added
  67682. */
  67683. static OnNewCacheEntry: (entry: string) => void;
  67684. private static _AddLogEntry;
  67685. private static _FormatMessage;
  67686. private static _LogDisabled;
  67687. private static _LogEnabled;
  67688. private static _WarnDisabled;
  67689. private static _WarnEnabled;
  67690. private static _ErrorDisabled;
  67691. private static _ErrorEnabled;
  67692. /**
  67693. * Log a message to the console
  67694. */
  67695. static Log: (message: string) => void;
  67696. /**
  67697. * Write a warning message to the console
  67698. */
  67699. static Warn: (message: string) => void;
  67700. /**
  67701. * Write an error message to the console
  67702. */
  67703. static Error: (message: string) => void;
  67704. /**
  67705. * Gets current log cache (list of logs)
  67706. */
  67707. static readonly LogCache: string;
  67708. /**
  67709. * Clears the log cache
  67710. */
  67711. static ClearLogCache(): void;
  67712. /**
  67713. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67714. */
  67715. static LogLevels: number;
  67716. }
  67717. }
  67718. declare module BABYLON {
  67719. /** @hidden */
  67720. export class _TypeStore {
  67721. /** @hidden */
  67722. static RegisteredTypes: {
  67723. [key: string]: Object;
  67724. };
  67725. /** @hidden */
  67726. static GetClass(fqdn: string): any;
  67727. }
  67728. }
  67729. declare module BABYLON {
  67730. /**
  67731. * Class containing a set of static utilities functions for deep copy.
  67732. */
  67733. export class DeepCopier {
  67734. /**
  67735. * Tries to copy an object by duplicating every property
  67736. * @param source defines the source object
  67737. * @param destination defines the target object
  67738. * @param doNotCopyList defines a list of properties to avoid
  67739. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67740. */
  67741. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /**
  67746. * Class containing a set of static utilities functions for precision date
  67747. */
  67748. export class PrecisionDate {
  67749. /**
  67750. * Gets either window.performance.now() if supported or Date.now() else
  67751. */
  67752. static readonly Now: number;
  67753. }
  67754. }
  67755. declare module BABYLON {
  67756. /** @hidden */
  67757. export class _DevTools {
  67758. static WarnImport(name: string): string;
  67759. }
  67760. }
  67761. declare module BABYLON {
  67762. /**
  67763. * Interface used to define the mechanism to get data from the network
  67764. */
  67765. export interface IWebRequest {
  67766. /**
  67767. * Returns client's response url
  67768. */
  67769. responseURL: string;
  67770. /**
  67771. * Returns client's status
  67772. */
  67773. status: number;
  67774. /**
  67775. * Returns client's status as a text
  67776. */
  67777. statusText: string;
  67778. }
  67779. }
  67780. declare module BABYLON {
  67781. /**
  67782. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67783. */
  67784. export class WebRequest implements IWebRequest {
  67785. private _xhr;
  67786. /**
  67787. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67788. * i.e. when loading files, where the server/service expects an Authorization header
  67789. */
  67790. static CustomRequestHeaders: {
  67791. [key: string]: string;
  67792. };
  67793. /**
  67794. * Add callback functions in this array to update all the requests before they get sent to the network
  67795. */
  67796. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67797. private _injectCustomRequestHeaders;
  67798. /**
  67799. * Gets or sets a function to be called when loading progress changes
  67800. */
  67801. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67802. /**
  67803. * Returns client's state
  67804. */
  67805. readonly readyState: number;
  67806. /**
  67807. * Returns client's status
  67808. */
  67809. readonly status: number;
  67810. /**
  67811. * Returns client's status as a text
  67812. */
  67813. readonly statusText: string;
  67814. /**
  67815. * Returns client's response
  67816. */
  67817. readonly response: any;
  67818. /**
  67819. * Returns client's response url
  67820. */
  67821. readonly responseURL: string;
  67822. /**
  67823. * Returns client's response as text
  67824. */
  67825. readonly responseText: string;
  67826. /**
  67827. * Gets or sets the expected response type
  67828. */
  67829. responseType: XMLHttpRequestResponseType;
  67830. /** @hidden */
  67831. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67832. /** @hidden */
  67833. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67834. /**
  67835. * Cancels any network activity
  67836. */
  67837. abort(): void;
  67838. /**
  67839. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67840. * @param body defines an optional request body
  67841. */
  67842. send(body?: Document | BodyInit | null): void;
  67843. /**
  67844. * Sets the request method, request URL
  67845. * @param method defines the method to use (GET, POST, etc..)
  67846. * @param url defines the url to connect with
  67847. */
  67848. open(method: string, url: string): void;
  67849. }
  67850. }
  67851. declare module BABYLON {
  67852. /**
  67853. * File request interface
  67854. */
  67855. export interface IFileRequest {
  67856. /**
  67857. * Raised when the request is complete (success or error).
  67858. */
  67859. onCompleteObservable: Observable<IFileRequest>;
  67860. /**
  67861. * Aborts the request for a file.
  67862. */
  67863. abort: () => void;
  67864. }
  67865. }
  67866. declare module BABYLON {
  67867. /**
  67868. * Define options used to create a render target texture
  67869. */
  67870. export class RenderTargetCreationOptions {
  67871. /**
  67872. * Specifies is mipmaps must be generated
  67873. */
  67874. generateMipMaps?: boolean;
  67875. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67876. generateDepthBuffer?: boolean;
  67877. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67878. generateStencilBuffer?: boolean;
  67879. /** Defines texture type (int by default) */
  67880. type?: number;
  67881. /** Defines sampling mode (trilinear by default) */
  67882. samplingMode?: number;
  67883. /** Defines format (RGBA by default) */
  67884. format?: number;
  67885. }
  67886. }
  67887. declare module BABYLON {
  67888. /**
  67889. * @hidden
  67890. **/
  67891. export class _TimeToken {
  67892. _startTimeQuery: Nullable<WebGLQuery>;
  67893. _endTimeQuery: Nullable<WebGLQuery>;
  67894. _timeElapsedQuery: Nullable<WebGLQuery>;
  67895. _timeElapsedQueryEnded: boolean;
  67896. }
  67897. }
  67898. declare module BABYLON {
  67899. /** Defines the cross module used constants to avoid circular dependncies */
  67900. export class Constants {
  67901. /** Defines that alpha blending is disabled */
  67902. static readonly ALPHA_DISABLE: number;
  67903. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67904. static readonly ALPHA_ADD: number;
  67905. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67906. static readonly ALPHA_COMBINE: number;
  67907. /** Defines that alpha blending to DEST - SRC * DEST */
  67908. static readonly ALPHA_SUBTRACT: number;
  67909. /** Defines that alpha blending to SRC * DEST */
  67910. static readonly ALPHA_MULTIPLY: number;
  67911. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67912. static readonly ALPHA_MAXIMIZED: number;
  67913. /** Defines that alpha blending to SRC + DEST */
  67914. static readonly ALPHA_ONEONE: number;
  67915. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67916. static readonly ALPHA_PREMULTIPLIED: number;
  67917. /**
  67918. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67919. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67920. */
  67921. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67922. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67923. static readonly ALPHA_INTERPOLATE: number;
  67924. /**
  67925. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67926. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67927. */
  67928. static readonly ALPHA_SCREENMODE: number;
  67929. /**
  67930. * Defines that alpha blending to SRC + DST
  67931. * Alpha will be set to SRC ALPHA + DST ALPHA
  67932. */
  67933. static readonly ALPHA_ONEONE_ONEONE: number;
  67934. /**
  67935. * Defines that alpha blending to SRC * DST ALPHA + DST
  67936. * Alpha will be set to 0
  67937. */
  67938. static readonly ALPHA_ALPHATOCOLOR: number;
  67939. /**
  67940. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67941. */
  67942. static readonly ALPHA_REVERSEONEMINUS: number;
  67943. /**
  67944. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67945. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67946. */
  67947. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67948. /**
  67949. * Defines that alpha blending to SRC + DST
  67950. * Alpha will be set to SRC ALPHA
  67951. */
  67952. static readonly ALPHA_ONEONE_ONEZERO: number;
  67953. /** Defines that alpha blending equation a SUM */
  67954. static readonly ALPHA_EQUATION_ADD: number;
  67955. /** Defines that alpha blending equation a SUBSTRACTION */
  67956. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67957. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67958. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67959. /** Defines that alpha blending equation a MAX operation */
  67960. static readonly ALPHA_EQUATION_MAX: number;
  67961. /** Defines that alpha blending equation a MIN operation */
  67962. static readonly ALPHA_EQUATION_MIN: number;
  67963. /**
  67964. * Defines that alpha blending equation a DARKEN operation:
  67965. * It takes the min of the src and sums the alpha channels.
  67966. */
  67967. static readonly ALPHA_EQUATION_DARKEN: number;
  67968. /** Defines that the ressource is not delayed*/
  67969. static readonly DELAYLOADSTATE_NONE: number;
  67970. /** Defines that the ressource was successfully delay loaded */
  67971. static readonly DELAYLOADSTATE_LOADED: number;
  67972. /** Defines that the ressource is currently delay loading */
  67973. static readonly DELAYLOADSTATE_LOADING: number;
  67974. /** Defines that the ressource is delayed and has not started loading */
  67975. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67976. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67977. static readonly NEVER: number;
  67978. /** 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 */
  67979. static readonly ALWAYS: number;
  67980. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67981. static readonly LESS: number;
  67982. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67983. static readonly EQUAL: number;
  67984. /** 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 */
  67985. static readonly LEQUAL: number;
  67986. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67987. static readonly GREATER: number;
  67988. /** 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 */
  67989. static readonly GEQUAL: number;
  67990. /** 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 */
  67991. static readonly NOTEQUAL: number;
  67992. /** Passed to stencilOperation to specify that stencil value must be kept */
  67993. static readonly KEEP: number;
  67994. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67995. static readonly REPLACE: number;
  67996. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67997. static readonly INCR: number;
  67998. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67999. static readonly DECR: number;
  68000. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68001. static readonly INVERT: number;
  68002. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68003. static readonly INCR_WRAP: number;
  68004. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68005. static readonly DECR_WRAP: number;
  68006. /** Texture is not repeating outside of 0..1 UVs */
  68007. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68008. /** Texture is repeating outside of 0..1 UVs */
  68009. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68010. /** Texture is repeating and mirrored */
  68011. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68012. /** ALPHA */
  68013. static readonly TEXTUREFORMAT_ALPHA: number;
  68014. /** LUMINANCE */
  68015. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68016. /** LUMINANCE_ALPHA */
  68017. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68018. /** RGB */
  68019. static readonly TEXTUREFORMAT_RGB: number;
  68020. /** RGBA */
  68021. static readonly TEXTUREFORMAT_RGBA: number;
  68022. /** RED */
  68023. static readonly TEXTUREFORMAT_RED: number;
  68024. /** RED (2nd reference) */
  68025. static readonly TEXTUREFORMAT_R: number;
  68026. /** RG */
  68027. static readonly TEXTUREFORMAT_RG: number;
  68028. /** RED_INTEGER */
  68029. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68030. /** RED_INTEGER (2nd reference) */
  68031. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68032. /** RG_INTEGER */
  68033. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68034. /** RGB_INTEGER */
  68035. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68036. /** RGBA_INTEGER */
  68037. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68038. /** UNSIGNED_BYTE */
  68039. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68040. /** UNSIGNED_BYTE (2nd reference) */
  68041. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68042. /** FLOAT */
  68043. static readonly TEXTURETYPE_FLOAT: number;
  68044. /** HALF_FLOAT */
  68045. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68046. /** BYTE */
  68047. static readonly TEXTURETYPE_BYTE: number;
  68048. /** SHORT */
  68049. static readonly TEXTURETYPE_SHORT: number;
  68050. /** UNSIGNED_SHORT */
  68051. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68052. /** INT */
  68053. static readonly TEXTURETYPE_INT: number;
  68054. /** UNSIGNED_INT */
  68055. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68056. /** UNSIGNED_SHORT_4_4_4_4 */
  68057. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68058. /** UNSIGNED_SHORT_5_5_5_1 */
  68059. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68060. /** UNSIGNED_SHORT_5_6_5 */
  68061. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68062. /** UNSIGNED_INT_2_10_10_10_REV */
  68063. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68064. /** UNSIGNED_INT_24_8 */
  68065. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68066. /** UNSIGNED_INT_10F_11F_11F_REV */
  68067. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68068. /** UNSIGNED_INT_5_9_9_9_REV */
  68069. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68070. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68071. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68072. /** nearest is mag = nearest and min = nearest and mip = linear */
  68073. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68074. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68075. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68076. /** Trilinear is mag = linear and min = linear and mip = linear */
  68077. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68078. /** nearest is mag = nearest and min = nearest and mip = linear */
  68079. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68080. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68081. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68082. /** Trilinear is mag = linear and min = linear and mip = linear */
  68083. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68084. /** mag = nearest and min = nearest and mip = nearest */
  68085. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68086. /** mag = nearest and min = linear and mip = nearest */
  68087. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68088. /** mag = nearest and min = linear and mip = linear */
  68089. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68090. /** mag = nearest and min = linear and mip = none */
  68091. static readonly TEXTURE_NEAREST_LINEAR: number;
  68092. /** mag = nearest and min = nearest and mip = none */
  68093. static readonly TEXTURE_NEAREST_NEAREST: number;
  68094. /** mag = linear and min = nearest and mip = nearest */
  68095. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68096. /** mag = linear and min = nearest and mip = linear */
  68097. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68098. /** mag = linear and min = linear and mip = none */
  68099. static readonly TEXTURE_LINEAR_LINEAR: number;
  68100. /** mag = linear and min = nearest and mip = none */
  68101. static readonly TEXTURE_LINEAR_NEAREST: number;
  68102. /** Explicit coordinates mode */
  68103. static readonly TEXTURE_EXPLICIT_MODE: number;
  68104. /** Spherical coordinates mode */
  68105. static readonly TEXTURE_SPHERICAL_MODE: number;
  68106. /** Planar coordinates mode */
  68107. static readonly TEXTURE_PLANAR_MODE: number;
  68108. /** Cubic coordinates mode */
  68109. static readonly TEXTURE_CUBIC_MODE: number;
  68110. /** Projection coordinates mode */
  68111. static readonly TEXTURE_PROJECTION_MODE: number;
  68112. /** Skybox coordinates mode */
  68113. static readonly TEXTURE_SKYBOX_MODE: number;
  68114. /** Inverse Cubic coordinates mode */
  68115. static readonly TEXTURE_INVCUBIC_MODE: number;
  68116. /** Equirectangular coordinates mode */
  68117. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68118. /** Equirectangular Fixed coordinates mode */
  68119. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68120. /** Equirectangular Fixed Mirrored coordinates mode */
  68121. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68122. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68123. static readonly SCALEMODE_FLOOR: number;
  68124. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68125. static readonly SCALEMODE_NEAREST: number;
  68126. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68127. static readonly SCALEMODE_CEILING: number;
  68128. /**
  68129. * The dirty texture flag value
  68130. */
  68131. static readonly MATERIAL_TextureDirtyFlag: number;
  68132. /**
  68133. * The dirty light flag value
  68134. */
  68135. static readonly MATERIAL_LightDirtyFlag: number;
  68136. /**
  68137. * The dirty fresnel flag value
  68138. */
  68139. static readonly MATERIAL_FresnelDirtyFlag: number;
  68140. /**
  68141. * The dirty attribute flag value
  68142. */
  68143. static readonly MATERIAL_AttributesDirtyFlag: number;
  68144. /**
  68145. * The dirty misc flag value
  68146. */
  68147. static readonly MATERIAL_MiscDirtyFlag: number;
  68148. /**
  68149. * The all dirty flag value
  68150. */
  68151. static readonly MATERIAL_AllDirtyFlag: number;
  68152. /**
  68153. * Returns the triangle fill mode
  68154. */
  68155. static readonly MATERIAL_TriangleFillMode: number;
  68156. /**
  68157. * Returns the wireframe mode
  68158. */
  68159. static readonly MATERIAL_WireFrameFillMode: number;
  68160. /**
  68161. * Returns the point fill mode
  68162. */
  68163. static readonly MATERIAL_PointFillMode: number;
  68164. /**
  68165. * Returns the point list draw mode
  68166. */
  68167. static readonly MATERIAL_PointListDrawMode: number;
  68168. /**
  68169. * Returns the line list draw mode
  68170. */
  68171. static readonly MATERIAL_LineListDrawMode: number;
  68172. /**
  68173. * Returns the line loop draw mode
  68174. */
  68175. static readonly MATERIAL_LineLoopDrawMode: number;
  68176. /**
  68177. * Returns the line strip draw mode
  68178. */
  68179. static readonly MATERIAL_LineStripDrawMode: number;
  68180. /**
  68181. * Returns the triangle strip draw mode
  68182. */
  68183. static readonly MATERIAL_TriangleStripDrawMode: number;
  68184. /**
  68185. * Returns the triangle fan draw mode
  68186. */
  68187. static readonly MATERIAL_TriangleFanDrawMode: number;
  68188. /**
  68189. * Stores the clock-wise side orientation
  68190. */
  68191. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68192. /**
  68193. * Stores the counter clock-wise side orientation
  68194. */
  68195. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68196. /**
  68197. * Nothing
  68198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68199. */
  68200. static readonly ACTION_NothingTrigger: number;
  68201. /**
  68202. * On pick
  68203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68204. */
  68205. static readonly ACTION_OnPickTrigger: number;
  68206. /**
  68207. * On left pick
  68208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68209. */
  68210. static readonly ACTION_OnLeftPickTrigger: number;
  68211. /**
  68212. * On right pick
  68213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68214. */
  68215. static readonly ACTION_OnRightPickTrigger: number;
  68216. /**
  68217. * On center pick
  68218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68219. */
  68220. static readonly ACTION_OnCenterPickTrigger: number;
  68221. /**
  68222. * On pick down
  68223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68224. */
  68225. static readonly ACTION_OnPickDownTrigger: number;
  68226. /**
  68227. * On double pick
  68228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68229. */
  68230. static readonly ACTION_OnDoublePickTrigger: number;
  68231. /**
  68232. * On pick up
  68233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68234. */
  68235. static readonly ACTION_OnPickUpTrigger: number;
  68236. /**
  68237. * On pick out.
  68238. * This trigger will only be raised if you also declared a OnPickDown
  68239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68240. */
  68241. static readonly ACTION_OnPickOutTrigger: number;
  68242. /**
  68243. * On long press
  68244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68245. */
  68246. static readonly ACTION_OnLongPressTrigger: number;
  68247. /**
  68248. * On pointer over
  68249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68250. */
  68251. static readonly ACTION_OnPointerOverTrigger: number;
  68252. /**
  68253. * On pointer out
  68254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68255. */
  68256. static readonly ACTION_OnPointerOutTrigger: number;
  68257. /**
  68258. * On every frame
  68259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68260. */
  68261. static readonly ACTION_OnEveryFrameTrigger: number;
  68262. /**
  68263. * On intersection enter
  68264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68265. */
  68266. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68267. /**
  68268. * On intersection exit
  68269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68270. */
  68271. static readonly ACTION_OnIntersectionExitTrigger: number;
  68272. /**
  68273. * On key down
  68274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68275. */
  68276. static readonly ACTION_OnKeyDownTrigger: number;
  68277. /**
  68278. * On key up
  68279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68280. */
  68281. static readonly ACTION_OnKeyUpTrigger: number;
  68282. /**
  68283. * Billboard mode will only apply to Y axis
  68284. */
  68285. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68286. /**
  68287. * Billboard mode will apply to all axes
  68288. */
  68289. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68290. /**
  68291. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68292. */
  68293. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68294. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68295. * Test order :
  68296. * Is the bounding sphere outside the frustum ?
  68297. * If not, are the bounding box vertices outside the frustum ?
  68298. * It not, then the cullable object is in the frustum.
  68299. */
  68300. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68301. /** Culling strategy : Bounding Sphere Only.
  68302. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68303. * It's also less accurate than the standard because some not visible objects can still be selected.
  68304. * Test : is the bounding sphere outside the frustum ?
  68305. * If not, then the cullable object is in the frustum.
  68306. */
  68307. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68308. /** Culling strategy : Optimistic Inclusion.
  68309. * This in an inclusion test first, then the standard exclusion test.
  68310. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68311. * 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.
  68312. * Anyway, it's as accurate as the standard strategy.
  68313. * Test :
  68314. * Is the cullable object bounding sphere center in the frustum ?
  68315. * If not, apply the default culling strategy.
  68316. */
  68317. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68318. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68319. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68320. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68321. * 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.
  68322. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68323. * Test :
  68324. * Is the cullable object bounding sphere center in the frustum ?
  68325. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68326. */
  68327. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68328. /**
  68329. * No logging while loading
  68330. */
  68331. static readonly SCENELOADER_NO_LOGGING: number;
  68332. /**
  68333. * Minimal logging while loading
  68334. */
  68335. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68336. /**
  68337. * Summary logging while loading
  68338. */
  68339. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68340. /**
  68341. * Detailled logging while loading
  68342. */
  68343. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /**
  68348. * This represents the required contract to create a new type of texture loader.
  68349. */
  68350. export interface IInternalTextureLoader {
  68351. /**
  68352. * Defines wether the loader supports cascade loading the different faces.
  68353. */
  68354. supportCascades: boolean;
  68355. /**
  68356. * This returns if the loader support the current file information.
  68357. * @param extension defines the file extension of the file being loaded
  68358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68359. * @param fallback defines the fallback internal texture if any
  68360. * @param isBase64 defines whether the texture is encoded as a base64
  68361. * @param isBuffer defines whether the texture data are stored as a buffer
  68362. * @returns true if the loader can load the specified file
  68363. */
  68364. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68365. /**
  68366. * Transform the url before loading if required.
  68367. * @param rootUrl the url of the texture
  68368. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68369. * @returns the transformed texture
  68370. */
  68371. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68372. /**
  68373. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68374. * @param rootUrl the url of the texture
  68375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68376. * @returns the fallback texture
  68377. */
  68378. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68379. /**
  68380. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68381. * @param data contains the texture data
  68382. * @param texture defines the BabylonJS internal texture
  68383. * @param createPolynomials will be true if polynomials have been requested
  68384. * @param onLoad defines the callback to trigger once the texture is ready
  68385. * @param onError defines the callback to trigger in case of error
  68386. */
  68387. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68388. /**
  68389. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68390. * @param data contains the texture data
  68391. * @param texture defines the BabylonJS internal texture
  68392. * @param callback defines the method to call once ready to upload
  68393. */
  68394. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68395. }
  68396. }
  68397. declare module BABYLON {
  68398. /**
  68399. * Class used to store and describe the pipeline context associated with an effect
  68400. */
  68401. export interface IPipelineContext {
  68402. /**
  68403. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68404. */
  68405. isAsync: boolean;
  68406. /**
  68407. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68408. */
  68409. isReady: boolean;
  68410. /** @hidden */
  68411. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68412. }
  68413. }
  68414. declare module BABYLON {
  68415. /**
  68416. * Class used to store gfx data (like WebGLBuffer)
  68417. */
  68418. export class DataBuffer {
  68419. /**
  68420. * Gets or sets the number of objects referencing this buffer
  68421. */
  68422. references: number;
  68423. /** Gets or sets the size of the underlying buffer */
  68424. capacity: number;
  68425. /**
  68426. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68427. */
  68428. is32Bits: boolean;
  68429. /**
  68430. * Gets the underlying buffer
  68431. */
  68432. readonly underlyingResource: any;
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /** @hidden */
  68437. export interface IShaderProcessor {
  68438. attributeProcessor?: (attribute: string) => string;
  68439. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68440. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68441. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68442. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68443. lineProcessor?: (line: string, isFragment: boolean) => string;
  68444. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68445. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68446. }
  68447. }
  68448. declare module BABYLON {
  68449. /** @hidden */
  68450. export interface ProcessingOptions {
  68451. defines: string[];
  68452. indexParameters: any;
  68453. isFragment: boolean;
  68454. shouldUseHighPrecisionShader: boolean;
  68455. supportsUniformBuffers: boolean;
  68456. shadersRepository: string;
  68457. includesShadersStore: {
  68458. [key: string]: string;
  68459. };
  68460. processor?: IShaderProcessor;
  68461. version: string;
  68462. platformName: string;
  68463. lookForClosingBracketForUniformBuffer?: boolean;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * Helper to manipulate strings
  68469. */
  68470. export class StringTools {
  68471. /**
  68472. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68473. * @param str Source string
  68474. * @param suffix Suffix to search for in the source string
  68475. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68476. */
  68477. static EndsWith(str: string, suffix: string): boolean;
  68478. /**
  68479. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68480. * @param str Source string
  68481. * @param suffix Suffix to search for in the source string
  68482. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68483. */
  68484. static StartsWith(str: string, suffix: string): boolean;
  68485. }
  68486. }
  68487. declare module BABYLON {
  68488. /** @hidden */
  68489. export class ShaderCodeNode {
  68490. line: string;
  68491. children: ShaderCodeNode[];
  68492. additionalDefineKey?: string;
  68493. additionalDefineValue?: string;
  68494. isValid(preprocessors: {
  68495. [key: string]: string;
  68496. }): boolean;
  68497. process(preprocessors: {
  68498. [key: string]: string;
  68499. }, options: ProcessingOptions): string;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /** @hidden */
  68504. export class ShaderCodeCursor {
  68505. private _lines;
  68506. lineIndex: number;
  68507. readonly currentLine: string;
  68508. readonly canRead: boolean;
  68509. lines: string[];
  68510. }
  68511. }
  68512. declare module BABYLON {
  68513. /** @hidden */
  68514. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68515. process(preprocessors: {
  68516. [key: string]: string;
  68517. }, options: ProcessingOptions): string;
  68518. }
  68519. }
  68520. declare module BABYLON {
  68521. /** @hidden */
  68522. export class ShaderDefineExpression {
  68523. isTrue(preprocessors: {
  68524. [key: string]: string;
  68525. }): boolean;
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export class ShaderCodeTestNode extends ShaderCodeNode {
  68531. testExpression: ShaderDefineExpression;
  68532. isValid(preprocessors: {
  68533. [key: string]: string;
  68534. }): boolean;
  68535. }
  68536. }
  68537. declare module BABYLON {
  68538. /** @hidden */
  68539. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68540. define: string;
  68541. not: boolean;
  68542. constructor(define: string, not?: boolean);
  68543. isTrue(preprocessors: {
  68544. [key: string]: string;
  68545. }): boolean;
  68546. }
  68547. }
  68548. declare module BABYLON {
  68549. /** @hidden */
  68550. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68551. leftOperand: ShaderDefineExpression;
  68552. rightOperand: ShaderDefineExpression;
  68553. isTrue(preprocessors: {
  68554. [key: string]: string;
  68555. }): boolean;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. /** @hidden */
  68560. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68561. leftOperand: ShaderDefineExpression;
  68562. rightOperand: ShaderDefineExpression;
  68563. isTrue(preprocessors: {
  68564. [key: string]: string;
  68565. }): boolean;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /** @hidden */
  68570. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68571. define: string;
  68572. operand: string;
  68573. testValue: string;
  68574. constructor(define: string, operand: string, testValue: string);
  68575. isTrue(preprocessors: {
  68576. [key: string]: string;
  68577. }): boolean;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * @ignore
  68583. * Application error to support additional information when loading a file
  68584. */
  68585. export class LoadFileError extends Error {
  68586. /** defines the optional web request */
  68587. request?: WebRequest | undefined;
  68588. private static _setPrototypeOf;
  68589. /**
  68590. * Creates a new LoadFileError
  68591. * @param message defines the message of the error
  68592. * @param request defines the optional web request
  68593. */
  68594. constructor(message: string,
  68595. /** defines the optional web request */
  68596. request?: WebRequest | undefined);
  68597. }
  68598. }
  68599. declare module BABYLON {
  68600. /**
  68601. * Class used to enable access to offline support
  68602. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68603. */
  68604. export interface IOfflineProvider {
  68605. /**
  68606. * Gets a boolean indicating if scene must be saved in the database
  68607. */
  68608. enableSceneOffline: boolean;
  68609. /**
  68610. * Gets a boolean indicating if textures must be saved in the database
  68611. */
  68612. enableTexturesOffline: boolean;
  68613. /**
  68614. * Open the offline support and make it available
  68615. * @param successCallback defines the callback to call on success
  68616. * @param errorCallback defines the callback to call on error
  68617. */
  68618. open(successCallback: () => void, errorCallback: () => void): void;
  68619. /**
  68620. * Loads an image from the offline support
  68621. * @param url defines the url to load from
  68622. * @param image defines the target DOM image
  68623. */
  68624. loadImage(url: string, image: HTMLImageElement): void;
  68625. /**
  68626. * Loads a file from offline support
  68627. * @param url defines the URL to load from
  68628. * @param sceneLoaded defines a callback to call on success
  68629. * @param progressCallBack defines a callback to call when progress changed
  68630. * @param errorCallback defines a callback to call on error
  68631. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68632. */
  68633. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68634. }
  68635. }
  68636. declare module BABYLON {
  68637. /**
  68638. * Class used to help managing file picking and drag'n'drop
  68639. * File Storage
  68640. */
  68641. export class FilesInputStore {
  68642. /**
  68643. * List of files ready to be loaded
  68644. */
  68645. static FilesToLoad: {
  68646. [key: string]: File;
  68647. };
  68648. }
  68649. }
  68650. declare module BABYLON {
  68651. /**
  68652. * Class used to define a retry strategy when error happens while loading assets
  68653. */
  68654. export class RetryStrategy {
  68655. /**
  68656. * Function used to defines an exponential back off strategy
  68657. * @param maxRetries defines the maximum number of retries (3 by default)
  68658. * @param baseInterval defines the interval between retries
  68659. * @returns the strategy function to use
  68660. */
  68661. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68662. }
  68663. }
  68664. declare module BABYLON {
  68665. /**
  68666. * @hidden
  68667. */
  68668. export class FileTools {
  68669. /**
  68670. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68671. */
  68672. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68673. /**
  68674. * Gets or sets the base URL to use to load assets
  68675. */
  68676. static BaseUrl: string;
  68677. /**
  68678. * Default behaviour for cors in the application.
  68679. * It can be a string if the expected behavior is identical in the entire app.
  68680. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68681. */
  68682. static CorsBehavior: string | ((url: string | string[]) => string);
  68683. /**
  68684. * Gets or sets a function used to pre-process url before using them to load assets
  68685. */
  68686. static PreprocessUrl: (url: string) => string;
  68687. /**
  68688. * Removes unwanted characters from an url
  68689. * @param url defines the url to clean
  68690. * @returns the cleaned url
  68691. */
  68692. private static _CleanUrl;
  68693. /**
  68694. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68695. * @param url define the url we are trying
  68696. * @param element define the dom element where to configure the cors policy
  68697. */
  68698. static SetCorsBehavior(url: string | string[], element: {
  68699. crossOrigin: string | null;
  68700. }): void;
  68701. private static _ArrayBufferToBase64;
  68702. /**
  68703. * Loads an image as an HTMLImageElement.
  68704. * @param input url string, ArrayBuffer, or Blob to load
  68705. * @param onLoad callback called when the image successfully loads
  68706. * @param onError callback called when the image fails to load
  68707. * @param offlineProvider offline provider for caching
  68708. * @param mimeType optional mime type
  68709. * @returns the HTMLImageElement of the loaded image
  68710. */
  68711. 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>;
  68712. /**
  68713. * Loads a file
  68714. * @param fileToLoad defines the file to load
  68715. * @param callback defines the callback to call when data is loaded
  68716. * @param progressCallBack defines the callback to call during loading process
  68717. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68718. * @returns a file request object
  68719. */
  68720. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68721. /**
  68722. * Loads a file
  68723. * @param url url string, ArrayBuffer, or Blob to load
  68724. * @param onSuccess callback called when the file successfully loads
  68725. * @param onProgress callback called while file is loading (if the server supports this mode)
  68726. * @param offlineProvider defines the offline provider for caching
  68727. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68728. * @param onError callback called when the file fails to load
  68729. * @returns a file request object
  68730. */
  68731. 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;
  68732. /**
  68733. * Checks if the loaded document was accessed via `file:`-Protocol.
  68734. * @returns boolean
  68735. */
  68736. static IsFileURL(): boolean;
  68737. }
  68738. }
  68739. declare module BABYLON {
  68740. /** @hidden */
  68741. export class ShaderProcessor {
  68742. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68743. private static _ProcessPrecision;
  68744. private static _ExtractOperation;
  68745. private static _BuildSubExpression;
  68746. private static _BuildExpression;
  68747. private static _MoveCursorWithinIf;
  68748. private static _MoveCursor;
  68749. private static _EvaluatePreProcessors;
  68750. private static _PreparePreProcessors;
  68751. private static _ProcessShaderConversion;
  68752. private static _ProcessIncludes;
  68753. }
  68754. }
  68755. declare module BABYLON {
  68756. /**
  68757. * @hidden
  68758. */
  68759. export interface IColor4Like {
  68760. r: float;
  68761. g: float;
  68762. b: float;
  68763. a: float;
  68764. }
  68765. /**
  68766. * @hidden
  68767. */
  68768. export interface IColor3Like {
  68769. r: float;
  68770. g: float;
  68771. b: float;
  68772. }
  68773. /**
  68774. * @hidden
  68775. */
  68776. export interface IVector4Like {
  68777. x: float;
  68778. y: float;
  68779. z: float;
  68780. w: float;
  68781. }
  68782. /**
  68783. * @hidden
  68784. */
  68785. export interface IVector3Like {
  68786. x: float;
  68787. y: float;
  68788. z: float;
  68789. }
  68790. /**
  68791. * @hidden
  68792. */
  68793. export interface IVector2Like {
  68794. x: float;
  68795. y: float;
  68796. }
  68797. /**
  68798. * @hidden
  68799. */
  68800. export interface IMatrixLike {
  68801. toArray(): DeepImmutable<Float32Array>;
  68802. updateFlag: int;
  68803. }
  68804. /**
  68805. * @hidden
  68806. */
  68807. export interface IViewportLike {
  68808. x: float;
  68809. y: float;
  68810. width: float;
  68811. height: float;
  68812. }
  68813. /**
  68814. * @hidden
  68815. */
  68816. export interface IPlaneLike {
  68817. normal: IVector3Like;
  68818. d: float;
  68819. normalize(): void;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * Interface used to define common properties for effect fallbacks
  68825. */
  68826. export interface IEffectFallbacks {
  68827. /**
  68828. * Removes the defines that should be removed when falling back.
  68829. * @param currentDefines defines the current define statements for the shader.
  68830. * @param effect defines the current effect we try to compile
  68831. * @returns The resulting defines with defines of the current rank removed.
  68832. */
  68833. reduce(currentDefines: string, effect: Effect): string;
  68834. /**
  68835. * Removes the fallback from the bound mesh.
  68836. */
  68837. unBindMesh(): void;
  68838. /**
  68839. * Checks to see if more fallbacks are still availible.
  68840. */
  68841. hasMoreFallbacks: boolean;
  68842. }
  68843. }
  68844. declare module BABYLON {
  68845. /**
  68846. * Class used to evalaute queries containing `and` and `or` operators
  68847. */
  68848. export class AndOrNotEvaluator {
  68849. /**
  68850. * Evaluate a query
  68851. * @param query defines the query to evaluate
  68852. * @param evaluateCallback defines the callback used to filter result
  68853. * @returns true if the query matches
  68854. */
  68855. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68856. private static _HandleParenthesisContent;
  68857. private static _SimplifyNegation;
  68858. }
  68859. }
  68860. declare module BABYLON {
  68861. /**
  68862. * Class used to store custom tags
  68863. */
  68864. export class Tags {
  68865. /**
  68866. * Adds support for tags on the given object
  68867. * @param obj defines the object to use
  68868. */
  68869. static EnableFor(obj: any): void;
  68870. /**
  68871. * Removes tags support
  68872. * @param obj defines the object to use
  68873. */
  68874. static DisableFor(obj: any): void;
  68875. /**
  68876. * Gets a boolean indicating if the given object has tags
  68877. * @param obj defines the object to use
  68878. * @returns a boolean
  68879. */
  68880. static HasTags(obj: any): boolean;
  68881. /**
  68882. * Gets the tags available on a given object
  68883. * @param obj defines the object to use
  68884. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68885. * @returns the tags
  68886. */
  68887. static GetTags(obj: any, asString?: boolean): any;
  68888. /**
  68889. * Adds tags to an object
  68890. * @param obj defines the object to use
  68891. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68892. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68893. */
  68894. static AddTagsTo(obj: any, tagsString: string): void;
  68895. /**
  68896. * @hidden
  68897. */
  68898. static _AddTagTo(obj: any, tag: string): void;
  68899. /**
  68900. * Removes specific tags from a specific object
  68901. * @param obj defines the object to use
  68902. * @param tagsString defines the tags to remove
  68903. */
  68904. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68905. /**
  68906. * @hidden
  68907. */
  68908. static _RemoveTagFrom(obj: any, tag: string): void;
  68909. /**
  68910. * Defines if tags hosted on an object match a given query
  68911. * @param obj defines the object to use
  68912. * @param tagsQuery defines the tag query
  68913. * @returns a boolean
  68914. */
  68915. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68916. }
  68917. }
  68918. declare module BABYLON {
  68919. /**
  68920. * Scalar computation library
  68921. */
  68922. export class Scalar {
  68923. /**
  68924. * Two pi constants convenient for computation.
  68925. */
  68926. static TwoPi: number;
  68927. /**
  68928. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68929. * @param a number
  68930. * @param b number
  68931. * @param epsilon (default = 1.401298E-45)
  68932. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68933. */
  68934. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68935. /**
  68936. * Returns a string : the upper case translation of the number i to hexadecimal.
  68937. * @param i number
  68938. * @returns the upper case translation of the number i to hexadecimal.
  68939. */
  68940. static ToHex(i: number): string;
  68941. /**
  68942. * Returns -1 if value is negative and +1 is value is positive.
  68943. * @param value the value
  68944. * @returns the value itself if it's equal to zero.
  68945. */
  68946. static Sign(value: number): number;
  68947. /**
  68948. * Returns the value itself if it's between min and max.
  68949. * Returns min if the value is lower than min.
  68950. * Returns max if the value is greater than max.
  68951. * @param value the value to clmap
  68952. * @param min the min value to clamp to (default: 0)
  68953. * @param max the max value to clamp to (default: 1)
  68954. * @returns the clamped value
  68955. */
  68956. static Clamp(value: number, min?: number, max?: number): number;
  68957. /**
  68958. * the log2 of value.
  68959. * @param value the value to compute log2 of
  68960. * @returns the log2 of value.
  68961. */
  68962. static Log2(value: number): number;
  68963. /**
  68964. * Loops the value, so that it is never larger than length and never smaller than 0.
  68965. *
  68966. * This is similar to the modulo operator but it works with floating point numbers.
  68967. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68968. * With t = 5 and length = 2.5, the result would be 0.0.
  68969. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68970. * @param value the value
  68971. * @param length the length
  68972. * @returns the looped value
  68973. */
  68974. static Repeat(value: number, length: number): number;
  68975. /**
  68976. * Normalize the value between 0.0 and 1.0 using min and max values
  68977. * @param value value to normalize
  68978. * @param min max to normalize between
  68979. * @param max min to normalize between
  68980. * @returns the normalized value
  68981. */
  68982. static Normalize(value: number, min: number, max: number): number;
  68983. /**
  68984. * Denormalize the value from 0.0 and 1.0 using min and max values
  68985. * @param normalized value to denormalize
  68986. * @param min max to denormalize between
  68987. * @param max min to denormalize between
  68988. * @returns the denormalized value
  68989. */
  68990. static Denormalize(normalized: number, min: number, max: number): number;
  68991. /**
  68992. * Calculates the shortest difference between two given angles given in degrees.
  68993. * @param current current angle in degrees
  68994. * @param target target angle in degrees
  68995. * @returns the delta
  68996. */
  68997. static DeltaAngle(current: number, target: number): number;
  68998. /**
  68999. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69000. * @param tx value
  69001. * @param length length
  69002. * @returns The returned value will move back and forth between 0 and length
  69003. */
  69004. static PingPong(tx: number, length: number): number;
  69005. /**
  69006. * Interpolates between min and max with smoothing at the limits.
  69007. *
  69008. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69009. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69010. * @param from from
  69011. * @param to to
  69012. * @param tx value
  69013. * @returns the smooth stepped value
  69014. */
  69015. static SmoothStep(from: number, to: number, tx: number): number;
  69016. /**
  69017. * Moves a value current towards target.
  69018. *
  69019. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69020. * Negative values of maxDelta pushes the value away from target.
  69021. * @param current current value
  69022. * @param target target value
  69023. * @param maxDelta max distance to move
  69024. * @returns resulting value
  69025. */
  69026. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69027. /**
  69028. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69029. *
  69030. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69031. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69032. * @param current current value
  69033. * @param target target value
  69034. * @param maxDelta max distance to move
  69035. * @returns resulting angle
  69036. */
  69037. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69038. /**
  69039. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69040. * @param start start value
  69041. * @param end target value
  69042. * @param amount amount to lerp between
  69043. * @returns the lerped value
  69044. */
  69045. static Lerp(start: number, end: number, amount: number): number;
  69046. /**
  69047. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69048. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69049. * @param start start value
  69050. * @param end target value
  69051. * @param amount amount to lerp between
  69052. * @returns the lerped value
  69053. */
  69054. static LerpAngle(start: number, end: number, amount: number): number;
  69055. /**
  69056. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69057. * @param a start value
  69058. * @param b target value
  69059. * @param value value between a and b
  69060. * @returns the inverseLerp value
  69061. */
  69062. static InverseLerp(a: number, b: number, value: number): number;
  69063. /**
  69064. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69065. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69066. * @param value1 spline value
  69067. * @param tangent1 spline value
  69068. * @param value2 spline value
  69069. * @param tangent2 spline value
  69070. * @param amount input value
  69071. * @returns hermite result
  69072. */
  69073. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69074. /**
  69075. * Returns a random float number between and min and max values
  69076. * @param min min value of random
  69077. * @param max max value of random
  69078. * @returns random value
  69079. */
  69080. static RandomRange(min: number, max: number): number;
  69081. /**
  69082. * This function returns percentage of a number in a given range.
  69083. *
  69084. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69085. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69086. * @param number to convert to percentage
  69087. * @param min min range
  69088. * @param max max range
  69089. * @returns the percentage
  69090. */
  69091. static RangeToPercent(number: number, min: number, max: number): number;
  69092. /**
  69093. * This function returns number that corresponds to the percentage in a given range.
  69094. *
  69095. * PercentToRange(0.34,0,100) will return 34.
  69096. * @param percent to convert to number
  69097. * @param min min range
  69098. * @param max max range
  69099. * @returns the number
  69100. */
  69101. static PercentToRange(percent: number, min: number, max: number): number;
  69102. /**
  69103. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69104. * @param angle The angle to normalize in radian.
  69105. * @return The converted angle.
  69106. */
  69107. static NormalizeRadians(angle: number): number;
  69108. }
  69109. }
  69110. declare module BABYLON {
  69111. /**
  69112. * Constant used to convert a value to gamma space
  69113. * @ignorenaming
  69114. */
  69115. export const ToGammaSpace: number;
  69116. /**
  69117. * Constant used to convert a value to linear space
  69118. * @ignorenaming
  69119. */
  69120. export const ToLinearSpace = 2.2;
  69121. /**
  69122. * Constant used to define the minimal number value in Babylon.js
  69123. * @ignorenaming
  69124. */
  69125. let Epsilon: number;
  69126. }
  69127. declare module BABYLON {
  69128. /**
  69129. * Class used to represent a viewport on screen
  69130. */
  69131. export class Viewport {
  69132. /** viewport left coordinate */
  69133. x: number;
  69134. /** viewport top coordinate */
  69135. y: number;
  69136. /**viewport width */
  69137. width: number;
  69138. /** viewport height */
  69139. height: number;
  69140. /**
  69141. * Creates a Viewport object located at (x, y) and sized (width, height)
  69142. * @param x defines viewport left coordinate
  69143. * @param y defines viewport top coordinate
  69144. * @param width defines the viewport width
  69145. * @param height defines the viewport height
  69146. */
  69147. constructor(
  69148. /** viewport left coordinate */
  69149. x: number,
  69150. /** viewport top coordinate */
  69151. y: number,
  69152. /**viewport width */
  69153. width: number,
  69154. /** viewport height */
  69155. height: number);
  69156. /**
  69157. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69158. * @param renderWidth defines the rendering width
  69159. * @param renderHeight defines the rendering height
  69160. * @returns a new Viewport
  69161. */
  69162. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69163. /**
  69164. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69165. * @param renderWidth defines the rendering width
  69166. * @param renderHeight defines the rendering height
  69167. * @param ref defines the target viewport
  69168. * @returns the current viewport
  69169. */
  69170. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69171. /**
  69172. * Returns a new Viewport copied from the current one
  69173. * @returns a new Viewport
  69174. */
  69175. clone(): Viewport;
  69176. }
  69177. }
  69178. declare module BABYLON {
  69179. /**
  69180. * Class containing a set of static utilities functions for arrays.
  69181. */
  69182. export class ArrayTools {
  69183. /**
  69184. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69185. * @param size the number of element to construct and put in the array
  69186. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69187. * @returns a new array filled with new objects
  69188. */
  69189. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69190. }
  69191. }
  69192. declare module BABYLON {
  69193. /**
  69194. * Class representing a vector containing 2 coordinates
  69195. */
  69196. export class Vector2 {
  69197. /** defines the first coordinate */
  69198. x: number;
  69199. /** defines the second coordinate */
  69200. y: number;
  69201. /**
  69202. * Creates a new Vector2 from the given x and y coordinates
  69203. * @param x defines the first coordinate
  69204. * @param y defines the second coordinate
  69205. */
  69206. constructor(
  69207. /** defines the first coordinate */
  69208. x?: number,
  69209. /** defines the second coordinate */
  69210. y?: number);
  69211. /**
  69212. * Gets a string with the Vector2 coordinates
  69213. * @returns a string with the Vector2 coordinates
  69214. */
  69215. toString(): string;
  69216. /**
  69217. * Gets class name
  69218. * @returns the string "Vector2"
  69219. */
  69220. getClassName(): string;
  69221. /**
  69222. * Gets current vector hash code
  69223. * @returns the Vector2 hash code as a number
  69224. */
  69225. getHashCode(): number;
  69226. /**
  69227. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69228. * @param array defines the source array
  69229. * @param index defines the offset in source array
  69230. * @returns the current Vector2
  69231. */
  69232. toArray(array: FloatArray, index?: number): Vector2;
  69233. /**
  69234. * Copy the current vector to an array
  69235. * @returns a new array with 2 elements: the Vector2 coordinates.
  69236. */
  69237. asArray(): number[];
  69238. /**
  69239. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69240. * @param source defines the source Vector2
  69241. * @returns the current updated Vector2
  69242. */
  69243. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69244. /**
  69245. * Sets the Vector2 coordinates with the given floats
  69246. * @param x defines the first coordinate
  69247. * @param y defines the second coordinate
  69248. * @returns the current updated Vector2
  69249. */
  69250. copyFromFloats(x: number, y: number): Vector2;
  69251. /**
  69252. * Sets the Vector2 coordinates with the given floats
  69253. * @param x defines the first coordinate
  69254. * @param y defines the second coordinate
  69255. * @returns the current updated Vector2
  69256. */
  69257. set(x: number, y: number): Vector2;
  69258. /**
  69259. * Add another vector with the current one
  69260. * @param otherVector defines the other vector
  69261. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69262. */
  69263. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69264. /**
  69265. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69266. * @param otherVector defines the other vector
  69267. * @param result defines the target vector
  69268. * @returns the unmodified current Vector2
  69269. */
  69270. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69271. /**
  69272. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69273. * @param otherVector defines the other vector
  69274. * @returns the current updated Vector2
  69275. */
  69276. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69277. /**
  69278. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69279. * @param otherVector defines the other vector
  69280. * @returns a new Vector2
  69281. */
  69282. addVector3(otherVector: Vector3): Vector2;
  69283. /**
  69284. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69285. * @param otherVector defines the other vector
  69286. * @returns a new Vector2
  69287. */
  69288. subtract(otherVector: Vector2): Vector2;
  69289. /**
  69290. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69291. * @param otherVector defines the other vector
  69292. * @param result defines the target vector
  69293. * @returns the unmodified current Vector2
  69294. */
  69295. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69296. /**
  69297. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69298. * @param otherVector defines the other vector
  69299. * @returns the current updated Vector2
  69300. */
  69301. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69302. /**
  69303. * Multiplies in place the current Vector2 coordinates by the given ones
  69304. * @param otherVector defines the other vector
  69305. * @returns the current updated Vector2
  69306. */
  69307. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69308. /**
  69309. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69310. * @param otherVector defines the other vector
  69311. * @returns a new Vector2
  69312. */
  69313. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69314. /**
  69315. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69316. * @param otherVector defines the other vector
  69317. * @param result defines the target vector
  69318. * @returns the unmodified current Vector2
  69319. */
  69320. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69321. /**
  69322. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69323. * @param x defines the first coordinate
  69324. * @param y defines the second coordinate
  69325. * @returns a new Vector2
  69326. */
  69327. multiplyByFloats(x: number, y: number): Vector2;
  69328. /**
  69329. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69330. * @param otherVector defines the other vector
  69331. * @returns a new Vector2
  69332. */
  69333. divide(otherVector: Vector2): Vector2;
  69334. /**
  69335. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69336. * @param otherVector defines the other vector
  69337. * @param result defines the target vector
  69338. * @returns the unmodified current Vector2
  69339. */
  69340. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69341. /**
  69342. * Divides the current Vector2 coordinates by the given ones
  69343. * @param otherVector defines the other vector
  69344. * @returns the current updated Vector2
  69345. */
  69346. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69347. /**
  69348. * Gets a new Vector2 with current Vector2 negated coordinates
  69349. * @returns a new Vector2
  69350. */
  69351. negate(): Vector2;
  69352. /**
  69353. * Multiply the Vector2 coordinates by scale
  69354. * @param scale defines the scaling factor
  69355. * @returns the current updated Vector2
  69356. */
  69357. scaleInPlace(scale: number): Vector2;
  69358. /**
  69359. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69360. * @param scale defines the scaling factor
  69361. * @returns a new Vector2
  69362. */
  69363. scale(scale: number): Vector2;
  69364. /**
  69365. * Scale the current Vector2 values by a factor to a given Vector2
  69366. * @param scale defines the scale factor
  69367. * @param result defines the Vector2 object where to store the result
  69368. * @returns the unmodified current Vector2
  69369. */
  69370. scaleToRef(scale: number, result: Vector2): Vector2;
  69371. /**
  69372. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69373. * @param scale defines the scale factor
  69374. * @param result defines the Vector2 object where to store the result
  69375. * @returns the unmodified current Vector2
  69376. */
  69377. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69378. /**
  69379. * Gets a boolean if two vectors are equals
  69380. * @param otherVector defines the other vector
  69381. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69382. */
  69383. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69384. /**
  69385. * Gets a boolean if two vectors are equals (using an epsilon value)
  69386. * @param otherVector defines the other vector
  69387. * @param epsilon defines the minimal distance to consider equality
  69388. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69389. */
  69390. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69391. /**
  69392. * Gets a new Vector2 from current Vector2 floored values
  69393. * @returns a new Vector2
  69394. */
  69395. floor(): Vector2;
  69396. /**
  69397. * Gets a new Vector2 from current Vector2 floored values
  69398. * @returns a new Vector2
  69399. */
  69400. fract(): Vector2;
  69401. /**
  69402. * Gets the length of the vector
  69403. * @returns the vector length (float)
  69404. */
  69405. length(): number;
  69406. /**
  69407. * Gets the vector squared length
  69408. * @returns the vector squared length (float)
  69409. */
  69410. lengthSquared(): number;
  69411. /**
  69412. * Normalize the vector
  69413. * @returns the current updated Vector2
  69414. */
  69415. normalize(): Vector2;
  69416. /**
  69417. * Gets a new Vector2 copied from the Vector2
  69418. * @returns a new Vector2
  69419. */
  69420. clone(): Vector2;
  69421. /**
  69422. * Gets a new Vector2(0, 0)
  69423. * @returns a new Vector2
  69424. */
  69425. static Zero(): Vector2;
  69426. /**
  69427. * Gets a new Vector2(1, 1)
  69428. * @returns a new Vector2
  69429. */
  69430. static One(): Vector2;
  69431. /**
  69432. * Gets a new Vector2 set from the given index element of the given array
  69433. * @param array defines the data source
  69434. * @param offset defines the offset in the data source
  69435. * @returns a new Vector2
  69436. */
  69437. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69438. /**
  69439. * Sets "result" from the given index element of the given array
  69440. * @param array defines the data source
  69441. * @param offset defines the offset in the data source
  69442. * @param result defines the target vector
  69443. */
  69444. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69445. /**
  69446. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69447. * @param value1 defines 1st point of control
  69448. * @param value2 defines 2nd point of control
  69449. * @param value3 defines 3rd point of control
  69450. * @param value4 defines 4th point of control
  69451. * @param amount defines the interpolation factor
  69452. * @returns a new Vector2
  69453. */
  69454. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69455. /**
  69456. * 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".
  69457. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69458. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69459. * @param value defines the value to clamp
  69460. * @param min defines the lower limit
  69461. * @param max defines the upper limit
  69462. * @returns a new Vector2
  69463. */
  69464. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69465. /**
  69466. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69467. * @param value1 defines the 1st control point
  69468. * @param tangent1 defines the outgoing tangent
  69469. * @param value2 defines the 2nd control point
  69470. * @param tangent2 defines the incoming tangent
  69471. * @param amount defines the interpolation factor
  69472. * @returns a new Vector2
  69473. */
  69474. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69475. /**
  69476. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69477. * @param start defines the start vector
  69478. * @param end defines the end vector
  69479. * @param amount defines the interpolation factor
  69480. * @returns a new Vector2
  69481. */
  69482. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69483. /**
  69484. * Gets the dot product of the vector "left" and the vector "right"
  69485. * @param left defines first vector
  69486. * @param right defines second vector
  69487. * @returns the dot product (float)
  69488. */
  69489. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69490. /**
  69491. * Returns a new Vector2 equal to the normalized given vector
  69492. * @param vector defines the vector to normalize
  69493. * @returns a new Vector2
  69494. */
  69495. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69496. /**
  69497. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69498. * @param left defines 1st vector
  69499. * @param right defines 2nd vector
  69500. * @returns a new Vector2
  69501. */
  69502. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69503. /**
  69504. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69505. * @param left defines 1st vector
  69506. * @param right defines 2nd vector
  69507. * @returns a new Vector2
  69508. */
  69509. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69510. /**
  69511. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69512. * @param vector defines the vector to transform
  69513. * @param transformation defines the matrix to apply
  69514. * @returns a new Vector2
  69515. */
  69516. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69517. /**
  69518. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69519. * @param vector defines the vector to transform
  69520. * @param transformation defines the matrix to apply
  69521. * @param result defines the target vector
  69522. */
  69523. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69524. /**
  69525. * Determines if a given vector is included in a triangle
  69526. * @param p defines the vector to test
  69527. * @param p0 defines 1st triangle point
  69528. * @param p1 defines 2nd triangle point
  69529. * @param p2 defines 3rd triangle point
  69530. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69531. */
  69532. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69533. /**
  69534. * Gets the distance between the vectors "value1" and "value2"
  69535. * @param value1 defines first vector
  69536. * @param value2 defines second vector
  69537. * @returns the distance between vectors
  69538. */
  69539. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69540. /**
  69541. * Returns the squared distance between the vectors "value1" and "value2"
  69542. * @param value1 defines first vector
  69543. * @param value2 defines second vector
  69544. * @returns the squared distance between vectors
  69545. */
  69546. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69547. /**
  69548. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69549. * @param value1 defines first vector
  69550. * @param value2 defines second vector
  69551. * @returns a new Vector2
  69552. */
  69553. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69554. /**
  69555. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69556. * @param p defines the middle point
  69557. * @param segA defines one point of the segment
  69558. * @param segB defines the other point of the segment
  69559. * @returns the shortest distance
  69560. */
  69561. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69562. }
  69563. /**
  69564. * Classed used to store (x,y,z) vector representation
  69565. * A Vector3 is the main object used in 3D geometry
  69566. * It can represent etiher the coordinates of a point the space, either a direction
  69567. * Reminder: js uses a left handed forward facing system
  69568. */
  69569. export class Vector3 {
  69570. /**
  69571. * Defines the first coordinates (on X axis)
  69572. */
  69573. x: number;
  69574. /**
  69575. * Defines the second coordinates (on Y axis)
  69576. */
  69577. y: number;
  69578. /**
  69579. * Defines the third coordinates (on Z axis)
  69580. */
  69581. z: number;
  69582. private static _UpReadOnly;
  69583. private static _ZeroReadOnly;
  69584. /**
  69585. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69586. * @param x defines the first coordinates (on X axis)
  69587. * @param y defines the second coordinates (on Y axis)
  69588. * @param z defines the third coordinates (on Z axis)
  69589. */
  69590. constructor(
  69591. /**
  69592. * Defines the first coordinates (on X axis)
  69593. */
  69594. x?: number,
  69595. /**
  69596. * Defines the second coordinates (on Y axis)
  69597. */
  69598. y?: number,
  69599. /**
  69600. * Defines the third coordinates (on Z axis)
  69601. */
  69602. z?: number);
  69603. /**
  69604. * Creates a string representation of the Vector3
  69605. * @returns a string with the Vector3 coordinates.
  69606. */
  69607. toString(): string;
  69608. /**
  69609. * Gets the class name
  69610. * @returns the string "Vector3"
  69611. */
  69612. getClassName(): string;
  69613. /**
  69614. * Creates the Vector3 hash code
  69615. * @returns a number which tends to be unique between Vector3 instances
  69616. */
  69617. getHashCode(): number;
  69618. /**
  69619. * Creates an array containing three elements : the coordinates of the Vector3
  69620. * @returns a new array of numbers
  69621. */
  69622. asArray(): number[];
  69623. /**
  69624. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69625. * @param array defines the destination array
  69626. * @param index defines the offset in the destination array
  69627. * @returns the current Vector3
  69628. */
  69629. toArray(array: FloatArray, index?: number): Vector3;
  69630. /**
  69631. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69632. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69633. */
  69634. toQuaternion(): Quaternion;
  69635. /**
  69636. * Adds the given vector to the current Vector3
  69637. * @param otherVector defines the second operand
  69638. * @returns the current updated Vector3
  69639. */
  69640. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69641. /**
  69642. * Adds the given coordinates to the current Vector3
  69643. * @param x defines the x coordinate of the operand
  69644. * @param y defines the y coordinate of the operand
  69645. * @param z defines the z coordinate of the operand
  69646. * @returns the current updated Vector3
  69647. */
  69648. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69649. /**
  69650. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69651. * @param otherVector defines the second operand
  69652. * @returns the resulting Vector3
  69653. */
  69654. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69655. /**
  69656. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69657. * @param otherVector defines the second operand
  69658. * @param result defines the Vector3 object where to store the result
  69659. * @returns the current Vector3
  69660. */
  69661. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69662. /**
  69663. * Subtract the given vector from the current Vector3
  69664. * @param otherVector defines the second operand
  69665. * @returns the current updated Vector3
  69666. */
  69667. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69668. /**
  69669. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69670. * @param otherVector defines the second operand
  69671. * @returns the resulting Vector3
  69672. */
  69673. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69674. /**
  69675. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69676. * @param otherVector defines the second operand
  69677. * @param result defines the Vector3 object where to store the result
  69678. * @returns the current Vector3
  69679. */
  69680. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69681. /**
  69682. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69683. * @param x defines the x coordinate of the operand
  69684. * @param y defines the y coordinate of the operand
  69685. * @param z defines the z coordinate of the operand
  69686. * @returns the resulting Vector3
  69687. */
  69688. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69689. /**
  69690. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69691. * @param x defines the x coordinate of the operand
  69692. * @param y defines the y coordinate of the operand
  69693. * @param z defines the z coordinate of the operand
  69694. * @param result defines the Vector3 object where to store the result
  69695. * @returns the current Vector3
  69696. */
  69697. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69698. /**
  69699. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69700. * @returns a new Vector3
  69701. */
  69702. negate(): Vector3;
  69703. /**
  69704. * Multiplies the Vector3 coordinates by the float "scale"
  69705. * @param scale defines the multiplier factor
  69706. * @returns the current updated Vector3
  69707. */
  69708. scaleInPlace(scale: number): Vector3;
  69709. /**
  69710. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69711. * @param scale defines the multiplier factor
  69712. * @returns a new Vector3
  69713. */
  69714. scale(scale: number): Vector3;
  69715. /**
  69716. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69717. * @param scale defines the multiplier factor
  69718. * @param result defines the Vector3 object where to store the result
  69719. * @returns the current Vector3
  69720. */
  69721. scaleToRef(scale: number, result: Vector3): Vector3;
  69722. /**
  69723. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69724. * @param scale defines the scale factor
  69725. * @param result defines the Vector3 object where to store the result
  69726. * @returns the unmodified current Vector3
  69727. */
  69728. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69729. /**
  69730. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69731. * @param otherVector defines the second operand
  69732. * @returns true if both vectors are equals
  69733. */
  69734. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69735. /**
  69736. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69737. * @param otherVector defines the second operand
  69738. * @param epsilon defines the minimal distance to define values as equals
  69739. * @returns true if both vectors are distant less than epsilon
  69740. */
  69741. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69742. /**
  69743. * Returns true if the current Vector3 coordinates equals the given floats
  69744. * @param x defines the x coordinate of the operand
  69745. * @param y defines the y coordinate of the operand
  69746. * @param z defines the z coordinate of the operand
  69747. * @returns true if both vectors are equals
  69748. */
  69749. equalsToFloats(x: number, y: number, z: number): boolean;
  69750. /**
  69751. * Multiplies the current Vector3 coordinates by the given ones
  69752. * @param otherVector defines the second operand
  69753. * @returns the current updated Vector3
  69754. */
  69755. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69756. /**
  69757. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69758. * @param otherVector defines the second operand
  69759. * @returns the new Vector3
  69760. */
  69761. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69762. /**
  69763. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69764. * @param otherVector defines the second operand
  69765. * @param result defines the Vector3 object where to store the result
  69766. * @returns the current Vector3
  69767. */
  69768. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69769. /**
  69770. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69771. * @param x defines the x coordinate of the operand
  69772. * @param y defines the y coordinate of the operand
  69773. * @param z defines the z coordinate of the operand
  69774. * @returns the new Vector3
  69775. */
  69776. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69777. /**
  69778. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69779. * @param otherVector defines the second operand
  69780. * @returns the new Vector3
  69781. */
  69782. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69783. /**
  69784. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69785. * @param otherVector defines the second operand
  69786. * @param result defines the Vector3 object where to store the result
  69787. * @returns the current Vector3
  69788. */
  69789. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69790. /**
  69791. * Divides the current Vector3 coordinates by the given ones.
  69792. * @param otherVector defines the second operand
  69793. * @returns the current updated Vector3
  69794. */
  69795. divideInPlace(otherVector: Vector3): Vector3;
  69796. /**
  69797. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69798. * @param other defines the second operand
  69799. * @returns the current updated Vector3
  69800. */
  69801. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69802. /**
  69803. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69804. * @param other defines the second operand
  69805. * @returns the current updated Vector3
  69806. */
  69807. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69808. /**
  69809. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69810. * @param x defines the x coordinate of the operand
  69811. * @param y defines the y coordinate of the operand
  69812. * @param z defines the z coordinate of the operand
  69813. * @returns the current updated Vector3
  69814. */
  69815. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69816. /**
  69817. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69818. * @param x defines the x coordinate of the operand
  69819. * @param y defines the y coordinate of the operand
  69820. * @param z defines the z coordinate of the operand
  69821. * @returns the current updated Vector3
  69822. */
  69823. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69824. /**
  69825. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69826. * Check if is non uniform within a certain amount of decimal places to account for this
  69827. * @param epsilon the amount the values can differ
  69828. * @returns if the the vector is non uniform to a certain number of decimal places
  69829. */
  69830. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69831. /**
  69832. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69833. */
  69834. readonly isNonUniform: boolean;
  69835. /**
  69836. * Gets a new Vector3 from current Vector3 floored values
  69837. * @returns a new Vector3
  69838. */
  69839. floor(): Vector3;
  69840. /**
  69841. * Gets a new Vector3 from current Vector3 floored values
  69842. * @returns a new Vector3
  69843. */
  69844. fract(): Vector3;
  69845. /**
  69846. * Gets the length of the Vector3
  69847. * @returns the length of the Vector3
  69848. */
  69849. length(): number;
  69850. /**
  69851. * Gets the squared length of the Vector3
  69852. * @returns squared length of the Vector3
  69853. */
  69854. lengthSquared(): number;
  69855. /**
  69856. * Normalize the current Vector3.
  69857. * Please note that this is an in place operation.
  69858. * @returns the current updated Vector3
  69859. */
  69860. normalize(): Vector3;
  69861. /**
  69862. * Reorders the x y z properties of the vector in place
  69863. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69864. * @returns the current updated vector
  69865. */
  69866. reorderInPlace(order: string): this;
  69867. /**
  69868. * Rotates the vector around 0,0,0 by a quaternion
  69869. * @param quaternion the rotation quaternion
  69870. * @param result vector to store the result
  69871. * @returns the resulting vector
  69872. */
  69873. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69874. /**
  69875. * Rotates a vector around a given point
  69876. * @param quaternion the rotation quaternion
  69877. * @param point the point to rotate around
  69878. * @param result vector to store the result
  69879. * @returns the resulting vector
  69880. */
  69881. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69882. /**
  69883. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69884. * The cross product is then orthogonal to both current and "other"
  69885. * @param other defines the right operand
  69886. * @returns the cross product
  69887. */
  69888. cross(other: Vector3): Vector3;
  69889. /**
  69890. * Normalize the current Vector3 with the given input length.
  69891. * Please note that this is an in place operation.
  69892. * @param len the length of the vector
  69893. * @returns the current updated Vector3
  69894. */
  69895. normalizeFromLength(len: number): Vector3;
  69896. /**
  69897. * Normalize the current Vector3 to a new vector
  69898. * @returns the new Vector3
  69899. */
  69900. normalizeToNew(): Vector3;
  69901. /**
  69902. * Normalize the current Vector3 to the reference
  69903. * @param reference define the Vector3 to update
  69904. * @returns the updated Vector3
  69905. */
  69906. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69907. /**
  69908. * Creates a new Vector3 copied from the current Vector3
  69909. * @returns the new Vector3
  69910. */
  69911. clone(): Vector3;
  69912. /**
  69913. * Copies the given vector coordinates to the current Vector3 ones
  69914. * @param source defines the source Vector3
  69915. * @returns the current updated Vector3
  69916. */
  69917. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69918. /**
  69919. * Copies the given floats to the current Vector3 coordinates
  69920. * @param x defines the x coordinate of the operand
  69921. * @param y defines the y coordinate of the operand
  69922. * @param z defines the z coordinate of the operand
  69923. * @returns the current updated Vector3
  69924. */
  69925. copyFromFloats(x: number, y: number, z: number): Vector3;
  69926. /**
  69927. * Copies the given floats to the current Vector3 coordinates
  69928. * @param x defines the x coordinate of the operand
  69929. * @param y defines the y coordinate of the operand
  69930. * @param z defines the z coordinate of the operand
  69931. * @returns the current updated Vector3
  69932. */
  69933. set(x: number, y: number, z: number): Vector3;
  69934. /**
  69935. * Copies the given float to the current Vector3 coordinates
  69936. * @param v defines the x, y and z coordinates of the operand
  69937. * @returns the current updated Vector3
  69938. */
  69939. setAll(v: number): Vector3;
  69940. /**
  69941. * Get the clip factor between two vectors
  69942. * @param vector0 defines the first operand
  69943. * @param vector1 defines the second operand
  69944. * @param axis defines the axis to use
  69945. * @param size defines the size along the axis
  69946. * @returns the clip factor
  69947. */
  69948. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69949. /**
  69950. * Get angle between two vectors
  69951. * @param vector0 angle between vector0 and vector1
  69952. * @param vector1 angle between vector0 and vector1
  69953. * @param normal direction of the normal
  69954. * @return the angle between vector0 and vector1
  69955. */
  69956. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69957. /**
  69958. * Returns a new Vector3 set from the index "offset" of the given array
  69959. * @param array defines the source array
  69960. * @param offset defines the offset in the source array
  69961. * @returns the new Vector3
  69962. */
  69963. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69964. /**
  69965. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69966. * This function is deprecated. Use FromArray instead
  69967. * @param array defines the source array
  69968. * @param offset defines the offset in the source array
  69969. * @returns the new Vector3
  69970. */
  69971. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69972. /**
  69973. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69974. * @param array defines the source array
  69975. * @param offset defines the offset in the source array
  69976. * @param result defines the Vector3 where to store the result
  69977. */
  69978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69979. /**
  69980. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69981. * This function is deprecated. Use FromArrayToRef instead.
  69982. * @param array defines the source array
  69983. * @param offset defines the offset in the source array
  69984. * @param result defines the Vector3 where to store the result
  69985. */
  69986. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69987. /**
  69988. * Sets the given vector "result" with the given floats.
  69989. * @param x defines the x coordinate of the source
  69990. * @param y defines the y coordinate of the source
  69991. * @param z defines the z coordinate of the source
  69992. * @param result defines the Vector3 where to store the result
  69993. */
  69994. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69995. /**
  69996. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69997. * @returns a new empty Vector3
  69998. */
  69999. static Zero(): Vector3;
  70000. /**
  70001. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70002. * @returns a new unit Vector3
  70003. */
  70004. static One(): Vector3;
  70005. /**
  70006. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70007. * @returns a new up Vector3
  70008. */
  70009. static Up(): Vector3;
  70010. /**
  70011. * Gets a up Vector3 that must not be updated
  70012. */
  70013. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70014. /**
  70015. * Gets a zero Vector3 that must not be updated
  70016. */
  70017. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70018. /**
  70019. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70020. * @returns a new down Vector3
  70021. */
  70022. static Down(): Vector3;
  70023. /**
  70024. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70025. * @returns a new forward Vector3
  70026. */
  70027. static Forward(): Vector3;
  70028. /**
  70029. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70030. * @returns a new forward Vector3
  70031. */
  70032. static Backward(): Vector3;
  70033. /**
  70034. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70035. * @returns a new right Vector3
  70036. */
  70037. static Right(): Vector3;
  70038. /**
  70039. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70040. * @returns a new left Vector3
  70041. */
  70042. static Left(): Vector3;
  70043. /**
  70044. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70045. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70046. * @param vector defines the Vector3 to transform
  70047. * @param transformation defines the transformation matrix
  70048. * @returns the transformed Vector3
  70049. */
  70050. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70051. /**
  70052. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70053. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70054. * @param vector defines the Vector3 to transform
  70055. * @param transformation defines the transformation matrix
  70056. * @param result defines the Vector3 where to store the result
  70057. */
  70058. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70059. /**
  70060. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70061. * This method computes tranformed coordinates only, not transformed direction vectors
  70062. * @param x define the x coordinate of the source vector
  70063. * @param y define the y coordinate of the source vector
  70064. * @param z define the z coordinate of the source vector
  70065. * @param transformation defines the transformation matrix
  70066. * @param result defines the Vector3 where to store the result
  70067. */
  70068. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70069. /**
  70070. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70071. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70072. * @param vector defines the Vector3 to transform
  70073. * @param transformation defines the transformation matrix
  70074. * @returns the new Vector3
  70075. */
  70076. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70077. /**
  70078. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70079. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70080. * @param vector defines the Vector3 to transform
  70081. * @param transformation defines the transformation matrix
  70082. * @param result defines the Vector3 where to store the result
  70083. */
  70084. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70085. /**
  70086. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70087. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70088. * @param x define the x coordinate of the source vector
  70089. * @param y define the y coordinate of the source vector
  70090. * @param z define the z coordinate of the source vector
  70091. * @param transformation defines the transformation matrix
  70092. * @param result defines the Vector3 where to store the result
  70093. */
  70094. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70095. /**
  70096. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70097. * @param value1 defines the first control point
  70098. * @param value2 defines the second control point
  70099. * @param value3 defines the third control point
  70100. * @param value4 defines the fourth control point
  70101. * @param amount defines the amount on the spline to use
  70102. * @returns the new Vector3
  70103. */
  70104. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70105. /**
  70106. * 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"
  70107. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70108. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70109. * @param value defines the current value
  70110. * @param min defines the lower range value
  70111. * @param max defines the upper range value
  70112. * @returns the new Vector3
  70113. */
  70114. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70115. /**
  70116. * 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"
  70117. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70118. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70119. * @param value defines the current value
  70120. * @param min defines the lower range value
  70121. * @param max defines the upper range value
  70122. * @param result defines the Vector3 where to store the result
  70123. */
  70124. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70125. /**
  70126. * Checks if a given vector is inside a specific range
  70127. * @param v defines the vector to test
  70128. * @param min defines the minimum range
  70129. * @param max defines the maximum range
  70130. */
  70131. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70132. /**
  70133. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70134. * @param value1 defines the first control point
  70135. * @param tangent1 defines the first tangent vector
  70136. * @param value2 defines the second control point
  70137. * @param tangent2 defines the second tangent vector
  70138. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70139. * @returns the new Vector3
  70140. */
  70141. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70142. /**
  70143. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70144. * @param start defines the start value
  70145. * @param end defines the end value
  70146. * @param amount max defines amount between both (between 0 and 1)
  70147. * @returns the new Vector3
  70148. */
  70149. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70150. /**
  70151. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70152. * @param start defines the start value
  70153. * @param end defines the end value
  70154. * @param amount max defines amount between both (between 0 and 1)
  70155. * @param result defines the Vector3 where to store the result
  70156. */
  70157. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70158. /**
  70159. * Returns the dot product (float) between the vectors "left" and "right"
  70160. * @param left defines the left operand
  70161. * @param right defines the right operand
  70162. * @returns the dot product
  70163. */
  70164. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70165. /**
  70166. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70167. * The cross product is then orthogonal to both "left" and "right"
  70168. * @param left defines the left operand
  70169. * @param right defines the right operand
  70170. * @returns the cross product
  70171. */
  70172. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70173. /**
  70174. * Sets the given vector "result" with the cross product of "left" and "right"
  70175. * The cross product is then orthogonal to both "left" and "right"
  70176. * @param left defines the left operand
  70177. * @param right defines the right operand
  70178. * @param result defines the Vector3 where to store the result
  70179. */
  70180. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70181. /**
  70182. * Returns a new Vector3 as the normalization of the given vector
  70183. * @param vector defines the Vector3 to normalize
  70184. * @returns the new Vector3
  70185. */
  70186. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70187. /**
  70188. * Sets the given vector "result" with the normalization of the given first vector
  70189. * @param vector defines the Vector3 to normalize
  70190. * @param result defines the Vector3 where to store the result
  70191. */
  70192. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70193. /**
  70194. * Project a Vector3 onto screen space
  70195. * @param vector defines the Vector3 to project
  70196. * @param world defines the world matrix to use
  70197. * @param transform defines the transform (view x projection) matrix to use
  70198. * @param viewport defines the screen viewport to use
  70199. * @returns the new Vector3
  70200. */
  70201. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70202. /** @hidden */
  70203. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70204. /**
  70205. * Unproject from screen space to object space
  70206. * @param source defines the screen space Vector3 to use
  70207. * @param viewportWidth defines the current width of the viewport
  70208. * @param viewportHeight defines the current height of the viewport
  70209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70210. * @param transform defines the transform (view x projection) matrix to use
  70211. * @returns the new Vector3
  70212. */
  70213. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70214. /**
  70215. * Unproject from screen space to object space
  70216. * @param source defines the screen space Vector3 to use
  70217. * @param viewportWidth defines the current width of the viewport
  70218. * @param viewportHeight defines the current height of the viewport
  70219. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70220. * @param view defines the view matrix to use
  70221. * @param projection defines the projection matrix to use
  70222. * @returns the new Vector3
  70223. */
  70224. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70225. /**
  70226. * Unproject from screen space to object space
  70227. * @param source defines the screen space Vector3 to use
  70228. * @param viewportWidth defines the current width of the viewport
  70229. * @param viewportHeight defines the current height of the viewport
  70230. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70231. * @param view defines the view matrix to use
  70232. * @param projection defines the projection matrix to use
  70233. * @param result defines the Vector3 where to store the result
  70234. */
  70235. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70236. /**
  70237. * Unproject from screen space to object space
  70238. * @param sourceX defines the screen space x coordinate to use
  70239. * @param sourceY defines the screen space y coordinate to use
  70240. * @param sourceZ defines the screen space z coordinate to use
  70241. * @param viewportWidth defines the current width of the viewport
  70242. * @param viewportHeight defines the current height of the viewport
  70243. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70244. * @param view defines the view matrix to use
  70245. * @param projection defines the projection matrix to use
  70246. * @param result defines the Vector3 where to store the result
  70247. */
  70248. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70249. /**
  70250. * Gets the minimal coordinate values between two Vector3
  70251. * @param left defines the first operand
  70252. * @param right defines the second operand
  70253. * @returns the new Vector3
  70254. */
  70255. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70256. /**
  70257. * Gets the maximal coordinate values between two Vector3
  70258. * @param left defines the first operand
  70259. * @param right defines the second operand
  70260. * @returns the new Vector3
  70261. */
  70262. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70263. /**
  70264. * Returns the distance between the vectors "value1" and "value2"
  70265. * @param value1 defines the first operand
  70266. * @param value2 defines the second operand
  70267. * @returns the distance
  70268. */
  70269. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70270. /**
  70271. * Returns the squared distance between the vectors "value1" and "value2"
  70272. * @param value1 defines the first operand
  70273. * @param value2 defines the second operand
  70274. * @returns the squared distance
  70275. */
  70276. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70277. /**
  70278. * Returns a new Vector3 located at the center between "value1" and "value2"
  70279. * @param value1 defines the first operand
  70280. * @param value2 defines the second operand
  70281. * @returns the new Vector3
  70282. */
  70283. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70284. /**
  70285. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70286. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70287. * to something in order to rotate it from its local system to the given target system
  70288. * Note: axis1, axis2 and axis3 are normalized during this operation
  70289. * @param axis1 defines the first axis
  70290. * @param axis2 defines the second axis
  70291. * @param axis3 defines the third axis
  70292. * @returns a new Vector3
  70293. */
  70294. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70295. /**
  70296. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70297. * @param axis1 defines the first axis
  70298. * @param axis2 defines the second axis
  70299. * @param axis3 defines the third axis
  70300. * @param ref defines the Vector3 where to store the result
  70301. */
  70302. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70303. }
  70304. /**
  70305. * Vector4 class created for EulerAngle class conversion to Quaternion
  70306. */
  70307. export class Vector4 {
  70308. /** x value of the vector */
  70309. x: number;
  70310. /** y value of the vector */
  70311. y: number;
  70312. /** z value of the vector */
  70313. z: number;
  70314. /** w value of the vector */
  70315. w: number;
  70316. /**
  70317. * Creates a Vector4 object from the given floats.
  70318. * @param x x value of the vector
  70319. * @param y y value of the vector
  70320. * @param z z value of the vector
  70321. * @param w w value of the vector
  70322. */
  70323. constructor(
  70324. /** x value of the vector */
  70325. x: number,
  70326. /** y value of the vector */
  70327. y: number,
  70328. /** z value of the vector */
  70329. z: number,
  70330. /** w value of the vector */
  70331. w: number);
  70332. /**
  70333. * Returns the string with the Vector4 coordinates.
  70334. * @returns a string containing all the vector values
  70335. */
  70336. toString(): string;
  70337. /**
  70338. * Returns the string "Vector4".
  70339. * @returns "Vector4"
  70340. */
  70341. getClassName(): string;
  70342. /**
  70343. * Returns the Vector4 hash code.
  70344. * @returns a unique hash code
  70345. */
  70346. getHashCode(): number;
  70347. /**
  70348. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70349. * @returns the resulting array
  70350. */
  70351. asArray(): number[];
  70352. /**
  70353. * Populates the given array from the given index with the Vector4 coordinates.
  70354. * @param array array to populate
  70355. * @param index index of the array to start at (default: 0)
  70356. * @returns the Vector4.
  70357. */
  70358. toArray(array: FloatArray, index?: number): Vector4;
  70359. /**
  70360. * Adds the given vector to the current Vector4.
  70361. * @param otherVector the vector to add
  70362. * @returns the updated Vector4.
  70363. */
  70364. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70365. /**
  70366. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70367. * @param otherVector the vector to add
  70368. * @returns the resulting vector
  70369. */
  70370. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70371. /**
  70372. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70373. * @param otherVector the vector to add
  70374. * @param result the vector to store the result
  70375. * @returns the current Vector4.
  70376. */
  70377. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70378. /**
  70379. * Subtract in place the given vector from the current Vector4.
  70380. * @param otherVector the vector to subtract
  70381. * @returns the updated Vector4.
  70382. */
  70383. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70384. /**
  70385. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70386. * @param otherVector the vector to add
  70387. * @returns the new vector with the result
  70388. */
  70389. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70390. /**
  70391. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70392. * @param otherVector the vector to subtract
  70393. * @param result the vector to store the result
  70394. * @returns the current Vector4.
  70395. */
  70396. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70397. /**
  70398. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70399. */
  70400. /**
  70401. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70402. * @param x value to subtract
  70403. * @param y value to subtract
  70404. * @param z value to subtract
  70405. * @param w value to subtract
  70406. * @returns new vector containing the result
  70407. */
  70408. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70409. /**
  70410. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70411. * @param x value to subtract
  70412. * @param y value to subtract
  70413. * @param z value to subtract
  70414. * @param w value to subtract
  70415. * @param result the vector to store the result in
  70416. * @returns the current Vector4.
  70417. */
  70418. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70419. /**
  70420. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70421. * @returns a new vector with the negated values
  70422. */
  70423. negate(): Vector4;
  70424. /**
  70425. * Multiplies the current Vector4 coordinates by scale (float).
  70426. * @param scale the number to scale with
  70427. * @returns the updated Vector4.
  70428. */
  70429. scaleInPlace(scale: number): Vector4;
  70430. /**
  70431. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70432. * @param scale the number to scale with
  70433. * @returns a new vector with the result
  70434. */
  70435. scale(scale: number): Vector4;
  70436. /**
  70437. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70438. * @param scale the number to scale with
  70439. * @param result a vector to store the result in
  70440. * @returns the current Vector4.
  70441. */
  70442. scaleToRef(scale: number, result: Vector4): Vector4;
  70443. /**
  70444. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70445. * @param scale defines the scale factor
  70446. * @param result defines the Vector4 object where to store the result
  70447. * @returns the unmodified current Vector4
  70448. */
  70449. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70450. /**
  70451. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70452. * @param otherVector the vector to compare against
  70453. * @returns true if they are equal
  70454. */
  70455. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70456. /**
  70457. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70458. * @param otherVector vector to compare against
  70459. * @param epsilon (Default: very small number)
  70460. * @returns true if they are equal
  70461. */
  70462. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70463. /**
  70464. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70465. * @param x x value to compare against
  70466. * @param y y value to compare against
  70467. * @param z z value to compare against
  70468. * @param w w value to compare against
  70469. * @returns true if equal
  70470. */
  70471. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70472. /**
  70473. * Multiplies in place the current Vector4 by the given one.
  70474. * @param otherVector vector to multiple with
  70475. * @returns the updated Vector4.
  70476. */
  70477. multiplyInPlace(otherVector: Vector4): Vector4;
  70478. /**
  70479. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70480. * @param otherVector vector to multiple with
  70481. * @returns resulting new vector
  70482. */
  70483. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70484. /**
  70485. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70486. * @param otherVector vector to multiple with
  70487. * @param result vector to store the result
  70488. * @returns the current Vector4.
  70489. */
  70490. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70491. /**
  70492. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70493. * @param x x value multiply with
  70494. * @param y y value multiply with
  70495. * @param z z value multiply with
  70496. * @param w w value multiply with
  70497. * @returns resulting new vector
  70498. */
  70499. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70500. /**
  70501. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70502. * @param otherVector vector to devide with
  70503. * @returns resulting new vector
  70504. */
  70505. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70506. /**
  70507. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70508. * @param otherVector vector to devide with
  70509. * @param result vector to store the result
  70510. * @returns the current Vector4.
  70511. */
  70512. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70513. /**
  70514. * Divides the current Vector3 coordinates by the given ones.
  70515. * @param otherVector vector to devide with
  70516. * @returns the updated Vector3.
  70517. */
  70518. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70519. /**
  70520. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70521. * @param other defines the second operand
  70522. * @returns the current updated Vector4
  70523. */
  70524. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70525. /**
  70526. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70527. * @param other defines the second operand
  70528. * @returns the current updated Vector4
  70529. */
  70530. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70531. /**
  70532. * Gets a new Vector4 from current Vector4 floored values
  70533. * @returns a new Vector4
  70534. */
  70535. floor(): Vector4;
  70536. /**
  70537. * Gets a new Vector4 from current Vector3 floored values
  70538. * @returns a new Vector4
  70539. */
  70540. fract(): Vector4;
  70541. /**
  70542. * Returns the Vector4 length (float).
  70543. * @returns the length
  70544. */
  70545. length(): number;
  70546. /**
  70547. * Returns the Vector4 squared length (float).
  70548. * @returns the length squared
  70549. */
  70550. lengthSquared(): number;
  70551. /**
  70552. * Normalizes in place the Vector4.
  70553. * @returns the updated Vector4.
  70554. */
  70555. normalize(): Vector4;
  70556. /**
  70557. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70558. * @returns this converted to a new vector3
  70559. */
  70560. toVector3(): Vector3;
  70561. /**
  70562. * Returns a new Vector4 copied from the current one.
  70563. * @returns the new cloned vector
  70564. */
  70565. clone(): Vector4;
  70566. /**
  70567. * Updates the current Vector4 with the given one coordinates.
  70568. * @param source the source vector to copy from
  70569. * @returns the updated Vector4.
  70570. */
  70571. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70572. /**
  70573. * Updates the current Vector4 coordinates with the given floats.
  70574. * @param x float to copy from
  70575. * @param y float to copy from
  70576. * @param z float to copy from
  70577. * @param w float to copy from
  70578. * @returns the updated Vector4.
  70579. */
  70580. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70581. /**
  70582. * Updates the current Vector4 coordinates with the given floats.
  70583. * @param x float to set from
  70584. * @param y float to set from
  70585. * @param z float to set from
  70586. * @param w float to set from
  70587. * @returns the updated Vector4.
  70588. */
  70589. set(x: number, y: number, z: number, w: number): Vector4;
  70590. /**
  70591. * Copies the given float to the current Vector3 coordinates
  70592. * @param v defines the x, y, z and w coordinates of the operand
  70593. * @returns the current updated Vector3
  70594. */
  70595. setAll(v: number): Vector4;
  70596. /**
  70597. * Returns a new Vector4 set from the starting index of the given array.
  70598. * @param array the array to pull values from
  70599. * @param offset the offset into the array to start at
  70600. * @returns the new vector
  70601. */
  70602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70603. /**
  70604. * Updates the given vector "result" from the starting index of the given array.
  70605. * @param array the array to pull values from
  70606. * @param offset the offset into the array to start at
  70607. * @param result the vector to store the result in
  70608. */
  70609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70610. /**
  70611. * Updates the given vector "result" from the starting index of the given Float32Array.
  70612. * @param array the array to pull values from
  70613. * @param offset the offset into the array to start at
  70614. * @param result the vector to store the result in
  70615. */
  70616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70617. /**
  70618. * Updates the given vector "result" coordinates from the given floats.
  70619. * @param x float to set from
  70620. * @param y float to set from
  70621. * @param z float to set from
  70622. * @param w float to set from
  70623. * @param result the vector to the floats in
  70624. */
  70625. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70626. /**
  70627. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70628. * @returns the new vector
  70629. */
  70630. static Zero(): Vector4;
  70631. /**
  70632. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70633. * @returns the new vector
  70634. */
  70635. static One(): Vector4;
  70636. /**
  70637. * Returns a new normalized Vector4 from the given one.
  70638. * @param vector the vector to normalize
  70639. * @returns the vector
  70640. */
  70641. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70642. /**
  70643. * Updates the given vector "result" from the normalization of the given one.
  70644. * @param vector the vector to normalize
  70645. * @param result the vector to store the result in
  70646. */
  70647. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70648. /**
  70649. * Returns a vector with the minimum values from the left and right vectors
  70650. * @param left left vector to minimize
  70651. * @param right right vector to minimize
  70652. * @returns a new vector with the minimum of the left and right vector values
  70653. */
  70654. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70655. /**
  70656. * Returns a vector with the maximum values from the left and right vectors
  70657. * @param left left vector to maximize
  70658. * @param right right vector to maximize
  70659. * @returns a new vector with the maximum of the left and right vector values
  70660. */
  70661. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70662. /**
  70663. * Returns the distance (float) between the vectors "value1" and "value2".
  70664. * @param value1 value to calulate the distance between
  70665. * @param value2 value to calulate the distance between
  70666. * @return the distance between the two vectors
  70667. */
  70668. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70669. /**
  70670. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70671. * @param value1 value to calulate the distance between
  70672. * @param value2 value to calulate the distance between
  70673. * @return the distance between the two vectors squared
  70674. */
  70675. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70676. /**
  70677. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70678. * @param value1 value to calulate the center between
  70679. * @param value2 value to calulate the center between
  70680. * @return the center between the two vectors
  70681. */
  70682. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70683. /**
  70684. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70685. * This methods computes transformed normalized direction vectors only.
  70686. * @param vector the vector to transform
  70687. * @param transformation the transformation matrix to apply
  70688. * @returns the new vector
  70689. */
  70690. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70691. /**
  70692. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70693. * This methods computes transformed normalized direction vectors only.
  70694. * @param vector the vector to transform
  70695. * @param transformation the transformation matrix to apply
  70696. * @param result the vector to store the result in
  70697. */
  70698. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70699. /**
  70700. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70701. * This methods computes transformed normalized direction vectors only.
  70702. * @param x value to transform
  70703. * @param y value to transform
  70704. * @param z value to transform
  70705. * @param w value to transform
  70706. * @param transformation the transformation matrix to apply
  70707. * @param result the vector to store the results in
  70708. */
  70709. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70710. /**
  70711. * Creates a new Vector4 from a Vector3
  70712. * @param source defines the source data
  70713. * @param w defines the 4th component (default is 0)
  70714. * @returns a new Vector4
  70715. */
  70716. static FromVector3(source: Vector3, w?: number): Vector4;
  70717. }
  70718. /**
  70719. * Class used to store quaternion data
  70720. * @see https://en.wikipedia.org/wiki/Quaternion
  70721. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70722. */
  70723. export class Quaternion {
  70724. /** defines the first component (0 by default) */
  70725. x: number;
  70726. /** defines the second component (0 by default) */
  70727. y: number;
  70728. /** defines the third component (0 by default) */
  70729. z: number;
  70730. /** defines the fourth component (1.0 by default) */
  70731. w: number;
  70732. /**
  70733. * Creates a new Quaternion from the given floats
  70734. * @param x defines the first component (0 by default)
  70735. * @param y defines the second component (0 by default)
  70736. * @param z defines the third component (0 by default)
  70737. * @param w defines the fourth component (1.0 by default)
  70738. */
  70739. constructor(
  70740. /** defines the first component (0 by default) */
  70741. x?: number,
  70742. /** defines the second component (0 by default) */
  70743. y?: number,
  70744. /** defines the third component (0 by default) */
  70745. z?: number,
  70746. /** defines the fourth component (1.0 by default) */
  70747. w?: number);
  70748. /**
  70749. * Gets a string representation for the current quaternion
  70750. * @returns a string with the Quaternion coordinates
  70751. */
  70752. toString(): string;
  70753. /**
  70754. * Gets the class name of the quaternion
  70755. * @returns the string "Quaternion"
  70756. */
  70757. getClassName(): string;
  70758. /**
  70759. * Gets a hash code for this quaternion
  70760. * @returns the quaternion hash code
  70761. */
  70762. getHashCode(): number;
  70763. /**
  70764. * Copy the quaternion to an array
  70765. * @returns a new array populated with 4 elements from the quaternion coordinates
  70766. */
  70767. asArray(): number[];
  70768. /**
  70769. * Check if two quaternions are equals
  70770. * @param otherQuaternion defines the second operand
  70771. * @return true if the current quaternion and the given one coordinates are strictly equals
  70772. */
  70773. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70774. /**
  70775. * Clone the current quaternion
  70776. * @returns a new quaternion copied from the current one
  70777. */
  70778. clone(): Quaternion;
  70779. /**
  70780. * Copy a quaternion to the current one
  70781. * @param other defines the other quaternion
  70782. * @returns the updated current quaternion
  70783. */
  70784. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70785. /**
  70786. * Updates the current quaternion with the given float coordinates
  70787. * @param x defines the x coordinate
  70788. * @param y defines the y coordinate
  70789. * @param z defines the z coordinate
  70790. * @param w defines the w coordinate
  70791. * @returns the updated current quaternion
  70792. */
  70793. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70794. /**
  70795. * Updates the current quaternion from the given float coordinates
  70796. * @param x defines the x coordinate
  70797. * @param y defines the y coordinate
  70798. * @param z defines the z coordinate
  70799. * @param w defines the w coordinate
  70800. * @returns the updated current quaternion
  70801. */
  70802. set(x: number, y: number, z: number, w: number): Quaternion;
  70803. /**
  70804. * Adds two quaternions
  70805. * @param other defines the second operand
  70806. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70807. */
  70808. add(other: DeepImmutable<Quaternion>): Quaternion;
  70809. /**
  70810. * Add a quaternion to the current one
  70811. * @param other defines the quaternion to add
  70812. * @returns the current quaternion
  70813. */
  70814. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70815. /**
  70816. * Subtract two quaternions
  70817. * @param other defines the second operand
  70818. * @returns a new quaternion as the subtraction result of the given one from the current one
  70819. */
  70820. subtract(other: Quaternion): Quaternion;
  70821. /**
  70822. * Multiplies the current quaternion by a scale factor
  70823. * @param value defines the scale factor
  70824. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70825. */
  70826. scale(value: number): Quaternion;
  70827. /**
  70828. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70829. * @param scale defines the scale factor
  70830. * @param result defines the Quaternion object where to store the result
  70831. * @returns the unmodified current quaternion
  70832. */
  70833. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70834. /**
  70835. * Multiplies in place the current quaternion by a scale factor
  70836. * @param value defines the scale factor
  70837. * @returns the current modified quaternion
  70838. */
  70839. scaleInPlace(value: number): Quaternion;
  70840. /**
  70841. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70842. * @param scale defines the scale factor
  70843. * @param result defines the Quaternion object where to store the result
  70844. * @returns the unmodified current quaternion
  70845. */
  70846. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70847. /**
  70848. * Multiplies two quaternions
  70849. * @param q1 defines the second operand
  70850. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70851. */
  70852. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70853. /**
  70854. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70855. * @param q1 defines the second operand
  70856. * @param result defines the target quaternion
  70857. * @returns the current quaternion
  70858. */
  70859. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70860. /**
  70861. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70862. * @param q1 defines the second operand
  70863. * @returns the currentupdated quaternion
  70864. */
  70865. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70866. /**
  70867. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70868. * @param ref defines the target quaternion
  70869. * @returns the current quaternion
  70870. */
  70871. conjugateToRef(ref: Quaternion): Quaternion;
  70872. /**
  70873. * Conjugates in place (1-q) the current quaternion
  70874. * @returns the current updated quaternion
  70875. */
  70876. conjugateInPlace(): Quaternion;
  70877. /**
  70878. * Conjugates in place (1-q) the current quaternion
  70879. * @returns a new quaternion
  70880. */
  70881. conjugate(): Quaternion;
  70882. /**
  70883. * Gets length of current quaternion
  70884. * @returns the quaternion length (float)
  70885. */
  70886. length(): number;
  70887. /**
  70888. * Normalize in place the current quaternion
  70889. * @returns the current updated quaternion
  70890. */
  70891. normalize(): Quaternion;
  70892. /**
  70893. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70894. * @param order is a reserved parameter and is ignore for now
  70895. * @returns a new Vector3 containing the Euler angles
  70896. */
  70897. toEulerAngles(order?: string): Vector3;
  70898. /**
  70899. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70900. * @param result defines the vector which will be filled with the Euler angles
  70901. * @param order is a reserved parameter and is ignore for now
  70902. * @returns the current unchanged quaternion
  70903. */
  70904. toEulerAnglesToRef(result: Vector3): Quaternion;
  70905. /**
  70906. * Updates the given rotation matrix with the current quaternion values
  70907. * @param result defines the target matrix
  70908. * @returns the current unchanged quaternion
  70909. */
  70910. toRotationMatrix(result: Matrix): Quaternion;
  70911. /**
  70912. * Updates the current quaternion from the given rotation matrix values
  70913. * @param matrix defines the source matrix
  70914. * @returns the current updated quaternion
  70915. */
  70916. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70917. /**
  70918. * Creates a new quaternion from a rotation matrix
  70919. * @param matrix defines the source matrix
  70920. * @returns a new quaternion created from the given rotation matrix values
  70921. */
  70922. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70923. /**
  70924. * Updates the given quaternion with the given rotation matrix values
  70925. * @param matrix defines the source matrix
  70926. * @param result defines the target quaternion
  70927. */
  70928. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70929. /**
  70930. * Returns the dot product (float) between the quaternions "left" and "right"
  70931. * @param left defines the left operand
  70932. * @param right defines the right operand
  70933. * @returns the dot product
  70934. */
  70935. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70936. /**
  70937. * Checks if the two quaternions are close to each other
  70938. * @param quat0 defines the first quaternion to check
  70939. * @param quat1 defines the second quaternion to check
  70940. * @returns true if the two quaternions are close to each other
  70941. */
  70942. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70943. /**
  70944. * Creates an empty quaternion
  70945. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70946. */
  70947. static Zero(): Quaternion;
  70948. /**
  70949. * Inverse a given quaternion
  70950. * @param q defines the source quaternion
  70951. * @returns a new quaternion as the inverted current quaternion
  70952. */
  70953. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70954. /**
  70955. * Inverse a given quaternion
  70956. * @param q defines the source quaternion
  70957. * @param result the quaternion the result will be stored in
  70958. * @returns the result quaternion
  70959. */
  70960. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70961. /**
  70962. * Creates an identity quaternion
  70963. * @returns the identity quaternion
  70964. */
  70965. static Identity(): Quaternion;
  70966. /**
  70967. * Gets a boolean indicating if the given quaternion is identity
  70968. * @param quaternion defines the quaternion to check
  70969. * @returns true if the quaternion is identity
  70970. */
  70971. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70972. /**
  70973. * Creates a quaternion from a rotation around an axis
  70974. * @param axis defines the axis to use
  70975. * @param angle defines the angle to use
  70976. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70977. */
  70978. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70979. /**
  70980. * Creates a rotation around an axis and stores it into the given quaternion
  70981. * @param axis defines the axis to use
  70982. * @param angle defines the angle to use
  70983. * @param result defines the target quaternion
  70984. * @returns the target quaternion
  70985. */
  70986. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70987. /**
  70988. * Creates a new quaternion from data stored into an array
  70989. * @param array defines the data source
  70990. * @param offset defines the offset in the source array where the data starts
  70991. * @returns a new quaternion
  70992. */
  70993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70994. /**
  70995. * Create a quaternion from Euler rotation angles
  70996. * @param x Pitch
  70997. * @param y Yaw
  70998. * @param z Roll
  70999. * @returns the new Quaternion
  71000. */
  71001. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71002. /**
  71003. * Updates a quaternion from Euler rotation angles
  71004. * @param x Pitch
  71005. * @param y Yaw
  71006. * @param z Roll
  71007. * @param result the quaternion to store the result
  71008. * @returns the updated quaternion
  71009. */
  71010. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71011. /**
  71012. * Create a quaternion from Euler rotation vector
  71013. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71014. * @returns the new Quaternion
  71015. */
  71016. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71017. /**
  71018. * Updates a quaternion from Euler rotation vector
  71019. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71020. * @param result the quaternion to store the result
  71021. * @returns the updated quaternion
  71022. */
  71023. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71024. /**
  71025. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71026. * @param yaw defines the rotation around Y axis
  71027. * @param pitch defines the rotation around X axis
  71028. * @param roll defines the rotation around Z axis
  71029. * @returns the new quaternion
  71030. */
  71031. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71032. /**
  71033. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71034. * @param yaw defines the rotation around Y axis
  71035. * @param pitch defines the rotation around X axis
  71036. * @param roll defines the rotation around Z axis
  71037. * @param result defines the target quaternion
  71038. */
  71039. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71040. /**
  71041. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71042. * @param alpha defines the rotation around first axis
  71043. * @param beta defines the rotation around second axis
  71044. * @param gamma defines the rotation around third axis
  71045. * @returns the new quaternion
  71046. */
  71047. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71048. /**
  71049. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71050. * @param alpha defines the rotation around first axis
  71051. * @param beta defines the rotation around second axis
  71052. * @param gamma defines the rotation around third axis
  71053. * @param result defines the target quaternion
  71054. */
  71055. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71056. /**
  71057. * 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)
  71058. * @param axis1 defines the first axis
  71059. * @param axis2 defines the second axis
  71060. * @param axis3 defines the third axis
  71061. * @returns the new quaternion
  71062. */
  71063. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71064. /**
  71065. * 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
  71066. * @param axis1 defines the first axis
  71067. * @param axis2 defines the second axis
  71068. * @param axis3 defines the third axis
  71069. * @param ref defines the target quaternion
  71070. */
  71071. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71072. /**
  71073. * Interpolates between two quaternions
  71074. * @param left defines first quaternion
  71075. * @param right defines second quaternion
  71076. * @param amount defines the gradient to use
  71077. * @returns the new interpolated quaternion
  71078. */
  71079. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71080. /**
  71081. * Interpolates between two quaternions and stores it into a target quaternion
  71082. * @param left defines first quaternion
  71083. * @param right defines second quaternion
  71084. * @param amount defines the gradient to use
  71085. * @param result defines the target quaternion
  71086. */
  71087. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71088. /**
  71089. * Interpolate between two quaternions using Hermite interpolation
  71090. * @param value1 defines first quaternion
  71091. * @param tangent1 defines the incoming tangent
  71092. * @param value2 defines second quaternion
  71093. * @param tangent2 defines the outgoing tangent
  71094. * @param amount defines the target quaternion
  71095. * @returns the new interpolated quaternion
  71096. */
  71097. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71098. }
  71099. /**
  71100. * Class used to store matrix data (4x4)
  71101. */
  71102. export class Matrix {
  71103. private static _updateFlagSeed;
  71104. private static _identityReadOnly;
  71105. private _isIdentity;
  71106. private _isIdentityDirty;
  71107. private _isIdentity3x2;
  71108. private _isIdentity3x2Dirty;
  71109. /**
  71110. * Gets the update flag of the matrix which is an unique number for the matrix.
  71111. * It will be incremented every time the matrix data change.
  71112. * You can use it to speed the comparison between two versions of the same matrix.
  71113. */
  71114. updateFlag: number;
  71115. private readonly _m;
  71116. /**
  71117. * Gets the internal data of the matrix
  71118. */
  71119. readonly m: DeepImmutable<Float32Array>;
  71120. /** @hidden */
  71121. _markAsUpdated(): void;
  71122. /** @hidden */
  71123. private _updateIdentityStatus;
  71124. /**
  71125. * Creates an empty matrix (filled with zeros)
  71126. */
  71127. constructor();
  71128. /**
  71129. * Check if the current matrix is identity
  71130. * @returns true is the matrix is the identity matrix
  71131. */
  71132. isIdentity(): boolean;
  71133. /**
  71134. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71135. * @returns true is the matrix is the identity matrix
  71136. */
  71137. isIdentityAs3x2(): boolean;
  71138. /**
  71139. * Gets the determinant of the matrix
  71140. * @returns the matrix determinant
  71141. */
  71142. determinant(): number;
  71143. /**
  71144. * Returns the matrix as a Float32Array
  71145. * @returns the matrix underlying array
  71146. */
  71147. toArray(): DeepImmutable<Float32Array>;
  71148. /**
  71149. * Returns the matrix as a Float32Array
  71150. * @returns the matrix underlying array.
  71151. */
  71152. asArray(): DeepImmutable<Float32Array>;
  71153. /**
  71154. * Inverts the current matrix in place
  71155. * @returns the current inverted matrix
  71156. */
  71157. invert(): Matrix;
  71158. /**
  71159. * Sets all the matrix elements to zero
  71160. * @returns the current matrix
  71161. */
  71162. reset(): Matrix;
  71163. /**
  71164. * Adds the current matrix with a second one
  71165. * @param other defines the matrix to add
  71166. * @returns a new matrix as the addition of the current matrix and the given one
  71167. */
  71168. add(other: DeepImmutable<Matrix>): Matrix;
  71169. /**
  71170. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71171. * @param other defines the matrix to add
  71172. * @param result defines the target matrix
  71173. * @returns the current matrix
  71174. */
  71175. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71176. /**
  71177. * Adds in place the given matrix to the current matrix
  71178. * @param other defines the second operand
  71179. * @returns the current updated matrix
  71180. */
  71181. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71182. /**
  71183. * Sets the given matrix to the current inverted Matrix
  71184. * @param other defines the target matrix
  71185. * @returns the unmodified current matrix
  71186. */
  71187. invertToRef(other: Matrix): Matrix;
  71188. /**
  71189. * add a value at the specified position in the current Matrix
  71190. * @param index the index of the value within the matrix. between 0 and 15.
  71191. * @param value the value to be added
  71192. * @returns the current updated matrix
  71193. */
  71194. addAtIndex(index: number, value: number): Matrix;
  71195. /**
  71196. * mutiply the specified position in the current Matrix by a value
  71197. * @param index the index of the value within the matrix. between 0 and 15.
  71198. * @param value the value to be added
  71199. * @returns the current updated matrix
  71200. */
  71201. multiplyAtIndex(index: number, value: number): Matrix;
  71202. /**
  71203. * Inserts the translation vector (using 3 floats) in the current matrix
  71204. * @param x defines the 1st component of the translation
  71205. * @param y defines the 2nd component of the translation
  71206. * @param z defines the 3rd component of the translation
  71207. * @returns the current updated matrix
  71208. */
  71209. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71210. /**
  71211. * Adds the translation vector (using 3 floats) in the current matrix
  71212. * @param x defines the 1st component of the translation
  71213. * @param y defines the 2nd component of the translation
  71214. * @param z defines the 3rd component of the translation
  71215. * @returns the current updated matrix
  71216. */
  71217. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71218. /**
  71219. * Inserts the translation vector in the current matrix
  71220. * @param vector3 defines the translation to insert
  71221. * @returns the current updated matrix
  71222. */
  71223. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71224. /**
  71225. * Gets the translation value of the current matrix
  71226. * @returns a new Vector3 as the extracted translation from the matrix
  71227. */
  71228. getTranslation(): Vector3;
  71229. /**
  71230. * Fill a Vector3 with the extracted translation from the matrix
  71231. * @param result defines the Vector3 where to store the translation
  71232. * @returns the current matrix
  71233. */
  71234. getTranslationToRef(result: Vector3): Matrix;
  71235. /**
  71236. * Remove rotation and scaling part from the matrix
  71237. * @returns the updated matrix
  71238. */
  71239. removeRotationAndScaling(): Matrix;
  71240. /**
  71241. * Multiply two matrices
  71242. * @param other defines the second operand
  71243. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71244. */
  71245. multiply(other: DeepImmutable<Matrix>): Matrix;
  71246. /**
  71247. * Copy the current matrix from the given one
  71248. * @param other defines the source matrix
  71249. * @returns the current updated matrix
  71250. */
  71251. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71252. /**
  71253. * Populates the given array from the starting index with the current matrix values
  71254. * @param array defines the target array
  71255. * @param offset defines the offset in the target array where to start storing values
  71256. * @returns the current matrix
  71257. */
  71258. copyToArray(array: Float32Array, offset?: number): Matrix;
  71259. /**
  71260. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71261. * @param other defines the second operand
  71262. * @param result defines the matrix where to store the multiplication
  71263. * @returns the current matrix
  71264. */
  71265. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71266. /**
  71267. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71268. * @param other defines the second operand
  71269. * @param result defines the array where to store the multiplication
  71270. * @param offset defines the offset in the target array where to start storing values
  71271. * @returns the current matrix
  71272. */
  71273. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71274. /**
  71275. * Check equality between this matrix and a second one
  71276. * @param value defines the second matrix to compare
  71277. * @returns true is the current matrix and the given one values are strictly equal
  71278. */
  71279. equals(value: DeepImmutable<Matrix>): boolean;
  71280. /**
  71281. * Clone the current matrix
  71282. * @returns a new matrix from the current matrix
  71283. */
  71284. clone(): Matrix;
  71285. /**
  71286. * Returns the name of the current matrix class
  71287. * @returns the string "Matrix"
  71288. */
  71289. getClassName(): string;
  71290. /**
  71291. * Gets the hash code of the current matrix
  71292. * @returns the hash code
  71293. */
  71294. getHashCode(): number;
  71295. /**
  71296. * Decomposes the current Matrix into a translation, rotation and scaling components
  71297. * @param scale defines the scale vector3 given as a reference to update
  71298. * @param rotation defines the rotation quaternion given as a reference to update
  71299. * @param translation defines the translation vector3 given as a reference to update
  71300. * @returns true if operation was successful
  71301. */
  71302. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71303. /**
  71304. * Gets specific row of the matrix
  71305. * @param index defines the number of the row to get
  71306. * @returns the index-th row of the current matrix as a new Vector4
  71307. */
  71308. getRow(index: number): Nullable<Vector4>;
  71309. /**
  71310. * Sets the index-th row of the current matrix to the vector4 values
  71311. * @param index defines the number of the row to set
  71312. * @param row defines the target vector4
  71313. * @returns the updated current matrix
  71314. */
  71315. setRow(index: number, row: Vector4): Matrix;
  71316. /**
  71317. * Compute the transpose of the matrix
  71318. * @returns the new transposed matrix
  71319. */
  71320. transpose(): Matrix;
  71321. /**
  71322. * Compute the transpose of the matrix and store it in a given matrix
  71323. * @param result defines the target matrix
  71324. * @returns the current matrix
  71325. */
  71326. transposeToRef(result: Matrix): Matrix;
  71327. /**
  71328. * Sets the index-th row of the current matrix with the given 4 x float values
  71329. * @param index defines the row index
  71330. * @param x defines the x component to set
  71331. * @param y defines the y component to set
  71332. * @param z defines the z component to set
  71333. * @param w defines the w component to set
  71334. * @returns the updated current matrix
  71335. */
  71336. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71337. /**
  71338. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71339. * @param scale defines the scale factor
  71340. * @returns a new matrix
  71341. */
  71342. scale(scale: number): Matrix;
  71343. /**
  71344. * Scale the current matrix values by a factor to a given result matrix
  71345. * @param scale defines the scale factor
  71346. * @param result defines the matrix to store the result
  71347. * @returns the current matrix
  71348. */
  71349. scaleToRef(scale: number, result: Matrix): Matrix;
  71350. /**
  71351. * Scale the current matrix values by a factor and add the result to a given matrix
  71352. * @param scale defines the scale factor
  71353. * @param result defines the Matrix to store the result
  71354. * @returns the current matrix
  71355. */
  71356. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71357. /**
  71358. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71359. * @param ref matrix to store the result
  71360. */
  71361. toNormalMatrix(ref: Matrix): void;
  71362. /**
  71363. * Gets only rotation part of the current matrix
  71364. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71365. */
  71366. getRotationMatrix(): Matrix;
  71367. /**
  71368. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71369. * @param result defines the target matrix to store data to
  71370. * @returns the current matrix
  71371. */
  71372. getRotationMatrixToRef(result: Matrix): Matrix;
  71373. /**
  71374. * Toggles model matrix from being right handed to left handed in place and vice versa
  71375. */
  71376. toggleModelMatrixHandInPlace(): void;
  71377. /**
  71378. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71379. */
  71380. toggleProjectionMatrixHandInPlace(): void;
  71381. /**
  71382. * Creates a matrix from an array
  71383. * @param array defines the source array
  71384. * @param offset defines an offset in the source array
  71385. * @returns a new Matrix set from the starting index of the given array
  71386. */
  71387. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71388. /**
  71389. * Copy the content of an array into a given matrix
  71390. * @param array defines the source array
  71391. * @param offset defines an offset in the source array
  71392. * @param result defines the target matrix
  71393. */
  71394. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71395. /**
  71396. * Stores an array into a matrix after having multiplied each component by a given factor
  71397. * @param array defines the source array
  71398. * @param offset defines the offset in the source array
  71399. * @param scale defines the scaling factor
  71400. * @param result defines the target matrix
  71401. */
  71402. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71403. /**
  71404. * Gets an identity matrix that must not be updated
  71405. */
  71406. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71407. /**
  71408. * Stores a list of values (16) inside a given matrix
  71409. * @param initialM11 defines 1st value of 1st row
  71410. * @param initialM12 defines 2nd value of 1st row
  71411. * @param initialM13 defines 3rd value of 1st row
  71412. * @param initialM14 defines 4th value of 1st row
  71413. * @param initialM21 defines 1st value of 2nd row
  71414. * @param initialM22 defines 2nd value of 2nd row
  71415. * @param initialM23 defines 3rd value of 2nd row
  71416. * @param initialM24 defines 4th value of 2nd row
  71417. * @param initialM31 defines 1st value of 3rd row
  71418. * @param initialM32 defines 2nd value of 3rd row
  71419. * @param initialM33 defines 3rd value of 3rd row
  71420. * @param initialM34 defines 4th value of 3rd row
  71421. * @param initialM41 defines 1st value of 4th row
  71422. * @param initialM42 defines 2nd value of 4th row
  71423. * @param initialM43 defines 3rd value of 4th row
  71424. * @param initialM44 defines 4th value of 4th row
  71425. * @param result defines the target matrix
  71426. */
  71427. 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;
  71428. /**
  71429. * Creates new matrix from a list of values (16)
  71430. * @param initialM11 defines 1st value of 1st row
  71431. * @param initialM12 defines 2nd value of 1st row
  71432. * @param initialM13 defines 3rd value of 1st row
  71433. * @param initialM14 defines 4th value of 1st row
  71434. * @param initialM21 defines 1st value of 2nd row
  71435. * @param initialM22 defines 2nd value of 2nd row
  71436. * @param initialM23 defines 3rd value of 2nd row
  71437. * @param initialM24 defines 4th value of 2nd row
  71438. * @param initialM31 defines 1st value of 3rd row
  71439. * @param initialM32 defines 2nd value of 3rd row
  71440. * @param initialM33 defines 3rd value of 3rd row
  71441. * @param initialM34 defines 4th value of 3rd row
  71442. * @param initialM41 defines 1st value of 4th row
  71443. * @param initialM42 defines 2nd value of 4th row
  71444. * @param initialM43 defines 3rd value of 4th row
  71445. * @param initialM44 defines 4th value of 4th row
  71446. * @returns the new matrix
  71447. */
  71448. 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;
  71449. /**
  71450. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71451. * @param scale defines the scale vector3
  71452. * @param rotation defines the rotation quaternion
  71453. * @param translation defines the translation vector3
  71454. * @returns a new matrix
  71455. */
  71456. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71457. /**
  71458. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71459. * @param scale defines the scale vector3
  71460. * @param rotation defines the rotation quaternion
  71461. * @param translation defines the translation vector3
  71462. * @param result defines the target matrix
  71463. */
  71464. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71465. /**
  71466. * Creates a new identity matrix
  71467. * @returns a new identity matrix
  71468. */
  71469. static Identity(): Matrix;
  71470. /**
  71471. * Creates a new identity matrix and stores the result in a given matrix
  71472. * @param result defines the target matrix
  71473. */
  71474. static IdentityToRef(result: Matrix): void;
  71475. /**
  71476. * Creates a new zero matrix
  71477. * @returns a new zero matrix
  71478. */
  71479. static Zero(): Matrix;
  71480. /**
  71481. * Creates a new rotation matrix for "angle" radians around the X axis
  71482. * @param angle defines the angle (in radians) to use
  71483. * @return the new matrix
  71484. */
  71485. static RotationX(angle: number): Matrix;
  71486. /**
  71487. * Creates a new matrix as the invert of a given matrix
  71488. * @param source defines the source matrix
  71489. * @returns the new matrix
  71490. */
  71491. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71492. /**
  71493. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71494. * @param angle defines the angle (in radians) to use
  71495. * @param result defines the target matrix
  71496. */
  71497. static RotationXToRef(angle: number, result: Matrix): void;
  71498. /**
  71499. * Creates a new rotation matrix for "angle" radians around the Y axis
  71500. * @param angle defines the angle (in radians) to use
  71501. * @return the new matrix
  71502. */
  71503. static RotationY(angle: number): Matrix;
  71504. /**
  71505. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71506. * @param angle defines the angle (in radians) to use
  71507. * @param result defines the target matrix
  71508. */
  71509. static RotationYToRef(angle: number, result: Matrix): void;
  71510. /**
  71511. * Creates a new rotation matrix for "angle" radians around the Z axis
  71512. * @param angle defines the angle (in radians) to use
  71513. * @return the new matrix
  71514. */
  71515. static RotationZ(angle: number): Matrix;
  71516. /**
  71517. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71518. * @param angle defines the angle (in radians) to use
  71519. * @param result defines the target matrix
  71520. */
  71521. static RotationZToRef(angle: number, result: Matrix): void;
  71522. /**
  71523. * Creates a new rotation matrix for "angle" radians around the given axis
  71524. * @param axis defines the axis to use
  71525. * @param angle defines the angle (in radians) to use
  71526. * @return the new matrix
  71527. */
  71528. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71529. /**
  71530. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71531. * @param axis defines the axis to use
  71532. * @param angle defines the angle (in radians) to use
  71533. * @param result defines the target matrix
  71534. */
  71535. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71536. /**
  71537. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71538. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71539. * @param from defines the vector to align
  71540. * @param to defines the vector to align to
  71541. * @param result defines the target matrix
  71542. */
  71543. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71544. /**
  71545. * Creates a rotation matrix
  71546. * @param yaw defines the yaw angle in radians (Y axis)
  71547. * @param pitch defines the pitch angle in radians (X axis)
  71548. * @param roll defines the roll angle in radians (X axis)
  71549. * @returns the new rotation matrix
  71550. */
  71551. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71552. /**
  71553. * Creates a rotation matrix and stores it in a given matrix
  71554. * @param yaw defines the yaw angle in radians (Y axis)
  71555. * @param pitch defines the pitch angle in radians (X axis)
  71556. * @param roll defines the roll angle in radians (X axis)
  71557. * @param result defines the target matrix
  71558. */
  71559. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71560. /**
  71561. * Creates a scaling matrix
  71562. * @param x defines the scale factor on X axis
  71563. * @param y defines the scale factor on Y axis
  71564. * @param z defines the scale factor on Z axis
  71565. * @returns the new matrix
  71566. */
  71567. static Scaling(x: number, y: number, z: number): Matrix;
  71568. /**
  71569. * Creates a scaling matrix and stores it in a given matrix
  71570. * @param x defines the scale factor on X axis
  71571. * @param y defines the scale factor on Y axis
  71572. * @param z defines the scale factor on Z axis
  71573. * @param result defines the target matrix
  71574. */
  71575. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71576. /**
  71577. * Creates a translation matrix
  71578. * @param x defines the translation on X axis
  71579. * @param y defines the translation on Y axis
  71580. * @param z defines the translationon Z axis
  71581. * @returns the new matrix
  71582. */
  71583. static Translation(x: number, y: number, z: number): Matrix;
  71584. /**
  71585. * Creates a translation matrix and stores it in a given matrix
  71586. * @param x defines the translation on X axis
  71587. * @param y defines the translation on Y axis
  71588. * @param z defines the translationon Z axis
  71589. * @param result defines the target matrix
  71590. */
  71591. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71592. /**
  71593. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71594. * @param startValue defines the start value
  71595. * @param endValue defines the end value
  71596. * @param gradient defines the gradient factor
  71597. * @returns the new matrix
  71598. */
  71599. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71600. /**
  71601. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71602. * @param startValue defines the start value
  71603. * @param endValue defines the end value
  71604. * @param gradient defines the gradient factor
  71605. * @param result defines the Matrix object where to store data
  71606. */
  71607. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71608. /**
  71609. * Builds a new matrix whose values are computed by:
  71610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71613. * @param startValue defines the first matrix
  71614. * @param endValue defines the second matrix
  71615. * @param gradient defines the gradient between the two matrices
  71616. * @returns the new matrix
  71617. */
  71618. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71619. /**
  71620. * Update a matrix to values which are computed by:
  71621. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71622. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71623. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71624. * @param startValue defines the first matrix
  71625. * @param endValue defines the second matrix
  71626. * @param gradient defines the gradient between the two matrices
  71627. * @param result defines the target matrix
  71628. */
  71629. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71630. /**
  71631. * 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"
  71632. * This function works in left handed mode
  71633. * @param eye defines the final position of the entity
  71634. * @param target defines where the entity should look at
  71635. * @param up defines the up vector for the entity
  71636. * @returns the new matrix
  71637. */
  71638. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71639. /**
  71640. * 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".
  71641. * This function works in left handed mode
  71642. * @param eye defines the final position of the entity
  71643. * @param target defines where the entity should look at
  71644. * @param up defines the up vector for the entity
  71645. * @param result defines the target matrix
  71646. */
  71647. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71648. /**
  71649. * 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"
  71650. * This function works in right handed mode
  71651. * @param eye defines the final position of the entity
  71652. * @param target defines where the entity should look at
  71653. * @param up defines the up vector for the entity
  71654. * @returns the new matrix
  71655. */
  71656. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71657. /**
  71658. * 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".
  71659. * This function works in right handed mode
  71660. * @param eye defines the final position of the entity
  71661. * @param target defines where the entity should look at
  71662. * @param up defines the up vector for the entity
  71663. * @param result defines the target matrix
  71664. */
  71665. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71666. /**
  71667. * Create a left-handed orthographic projection matrix
  71668. * @param width defines the viewport width
  71669. * @param height defines the viewport height
  71670. * @param znear defines the near clip plane
  71671. * @param zfar defines the far clip plane
  71672. * @returns a new matrix as a left-handed orthographic projection matrix
  71673. */
  71674. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71675. /**
  71676. * Store a left-handed orthographic projection to a given matrix
  71677. * @param width defines the viewport width
  71678. * @param height defines the viewport height
  71679. * @param znear defines the near clip plane
  71680. * @param zfar defines the far clip plane
  71681. * @param result defines the target matrix
  71682. */
  71683. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71684. /**
  71685. * Create a left-handed orthographic projection matrix
  71686. * @param left defines the viewport left coordinate
  71687. * @param right defines the viewport right coordinate
  71688. * @param bottom defines the viewport bottom coordinate
  71689. * @param top defines the viewport top coordinate
  71690. * @param znear defines the near clip plane
  71691. * @param zfar defines the far clip plane
  71692. * @returns a new matrix as a left-handed orthographic projection matrix
  71693. */
  71694. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71695. /**
  71696. * Stores a left-handed orthographic projection into a given matrix
  71697. * @param left defines the viewport left coordinate
  71698. * @param right defines the viewport right coordinate
  71699. * @param bottom defines the viewport bottom coordinate
  71700. * @param top defines the viewport top coordinate
  71701. * @param znear defines the near clip plane
  71702. * @param zfar defines the far clip plane
  71703. * @param result defines the target matrix
  71704. */
  71705. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71706. /**
  71707. * Creates a right-handed orthographic projection matrix
  71708. * @param left defines the viewport left coordinate
  71709. * @param right defines the viewport right coordinate
  71710. * @param bottom defines the viewport bottom coordinate
  71711. * @param top defines the viewport top coordinate
  71712. * @param znear defines the near clip plane
  71713. * @param zfar defines the far clip plane
  71714. * @returns a new matrix as a right-handed orthographic projection matrix
  71715. */
  71716. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71717. /**
  71718. * Stores a right-handed orthographic projection into a given matrix
  71719. * @param left defines the viewport left coordinate
  71720. * @param right defines the viewport right coordinate
  71721. * @param bottom defines the viewport bottom coordinate
  71722. * @param top defines the viewport top coordinate
  71723. * @param znear defines the near clip plane
  71724. * @param zfar defines the far clip plane
  71725. * @param result defines the target matrix
  71726. */
  71727. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71728. /**
  71729. * Creates a left-handed perspective projection matrix
  71730. * @param width defines the viewport width
  71731. * @param height defines the viewport height
  71732. * @param znear defines the near clip plane
  71733. * @param zfar defines the far clip plane
  71734. * @returns a new matrix as a left-handed perspective projection matrix
  71735. */
  71736. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71737. /**
  71738. * Creates a left-handed perspective projection matrix
  71739. * @param fov defines the horizontal field of view
  71740. * @param aspect defines the aspect ratio
  71741. * @param znear defines the near clip plane
  71742. * @param zfar defines the far clip plane
  71743. * @returns a new matrix as a left-handed perspective projection matrix
  71744. */
  71745. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71746. /**
  71747. * Stores a left-handed perspective projection into a given matrix
  71748. * @param fov defines the horizontal field of view
  71749. * @param aspect defines the aspect ratio
  71750. * @param znear defines the near clip plane
  71751. * @param zfar defines the far clip plane
  71752. * @param result defines the target matrix
  71753. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71754. */
  71755. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71756. /**
  71757. * Creates a right-handed perspective projection matrix
  71758. * @param fov defines the horizontal field of view
  71759. * @param aspect defines the aspect ratio
  71760. * @param znear defines the near clip plane
  71761. * @param zfar defines the far clip plane
  71762. * @returns a new matrix as a right-handed perspective projection matrix
  71763. */
  71764. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71765. /**
  71766. * Stores a right-handed perspective projection into a given matrix
  71767. * @param fov defines the horizontal field of view
  71768. * @param aspect defines the aspect ratio
  71769. * @param znear defines the near clip plane
  71770. * @param zfar defines the far clip plane
  71771. * @param result defines the target matrix
  71772. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71773. */
  71774. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71775. /**
  71776. * Stores a perspective projection for WebVR info a given matrix
  71777. * @param fov defines the field of view
  71778. * @param znear defines the near clip plane
  71779. * @param zfar defines the far clip plane
  71780. * @param result defines the target matrix
  71781. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71782. */
  71783. static PerspectiveFovWebVRToRef(fov: {
  71784. upDegrees: number;
  71785. downDegrees: number;
  71786. leftDegrees: number;
  71787. rightDegrees: number;
  71788. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71789. /**
  71790. * Computes a complete transformation matrix
  71791. * @param viewport defines the viewport to use
  71792. * @param world defines the world matrix
  71793. * @param view defines the view matrix
  71794. * @param projection defines the projection matrix
  71795. * @param zmin defines the near clip plane
  71796. * @param zmax defines the far clip plane
  71797. * @returns the transformation matrix
  71798. */
  71799. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71800. /**
  71801. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71802. * @param matrix defines the matrix to use
  71803. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71804. */
  71805. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71806. /**
  71807. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71808. * @param matrix defines the matrix to use
  71809. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71810. */
  71811. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71812. /**
  71813. * Compute the transpose of a given matrix
  71814. * @param matrix defines the matrix to transpose
  71815. * @returns the new matrix
  71816. */
  71817. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71818. /**
  71819. * Compute the transpose of a matrix and store it in a target matrix
  71820. * @param matrix defines the matrix to transpose
  71821. * @param result defines the target matrix
  71822. */
  71823. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71824. /**
  71825. * Computes a reflection matrix from a plane
  71826. * @param plane defines the reflection plane
  71827. * @returns a new matrix
  71828. */
  71829. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71830. /**
  71831. * Computes a reflection matrix from a plane
  71832. * @param plane defines the reflection plane
  71833. * @param result defines the target matrix
  71834. */
  71835. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71836. /**
  71837. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71838. * @param xaxis defines the value of the 1st axis
  71839. * @param yaxis defines the value of the 2nd axis
  71840. * @param zaxis defines the value of the 3rd axis
  71841. * @param result defines the target matrix
  71842. */
  71843. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71844. /**
  71845. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71846. * @param quat defines the quaternion to use
  71847. * @param result defines the target matrix
  71848. */
  71849. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71850. }
  71851. /**
  71852. * @hidden
  71853. */
  71854. export class TmpVectors {
  71855. static Vector2: Vector2[];
  71856. static Vector3: Vector3[];
  71857. static Vector4: Vector4[];
  71858. static Quaternion: Quaternion[];
  71859. static Matrix: Matrix[];
  71860. }
  71861. }
  71862. declare module BABYLON {
  71863. /**
  71864. * Defines potential orientation for back face culling
  71865. */
  71866. export enum Orientation {
  71867. /**
  71868. * Clockwise
  71869. */
  71870. CW = 0,
  71871. /** Counter clockwise */
  71872. CCW = 1
  71873. }
  71874. /** Class used to represent a Bezier curve */
  71875. export class BezierCurve {
  71876. /**
  71877. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71878. * @param t defines the time
  71879. * @param x1 defines the left coordinate on X axis
  71880. * @param y1 defines the left coordinate on Y axis
  71881. * @param x2 defines the right coordinate on X axis
  71882. * @param y2 defines the right coordinate on Y axis
  71883. * @returns the interpolated value
  71884. */
  71885. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71886. }
  71887. /**
  71888. * Defines angle representation
  71889. */
  71890. export class Angle {
  71891. private _radians;
  71892. /**
  71893. * Creates an Angle object of "radians" radians (float).
  71894. * @param radians the angle in radians
  71895. */
  71896. constructor(radians: number);
  71897. /**
  71898. * Get value in degrees
  71899. * @returns the Angle value in degrees (float)
  71900. */
  71901. degrees(): number;
  71902. /**
  71903. * Get value in radians
  71904. * @returns the Angle value in radians (float)
  71905. */
  71906. radians(): number;
  71907. /**
  71908. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71909. * @param a defines first vector
  71910. * @param b defines second vector
  71911. * @returns a new Angle
  71912. */
  71913. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71914. /**
  71915. * Gets a new Angle object from the given float in radians
  71916. * @param radians defines the angle value in radians
  71917. * @returns a new Angle
  71918. */
  71919. static FromRadians(radians: number): Angle;
  71920. /**
  71921. * Gets a new Angle object from the given float in degrees
  71922. * @param degrees defines the angle value in degrees
  71923. * @returns a new Angle
  71924. */
  71925. static FromDegrees(degrees: number): Angle;
  71926. }
  71927. /**
  71928. * This represents an arc in a 2d space.
  71929. */
  71930. export class Arc2 {
  71931. /** Defines the start point of the arc */
  71932. startPoint: Vector2;
  71933. /** Defines the mid point of the arc */
  71934. midPoint: Vector2;
  71935. /** Defines the end point of the arc */
  71936. endPoint: Vector2;
  71937. /**
  71938. * Defines the center point of the arc.
  71939. */
  71940. centerPoint: Vector2;
  71941. /**
  71942. * Defines the radius of the arc.
  71943. */
  71944. radius: number;
  71945. /**
  71946. * Defines the angle of the arc (from mid point to end point).
  71947. */
  71948. angle: Angle;
  71949. /**
  71950. * Defines the start angle of the arc (from start point to middle point).
  71951. */
  71952. startAngle: Angle;
  71953. /**
  71954. * Defines the orientation of the arc (clock wise/counter clock wise).
  71955. */
  71956. orientation: Orientation;
  71957. /**
  71958. * Creates an Arc object from the three given points : start, middle and end.
  71959. * @param startPoint Defines the start point of the arc
  71960. * @param midPoint Defines the midlle point of the arc
  71961. * @param endPoint Defines the end point of the arc
  71962. */
  71963. constructor(
  71964. /** Defines the start point of the arc */
  71965. startPoint: Vector2,
  71966. /** Defines the mid point of the arc */
  71967. midPoint: Vector2,
  71968. /** Defines the end point of the arc */
  71969. endPoint: Vector2);
  71970. }
  71971. /**
  71972. * Represents a 2D path made up of multiple 2D points
  71973. */
  71974. export class Path2 {
  71975. private _points;
  71976. private _length;
  71977. /**
  71978. * If the path start and end point are the same
  71979. */
  71980. closed: boolean;
  71981. /**
  71982. * Creates a Path2 object from the starting 2D coordinates x and y.
  71983. * @param x the starting points x value
  71984. * @param y the starting points y value
  71985. */
  71986. constructor(x: number, y: number);
  71987. /**
  71988. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71989. * @param x the added points x value
  71990. * @param y the added points y value
  71991. * @returns the updated Path2.
  71992. */
  71993. addLineTo(x: number, y: number): Path2;
  71994. /**
  71995. * 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.
  71996. * @param midX middle point x value
  71997. * @param midY middle point y value
  71998. * @param endX end point x value
  71999. * @param endY end point y value
  72000. * @param numberOfSegments (default: 36)
  72001. * @returns the updated Path2.
  72002. */
  72003. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72004. /**
  72005. * Closes the Path2.
  72006. * @returns the Path2.
  72007. */
  72008. close(): Path2;
  72009. /**
  72010. * Gets the sum of the distance between each sequential point in the path
  72011. * @returns the Path2 total length (float).
  72012. */
  72013. length(): number;
  72014. /**
  72015. * Gets the points which construct the path
  72016. * @returns the Path2 internal array of points.
  72017. */
  72018. getPoints(): Vector2[];
  72019. /**
  72020. * Retreives the point at the distance aways from the starting point
  72021. * @param normalizedLengthPosition the length along the path to retreive the point from
  72022. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72023. */
  72024. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72025. /**
  72026. * Creates a new path starting from an x and y position
  72027. * @param x starting x value
  72028. * @param y starting y value
  72029. * @returns a new Path2 starting at the coordinates (x, y).
  72030. */
  72031. static StartingAt(x: number, y: number): Path2;
  72032. }
  72033. /**
  72034. * Represents a 3D path made up of multiple 3D points
  72035. */
  72036. export class Path3D {
  72037. /**
  72038. * an array of Vector3, the curve axis of the Path3D
  72039. */
  72040. path: Vector3[];
  72041. private _curve;
  72042. private _distances;
  72043. private _tangents;
  72044. private _normals;
  72045. private _binormals;
  72046. private _raw;
  72047. /**
  72048. * new Path3D(path, normal, raw)
  72049. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72050. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72051. * @param path an array of Vector3, the curve axis of the Path3D
  72052. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72053. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72054. */
  72055. constructor(
  72056. /**
  72057. * an array of Vector3, the curve axis of the Path3D
  72058. */
  72059. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72060. /**
  72061. * Returns the Path3D array of successive Vector3 designing its curve.
  72062. * @returns the Path3D array of successive Vector3 designing its curve.
  72063. */
  72064. getCurve(): Vector3[];
  72065. /**
  72066. * Returns an array populated with tangent vectors on each Path3D curve point.
  72067. * @returns an array populated with tangent vectors on each Path3D curve point.
  72068. */
  72069. getTangents(): Vector3[];
  72070. /**
  72071. * Returns an array populated with normal vectors on each Path3D curve point.
  72072. * @returns an array populated with normal vectors on each Path3D curve point.
  72073. */
  72074. getNormals(): Vector3[];
  72075. /**
  72076. * Returns an array populated with binormal vectors on each Path3D curve point.
  72077. * @returns an array populated with binormal vectors on each Path3D curve point.
  72078. */
  72079. getBinormals(): Vector3[];
  72080. /**
  72081. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72082. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72083. */
  72084. getDistances(): number[];
  72085. /**
  72086. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72087. * @param path path which all values are copied into the curves points
  72088. * @param firstNormal which should be projected onto the curve
  72089. * @returns the same object updated.
  72090. */
  72091. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72092. private _compute;
  72093. private _getFirstNonNullVector;
  72094. private _getLastNonNullVector;
  72095. private _normalVector;
  72096. }
  72097. /**
  72098. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72099. * A Curve3 is designed from a series of successive Vector3.
  72100. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72101. */
  72102. export class Curve3 {
  72103. private _points;
  72104. private _length;
  72105. /**
  72106. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72107. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72108. * @param v1 (Vector3) the control point
  72109. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72110. * @param nbPoints (integer) the wanted number of points in the curve
  72111. * @returns the created Curve3
  72112. */
  72113. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72114. /**
  72115. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72116. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72117. * @param v1 (Vector3) the first control point
  72118. * @param v2 (Vector3) the second control point
  72119. * @param v3 (Vector3) the end point of the Cubic Bezier
  72120. * @param nbPoints (integer) the wanted number of points in the curve
  72121. * @returns the created Curve3
  72122. */
  72123. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72124. /**
  72125. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72126. * @param p1 (Vector3) the origin point of the Hermite Spline
  72127. * @param t1 (Vector3) the tangent vector at the origin point
  72128. * @param p2 (Vector3) the end point of the Hermite Spline
  72129. * @param t2 (Vector3) the tangent vector at the end point
  72130. * @param nbPoints (integer) the wanted number of points in the curve
  72131. * @returns the created Curve3
  72132. */
  72133. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72134. /**
  72135. * Returns a Curve3 object along a CatmullRom Spline curve :
  72136. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72137. * @param nbPoints (integer) the wanted number of points between each curve control points
  72138. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72139. * @returns the created Curve3
  72140. */
  72141. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72142. /**
  72143. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72144. * A Curve3 is designed from a series of successive Vector3.
  72145. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72146. * @param points points which make up the curve
  72147. */
  72148. constructor(points: Vector3[]);
  72149. /**
  72150. * @returns the Curve3 stored array of successive Vector3
  72151. */
  72152. getPoints(): Vector3[];
  72153. /**
  72154. * @returns the computed length (float) of the curve.
  72155. */
  72156. length(): number;
  72157. /**
  72158. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72159. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72160. * curveA and curveB keep unchanged.
  72161. * @param curve the curve to continue from this curve
  72162. * @returns the newly constructed curve
  72163. */
  72164. continue(curve: DeepImmutable<Curve3>): Curve3;
  72165. private _computeLength;
  72166. }
  72167. }
  72168. declare module BABYLON {
  72169. /**
  72170. * This represents the main contract an easing function should follow.
  72171. * Easing functions are used throughout the animation system.
  72172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72173. */
  72174. export interface IEasingFunction {
  72175. /**
  72176. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72177. * of the easing function.
  72178. * The link below provides some of the most common examples of easing functions.
  72179. * @see https://easings.net/
  72180. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72181. * @returns the corresponding value on the curve defined by the easing function
  72182. */
  72183. ease(gradient: number): number;
  72184. }
  72185. /**
  72186. * Base class used for every default easing function.
  72187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72188. */
  72189. export class EasingFunction implements IEasingFunction {
  72190. /**
  72191. * Interpolation follows the mathematical formula associated with the easing function.
  72192. */
  72193. static readonly EASINGMODE_EASEIN: number;
  72194. /**
  72195. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72196. */
  72197. static readonly EASINGMODE_EASEOUT: number;
  72198. /**
  72199. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72200. */
  72201. static readonly EASINGMODE_EASEINOUT: number;
  72202. private _easingMode;
  72203. /**
  72204. * Sets the easing mode of the current function.
  72205. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72206. */
  72207. setEasingMode(easingMode: number): void;
  72208. /**
  72209. * Gets the current easing mode.
  72210. * @returns the easing mode
  72211. */
  72212. getEasingMode(): number;
  72213. /**
  72214. * @hidden
  72215. */
  72216. easeInCore(gradient: number): number;
  72217. /**
  72218. * Given an input gradient between 0 and 1, this returns the corresponding value
  72219. * of the easing function.
  72220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72221. * @returns the corresponding value on the curve defined by the easing function
  72222. */
  72223. ease(gradient: number): number;
  72224. }
  72225. /**
  72226. * Easing function with a circle shape (see link below).
  72227. * @see https://easings.net/#easeInCirc
  72228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72229. */
  72230. export class CircleEase extends EasingFunction implements IEasingFunction {
  72231. /** @hidden */
  72232. easeInCore(gradient: number): number;
  72233. }
  72234. /**
  72235. * Easing function with a ease back shape (see link below).
  72236. * @see https://easings.net/#easeInBack
  72237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72238. */
  72239. export class BackEase extends EasingFunction implements IEasingFunction {
  72240. /** Defines the amplitude of the function */
  72241. amplitude: number;
  72242. /**
  72243. * Instantiates a back ease easing
  72244. * @see https://easings.net/#easeInBack
  72245. * @param amplitude Defines the amplitude of the function
  72246. */
  72247. constructor(
  72248. /** Defines the amplitude of the function */
  72249. amplitude?: number);
  72250. /** @hidden */
  72251. easeInCore(gradient: number): number;
  72252. }
  72253. /**
  72254. * Easing function with a bouncing shape (see link below).
  72255. * @see https://easings.net/#easeInBounce
  72256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72257. */
  72258. export class BounceEase extends EasingFunction implements IEasingFunction {
  72259. /** Defines the number of bounces */
  72260. bounces: number;
  72261. /** Defines the amplitude of the bounce */
  72262. bounciness: number;
  72263. /**
  72264. * Instantiates a bounce easing
  72265. * @see https://easings.net/#easeInBounce
  72266. * @param bounces Defines the number of bounces
  72267. * @param bounciness Defines the amplitude of the bounce
  72268. */
  72269. constructor(
  72270. /** Defines the number of bounces */
  72271. bounces?: number,
  72272. /** Defines the amplitude of the bounce */
  72273. bounciness?: number);
  72274. /** @hidden */
  72275. easeInCore(gradient: number): number;
  72276. }
  72277. /**
  72278. * Easing function with a power of 3 shape (see link below).
  72279. * @see https://easings.net/#easeInCubic
  72280. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72281. */
  72282. export class CubicEase extends EasingFunction implements IEasingFunction {
  72283. /** @hidden */
  72284. easeInCore(gradient: number): number;
  72285. }
  72286. /**
  72287. * Easing function with an elastic shape (see link below).
  72288. * @see https://easings.net/#easeInElastic
  72289. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72290. */
  72291. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72292. /** Defines the number of oscillations*/
  72293. oscillations: number;
  72294. /** Defines the amplitude of the oscillations*/
  72295. springiness: number;
  72296. /**
  72297. * Instantiates an elastic easing function
  72298. * @see https://easings.net/#easeInElastic
  72299. * @param oscillations Defines the number of oscillations
  72300. * @param springiness Defines the amplitude of the oscillations
  72301. */
  72302. constructor(
  72303. /** Defines the number of oscillations*/
  72304. oscillations?: number,
  72305. /** Defines the amplitude of the oscillations*/
  72306. springiness?: number);
  72307. /** @hidden */
  72308. easeInCore(gradient: number): number;
  72309. }
  72310. /**
  72311. * Easing function with an exponential shape (see link below).
  72312. * @see https://easings.net/#easeInExpo
  72313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72314. */
  72315. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72316. /** Defines the exponent of the function */
  72317. exponent: number;
  72318. /**
  72319. * Instantiates an exponential easing function
  72320. * @see https://easings.net/#easeInExpo
  72321. * @param exponent Defines the exponent of the function
  72322. */
  72323. constructor(
  72324. /** Defines the exponent of the function */
  72325. exponent?: number);
  72326. /** @hidden */
  72327. easeInCore(gradient: number): number;
  72328. }
  72329. /**
  72330. * Easing function with a power shape (see link below).
  72331. * @see https://easings.net/#easeInQuad
  72332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72333. */
  72334. export class PowerEase extends EasingFunction implements IEasingFunction {
  72335. /** Defines the power of the function */
  72336. power: number;
  72337. /**
  72338. * Instantiates an power base easing function
  72339. * @see https://easings.net/#easeInQuad
  72340. * @param power Defines the power of the function
  72341. */
  72342. constructor(
  72343. /** Defines the power of the function */
  72344. power?: number);
  72345. /** @hidden */
  72346. easeInCore(gradient: number): number;
  72347. }
  72348. /**
  72349. * Easing function with a power of 2 shape (see link below).
  72350. * @see https://easings.net/#easeInQuad
  72351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72352. */
  72353. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72354. /** @hidden */
  72355. easeInCore(gradient: number): number;
  72356. }
  72357. /**
  72358. * Easing function with a power of 4 shape (see link below).
  72359. * @see https://easings.net/#easeInQuart
  72360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72361. */
  72362. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72363. /** @hidden */
  72364. easeInCore(gradient: number): number;
  72365. }
  72366. /**
  72367. * Easing function with a power of 5 shape (see link below).
  72368. * @see https://easings.net/#easeInQuint
  72369. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72370. */
  72371. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72372. /** @hidden */
  72373. easeInCore(gradient: number): number;
  72374. }
  72375. /**
  72376. * Easing function with a sin shape (see link below).
  72377. * @see https://easings.net/#easeInSine
  72378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72379. */
  72380. export class SineEase extends EasingFunction implements IEasingFunction {
  72381. /** @hidden */
  72382. easeInCore(gradient: number): number;
  72383. }
  72384. /**
  72385. * Easing function with a bezier shape (see link below).
  72386. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72387. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72388. */
  72389. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72390. /** Defines the x component of the start tangent in the bezier curve */
  72391. x1: number;
  72392. /** Defines the y component of the start tangent in the bezier curve */
  72393. y1: number;
  72394. /** Defines the x component of the end tangent in the bezier curve */
  72395. x2: number;
  72396. /** Defines the y component of the end tangent in the bezier curve */
  72397. y2: number;
  72398. /**
  72399. * Instantiates a bezier function
  72400. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72401. * @param x1 Defines the x component of the start tangent in the bezier curve
  72402. * @param y1 Defines the y component of the start tangent in the bezier curve
  72403. * @param x2 Defines the x component of the end tangent in the bezier curve
  72404. * @param y2 Defines the y component of the end tangent in the bezier curve
  72405. */
  72406. constructor(
  72407. /** Defines the x component of the start tangent in the bezier curve */
  72408. x1?: number,
  72409. /** Defines the y component of the start tangent in the bezier curve */
  72410. y1?: number,
  72411. /** Defines the x component of the end tangent in the bezier curve */
  72412. x2?: number,
  72413. /** Defines the y component of the end tangent in the bezier curve */
  72414. y2?: number);
  72415. /** @hidden */
  72416. easeInCore(gradient: number): number;
  72417. }
  72418. }
  72419. declare module BABYLON {
  72420. /**
  72421. * Class used to hold a RBG color
  72422. */
  72423. export class Color3 {
  72424. /**
  72425. * Defines the red component (between 0 and 1, default is 0)
  72426. */
  72427. r: number;
  72428. /**
  72429. * Defines the green component (between 0 and 1, default is 0)
  72430. */
  72431. g: number;
  72432. /**
  72433. * Defines the blue component (between 0 and 1, default is 0)
  72434. */
  72435. b: number;
  72436. /**
  72437. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72438. * @param r defines the red component (between 0 and 1, default is 0)
  72439. * @param g defines the green component (between 0 and 1, default is 0)
  72440. * @param b defines the blue component (between 0 and 1, default is 0)
  72441. */
  72442. constructor(
  72443. /**
  72444. * Defines the red component (between 0 and 1, default is 0)
  72445. */
  72446. r?: number,
  72447. /**
  72448. * Defines the green component (between 0 and 1, default is 0)
  72449. */
  72450. g?: number,
  72451. /**
  72452. * Defines the blue component (between 0 and 1, default is 0)
  72453. */
  72454. b?: number);
  72455. /**
  72456. * Creates a string with the Color3 current values
  72457. * @returns the string representation of the Color3 object
  72458. */
  72459. toString(): string;
  72460. /**
  72461. * Returns the string "Color3"
  72462. * @returns "Color3"
  72463. */
  72464. getClassName(): string;
  72465. /**
  72466. * Compute the Color3 hash code
  72467. * @returns an unique number that can be used to hash Color3 objects
  72468. */
  72469. getHashCode(): number;
  72470. /**
  72471. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72472. * @param array defines the array where to store the r,g,b components
  72473. * @param index defines an optional index in the target array to define where to start storing values
  72474. * @returns the current Color3 object
  72475. */
  72476. toArray(array: FloatArray, index?: number): Color3;
  72477. /**
  72478. * Returns a new Color4 object from the current Color3 and the given alpha
  72479. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72480. * @returns a new Color4 object
  72481. */
  72482. toColor4(alpha?: number): Color4;
  72483. /**
  72484. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72485. * @returns the new array
  72486. */
  72487. asArray(): number[];
  72488. /**
  72489. * Returns the luminance value
  72490. * @returns a float value
  72491. */
  72492. toLuminance(): number;
  72493. /**
  72494. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72495. * @param otherColor defines the second operand
  72496. * @returns the new Color3 object
  72497. */
  72498. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72499. /**
  72500. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72501. * @param otherColor defines the second operand
  72502. * @param result defines the Color3 object where to store the result
  72503. * @returns the current Color3
  72504. */
  72505. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72506. /**
  72507. * Determines equality between Color3 objects
  72508. * @param otherColor defines the second operand
  72509. * @returns true if the rgb values are equal to the given ones
  72510. */
  72511. equals(otherColor: DeepImmutable<Color3>): boolean;
  72512. /**
  72513. * Determines equality between the current Color3 object and a set of r,b,g values
  72514. * @param r defines the red component to check
  72515. * @param g defines the green component to check
  72516. * @param b defines the blue component to check
  72517. * @returns true if the rgb values are equal to the given ones
  72518. */
  72519. equalsFloats(r: number, g: number, b: number): boolean;
  72520. /**
  72521. * Multiplies in place each rgb value by scale
  72522. * @param scale defines the scaling factor
  72523. * @returns the updated Color3
  72524. */
  72525. scale(scale: number): Color3;
  72526. /**
  72527. * Multiplies the rgb values by scale and stores the result into "result"
  72528. * @param scale defines the scaling factor
  72529. * @param result defines the Color3 object where to store the result
  72530. * @returns the unmodified current Color3
  72531. */
  72532. scaleToRef(scale: number, result: Color3): Color3;
  72533. /**
  72534. * Scale the current Color3 values by a factor and add the result to a given Color3
  72535. * @param scale defines the scale factor
  72536. * @param result defines color to store the result into
  72537. * @returns the unmodified current Color3
  72538. */
  72539. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72540. /**
  72541. * Clamps the rgb values by the min and max values and stores the result into "result"
  72542. * @param min defines minimum clamping value (default is 0)
  72543. * @param max defines maximum clamping value (default is 1)
  72544. * @param result defines color to store the result into
  72545. * @returns the original Color3
  72546. */
  72547. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72548. /**
  72549. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72550. * @param otherColor defines the second operand
  72551. * @returns the new Color3
  72552. */
  72553. add(otherColor: DeepImmutable<Color3>): Color3;
  72554. /**
  72555. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72556. * @param otherColor defines the second operand
  72557. * @param result defines Color3 object to store the result into
  72558. * @returns the unmodified current Color3
  72559. */
  72560. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72561. /**
  72562. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72563. * @param otherColor defines the second operand
  72564. * @returns the new Color3
  72565. */
  72566. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72567. /**
  72568. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72569. * @param otherColor defines the second operand
  72570. * @param result defines Color3 object to store the result into
  72571. * @returns the unmodified current Color3
  72572. */
  72573. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72574. /**
  72575. * Copy the current object
  72576. * @returns a new Color3 copied the current one
  72577. */
  72578. clone(): Color3;
  72579. /**
  72580. * Copies the rgb values from the source in the current Color3
  72581. * @param source defines the source Color3 object
  72582. * @returns the updated Color3 object
  72583. */
  72584. copyFrom(source: DeepImmutable<Color3>): Color3;
  72585. /**
  72586. * Updates the Color3 rgb values from the given floats
  72587. * @param r defines the red component to read from
  72588. * @param g defines the green component to read from
  72589. * @param b defines the blue component to read from
  72590. * @returns the current Color3 object
  72591. */
  72592. copyFromFloats(r: number, g: number, b: number): Color3;
  72593. /**
  72594. * Updates the Color3 rgb values from the given floats
  72595. * @param r defines the red component to read from
  72596. * @param g defines the green component to read from
  72597. * @param b defines the blue component to read from
  72598. * @returns the current Color3 object
  72599. */
  72600. set(r: number, g: number, b: number): Color3;
  72601. /**
  72602. * Compute the Color3 hexadecimal code as a string
  72603. * @returns a string containing the hexadecimal representation of the Color3 object
  72604. */
  72605. toHexString(): string;
  72606. /**
  72607. * Computes a new Color3 converted from the current one to linear space
  72608. * @returns a new Color3 object
  72609. */
  72610. toLinearSpace(): Color3;
  72611. /**
  72612. * Converts current color in rgb space to HSV values
  72613. * @returns a new color3 representing the HSV values
  72614. */
  72615. toHSV(): Color3;
  72616. /**
  72617. * Converts current color in rgb space to HSV values
  72618. * @param result defines the Color3 where to store the HSV values
  72619. */
  72620. toHSVToRef(result: Color3): void;
  72621. /**
  72622. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72623. * @param convertedColor defines the Color3 object where to store the linear space version
  72624. * @returns the unmodified Color3
  72625. */
  72626. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72627. /**
  72628. * Computes a new Color3 converted from the current one to gamma space
  72629. * @returns a new Color3 object
  72630. */
  72631. toGammaSpace(): Color3;
  72632. /**
  72633. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72634. * @param convertedColor defines the Color3 object where to store the gamma space version
  72635. * @returns the unmodified Color3
  72636. */
  72637. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72638. private static _BlackReadOnly;
  72639. /**
  72640. * Convert Hue, saturation and value to a Color3 (RGB)
  72641. * @param hue defines the hue
  72642. * @param saturation defines the saturation
  72643. * @param value defines the value
  72644. * @param result defines the Color3 where to store the RGB values
  72645. */
  72646. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72647. /**
  72648. * Creates a new Color3 from the string containing valid hexadecimal values
  72649. * @param hex defines a string containing valid hexadecimal values
  72650. * @returns a new Color3 object
  72651. */
  72652. static FromHexString(hex: string): Color3;
  72653. /**
  72654. * Creates a new Color3 from the starting index of the given array
  72655. * @param array defines the source array
  72656. * @param offset defines an offset in the source array
  72657. * @returns a new Color3 object
  72658. */
  72659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72660. /**
  72661. * Creates a new Color3 from integer values (< 256)
  72662. * @param r defines the red component to read from (value between 0 and 255)
  72663. * @param g defines the green component to read from (value between 0 and 255)
  72664. * @param b defines the blue component to read from (value between 0 and 255)
  72665. * @returns a new Color3 object
  72666. */
  72667. static FromInts(r: number, g: number, b: number): Color3;
  72668. /**
  72669. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72670. * @param start defines the start Color3 value
  72671. * @param end defines the end Color3 value
  72672. * @param amount defines the gradient value between start and end
  72673. * @returns a new Color3 object
  72674. */
  72675. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72676. /**
  72677. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72678. * @param left defines the start value
  72679. * @param right defines the end value
  72680. * @param amount defines the gradient factor
  72681. * @param result defines the Color3 object where to store the result
  72682. */
  72683. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72684. /**
  72685. * Returns a Color3 value containing a red color
  72686. * @returns a new Color3 object
  72687. */
  72688. static Red(): Color3;
  72689. /**
  72690. * Returns a Color3 value containing a green color
  72691. * @returns a new Color3 object
  72692. */
  72693. static Green(): Color3;
  72694. /**
  72695. * Returns a Color3 value containing a blue color
  72696. * @returns a new Color3 object
  72697. */
  72698. static Blue(): Color3;
  72699. /**
  72700. * Returns a Color3 value containing a black color
  72701. * @returns a new Color3 object
  72702. */
  72703. static Black(): Color3;
  72704. /**
  72705. * Gets a Color3 value containing a black color that must not be updated
  72706. */
  72707. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72708. /**
  72709. * Returns a Color3 value containing a white color
  72710. * @returns a new Color3 object
  72711. */
  72712. static White(): Color3;
  72713. /**
  72714. * Returns a Color3 value containing a purple color
  72715. * @returns a new Color3 object
  72716. */
  72717. static Purple(): Color3;
  72718. /**
  72719. * Returns a Color3 value containing a magenta color
  72720. * @returns a new Color3 object
  72721. */
  72722. static Magenta(): Color3;
  72723. /**
  72724. * Returns a Color3 value containing a yellow color
  72725. * @returns a new Color3 object
  72726. */
  72727. static Yellow(): Color3;
  72728. /**
  72729. * Returns a Color3 value containing a gray color
  72730. * @returns a new Color3 object
  72731. */
  72732. static Gray(): Color3;
  72733. /**
  72734. * Returns a Color3 value containing a teal color
  72735. * @returns a new Color3 object
  72736. */
  72737. static Teal(): Color3;
  72738. /**
  72739. * Returns a Color3 value containing a random color
  72740. * @returns a new Color3 object
  72741. */
  72742. static Random(): Color3;
  72743. }
  72744. /**
  72745. * Class used to hold a RBGA color
  72746. */
  72747. export class Color4 {
  72748. /**
  72749. * Defines the red component (between 0 and 1, default is 0)
  72750. */
  72751. r: number;
  72752. /**
  72753. * Defines the green component (between 0 and 1, default is 0)
  72754. */
  72755. g: number;
  72756. /**
  72757. * Defines the blue component (between 0 and 1, default is 0)
  72758. */
  72759. b: number;
  72760. /**
  72761. * Defines the alpha component (between 0 and 1, default is 1)
  72762. */
  72763. a: number;
  72764. /**
  72765. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72766. * @param r defines the red component (between 0 and 1, default is 0)
  72767. * @param g defines the green component (between 0 and 1, default is 0)
  72768. * @param b defines the blue component (between 0 and 1, default is 0)
  72769. * @param a defines the alpha component (between 0 and 1, default is 1)
  72770. */
  72771. constructor(
  72772. /**
  72773. * Defines the red component (between 0 and 1, default is 0)
  72774. */
  72775. r?: number,
  72776. /**
  72777. * Defines the green component (between 0 and 1, default is 0)
  72778. */
  72779. g?: number,
  72780. /**
  72781. * Defines the blue component (between 0 and 1, default is 0)
  72782. */
  72783. b?: number,
  72784. /**
  72785. * Defines the alpha component (between 0 and 1, default is 1)
  72786. */
  72787. a?: number);
  72788. /**
  72789. * Adds in place the given Color4 values to the current Color4 object
  72790. * @param right defines the second operand
  72791. * @returns the current updated Color4 object
  72792. */
  72793. addInPlace(right: DeepImmutable<Color4>): Color4;
  72794. /**
  72795. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72796. * @returns the new array
  72797. */
  72798. asArray(): number[];
  72799. /**
  72800. * Stores from the starting index in the given array the Color4 successive values
  72801. * @param array defines the array where to store the r,g,b components
  72802. * @param index defines an optional index in the target array to define where to start storing values
  72803. * @returns the current Color4 object
  72804. */
  72805. toArray(array: number[], index?: number): Color4;
  72806. /**
  72807. * Determines equality between Color4 objects
  72808. * @param otherColor defines the second operand
  72809. * @returns true if the rgba values are equal to the given ones
  72810. */
  72811. equals(otherColor: DeepImmutable<Color4>): boolean;
  72812. /**
  72813. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72814. * @param right defines the second operand
  72815. * @returns a new Color4 object
  72816. */
  72817. add(right: DeepImmutable<Color4>): Color4;
  72818. /**
  72819. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72820. * @param right defines the second operand
  72821. * @returns a new Color4 object
  72822. */
  72823. subtract(right: DeepImmutable<Color4>): Color4;
  72824. /**
  72825. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72826. * @param right defines the second operand
  72827. * @param result defines the Color4 object where to store the result
  72828. * @returns the current Color4 object
  72829. */
  72830. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72831. /**
  72832. * Creates a new Color4 with the current Color4 values multiplied by scale
  72833. * @param scale defines the scaling factor to apply
  72834. * @returns a new Color4 object
  72835. */
  72836. scale(scale: number): Color4;
  72837. /**
  72838. * Multiplies the current Color4 values by scale and stores the result in "result"
  72839. * @param scale defines the scaling factor to apply
  72840. * @param result defines the Color4 object where to store the result
  72841. * @returns the current unmodified Color4
  72842. */
  72843. scaleToRef(scale: number, result: Color4): Color4;
  72844. /**
  72845. * Scale the current Color4 values by a factor and add the result to a given Color4
  72846. * @param scale defines the scale factor
  72847. * @param result defines the Color4 object where to store the result
  72848. * @returns the unmodified current Color4
  72849. */
  72850. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72851. /**
  72852. * Clamps the rgb values by the min and max values and stores the result into "result"
  72853. * @param min defines minimum clamping value (default is 0)
  72854. * @param max defines maximum clamping value (default is 1)
  72855. * @param result defines color to store the result into.
  72856. * @returns the cuurent Color4
  72857. */
  72858. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72859. /**
  72860. * Multipy an Color4 value by another and return a new Color4 object
  72861. * @param color defines the Color4 value to multiply by
  72862. * @returns a new Color4 object
  72863. */
  72864. multiply(color: Color4): Color4;
  72865. /**
  72866. * Multipy a Color4 value by another and push the result in a reference value
  72867. * @param color defines the Color4 value to multiply by
  72868. * @param result defines the Color4 to fill the result in
  72869. * @returns the result Color4
  72870. */
  72871. multiplyToRef(color: Color4, result: Color4): Color4;
  72872. /**
  72873. * Creates a string with the Color4 current values
  72874. * @returns the string representation of the Color4 object
  72875. */
  72876. toString(): string;
  72877. /**
  72878. * Returns the string "Color4"
  72879. * @returns "Color4"
  72880. */
  72881. getClassName(): string;
  72882. /**
  72883. * Compute the Color4 hash code
  72884. * @returns an unique number that can be used to hash Color4 objects
  72885. */
  72886. getHashCode(): number;
  72887. /**
  72888. * Creates a new Color4 copied from the current one
  72889. * @returns a new Color4 object
  72890. */
  72891. clone(): Color4;
  72892. /**
  72893. * Copies the given Color4 values into the current one
  72894. * @param source defines the source Color4 object
  72895. * @returns the current updated Color4 object
  72896. */
  72897. copyFrom(source: Color4): Color4;
  72898. /**
  72899. * Copies the given float values into the current one
  72900. * @param r defines the red component to read from
  72901. * @param g defines the green component to read from
  72902. * @param b defines the blue component to read from
  72903. * @param a defines the alpha component to read from
  72904. * @returns the current updated Color4 object
  72905. */
  72906. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72907. /**
  72908. * Copies the given float values into the current one
  72909. * @param r defines the red component to read from
  72910. * @param g defines the green component to read from
  72911. * @param b defines the blue component to read from
  72912. * @param a defines the alpha component to read from
  72913. * @returns the current updated Color4 object
  72914. */
  72915. set(r: number, g: number, b: number, a: number): Color4;
  72916. /**
  72917. * Compute the Color4 hexadecimal code as a string
  72918. * @returns a string containing the hexadecimal representation of the Color4 object
  72919. */
  72920. toHexString(): string;
  72921. /**
  72922. * Computes a new Color4 converted from the current one to linear space
  72923. * @returns a new Color4 object
  72924. */
  72925. toLinearSpace(): Color4;
  72926. /**
  72927. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72928. * @param convertedColor defines the Color4 object where to store the linear space version
  72929. * @returns the unmodified Color4
  72930. */
  72931. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72932. /**
  72933. * Computes a new Color4 converted from the current one to gamma space
  72934. * @returns a new Color4 object
  72935. */
  72936. toGammaSpace(): Color4;
  72937. /**
  72938. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72939. * @param convertedColor defines the Color4 object where to store the gamma space version
  72940. * @returns the unmodified Color4
  72941. */
  72942. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72943. /**
  72944. * Creates a new Color4 from the string containing valid hexadecimal values
  72945. * @param hex defines a string containing valid hexadecimal values
  72946. * @returns a new Color4 object
  72947. */
  72948. static FromHexString(hex: string): Color4;
  72949. /**
  72950. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72951. * @param left defines the start value
  72952. * @param right defines the end value
  72953. * @param amount defines the gradient factor
  72954. * @returns a new Color4 object
  72955. */
  72956. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72957. /**
  72958. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72959. * @param left defines the start value
  72960. * @param right defines the end value
  72961. * @param amount defines the gradient factor
  72962. * @param result defines the Color4 object where to store data
  72963. */
  72964. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72965. /**
  72966. * Creates a new Color4 from a Color3 and an alpha value
  72967. * @param color3 defines the source Color3 to read from
  72968. * @param alpha defines the alpha component (1.0 by default)
  72969. * @returns a new Color4 object
  72970. */
  72971. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72972. /**
  72973. * Creates a new Color4 from the starting index element of the given array
  72974. * @param array defines the source array to read from
  72975. * @param offset defines the offset in the source array
  72976. * @returns a new Color4 object
  72977. */
  72978. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72979. /**
  72980. * Creates a new Color3 from integer values (< 256)
  72981. * @param r defines the red component to read from (value between 0 and 255)
  72982. * @param g defines the green component to read from (value between 0 and 255)
  72983. * @param b defines the blue component to read from (value between 0 and 255)
  72984. * @param a defines the alpha component to read from (value between 0 and 255)
  72985. * @returns a new Color3 object
  72986. */
  72987. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72988. /**
  72989. * Check the content of a given array and convert it to an array containing RGBA data
  72990. * If the original array was already containing count * 4 values then it is returned directly
  72991. * @param colors defines the array to check
  72992. * @param count defines the number of RGBA data to expect
  72993. * @returns an array containing count * 4 values (RGBA)
  72994. */
  72995. static CheckColors4(colors: number[], count: number): number[];
  72996. }
  72997. /**
  72998. * @hidden
  72999. */
  73000. export class TmpColors {
  73001. static Color3: Color3[];
  73002. static Color4: Color4[];
  73003. }
  73004. }
  73005. declare module BABYLON {
  73006. /**
  73007. * Defines an interface which represents an animation key frame
  73008. */
  73009. export interface IAnimationKey {
  73010. /**
  73011. * Frame of the key frame
  73012. */
  73013. frame: number;
  73014. /**
  73015. * Value at the specifies key frame
  73016. */
  73017. value: any;
  73018. /**
  73019. * The input tangent for the cubic hermite spline
  73020. */
  73021. inTangent?: any;
  73022. /**
  73023. * The output tangent for the cubic hermite spline
  73024. */
  73025. outTangent?: any;
  73026. /**
  73027. * The animation interpolation type
  73028. */
  73029. interpolation?: AnimationKeyInterpolation;
  73030. }
  73031. /**
  73032. * Enum for the animation key frame interpolation type
  73033. */
  73034. export enum AnimationKeyInterpolation {
  73035. /**
  73036. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73037. */
  73038. STEP = 1
  73039. }
  73040. }
  73041. declare module BABYLON {
  73042. /**
  73043. * Represents the range of an animation
  73044. */
  73045. export class AnimationRange {
  73046. /**The name of the animation range**/
  73047. name: string;
  73048. /**The starting frame of the animation */
  73049. from: number;
  73050. /**The ending frame of the animation*/
  73051. to: number;
  73052. /**
  73053. * Initializes the range of an animation
  73054. * @param name The name of the animation range
  73055. * @param from The starting frame of the animation
  73056. * @param to The ending frame of the animation
  73057. */
  73058. constructor(
  73059. /**The name of the animation range**/
  73060. name: string,
  73061. /**The starting frame of the animation */
  73062. from: number,
  73063. /**The ending frame of the animation*/
  73064. to: number);
  73065. /**
  73066. * Makes a copy of the animation range
  73067. * @returns A copy of the animation range
  73068. */
  73069. clone(): AnimationRange;
  73070. }
  73071. }
  73072. declare module BABYLON {
  73073. /**
  73074. * Composed of a frame, and an action function
  73075. */
  73076. export class AnimationEvent {
  73077. /** The frame for which the event is triggered **/
  73078. frame: number;
  73079. /** The event to perform when triggered **/
  73080. action: (currentFrame: number) => void;
  73081. /** Specifies if the event should be triggered only once**/
  73082. onlyOnce?: boolean | undefined;
  73083. /**
  73084. * Specifies if the animation event is done
  73085. */
  73086. isDone: boolean;
  73087. /**
  73088. * Initializes the animation event
  73089. * @param frame The frame for which the event is triggered
  73090. * @param action The event to perform when triggered
  73091. * @param onlyOnce Specifies if the event should be triggered only once
  73092. */
  73093. constructor(
  73094. /** The frame for which the event is triggered **/
  73095. frame: number,
  73096. /** The event to perform when triggered **/
  73097. action: (currentFrame: number) => void,
  73098. /** Specifies if the event should be triggered only once**/
  73099. onlyOnce?: boolean | undefined);
  73100. /** @hidden */
  73101. _clone(): AnimationEvent;
  73102. }
  73103. }
  73104. declare module BABYLON {
  73105. /**
  73106. * Interface used to define a behavior
  73107. */
  73108. export interface Behavior<T> {
  73109. /** gets or sets behavior's name */
  73110. name: string;
  73111. /**
  73112. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73113. */
  73114. init(): void;
  73115. /**
  73116. * Called when the behavior is attached to a target
  73117. * @param target defines the target where the behavior is attached to
  73118. */
  73119. attach(target: T): void;
  73120. /**
  73121. * Called when the behavior is detached from its target
  73122. */
  73123. detach(): void;
  73124. }
  73125. /**
  73126. * Interface implemented by classes supporting behaviors
  73127. */
  73128. export interface IBehaviorAware<T> {
  73129. /**
  73130. * Attach a behavior
  73131. * @param behavior defines the behavior to attach
  73132. * @returns the current host
  73133. */
  73134. addBehavior(behavior: Behavior<T>): T;
  73135. /**
  73136. * Remove a behavior from the current object
  73137. * @param behavior defines the behavior to detach
  73138. * @returns the current host
  73139. */
  73140. removeBehavior(behavior: Behavior<T>): T;
  73141. /**
  73142. * Gets a behavior using its name to search
  73143. * @param name defines the name to search
  73144. * @returns the behavior or null if not found
  73145. */
  73146. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Defines an array and its length.
  73152. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73153. */
  73154. export interface ISmartArrayLike<T> {
  73155. /**
  73156. * The data of the array.
  73157. */
  73158. data: Array<T>;
  73159. /**
  73160. * The active length of the array.
  73161. */
  73162. length: number;
  73163. }
  73164. /**
  73165. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73166. */
  73167. export class SmartArray<T> implements ISmartArrayLike<T> {
  73168. /**
  73169. * The full set of data from the array.
  73170. */
  73171. data: Array<T>;
  73172. /**
  73173. * The active length of the array.
  73174. */
  73175. length: number;
  73176. protected _id: number;
  73177. /**
  73178. * Instantiates a Smart Array.
  73179. * @param capacity defines the default capacity of the array.
  73180. */
  73181. constructor(capacity: number);
  73182. /**
  73183. * Pushes a value at the end of the active data.
  73184. * @param value defines the object to push in the array.
  73185. */
  73186. push(value: T): void;
  73187. /**
  73188. * Iterates over the active data and apply the lambda to them.
  73189. * @param func defines the action to apply on each value.
  73190. */
  73191. forEach(func: (content: T) => void): void;
  73192. /**
  73193. * Sorts the full sets of data.
  73194. * @param compareFn defines the comparison function to apply.
  73195. */
  73196. sort(compareFn: (a: T, b: T) => number): void;
  73197. /**
  73198. * Resets the active data to an empty array.
  73199. */
  73200. reset(): void;
  73201. /**
  73202. * Releases all the data from the array as well as the array.
  73203. */
  73204. dispose(): void;
  73205. /**
  73206. * Concats the active data with a given array.
  73207. * @param array defines the data to concatenate with.
  73208. */
  73209. concat(array: any): void;
  73210. /**
  73211. * Returns the position of a value in the active data.
  73212. * @param value defines the value to find the index for
  73213. * @returns the index if found in the active data otherwise -1
  73214. */
  73215. indexOf(value: T): number;
  73216. /**
  73217. * Returns whether an element is part of the active data.
  73218. * @param value defines the value to look for
  73219. * @returns true if found in the active data otherwise false
  73220. */
  73221. contains(value: T): boolean;
  73222. private static _GlobalId;
  73223. }
  73224. /**
  73225. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73226. * The data in this array can only be present once
  73227. */
  73228. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73229. private _duplicateId;
  73230. /**
  73231. * Pushes a value at the end of the active data.
  73232. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73233. * @param value defines the object to push in the array.
  73234. */
  73235. push(value: T): void;
  73236. /**
  73237. * Pushes a value at the end of the active data.
  73238. * If the data is already present, it won t be added again
  73239. * @param value defines the object to push in the array.
  73240. * @returns true if added false if it was already present
  73241. */
  73242. pushNoDuplicate(value: T): boolean;
  73243. /**
  73244. * Resets the active data to an empty array.
  73245. */
  73246. reset(): void;
  73247. /**
  73248. * Concats the active data with a given array.
  73249. * This ensures no dupplicate will be present in the result.
  73250. * @param array defines the data to concatenate with.
  73251. */
  73252. concatWithNoDuplicate(array: any): void;
  73253. }
  73254. }
  73255. declare module BABYLON {
  73256. /**
  73257. * @ignore
  73258. * This is a list of all the different input types that are available in the application.
  73259. * Fo instance: ArcRotateCameraGamepadInput...
  73260. */
  73261. export var CameraInputTypes: {};
  73262. /**
  73263. * This is the contract to implement in order to create a new input class.
  73264. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73265. */
  73266. export interface ICameraInput<TCamera extends Camera> {
  73267. /**
  73268. * Defines the camera the input is attached to.
  73269. */
  73270. camera: Nullable<TCamera>;
  73271. /**
  73272. * Gets the class name of the current intput.
  73273. * @returns the class name
  73274. */
  73275. getClassName(): string;
  73276. /**
  73277. * Get the friendly name associated with the input class.
  73278. * @returns the input friendly name
  73279. */
  73280. getSimpleName(): string;
  73281. /**
  73282. * Attach the input controls to a specific dom element to get the input from.
  73283. * @param element Defines the element the controls should be listened from
  73284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73285. */
  73286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73287. /**
  73288. * Detach the current controls from the specified dom element.
  73289. * @param element Defines the element to stop listening the inputs from
  73290. */
  73291. detachControl(element: Nullable<HTMLElement>): void;
  73292. /**
  73293. * Update the current camera state depending on the inputs that have been used this frame.
  73294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73295. */
  73296. checkInputs?: () => void;
  73297. }
  73298. /**
  73299. * Represents a map of input types to input instance or input index to input instance.
  73300. */
  73301. export interface CameraInputsMap<TCamera extends Camera> {
  73302. /**
  73303. * Accessor to the input by input type.
  73304. */
  73305. [name: string]: ICameraInput<TCamera>;
  73306. /**
  73307. * Accessor to the input by input index.
  73308. */
  73309. [idx: number]: ICameraInput<TCamera>;
  73310. }
  73311. /**
  73312. * This represents the input manager used within a camera.
  73313. * It helps dealing with all the different kind of input attached to a camera.
  73314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73315. */
  73316. export class CameraInputsManager<TCamera extends Camera> {
  73317. /**
  73318. * Defines the list of inputs attahed to the camera.
  73319. */
  73320. attached: CameraInputsMap<TCamera>;
  73321. /**
  73322. * Defines the dom element the camera is collecting inputs from.
  73323. * This is null if the controls have not been attached.
  73324. */
  73325. attachedElement: Nullable<HTMLElement>;
  73326. /**
  73327. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73328. */
  73329. noPreventDefault: boolean;
  73330. /**
  73331. * Defined the camera the input manager belongs to.
  73332. */
  73333. camera: TCamera;
  73334. /**
  73335. * Update the current camera state depending on the inputs that have been used this frame.
  73336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73337. */
  73338. checkInputs: () => void;
  73339. /**
  73340. * Instantiate a new Camera Input Manager.
  73341. * @param camera Defines the camera the input manager blongs to
  73342. */
  73343. constructor(camera: TCamera);
  73344. /**
  73345. * Add an input method to a camera
  73346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73347. * @param input camera input method
  73348. */
  73349. add(input: ICameraInput<TCamera>): void;
  73350. /**
  73351. * Remove a specific input method from a camera
  73352. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73353. * @param inputToRemove camera input method
  73354. */
  73355. remove(inputToRemove: ICameraInput<TCamera>): void;
  73356. /**
  73357. * Remove a specific input type from a camera
  73358. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73359. * @param inputType the type of the input to remove
  73360. */
  73361. removeByType(inputType: string): void;
  73362. private _addCheckInputs;
  73363. /**
  73364. * Attach the input controls to the currently attached dom element to listen the events from.
  73365. * @param input Defines the input to attach
  73366. */
  73367. attachInput(input: ICameraInput<TCamera>): void;
  73368. /**
  73369. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73370. * @param element Defines the dom element to collect the events from
  73371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73372. */
  73373. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73374. /**
  73375. * Detach the current manager inputs controls from a specific dom element.
  73376. * @param element Defines the dom element to collect the events from
  73377. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73378. */
  73379. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73380. /**
  73381. * Rebuild the dynamic inputCheck function from the current list of
  73382. * defined inputs in the manager.
  73383. */
  73384. rebuildInputCheck(): void;
  73385. /**
  73386. * Remove all attached input methods from a camera
  73387. */
  73388. clear(): void;
  73389. /**
  73390. * Serialize the current input manager attached to a camera.
  73391. * This ensures than once parsed,
  73392. * the input associated to the camera will be identical to the current ones
  73393. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73394. */
  73395. serialize(serializedCamera: any): void;
  73396. /**
  73397. * Parses an input manager serialized JSON to restore the previous list of inputs
  73398. * and states associated to a camera.
  73399. * @param parsedCamera Defines the JSON to parse
  73400. */
  73401. parse(parsedCamera: any): void;
  73402. }
  73403. }
  73404. declare module BABYLON {
  73405. /**
  73406. * Class used to store data that will be store in GPU memory
  73407. */
  73408. export class Buffer {
  73409. private _engine;
  73410. private _buffer;
  73411. /** @hidden */
  73412. _data: Nullable<DataArray>;
  73413. private _updatable;
  73414. private _instanced;
  73415. private _divisor;
  73416. /**
  73417. * Gets the byte stride.
  73418. */
  73419. readonly byteStride: number;
  73420. /**
  73421. * Constructor
  73422. * @param engine the engine
  73423. * @param data the data to use for this buffer
  73424. * @param updatable whether the data is updatable
  73425. * @param stride the stride (optional)
  73426. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73427. * @param instanced whether the buffer is instanced (optional)
  73428. * @param useBytes set to true if the stride in in bytes (optional)
  73429. * @param divisor sets an optional divisor for instances (1 by default)
  73430. */
  73431. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73432. /**
  73433. * Create a new VertexBuffer based on the current buffer
  73434. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73435. * @param offset defines offset in the buffer (0 by default)
  73436. * @param size defines the size in floats of attributes (position is 3 for instance)
  73437. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73438. * @param instanced defines if the vertex buffer contains indexed data
  73439. * @param useBytes defines if the offset and stride are in bytes *
  73440. * @param divisor sets an optional divisor for instances (1 by default)
  73441. * @returns the new vertex buffer
  73442. */
  73443. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73444. /**
  73445. * Gets a boolean indicating if the Buffer is updatable?
  73446. * @returns true if the buffer is updatable
  73447. */
  73448. isUpdatable(): boolean;
  73449. /**
  73450. * Gets current buffer's data
  73451. * @returns a DataArray or null
  73452. */
  73453. getData(): Nullable<DataArray>;
  73454. /**
  73455. * Gets underlying native buffer
  73456. * @returns underlying native buffer
  73457. */
  73458. getBuffer(): Nullable<DataBuffer>;
  73459. /**
  73460. * Gets the stride in float32 units (i.e. byte stride / 4).
  73461. * May not be an integer if the byte stride is not divisible by 4.
  73462. * DEPRECATED. Use byteStride instead.
  73463. * @returns the stride in float32 units
  73464. */
  73465. getStrideSize(): number;
  73466. /**
  73467. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73468. * @param data defines the data to store
  73469. */
  73470. create(data?: Nullable<DataArray>): void;
  73471. /** @hidden */
  73472. _rebuild(): void;
  73473. /**
  73474. * Update current buffer data
  73475. * @param data defines the data to store
  73476. */
  73477. update(data: DataArray): void;
  73478. /**
  73479. * Updates the data directly.
  73480. * @param data the new data
  73481. * @param offset the new offset
  73482. * @param vertexCount the vertex count (optional)
  73483. * @param useBytes set to true if the offset is in bytes
  73484. */
  73485. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73486. /**
  73487. * Release all resources
  73488. */
  73489. dispose(): void;
  73490. }
  73491. /**
  73492. * Specialized buffer used to store vertex data
  73493. */
  73494. export class VertexBuffer {
  73495. /** @hidden */
  73496. _buffer: Buffer;
  73497. private _kind;
  73498. private _size;
  73499. private _ownsBuffer;
  73500. private _instanced;
  73501. private _instanceDivisor;
  73502. /**
  73503. * The byte type.
  73504. */
  73505. static readonly BYTE: number;
  73506. /**
  73507. * The unsigned byte type.
  73508. */
  73509. static readonly UNSIGNED_BYTE: number;
  73510. /**
  73511. * The short type.
  73512. */
  73513. static readonly SHORT: number;
  73514. /**
  73515. * The unsigned short type.
  73516. */
  73517. static readonly UNSIGNED_SHORT: number;
  73518. /**
  73519. * The integer type.
  73520. */
  73521. static readonly INT: number;
  73522. /**
  73523. * The unsigned integer type.
  73524. */
  73525. static readonly UNSIGNED_INT: number;
  73526. /**
  73527. * The float type.
  73528. */
  73529. static readonly FLOAT: number;
  73530. /**
  73531. * Gets or sets the instance divisor when in instanced mode
  73532. */
  73533. instanceDivisor: number;
  73534. /**
  73535. * Gets the byte stride.
  73536. */
  73537. readonly byteStride: number;
  73538. /**
  73539. * Gets the byte offset.
  73540. */
  73541. readonly byteOffset: number;
  73542. /**
  73543. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73544. */
  73545. readonly normalized: boolean;
  73546. /**
  73547. * Gets the data type of each component in the array.
  73548. */
  73549. readonly type: number;
  73550. /**
  73551. * Constructor
  73552. * @param engine the engine
  73553. * @param data the data to use for this vertex buffer
  73554. * @param kind the vertex buffer kind
  73555. * @param updatable whether the data is updatable
  73556. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73557. * @param stride the stride (optional)
  73558. * @param instanced whether the buffer is instanced (optional)
  73559. * @param offset the offset of the data (optional)
  73560. * @param size the number of components (optional)
  73561. * @param type the type of the component (optional)
  73562. * @param normalized whether the data contains normalized data (optional)
  73563. * @param useBytes set to true if stride and offset are in bytes (optional)
  73564. * @param divisor defines the instance divisor to use (1 by default)
  73565. */
  73566. 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);
  73567. /** @hidden */
  73568. _rebuild(): void;
  73569. /**
  73570. * Returns the kind of the VertexBuffer (string)
  73571. * @returns a string
  73572. */
  73573. getKind(): string;
  73574. /**
  73575. * Gets a boolean indicating if the VertexBuffer is updatable?
  73576. * @returns true if the buffer is updatable
  73577. */
  73578. isUpdatable(): boolean;
  73579. /**
  73580. * Gets current buffer's data
  73581. * @returns a DataArray or null
  73582. */
  73583. getData(): Nullable<DataArray>;
  73584. /**
  73585. * Gets underlying native buffer
  73586. * @returns underlying native buffer
  73587. */
  73588. getBuffer(): Nullable<DataBuffer>;
  73589. /**
  73590. * Gets the stride in float32 units (i.e. byte stride / 4).
  73591. * May not be an integer if the byte stride is not divisible by 4.
  73592. * DEPRECATED. Use byteStride instead.
  73593. * @returns the stride in float32 units
  73594. */
  73595. getStrideSize(): number;
  73596. /**
  73597. * Returns the offset as a multiple of the type byte length.
  73598. * DEPRECATED. Use byteOffset instead.
  73599. * @returns the offset in bytes
  73600. */
  73601. getOffset(): number;
  73602. /**
  73603. * Returns the number of components per vertex attribute (integer)
  73604. * @returns the size in float
  73605. */
  73606. getSize(): number;
  73607. /**
  73608. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73609. * @returns true if this buffer is instanced
  73610. */
  73611. getIsInstanced(): boolean;
  73612. /**
  73613. * Returns the instancing divisor, zero for non-instanced (integer).
  73614. * @returns a number
  73615. */
  73616. getInstanceDivisor(): number;
  73617. /**
  73618. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73619. * @param data defines the data to store
  73620. */
  73621. create(data?: DataArray): void;
  73622. /**
  73623. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73624. * This function will create a new buffer if the current one is not updatable
  73625. * @param data defines the data to store
  73626. */
  73627. update(data: DataArray): void;
  73628. /**
  73629. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73630. * Returns the directly updated WebGLBuffer.
  73631. * @param data the new data
  73632. * @param offset the new offset
  73633. * @param useBytes set to true if the offset is in bytes
  73634. */
  73635. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73636. /**
  73637. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73638. */
  73639. dispose(): void;
  73640. /**
  73641. * Enumerates each value of this vertex buffer as numbers.
  73642. * @param count the number of values to enumerate
  73643. * @param callback the callback function called for each value
  73644. */
  73645. forEach(count: number, callback: (value: number, index: number) => void): void;
  73646. /**
  73647. * Positions
  73648. */
  73649. static readonly PositionKind: string;
  73650. /**
  73651. * Normals
  73652. */
  73653. static readonly NormalKind: string;
  73654. /**
  73655. * Tangents
  73656. */
  73657. static readonly TangentKind: string;
  73658. /**
  73659. * Texture coordinates
  73660. */
  73661. static readonly UVKind: string;
  73662. /**
  73663. * Texture coordinates 2
  73664. */
  73665. static readonly UV2Kind: string;
  73666. /**
  73667. * Texture coordinates 3
  73668. */
  73669. static readonly UV3Kind: string;
  73670. /**
  73671. * Texture coordinates 4
  73672. */
  73673. static readonly UV4Kind: string;
  73674. /**
  73675. * Texture coordinates 5
  73676. */
  73677. static readonly UV5Kind: string;
  73678. /**
  73679. * Texture coordinates 6
  73680. */
  73681. static readonly UV6Kind: string;
  73682. /**
  73683. * Colors
  73684. */
  73685. static readonly ColorKind: string;
  73686. /**
  73687. * Matrix indices (for bones)
  73688. */
  73689. static readonly MatricesIndicesKind: string;
  73690. /**
  73691. * Matrix weights (for bones)
  73692. */
  73693. static readonly MatricesWeightsKind: string;
  73694. /**
  73695. * Additional matrix indices (for bones)
  73696. */
  73697. static readonly MatricesIndicesExtraKind: string;
  73698. /**
  73699. * Additional matrix weights (for bones)
  73700. */
  73701. static readonly MatricesWeightsExtraKind: string;
  73702. /**
  73703. * Deduces the stride given a kind.
  73704. * @param kind The kind string to deduce
  73705. * @returns The deduced stride
  73706. */
  73707. static DeduceStride(kind: string): number;
  73708. /**
  73709. * Gets the byte length of the given type.
  73710. * @param type the type
  73711. * @returns the number of bytes
  73712. */
  73713. static GetTypeByteLength(type: number): number;
  73714. /**
  73715. * Enumerates each value of the given parameters as numbers.
  73716. * @param data the data to enumerate
  73717. * @param byteOffset the byte offset of the data
  73718. * @param byteStride the byte stride of the data
  73719. * @param componentCount the number of components per element
  73720. * @param componentType the type of the component
  73721. * @param count the number of values to enumerate
  73722. * @param normalized whether the data is normalized
  73723. * @param callback the callback function called for each value
  73724. */
  73725. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73726. private static _GetFloatValue;
  73727. }
  73728. }
  73729. declare module BABYLON {
  73730. /**
  73731. * @hidden
  73732. */
  73733. export class IntersectionInfo {
  73734. bu: Nullable<number>;
  73735. bv: Nullable<number>;
  73736. distance: number;
  73737. faceId: number;
  73738. subMeshId: number;
  73739. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73740. }
  73741. }
  73742. declare module BABYLON {
  73743. /**
  73744. * Represens a plane by the equation ax + by + cz + d = 0
  73745. */
  73746. export class Plane {
  73747. private static _TmpMatrix;
  73748. /**
  73749. * Normal of the plane (a,b,c)
  73750. */
  73751. normal: Vector3;
  73752. /**
  73753. * d component of the plane
  73754. */
  73755. d: number;
  73756. /**
  73757. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73758. * @param a a component of the plane
  73759. * @param b b component of the plane
  73760. * @param c c component of the plane
  73761. * @param d d component of the plane
  73762. */
  73763. constructor(a: number, b: number, c: number, d: number);
  73764. /**
  73765. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73766. */
  73767. asArray(): number[];
  73768. /**
  73769. * @returns a new plane copied from the current Plane.
  73770. */
  73771. clone(): Plane;
  73772. /**
  73773. * @returns the string "Plane".
  73774. */
  73775. getClassName(): string;
  73776. /**
  73777. * @returns the Plane hash code.
  73778. */
  73779. getHashCode(): number;
  73780. /**
  73781. * Normalize the current Plane in place.
  73782. * @returns the updated Plane.
  73783. */
  73784. normalize(): Plane;
  73785. /**
  73786. * Applies a transformation the plane and returns the result
  73787. * @param transformation the transformation matrix to be applied to the plane
  73788. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73789. */
  73790. transform(transformation: DeepImmutable<Matrix>): Plane;
  73791. /**
  73792. * Calcualtte the dot product between the point and the plane normal
  73793. * @param point point to calculate the dot product with
  73794. * @returns the dot product (float) of the point coordinates and the plane normal.
  73795. */
  73796. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73797. /**
  73798. * Updates the current Plane from the plane defined by the three given points.
  73799. * @param point1 one of the points used to contruct the plane
  73800. * @param point2 one of the points used to contruct the plane
  73801. * @param point3 one of the points used to contruct the plane
  73802. * @returns the updated Plane.
  73803. */
  73804. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73805. /**
  73806. * Checks if the plane is facing a given direction
  73807. * @param direction the direction to check if the plane is facing
  73808. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73809. * @returns True is the vector "direction" is the same side than the plane normal.
  73810. */
  73811. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73812. /**
  73813. * Calculates the distance to a point
  73814. * @param point point to calculate distance to
  73815. * @returns the signed distance (float) from the given point to the Plane.
  73816. */
  73817. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73818. /**
  73819. * Creates a plane from an array
  73820. * @param array the array to create a plane from
  73821. * @returns a new Plane from the given array.
  73822. */
  73823. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73824. /**
  73825. * Creates a plane from three points
  73826. * @param point1 point used to create the plane
  73827. * @param point2 point used to create the plane
  73828. * @param point3 point used to create the plane
  73829. * @returns a new Plane defined by the three given points.
  73830. */
  73831. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73832. /**
  73833. * Creates a plane from an origin point and a normal
  73834. * @param origin origin of the plane to be constructed
  73835. * @param normal normal of the plane to be constructed
  73836. * @returns a new Plane the normal vector to this plane at the given origin point.
  73837. * Note : the vector "normal" is updated because normalized.
  73838. */
  73839. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73840. /**
  73841. * Calculates the distance from a plane and a point
  73842. * @param origin origin of the plane to be constructed
  73843. * @param normal normal of the plane to be constructed
  73844. * @param point point to calculate distance to
  73845. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73846. */
  73847. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73848. }
  73849. }
  73850. declare module BABYLON {
  73851. /**
  73852. * Class used to store bounding sphere information
  73853. */
  73854. export class BoundingSphere {
  73855. /**
  73856. * Gets the center of the bounding sphere in local space
  73857. */
  73858. readonly center: Vector3;
  73859. /**
  73860. * Radius of the bounding sphere in local space
  73861. */
  73862. radius: number;
  73863. /**
  73864. * Gets the center of the bounding sphere in world space
  73865. */
  73866. readonly centerWorld: Vector3;
  73867. /**
  73868. * Radius of the bounding sphere in world space
  73869. */
  73870. radiusWorld: number;
  73871. /**
  73872. * Gets the minimum vector in local space
  73873. */
  73874. readonly minimum: Vector3;
  73875. /**
  73876. * Gets the maximum vector in local space
  73877. */
  73878. readonly maximum: Vector3;
  73879. private _worldMatrix;
  73880. private static readonly TmpVector3;
  73881. /**
  73882. * Creates a new bounding sphere
  73883. * @param min defines the minimum vector (in local space)
  73884. * @param max defines the maximum vector (in local space)
  73885. * @param worldMatrix defines the new world matrix
  73886. */
  73887. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73888. /**
  73889. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73890. * @param min defines the new minimum vector (in local space)
  73891. * @param max defines the new maximum vector (in local space)
  73892. * @param worldMatrix defines the new world matrix
  73893. */
  73894. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73895. /**
  73896. * Scale the current bounding sphere by applying a scale factor
  73897. * @param factor defines the scale factor to apply
  73898. * @returns the current bounding box
  73899. */
  73900. scale(factor: number): BoundingSphere;
  73901. /**
  73902. * Gets the world matrix of the bounding box
  73903. * @returns a matrix
  73904. */
  73905. getWorldMatrix(): DeepImmutable<Matrix>;
  73906. /** @hidden */
  73907. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73908. /**
  73909. * Tests if the bounding sphere is intersecting the frustum planes
  73910. * @param frustumPlanes defines the frustum planes to test
  73911. * @returns true if there is an intersection
  73912. */
  73913. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73914. /**
  73915. * Tests if the bounding sphere center is in between the frustum planes.
  73916. * Used for optimistic fast inclusion.
  73917. * @param frustumPlanes defines the frustum planes to test
  73918. * @returns true if the sphere center is in between the frustum planes
  73919. */
  73920. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73921. /**
  73922. * Tests if a point is inside the bounding sphere
  73923. * @param point defines the point to test
  73924. * @returns true if the point is inside the bounding sphere
  73925. */
  73926. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73927. /**
  73928. * Checks if two sphere intersct
  73929. * @param sphere0 sphere 0
  73930. * @param sphere1 sphere 1
  73931. * @returns true if the speres intersect
  73932. */
  73933. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73934. }
  73935. }
  73936. declare module BABYLON {
  73937. /**
  73938. * Class used to store bounding box information
  73939. */
  73940. export class BoundingBox implements ICullable {
  73941. /**
  73942. * Gets the 8 vectors representing the bounding box in local space
  73943. */
  73944. readonly vectors: Vector3[];
  73945. /**
  73946. * Gets the center of the bounding box in local space
  73947. */
  73948. readonly center: Vector3;
  73949. /**
  73950. * Gets the center of the bounding box in world space
  73951. */
  73952. readonly centerWorld: Vector3;
  73953. /**
  73954. * Gets the extend size in local space
  73955. */
  73956. readonly extendSize: Vector3;
  73957. /**
  73958. * Gets the extend size in world space
  73959. */
  73960. readonly extendSizeWorld: Vector3;
  73961. /**
  73962. * Gets the OBB (object bounding box) directions
  73963. */
  73964. readonly directions: Vector3[];
  73965. /**
  73966. * Gets the 8 vectors representing the bounding box in world space
  73967. */
  73968. readonly vectorsWorld: Vector3[];
  73969. /**
  73970. * Gets the minimum vector in world space
  73971. */
  73972. readonly minimumWorld: Vector3;
  73973. /**
  73974. * Gets the maximum vector in world space
  73975. */
  73976. readonly maximumWorld: Vector3;
  73977. /**
  73978. * Gets the minimum vector in local space
  73979. */
  73980. readonly minimum: Vector3;
  73981. /**
  73982. * Gets the maximum vector in local space
  73983. */
  73984. readonly maximum: Vector3;
  73985. private _worldMatrix;
  73986. private static readonly TmpVector3;
  73987. /**
  73988. * @hidden
  73989. */
  73990. _tag: number;
  73991. /**
  73992. * Creates a new bounding box
  73993. * @param min defines the minimum vector (in local space)
  73994. * @param max defines the maximum vector (in local space)
  73995. * @param worldMatrix defines the new world matrix
  73996. */
  73997. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73998. /**
  73999. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74000. * @param min defines the new minimum vector (in local space)
  74001. * @param max defines the new maximum vector (in local space)
  74002. * @param worldMatrix defines the new world matrix
  74003. */
  74004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74005. /**
  74006. * Scale the current bounding box by applying a scale factor
  74007. * @param factor defines the scale factor to apply
  74008. * @returns the current bounding box
  74009. */
  74010. scale(factor: number): BoundingBox;
  74011. /**
  74012. * Gets the world matrix of the bounding box
  74013. * @returns a matrix
  74014. */
  74015. getWorldMatrix(): DeepImmutable<Matrix>;
  74016. /** @hidden */
  74017. _update(world: DeepImmutable<Matrix>): void;
  74018. /**
  74019. * Tests if the bounding box is intersecting the frustum planes
  74020. * @param frustumPlanes defines the frustum planes to test
  74021. * @returns true if there is an intersection
  74022. */
  74023. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74024. /**
  74025. * Tests if the bounding box is entirely inside the frustum planes
  74026. * @param frustumPlanes defines the frustum planes to test
  74027. * @returns true if there is an inclusion
  74028. */
  74029. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74030. /**
  74031. * Tests if a point is inside the bounding box
  74032. * @param point defines the point to test
  74033. * @returns true if the point is inside the bounding box
  74034. */
  74035. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74036. /**
  74037. * Tests if the bounding box intersects with a bounding sphere
  74038. * @param sphere defines the sphere to test
  74039. * @returns true if there is an intersection
  74040. */
  74041. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74042. /**
  74043. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74044. * @param min defines the min vector to use
  74045. * @param max defines the max vector to use
  74046. * @returns true if there is an intersection
  74047. */
  74048. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74049. /**
  74050. * Tests if two bounding boxes are intersections
  74051. * @param box0 defines the first box to test
  74052. * @param box1 defines the second box to test
  74053. * @returns true if there is an intersection
  74054. */
  74055. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74056. /**
  74057. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74058. * @param minPoint defines the minimum vector of the bounding box
  74059. * @param maxPoint defines the maximum vector of the bounding box
  74060. * @param sphereCenter defines the sphere center
  74061. * @param sphereRadius defines the sphere radius
  74062. * @returns true if there is an intersection
  74063. */
  74064. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74065. /**
  74066. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74067. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74068. * @param frustumPlanes defines the frustum planes to test
  74069. * @return true if there is an inclusion
  74070. */
  74071. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74072. /**
  74073. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74074. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74075. * @param frustumPlanes defines the frustum planes to test
  74076. * @return true if there is an intersection
  74077. */
  74078. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74079. }
  74080. }
  74081. declare module BABYLON {
  74082. /** @hidden */
  74083. export class Collider {
  74084. /** Define if a collision was found */
  74085. collisionFound: boolean;
  74086. /**
  74087. * Define last intersection point in local space
  74088. */
  74089. intersectionPoint: Vector3;
  74090. /**
  74091. * Define last collided mesh
  74092. */
  74093. collidedMesh: Nullable<AbstractMesh>;
  74094. private _collisionPoint;
  74095. private _planeIntersectionPoint;
  74096. private _tempVector;
  74097. private _tempVector2;
  74098. private _tempVector3;
  74099. private _tempVector4;
  74100. private _edge;
  74101. private _baseToVertex;
  74102. private _destinationPoint;
  74103. private _slidePlaneNormal;
  74104. private _displacementVector;
  74105. /** @hidden */
  74106. _radius: Vector3;
  74107. /** @hidden */
  74108. _retry: number;
  74109. private _velocity;
  74110. private _basePoint;
  74111. private _epsilon;
  74112. /** @hidden */
  74113. _velocityWorldLength: number;
  74114. /** @hidden */
  74115. _basePointWorld: Vector3;
  74116. private _velocityWorld;
  74117. private _normalizedVelocity;
  74118. /** @hidden */
  74119. _initialVelocity: Vector3;
  74120. /** @hidden */
  74121. _initialPosition: Vector3;
  74122. private _nearestDistance;
  74123. private _collisionMask;
  74124. collisionMask: number;
  74125. /**
  74126. * Gets the plane normal used to compute the sliding response (in local space)
  74127. */
  74128. readonly slidePlaneNormal: Vector3;
  74129. /** @hidden */
  74130. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74131. /** @hidden */
  74132. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74133. /** @hidden */
  74134. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74135. /** @hidden */
  74136. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74137. /** @hidden */
  74138. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74139. /** @hidden */
  74140. _getResponse(pos: Vector3, vel: Vector3): void;
  74141. }
  74142. }
  74143. declare module BABYLON {
  74144. /**
  74145. * Interface for cullable objects
  74146. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74147. */
  74148. export interface ICullable {
  74149. /**
  74150. * Checks if the object or part of the object is in the frustum
  74151. * @param frustumPlanes Camera near/planes
  74152. * @returns true if the object is in frustum otherwise false
  74153. */
  74154. isInFrustum(frustumPlanes: Plane[]): boolean;
  74155. /**
  74156. * Checks if a cullable object (mesh...) is in the camera frustum
  74157. * Unlike isInFrustum this cheks the full bounding box
  74158. * @param frustumPlanes Camera near/planes
  74159. * @returns true if the object is in frustum otherwise false
  74160. */
  74161. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74162. }
  74163. /**
  74164. * Info for a bounding data of a mesh
  74165. */
  74166. export class BoundingInfo implements ICullable {
  74167. /**
  74168. * Bounding box for the mesh
  74169. */
  74170. readonly boundingBox: BoundingBox;
  74171. /**
  74172. * Bounding sphere for the mesh
  74173. */
  74174. readonly boundingSphere: BoundingSphere;
  74175. private _isLocked;
  74176. private static readonly TmpVector3;
  74177. /**
  74178. * Constructs bounding info
  74179. * @param minimum min vector of the bounding box/sphere
  74180. * @param maximum max vector of the bounding box/sphere
  74181. * @param worldMatrix defines the new world matrix
  74182. */
  74183. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74184. /**
  74185. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74186. * @param min defines the new minimum vector (in local space)
  74187. * @param max defines the new maximum vector (in local space)
  74188. * @param worldMatrix defines the new world matrix
  74189. */
  74190. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74191. /**
  74192. * min vector of the bounding box/sphere
  74193. */
  74194. readonly minimum: Vector3;
  74195. /**
  74196. * max vector of the bounding box/sphere
  74197. */
  74198. readonly maximum: Vector3;
  74199. /**
  74200. * If the info is locked and won't be updated to avoid perf overhead
  74201. */
  74202. isLocked: boolean;
  74203. /**
  74204. * Updates the bounding sphere and box
  74205. * @param world world matrix to be used to update
  74206. */
  74207. update(world: DeepImmutable<Matrix>): void;
  74208. /**
  74209. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74210. * @param center New center of the bounding info
  74211. * @param extend New extend of the bounding info
  74212. * @returns the current bounding info
  74213. */
  74214. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74215. /**
  74216. * Scale the current bounding info by applying a scale factor
  74217. * @param factor defines the scale factor to apply
  74218. * @returns the current bounding info
  74219. */
  74220. scale(factor: number): BoundingInfo;
  74221. /**
  74222. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74223. * @param frustumPlanes defines the frustum to test
  74224. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74225. * @returns true if the bounding info is in the frustum planes
  74226. */
  74227. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74228. /**
  74229. * Gets the world distance between the min and max points of the bounding box
  74230. */
  74231. readonly diagonalLength: number;
  74232. /**
  74233. * Checks if a cullable object (mesh...) is in the camera frustum
  74234. * Unlike isInFrustum this cheks the full bounding box
  74235. * @param frustumPlanes Camera near/planes
  74236. * @returns true if the object is in frustum otherwise false
  74237. */
  74238. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74239. /** @hidden */
  74240. _checkCollision(collider: Collider): boolean;
  74241. /**
  74242. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74243. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74244. * @param point the point to check intersection with
  74245. * @returns if the point intersects
  74246. */
  74247. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74248. /**
  74249. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74250. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74251. * @param boundingInfo the bounding info to check intersection with
  74252. * @param precise if the intersection should be done using OBB
  74253. * @returns if the bounding info intersects
  74254. */
  74255. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74256. }
  74257. }
  74258. declare module BABYLON {
  74259. /**
  74260. * Extracts minimum and maximum values from a list of indexed positions
  74261. * @param positions defines the positions to use
  74262. * @param indices defines the indices to the positions
  74263. * @param indexStart defines the start index
  74264. * @param indexCount defines the end index
  74265. * @param bias defines bias value to add to the result
  74266. * @return minimum and maximum values
  74267. */
  74268. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74269. minimum: Vector3;
  74270. maximum: Vector3;
  74271. };
  74272. /**
  74273. * Extracts minimum and maximum values from a list of positions
  74274. * @param positions defines the positions to use
  74275. * @param start defines the start index in the positions array
  74276. * @param count defines the number of positions to handle
  74277. * @param bias defines bias value to add to the result
  74278. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74279. * @return minimum and maximum values
  74280. */
  74281. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74282. minimum: Vector3;
  74283. maximum: Vector3;
  74284. };
  74285. }
  74286. declare module BABYLON {
  74287. /** @hidden */
  74288. export class WebGLDataBuffer extends DataBuffer {
  74289. private _buffer;
  74290. constructor(resource: WebGLBuffer);
  74291. readonly underlyingResource: any;
  74292. }
  74293. }
  74294. declare module BABYLON {
  74295. /** @hidden */
  74296. export class WebGLPipelineContext implements IPipelineContext {
  74297. engine: ThinEngine;
  74298. program: Nullable<WebGLProgram>;
  74299. context?: WebGLRenderingContext;
  74300. vertexShader?: WebGLShader;
  74301. fragmentShader?: WebGLShader;
  74302. isParallelCompiled: boolean;
  74303. onCompiled?: () => void;
  74304. transformFeedback?: WebGLTransformFeedback | null;
  74305. readonly isAsync: boolean;
  74306. readonly isReady: boolean;
  74307. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74308. }
  74309. }
  74310. declare module BABYLON {
  74311. interface ThinEngine {
  74312. /**
  74313. * Create an uniform buffer
  74314. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74315. * @param elements defines the content of the uniform buffer
  74316. * @returns the webGL uniform buffer
  74317. */
  74318. createUniformBuffer(elements: FloatArray): DataBuffer;
  74319. /**
  74320. * Create a dynamic uniform buffer
  74321. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74322. * @param elements defines the content of the uniform buffer
  74323. * @returns the webGL uniform buffer
  74324. */
  74325. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74326. /**
  74327. * Update an existing uniform buffer
  74328. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74329. * @param uniformBuffer defines the target uniform buffer
  74330. * @param elements defines the content to update
  74331. * @param offset defines the offset in the uniform buffer where update should start
  74332. * @param count defines the size of the data to update
  74333. */
  74334. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74335. /**
  74336. * Bind an uniform buffer to the current webGL context
  74337. * @param buffer defines the buffer to bind
  74338. */
  74339. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74340. /**
  74341. * Bind a buffer to the current webGL context at a given location
  74342. * @param buffer defines the buffer to bind
  74343. * @param location defines the index where to bind the buffer
  74344. */
  74345. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74346. /**
  74347. * Bind a specific block at a given index in a specific shader program
  74348. * @param pipelineContext defines the pipeline context to use
  74349. * @param blockName defines the block name
  74350. * @param index defines the index where to bind the block
  74351. */
  74352. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74353. }
  74354. }
  74355. declare module BABYLON {
  74356. /**
  74357. * Uniform buffer objects.
  74358. *
  74359. * Handles blocks of uniform on the GPU.
  74360. *
  74361. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74362. *
  74363. * For more information, please refer to :
  74364. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74365. */
  74366. export class UniformBuffer {
  74367. private _engine;
  74368. private _buffer;
  74369. private _data;
  74370. private _bufferData;
  74371. private _dynamic?;
  74372. private _uniformLocations;
  74373. private _uniformSizes;
  74374. private _uniformLocationPointer;
  74375. private _needSync;
  74376. private _noUBO;
  74377. private _currentEffect;
  74378. /** @hidden */
  74379. _alreadyBound: boolean;
  74380. private static _MAX_UNIFORM_SIZE;
  74381. private static _tempBuffer;
  74382. /**
  74383. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74384. * This is dynamic to allow compat with webgl 1 and 2.
  74385. * You will need to pass the name of the uniform as well as the value.
  74386. */
  74387. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74388. /**
  74389. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74390. * This is dynamic to allow compat with webgl 1 and 2.
  74391. * You will need to pass the name of the uniform as well as the value.
  74392. */
  74393. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74394. /**
  74395. * Lambda to Update a single float in a uniform buffer.
  74396. * This is dynamic to allow compat with webgl 1 and 2.
  74397. * You will need to pass the name of the uniform as well as the value.
  74398. */
  74399. updateFloat: (name: string, x: number) => void;
  74400. /**
  74401. * Lambda to Update a vec2 of float in a uniform buffer.
  74402. * This is dynamic to allow compat with webgl 1 and 2.
  74403. * You will need to pass the name of the uniform as well as the value.
  74404. */
  74405. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74406. /**
  74407. * Lambda to Update a vec3 of float in a uniform buffer.
  74408. * This is dynamic to allow compat with webgl 1 and 2.
  74409. * You will need to pass the name of the uniform as well as the value.
  74410. */
  74411. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74412. /**
  74413. * Lambda to Update a vec4 of float in a uniform buffer.
  74414. * This is dynamic to allow compat with webgl 1 and 2.
  74415. * You will need to pass the name of the uniform as well as the value.
  74416. */
  74417. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74418. /**
  74419. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74420. * This is dynamic to allow compat with webgl 1 and 2.
  74421. * You will need to pass the name of the uniform as well as the value.
  74422. */
  74423. updateMatrix: (name: string, mat: Matrix) => void;
  74424. /**
  74425. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74426. * This is dynamic to allow compat with webgl 1 and 2.
  74427. * You will need to pass the name of the uniform as well as the value.
  74428. */
  74429. updateVector3: (name: string, vector: Vector3) => void;
  74430. /**
  74431. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74432. * This is dynamic to allow compat with webgl 1 and 2.
  74433. * You will need to pass the name of the uniform as well as the value.
  74434. */
  74435. updateVector4: (name: string, vector: Vector4) => void;
  74436. /**
  74437. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74438. * This is dynamic to allow compat with webgl 1 and 2.
  74439. * You will need to pass the name of the uniform as well as the value.
  74440. */
  74441. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74442. /**
  74443. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74444. * This is dynamic to allow compat with webgl 1 and 2.
  74445. * You will need to pass the name of the uniform as well as the value.
  74446. */
  74447. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74448. /**
  74449. * Instantiates a new Uniform buffer objects.
  74450. *
  74451. * Handles blocks of uniform on the GPU.
  74452. *
  74453. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74454. *
  74455. * For more information, please refer to :
  74456. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74457. * @param engine Define the engine the buffer is associated with
  74458. * @param data Define the data contained in the buffer
  74459. * @param dynamic Define if the buffer is updatable
  74460. */
  74461. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74462. /**
  74463. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74464. * or just falling back on setUniformXXX calls.
  74465. */
  74466. readonly useUbo: boolean;
  74467. /**
  74468. * Indicates if the WebGL underlying uniform buffer is in sync
  74469. * with the javascript cache data.
  74470. */
  74471. readonly isSync: boolean;
  74472. /**
  74473. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74474. * Also, a dynamic UniformBuffer will disable cache verification and always
  74475. * update the underlying WebGL uniform buffer to the GPU.
  74476. * @returns if Dynamic, otherwise false
  74477. */
  74478. isDynamic(): boolean;
  74479. /**
  74480. * The data cache on JS side.
  74481. * @returns the underlying data as a float array
  74482. */
  74483. getData(): Float32Array;
  74484. /**
  74485. * The underlying WebGL Uniform buffer.
  74486. * @returns the webgl buffer
  74487. */
  74488. getBuffer(): Nullable<DataBuffer>;
  74489. /**
  74490. * std140 layout specifies how to align data within an UBO structure.
  74491. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74492. * for specs.
  74493. */
  74494. private _fillAlignment;
  74495. /**
  74496. * Adds an uniform in the buffer.
  74497. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74498. * for the layout to be correct !
  74499. * @param name Name of the uniform, as used in the uniform block in the shader.
  74500. * @param size Data size, or data directly.
  74501. */
  74502. addUniform(name: string, size: number | number[]): void;
  74503. /**
  74504. * Adds a Matrix 4x4 to the uniform buffer.
  74505. * @param name Name of the uniform, as used in the uniform block in the shader.
  74506. * @param mat A 4x4 matrix.
  74507. */
  74508. addMatrix(name: string, mat: Matrix): void;
  74509. /**
  74510. * Adds a vec2 to the uniform buffer.
  74511. * @param name Name of the uniform, as used in the uniform block in the shader.
  74512. * @param x Define the x component value of the vec2
  74513. * @param y Define the y component value of the vec2
  74514. */
  74515. addFloat2(name: string, x: number, y: number): void;
  74516. /**
  74517. * Adds a vec3 to the uniform buffer.
  74518. * @param name Name of the uniform, as used in the uniform block in the shader.
  74519. * @param x Define the x component value of the vec3
  74520. * @param y Define the y component value of the vec3
  74521. * @param z Define the z component value of the vec3
  74522. */
  74523. addFloat3(name: string, x: number, y: number, z: number): void;
  74524. /**
  74525. * Adds a vec3 to the uniform buffer.
  74526. * @param name Name of the uniform, as used in the uniform block in the shader.
  74527. * @param color Define the vec3 from a Color
  74528. */
  74529. addColor3(name: string, color: Color3): void;
  74530. /**
  74531. * Adds a vec4 to the uniform buffer.
  74532. * @param name Name of the uniform, as used in the uniform block in the shader.
  74533. * @param color Define the rgb components from a Color
  74534. * @param alpha Define the a component of the vec4
  74535. */
  74536. addColor4(name: string, color: Color3, alpha: number): void;
  74537. /**
  74538. * Adds a vec3 to the uniform buffer.
  74539. * @param name Name of the uniform, as used in the uniform block in the shader.
  74540. * @param vector Define the vec3 components from a Vector
  74541. */
  74542. addVector3(name: string, vector: Vector3): void;
  74543. /**
  74544. * Adds a Matrix 3x3 to the uniform buffer.
  74545. * @param name Name of the uniform, as used in the uniform block in the shader.
  74546. */
  74547. addMatrix3x3(name: string): void;
  74548. /**
  74549. * Adds a Matrix 2x2 to the uniform buffer.
  74550. * @param name Name of the uniform, as used in the uniform block in the shader.
  74551. */
  74552. addMatrix2x2(name: string): void;
  74553. /**
  74554. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74555. */
  74556. create(): void;
  74557. /** @hidden */
  74558. _rebuild(): void;
  74559. /**
  74560. * Updates the WebGL Uniform Buffer on the GPU.
  74561. * If the `dynamic` flag is set to true, no cache comparison is done.
  74562. * Otherwise, the buffer will be updated only if the cache differs.
  74563. */
  74564. update(): void;
  74565. /**
  74566. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74567. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74568. * @param data Define the flattened data
  74569. * @param size Define the size of the data.
  74570. */
  74571. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74572. private _valueCache;
  74573. private _cacheMatrix;
  74574. private _updateMatrix3x3ForUniform;
  74575. private _updateMatrix3x3ForEffect;
  74576. private _updateMatrix2x2ForEffect;
  74577. private _updateMatrix2x2ForUniform;
  74578. private _updateFloatForEffect;
  74579. private _updateFloatForUniform;
  74580. private _updateFloat2ForEffect;
  74581. private _updateFloat2ForUniform;
  74582. private _updateFloat3ForEffect;
  74583. private _updateFloat3ForUniform;
  74584. private _updateFloat4ForEffect;
  74585. private _updateFloat4ForUniform;
  74586. private _updateMatrixForEffect;
  74587. private _updateMatrixForUniform;
  74588. private _updateVector3ForEffect;
  74589. private _updateVector3ForUniform;
  74590. private _updateVector4ForEffect;
  74591. private _updateVector4ForUniform;
  74592. private _updateColor3ForEffect;
  74593. private _updateColor3ForUniform;
  74594. private _updateColor4ForEffect;
  74595. private _updateColor4ForUniform;
  74596. /**
  74597. * Sets a sampler uniform on the effect.
  74598. * @param name Define the name of the sampler.
  74599. * @param texture Define the texture to set in the sampler
  74600. */
  74601. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74602. /**
  74603. * Directly updates the value of the uniform in the cache AND on the GPU.
  74604. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74605. * @param data Define the flattened data
  74606. */
  74607. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74608. /**
  74609. * Binds this uniform buffer to an effect.
  74610. * @param effect Define the effect to bind the buffer to
  74611. * @param name Name of the uniform block in the shader.
  74612. */
  74613. bindToEffect(effect: Effect, name: string): void;
  74614. /**
  74615. * Disposes the uniform buffer.
  74616. */
  74617. dispose(): void;
  74618. }
  74619. }
  74620. declare module BABYLON {
  74621. /**
  74622. * Enum that determines the text-wrapping mode to use.
  74623. */
  74624. export enum InspectableType {
  74625. /**
  74626. * Checkbox for booleans
  74627. */
  74628. Checkbox = 0,
  74629. /**
  74630. * Sliders for numbers
  74631. */
  74632. Slider = 1,
  74633. /**
  74634. * Vector3
  74635. */
  74636. Vector3 = 2,
  74637. /**
  74638. * Quaternions
  74639. */
  74640. Quaternion = 3,
  74641. /**
  74642. * Color3
  74643. */
  74644. Color3 = 4,
  74645. /**
  74646. * String
  74647. */
  74648. String = 5
  74649. }
  74650. /**
  74651. * Interface used to define custom inspectable properties.
  74652. * This interface is used by the inspector to display custom property grids
  74653. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74654. */
  74655. export interface IInspectable {
  74656. /**
  74657. * Gets the label to display
  74658. */
  74659. label: string;
  74660. /**
  74661. * Gets the name of the property to edit
  74662. */
  74663. propertyName: string;
  74664. /**
  74665. * Gets the type of the editor to use
  74666. */
  74667. type: InspectableType;
  74668. /**
  74669. * Gets the minimum value of the property when using in "slider" mode
  74670. */
  74671. min?: number;
  74672. /**
  74673. * Gets the maximum value of the property when using in "slider" mode
  74674. */
  74675. max?: number;
  74676. /**
  74677. * Gets the setp to use when using in "slider" mode
  74678. */
  74679. step?: number;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * Class used to provide helper for timing
  74685. */
  74686. export class TimingTools {
  74687. /**
  74688. * Polyfill for setImmediate
  74689. * @param action defines the action to execute after the current execution block
  74690. */
  74691. static SetImmediate(action: () => void): void;
  74692. }
  74693. }
  74694. declare module BABYLON {
  74695. /**
  74696. * Class used to enable instatition of objects by class name
  74697. */
  74698. export class InstantiationTools {
  74699. /**
  74700. * Use this object to register external classes like custom textures or material
  74701. * to allow the laoders to instantiate them
  74702. */
  74703. static RegisteredExternalClasses: {
  74704. [key: string]: Object;
  74705. };
  74706. /**
  74707. * Tries to instantiate a new object from a given class name
  74708. * @param className defines the class name to instantiate
  74709. * @returns the new object or null if the system was not able to do the instantiation
  74710. */
  74711. static Instantiate(className: string): any;
  74712. }
  74713. }
  74714. declare module BABYLON {
  74715. /**
  74716. * Define options used to create a depth texture
  74717. */
  74718. export class DepthTextureCreationOptions {
  74719. /** Specifies whether or not a stencil should be allocated in the texture */
  74720. generateStencil?: boolean;
  74721. /** Specifies whether or not bilinear filtering is enable on the texture */
  74722. bilinearFiltering?: boolean;
  74723. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74724. comparisonFunction?: number;
  74725. /** Specifies if the created texture is a cube texture */
  74726. isCube?: boolean;
  74727. }
  74728. }
  74729. declare module BABYLON {
  74730. interface ThinEngine {
  74731. /**
  74732. * Creates a depth stencil cube texture.
  74733. * This is only available in WebGL 2.
  74734. * @param size The size of face edge in the cube texture.
  74735. * @param options The options defining the cube texture.
  74736. * @returns The cube texture
  74737. */
  74738. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74739. /**
  74740. * Creates a cube texture
  74741. * @param rootUrl defines the url where the files to load is located
  74742. * @param scene defines the current scene
  74743. * @param files defines the list of files to load (1 per face)
  74744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74745. * @param onLoad defines an optional callback raised when the texture is loaded
  74746. * @param onError defines an optional callback raised if there is an issue to load the texture
  74747. * @param format defines the format of the data
  74748. * @param forcedExtension defines the extension to use to pick the right loader
  74749. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74750. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74751. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74752. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74753. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74754. * @returns the cube texture as an InternalTexture
  74755. */
  74756. 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;
  74757. /**
  74758. * Creates a cube texture
  74759. * @param rootUrl defines the url where the files to load is located
  74760. * @param scene defines the current scene
  74761. * @param files defines the list of files to load (1 per face)
  74762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74763. * @param onLoad defines an optional callback raised when the texture is loaded
  74764. * @param onError defines an optional callback raised if there is an issue to load the texture
  74765. * @param format defines the format of the data
  74766. * @param forcedExtension defines the extension to use to pick the right loader
  74767. * @returns the cube texture as an InternalTexture
  74768. */
  74769. 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;
  74770. /**
  74771. * Creates a cube texture
  74772. * @param rootUrl defines the url where the files to load is located
  74773. * @param scene defines the current scene
  74774. * @param files defines the list of files to load (1 per face)
  74775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74776. * @param onLoad defines an optional callback raised when the texture is loaded
  74777. * @param onError defines an optional callback raised if there is an issue to load the texture
  74778. * @param format defines the format of the data
  74779. * @param forcedExtension defines the extension to use to pick the right loader
  74780. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74783. * @returns the cube texture as an InternalTexture
  74784. */
  74785. 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;
  74786. /** @hidden */
  74787. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74788. /** @hidden */
  74789. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74790. /** @hidden */
  74791. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74792. /** @hidden */
  74793. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74794. }
  74795. }
  74796. declare module BABYLON {
  74797. /**
  74798. * Class for creating a cube texture
  74799. */
  74800. export class CubeTexture extends BaseTexture {
  74801. private _delayedOnLoad;
  74802. /**
  74803. * The url of the texture
  74804. */
  74805. url: string;
  74806. /**
  74807. * Gets or sets the center of the bounding box associated with the cube texture.
  74808. * It must define where the camera used to render the texture was set
  74809. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74810. */
  74811. boundingBoxPosition: Vector3;
  74812. private _boundingBoxSize;
  74813. /**
  74814. * Gets or sets the size of the bounding box associated with the cube texture
  74815. * When defined, the cubemap will switch to local mode
  74816. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74817. * @example https://www.babylonjs-playground.com/#RNASML
  74818. */
  74819. /**
  74820. * Returns the bounding box size
  74821. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74822. */
  74823. boundingBoxSize: Vector3;
  74824. protected _rotationY: number;
  74825. /**
  74826. * Sets texture matrix rotation angle around Y axis in radians.
  74827. */
  74828. /**
  74829. * Gets texture matrix rotation angle around Y axis radians.
  74830. */
  74831. rotationY: number;
  74832. /**
  74833. * Are mip maps generated for this texture or not.
  74834. */
  74835. readonly noMipmap: boolean;
  74836. private _noMipmap;
  74837. private _files;
  74838. protected _forcedExtension: Nullable<string>;
  74839. private _extensions;
  74840. private _textureMatrix;
  74841. private _format;
  74842. private _createPolynomials;
  74843. /** @hidden */
  74844. _prefiltered: boolean;
  74845. /**
  74846. * Creates a cube texture from an array of image urls
  74847. * @param files defines an array of image urls
  74848. * @param scene defines the hosting scene
  74849. * @param noMipmap specifies if mip maps are not used
  74850. * @returns a cube texture
  74851. */
  74852. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74853. /**
  74854. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74855. * @param url defines the url of the prefiltered texture
  74856. * @param scene defines the scene the texture is attached to
  74857. * @param forcedExtension defines the extension of the file if different from the url
  74858. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74859. * @return the prefiltered texture
  74860. */
  74861. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74862. /**
  74863. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74864. * as prefiltered data.
  74865. * @param rootUrl defines the url of the texture or the root name of the six images
  74866. * @param scene defines the scene the texture is attached to
  74867. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74868. * @param noMipmap defines if mipmaps should be created or not
  74869. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74870. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74871. * @param onError defines a callback triggered in case of error during load
  74872. * @param format defines the internal format to use for the texture once loaded
  74873. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74874. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74875. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74878. * @return the cube texture
  74879. */
  74880. 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);
  74881. /**
  74882. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74883. */
  74884. readonly isPrefiltered: boolean;
  74885. /**
  74886. * Get the current class name of the texture useful for serialization or dynamic coding.
  74887. * @returns "CubeTexture"
  74888. */
  74889. getClassName(): string;
  74890. /**
  74891. * Update the url (and optional buffer) of this texture if url was null during construction.
  74892. * @param url the url of the texture
  74893. * @param forcedExtension defines the extension to use
  74894. * @param onLoad callback called when the texture is loaded (defaults to null)
  74895. */
  74896. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74897. /**
  74898. * Delays loading of the cube texture
  74899. * @param forcedExtension defines the extension to use
  74900. */
  74901. delayLoad(forcedExtension?: string): void;
  74902. /**
  74903. * Returns the reflection texture matrix
  74904. * @returns the reflection texture matrix
  74905. */
  74906. getReflectionTextureMatrix(): Matrix;
  74907. /**
  74908. * Sets the reflection texture matrix
  74909. * @param value Reflection texture matrix
  74910. */
  74911. setReflectionTextureMatrix(value: Matrix): void;
  74912. /**
  74913. * Parses text to create a cube texture
  74914. * @param parsedTexture define the serialized text to read from
  74915. * @param scene defines the hosting scene
  74916. * @param rootUrl defines the root url of the cube texture
  74917. * @returns a cube texture
  74918. */
  74919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74920. /**
  74921. * Makes a clone, or deep copy, of the cube texture
  74922. * @returns a new cube texture
  74923. */
  74924. clone(): CubeTexture;
  74925. }
  74926. }
  74927. declare module BABYLON {
  74928. /**
  74929. * Manages the defines for the Material
  74930. */
  74931. export class MaterialDefines {
  74932. /** @hidden */
  74933. protected _keys: string[];
  74934. private _isDirty;
  74935. /** @hidden */
  74936. _renderId: number;
  74937. /** @hidden */
  74938. _areLightsDirty: boolean;
  74939. /** @hidden */
  74940. _areLightsDisposed: boolean;
  74941. /** @hidden */
  74942. _areAttributesDirty: boolean;
  74943. /** @hidden */
  74944. _areTexturesDirty: boolean;
  74945. /** @hidden */
  74946. _areFresnelDirty: boolean;
  74947. /** @hidden */
  74948. _areMiscDirty: boolean;
  74949. /** @hidden */
  74950. _areImageProcessingDirty: boolean;
  74951. /** @hidden */
  74952. _normals: boolean;
  74953. /** @hidden */
  74954. _uvs: boolean;
  74955. /** @hidden */
  74956. _needNormals: boolean;
  74957. /** @hidden */
  74958. _needUVs: boolean;
  74959. [id: string]: any;
  74960. /**
  74961. * Specifies if the material needs to be re-calculated
  74962. */
  74963. readonly isDirty: boolean;
  74964. /**
  74965. * Marks the material to indicate that it has been re-calculated
  74966. */
  74967. markAsProcessed(): void;
  74968. /**
  74969. * Marks the material to indicate that it needs to be re-calculated
  74970. */
  74971. markAsUnprocessed(): void;
  74972. /**
  74973. * Marks the material to indicate all of its defines need to be re-calculated
  74974. */
  74975. markAllAsDirty(): void;
  74976. /**
  74977. * Marks the material to indicate that image processing needs to be re-calculated
  74978. */
  74979. markAsImageProcessingDirty(): void;
  74980. /**
  74981. * Marks the material to indicate the lights need to be re-calculated
  74982. * @param disposed Defines whether the light is dirty due to dispose or not
  74983. */
  74984. markAsLightDirty(disposed?: boolean): void;
  74985. /**
  74986. * Marks the attribute state as changed
  74987. */
  74988. markAsAttributesDirty(): void;
  74989. /**
  74990. * Marks the texture state as changed
  74991. */
  74992. markAsTexturesDirty(): void;
  74993. /**
  74994. * Marks the fresnel state as changed
  74995. */
  74996. markAsFresnelDirty(): void;
  74997. /**
  74998. * Marks the misc state as changed
  74999. */
  75000. markAsMiscDirty(): void;
  75001. /**
  75002. * Rebuilds the material defines
  75003. */
  75004. rebuild(): void;
  75005. /**
  75006. * Specifies if two material defines are equal
  75007. * @param other - A material define instance to compare to
  75008. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75009. */
  75010. isEqual(other: MaterialDefines): boolean;
  75011. /**
  75012. * Clones this instance's defines to another instance
  75013. * @param other - material defines to clone values to
  75014. */
  75015. cloneTo(other: MaterialDefines): void;
  75016. /**
  75017. * Resets the material define values
  75018. */
  75019. reset(): void;
  75020. /**
  75021. * Converts the material define values to a string
  75022. * @returns - String of material define information
  75023. */
  75024. toString(): string;
  75025. }
  75026. }
  75027. declare module BABYLON {
  75028. /**
  75029. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75030. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75031. * 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;
  75032. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75033. */
  75034. export class ColorCurves {
  75035. private _dirty;
  75036. private _tempColor;
  75037. private _globalCurve;
  75038. private _highlightsCurve;
  75039. private _midtonesCurve;
  75040. private _shadowsCurve;
  75041. private _positiveCurve;
  75042. private _negativeCurve;
  75043. private _globalHue;
  75044. private _globalDensity;
  75045. private _globalSaturation;
  75046. private _globalExposure;
  75047. /**
  75048. * Gets the global Hue value.
  75049. * 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).
  75050. */
  75051. /**
  75052. * Sets the global Hue value.
  75053. * 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).
  75054. */
  75055. globalHue: number;
  75056. /**
  75057. * Gets the global Density value.
  75058. * 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.
  75059. * Values less than zero provide a filter of opposite hue.
  75060. */
  75061. /**
  75062. * Sets the global Density value.
  75063. * 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.
  75064. * Values less than zero provide a filter of opposite hue.
  75065. */
  75066. globalDensity: number;
  75067. /**
  75068. * Gets the global Saturation value.
  75069. * 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.
  75070. */
  75071. /**
  75072. * Sets the global Saturation value.
  75073. * 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.
  75074. */
  75075. globalSaturation: number;
  75076. /**
  75077. * Gets the global Exposure value.
  75078. * 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.
  75079. */
  75080. /**
  75081. * Sets the global Exposure value.
  75082. * 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.
  75083. */
  75084. globalExposure: number;
  75085. private _highlightsHue;
  75086. private _highlightsDensity;
  75087. private _highlightsSaturation;
  75088. private _highlightsExposure;
  75089. /**
  75090. * Gets the highlights Hue value.
  75091. * 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).
  75092. */
  75093. /**
  75094. * Sets the highlights Hue value.
  75095. * 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).
  75096. */
  75097. highlightsHue: number;
  75098. /**
  75099. * Gets the highlights Density value.
  75100. * 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.
  75101. * Values less than zero provide a filter of opposite hue.
  75102. */
  75103. /**
  75104. * Sets the highlights Density value.
  75105. * 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.
  75106. * Values less than zero provide a filter of opposite hue.
  75107. */
  75108. highlightsDensity: number;
  75109. /**
  75110. * Gets the highlights Saturation value.
  75111. * 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.
  75112. */
  75113. /**
  75114. * Sets the highlights Saturation value.
  75115. * 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.
  75116. */
  75117. highlightsSaturation: number;
  75118. /**
  75119. * Gets the highlights Exposure value.
  75120. * 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.
  75121. */
  75122. /**
  75123. * Sets the highlights Exposure value.
  75124. * 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.
  75125. */
  75126. highlightsExposure: number;
  75127. private _midtonesHue;
  75128. private _midtonesDensity;
  75129. private _midtonesSaturation;
  75130. private _midtonesExposure;
  75131. /**
  75132. * Gets the midtones Hue value.
  75133. * 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).
  75134. */
  75135. /**
  75136. * Sets the midtones Hue value.
  75137. * 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).
  75138. */
  75139. midtonesHue: number;
  75140. /**
  75141. * Gets the midtones Density value.
  75142. * 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.
  75143. * Values less than zero provide a filter of opposite hue.
  75144. */
  75145. /**
  75146. * Sets the midtones Density value.
  75147. * 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.
  75148. * Values less than zero provide a filter of opposite hue.
  75149. */
  75150. midtonesDensity: number;
  75151. /**
  75152. * Gets the midtones Saturation value.
  75153. * 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.
  75154. */
  75155. /**
  75156. * Sets the midtones Saturation value.
  75157. * 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.
  75158. */
  75159. midtonesSaturation: number;
  75160. /**
  75161. * Gets the midtones Exposure value.
  75162. * 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.
  75163. */
  75164. /**
  75165. * Sets the midtones Exposure value.
  75166. * 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.
  75167. */
  75168. midtonesExposure: number;
  75169. private _shadowsHue;
  75170. private _shadowsDensity;
  75171. private _shadowsSaturation;
  75172. private _shadowsExposure;
  75173. /**
  75174. * Gets the shadows Hue value.
  75175. * 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).
  75176. */
  75177. /**
  75178. * Sets the shadows Hue value.
  75179. * 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).
  75180. */
  75181. shadowsHue: number;
  75182. /**
  75183. * Gets the shadows Density value.
  75184. * 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.
  75185. * Values less than zero provide a filter of opposite hue.
  75186. */
  75187. /**
  75188. * Sets the shadows Density value.
  75189. * 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.
  75190. * Values less than zero provide a filter of opposite hue.
  75191. */
  75192. shadowsDensity: number;
  75193. /**
  75194. * Gets the shadows Saturation value.
  75195. * 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.
  75196. */
  75197. /**
  75198. * Sets the shadows Saturation value.
  75199. * 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.
  75200. */
  75201. shadowsSaturation: number;
  75202. /**
  75203. * Gets the shadows Exposure value.
  75204. * 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.
  75205. */
  75206. /**
  75207. * Sets the shadows Exposure value.
  75208. * 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.
  75209. */
  75210. shadowsExposure: number;
  75211. /**
  75212. * Returns the class name
  75213. * @returns The class name
  75214. */
  75215. getClassName(): string;
  75216. /**
  75217. * Binds the color curves to the shader.
  75218. * @param colorCurves The color curve to bind
  75219. * @param effect The effect to bind to
  75220. * @param positiveUniform The positive uniform shader parameter
  75221. * @param neutralUniform The neutral uniform shader parameter
  75222. * @param negativeUniform The negative uniform shader parameter
  75223. */
  75224. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75225. /**
  75226. * Prepare the list of uniforms associated with the ColorCurves effects.
  75227. * @param uniformsList The list of uniforms used in the effect
  75228. */
  75229. static PrepareUniforms(uniformsList: string[]): void;
  75230. /**
  75231. * Returns color grading data based on a hue, density, saturation and exposure value.
  75232. * @param filterHue The hue of the color filter.
  75233. * @param filterDensity The density of the color filter.
  75234. * @param saturation The saturation.
  75235. * @param exposure The exposure.
  75236. * @param result The result data container.
  75237. */
  75238. private getColorGradingDataToRef;
  75239. /**
  75240. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75241. * @param value The input slider value in range [-100,100].
  75242. * @returns Adjusted value.
  75243. */
  75244. private static applyColorGradingSliderNonlinear;
  75245. /**
  75246. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75247. * @param hue The hue (H) input.
  75248. * @param saturation The saturation (S) input.
  75249. * @param brightness The brightness (B) input.
  75250. * @result An RGBA color represented as Vector4.
  75251. */
  75252. private static fromHSBToRef;
  75253. /**
  75254. * Returns a value clamped between min and max
  75255. * @param value The value to clamp
  75256. * @param min The minimum of value
  75257. * @param max The maximum of value
  75258. * @returns The clamped value.
  75259. */
  75260. private static clamp;
  75261. /**
  75262. * Clones the current color curve instance.
  75263. * @return The cloned curves
  75264. */
  75265. clone(): ColorCurves;
  75266. /**
  75267. * Serializes the current color curve instance to a json representation.
  75268. * @return a JSON representation
  75269. */
  75270. serialize(): any;
  75271. /**
  75272. * Parses the color curve from a json representation.
  75273. * @param source the JSON source to parse
  75274. * @return The parsed curves
  75275. */
  75276. static Parse(source: any): ColorCurves;
  75277. }
  75278. }
  75279. declare module BABYLON {
  75280. /**
  75281. * Interface to follow in your material defines to integrate easily the
  75282. * Image proccessing functions.
  75283. * @hidden
  75284. */
  75285. export interface IImageProcessingConfigurationDefines {
  75286. IMAGEPROCESSING: boolean;
  75287. VIGNETTE: boolean;
  75288. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75289. VIGNETTEBLENDMODEOPAQUE: boolean;
  75290. TONEMAPPING: boolean;
  75291. TONEMAPPING_ACES: boolean;
  75292. CONTRAST: boolean;
  75293. EXPOSURE: boolean;
  75294. COLORCURVES: boolean;
  75295. COLORGRADING: boolean;
  75296. COLORGRADING3D: boolean;
  75297. SAMPLER3DGREENDEPTH: boolean;
  75298. SAMPLER3DBGRMAP: boolean;
  75299. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75300. }
  75301. /**
  75302. * @hidden
  75303. */
  75304. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75305. IMAGEPROCESSING: boolean;
  75306. VIGNETTE: boolean;
  75307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75308. VIGNETTEBLENDMODEOPAQUE: boolean;
  75309. TONEMAPPING: boolean;
  75310. TONEMAPPING_ACES: boolean;
  75311. CONTRAST: boolean;
  75312. COLORCURVES: boolean;
  75313. COLORGRADING: boolean;
  75314. COLORGRADING3D: boolean;
  75315. SAMPLER3DGREENDEPTH: boolean;
  75316. SAMPLER3DBGRMAP: boolean;
  75317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75318. EXPOSURE: boolean;
  75319. constructor();
  75320. }
  75321. /**
  75322. * This groups together the common properties used for image processing either in direct forward pass
  75323. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75324. * or not.
  75325. */
  75326. export class ImageProcessingConfiguration {
  75327. /**
  75328. * Default tone mapping applied in BabylonJS.
  75329. */
  75330. static readonly TONEMAPPING_STANDARD: number;
  75331. /**
  75332. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75333. * to other engines rendering to increase portability.
  75334. */
  75335. static readonly TONEMAPPING_ACES: number;
  75336. /**
  75337. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75338. */
  75339. colorCurves: Nullable<ColorCurves>;
  75340. private _colorCurvesEnabled;
  75341. /**
  75342. * Gets wether the color curves effect is enabled.
  75343. */
  75344. /**
  75345. * Sets wether the color curves effect is enabled.
  75346. */
  75347. colorCurvesEnabled: boolean;
  75348. private _colorGradingTexture;
  75349. /**
  75350. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75351. */
  75352. /**
  75353. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75354. */
  75355. colorGradingTexture: Nullable<BaseTexture>;
  75356. private _colorGradingEnabled;
  75357. /**
  75358. * Gets wether the color grading effect is enabled.
  75359. */
  75360. /**
  75361. * Sets wether the color grading effect is enabled.
  75362. */
  75363. colorGradingEnabled: boolean;
  75364. private _colorGradingWithGreenDepth;
  75365. /**
  75366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75367. */
  75368. /**
  75369. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75370. */
  75371. colorGradingWithGreenDepth: boolean;
  75372. private _colorGradingBGR;
  75373. /**
  75374. * Gets wether the color grading texture contains BGR values.
  75375. */
  75376. /**
  75377. * Sets wether the color grading texture contains BGR values.
  75378. */
  75379. colorGradingBGR: boolean;
  75380. /** @hidden */
  75381. _exposure: number;
  75382. /**
  75383. * Gets the Exposure used in the effect.
  75384. */
  75385. /**
  75386. * Sets the Exposure used in the effect.
  75387. */
  75388. exposure: number;
  75389. private _toneMappingEnabled;
  75390. /**
  75391. * Gets wether the tone mapping effect is enabled.
  75392. */
  75393. /**
  75394. * Sets wether the tone mapping effect is enabled.
  75395. */
  75396. toneMappingEnabled: boolean;
  75397. private _toneMappingType;
  75398. /**
  75399. * Gets the type of tone mapping effect.
  75400. */
  75401. /**
  75402. * Sets the type of tone mapping effect used in BabylonJS.
  75403. */
  75404. toneMappingType: number;
  75405. protected _contrast: number;
  75406. /**
  75407. * Gets the contrast used in the effect.
  75408. */
  75409. /**
  75410. * Sets the contrast used in the effect.
  75411. */
  75412. contrast: number;
  75413. /**
  75414. * Vignette stretch size.
  75415. */
  75416. vignetteStretch: number;
  75417. /**
  75418. * Vignette centre X Offset.
  75419. */
  75420. vignetteCentreX: number;
  75421. /**
  75422. * Vignette centre Y Offset.
  75423. */
  75424. vignetteCentreY: number;
  75425. /**
  75426. * Vignette weight or intensity of the vignette effect.
  75427. */
  75428. vignetteWeight: number;
  75429. /**
  75430. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75431. * if vignetteEnabled is set to true.
  75432. */
  75433. vignetteColor: Color4;
  75434. /**
  75435. * Camera field of view used by the Vignette effect.
  75436. */
  75437. vignetteCameraFov: number;
  75438. private _vignetteBlendMode;
  75439. /**
  75440. * Gets the vignette blend mode allowing different kind of effect.
  75441. */
  75442. /**
  75443. * Sets the vignette blend mode allowing different kind of effect.
  75444. */
  75445. vignetteBlendMode: number;
  75446. private _vignetteEnabled;
  75447. /**
  75448. * Gets wether the vignette effect is enabled.
  75449. */
  75450. /**
  75451. * Sets wether the vignette effect is enabled.
  75452. */
  75453. vignetteEnabled: boolean;
  75454. private _applyByPostProcess;
  75455. /**
  75456. * Gets wether the image processing is applied through a post process or not.
  75457. */
  75458. /**
  75459. * Sets wether the image processing is applied through a post process or not.
  75460. */
  75461. applyByPostProcess: boolean;
  75462. private _isEnabled;
  75463. /**
  75464. * Gets wether the image processing is enabled or not.
  75465. */
  75466. /**
  75467. * Sets wether the image processing is enabled or not.
  75468. */
  75469. isEnabled: boolean;
  75470. /**
  75471. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75472. */
  75473. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75474. /**
  75475. * Method called each time the image processing information changes requires to recompile the effect.
  75476. */
  75477. protected _updateParameters(): void;
  75478. /**
  75479. * Gets the current class name.
  75480. * @return "ImageProcessingConfiguration"
  75481. */
  75482. getClassName(): string;
  75483. /**
  75484. * Prepare the list of uniforms associated with the Image Processing effects.
  75485. * @param uniforms The list of uniforms used in the effect
  75486. * @param defines the list of defines currently in use
  75487. */
  75488. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75489. /**
  75490. * Prepare the list of samplers associated with the Image Processing effects.
  75491. * @param samplersList The list of uniforms used in the effect
  75492. * @param defines the list of defines currently in use
  75493. */
  75494. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75495. /**
  75496. * Prepare the list of defines associated to the shader.
  75497. * @param defines the list of defines to complete
  75498. * @param forPostProcess Define if we are currently in post process mode or not
  75499. */
  75500. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75501. /**
  75502. * Returns true if all the image processing information are ready.
  75503. * @returns True if ready, otherwise, false
  75504. */
  75505. isReady(): boolean;
  75506. /**
  75507. * Binds the image processing to the shader.
  75508. * @param effect The effect to bind to
  75509. * @param aspectRatio Define the current aspect ratio of the effect
  75510. */
  75511. bind(effect: Effect, aspectRatio?: number): void;
  75512. /**
  75513. * Clones the current image processing instance.
  75514. * @return The cloned image processing
  75515. */
  75516. clone(): ImageProcessingConfiguration;
  75517. /**
  75518. * Serializes the current image processing instance to a json representation.
  75519. * @return a JSON representation
  75520. */
  75521. serialize(): any;
  75522. /**
  75523. * Parses the image processing from a json representation.
  75524. * @param source the JSON source to parse
  75525. * @return The parsed image processing
  75526. */
  75527. static Parse(source: any): ImageProcessingConfiguration;
  75528. private static _VIGNETTEMODE_MULTIPLY;
  75529. private static _VIGNETTEMODE_OPAQUE;
  75530. /**
  75531. * Used to apply the vignette as a mix with the pixel color.
  75532. */
  75533. static readonly VIGNETTEMODE_MULTIPLY: number;
  75534. /**
  75535. * Used to apply the vignette as a replacement of the pixel color.
  75536. */
  75537. static readonly VIGNETTEMODE_OPAQUE: number;
  75538. }
  75539. }
  75540. declare module BABYLON {
  75541. /** @hidden */
  75542. export var postprocessVertexShader: {
  75543. name: string;
  75544. shader: string;
  75545. };
  75546. }
  75547. declare module BABYLON {
  75548. interface ThinEngine {
  75549. /**
  75550. * Creates a new render target texture
  75551. * @param size defines the size of the texture
  75552. * @param options defines the options used to create the texture
  75553. * @returns a new render target texture stored in an InternalTexture
  75554. */
  75555. createRenderTargetTexture(size: number | {
  75556. width: number;
  75557. height: number;
  75558. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75559. }
  75560. }
  75561. declare module BABYLON {
  75562. /** Defines supported spaces */
  75563. export enum Space {
  75564. /** Local (object) space */
  75565. LOCAL = 0,
  75566. /** World space */
  75567. WORLD = 1,
  75568. /** Bone space */
  75569. BONE = 2
  75570. }
  75571. /** Defines the 3 main axes */
  75572. export class Axis {
  75573. /** X axis */
  75574. static X: Vector3;
  75575. /** Y axis */
  75576. static Y: Vector3;
  75577. /** Z axis */
  75578. static Z: Vector3;
  75579. }
  75580. }
  75581. declare module BABYLON {
  75582. /**
  75583. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75584. * This is the base of the follow, arc rotate cameras and Free camera
  75585. * @see http://doc.babylonjs.com/features/cameras
  75586. */
  75587. export class TargetCamera extends Camera {
  75588. private static _RigCamTransformMatrix;
  75589. private static _TargetTransformMatrix;
  75590. private static _TargetFocalPoint;
  75591. /**
  75592. * Define the current direction the camera is moving to
  75593. */
  75594. cameraDirection: Vector3;
  75595. /**
  75596. * Define the current rotation the camera is rotating to
  75597. */
  75598. cameraRotation: Vector2;
  75599. /**
  75600. * When set, the up vector of the camera will be updated by the rotation of the camera
  75601. */
  75602. updateUpVectorFromRotation: boolean;
  75603. private _tmpQuaternion;
  75604. /**
  75605. * Define the current rotation of the camera
  75606. */
  75607. rotation: Vector3;
  75608. /**
  75609. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75610. */
  75611. rotationQuaternion: Quaternion;
  75612. /**
  75613. * Define the current speed of the camera
  75614. */
  75615. speed: number;
  75616. /**
  75617. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75618. * around all axis.
  75619. */
  75620. noRotationConstraint: boolean;
  75621. /**
  75622. * Define the current target of the camera as an object or a position.
  75623. */
  75624. lockedTarget: any;
  75625. /** @hidden */
  75626. _currentTarget: Vector3;
  75627. /** @hidden */
  75628. _initialFocalDistance: number;
  75629. /** @hidden */
  75630. _viewMatrix: Matrix;
  75631. /** @hidden */
  75632. _camMatrix: Matrix;
  75633. /** @hidden */
  75634. _cameraTransformMatrix: Matrix;
  75635. /** @hidden */
  75636. _cameraRotationMatrix: Matrix;
  75637. /** @hidden */
  75638. _referencePoint: Vector3;
  75639. /** @hidden */
  75640. _transformedReferencePoint: Vector3;
  75641. protected _globalCurrentTarget: Vector3;
  75642. protected _globalCurrentUpVector: Vector3;
  75643. /** @hidden */
  75644. _reset: () => void;
  75645. private _defaultUp;
  75646. /**
  75647. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75648. * This is the base of the follow, arc rotate cameras and Free camera
  75649. * @see http://doc.babylonjs.com/features/cameras
  75650. * @param name Defines the name of the camera in the scene
  75651. * @param position Defines the start position of the camera in the scene
  75652. * @param scene Defines the scene the camera belongs to
  75653. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75654. */
  75655. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75656. /**
  75657. * Gets the position in front of the camera at a given distance.
  75658. * @param distance The distance from the camera we want the position to be
  75659. * @returns the position
  75660. */
  75661. getFrontPosition(distance: number): Vector3;
  75662. /** @hidden */
  75663. _getLockedTargetPosition(): Nullable<Vector3>;
  75664. private _storedPosition;
  75665. private _storedRotation;
  75666. private _storedRotationQuaternion;
  75667. /**
  75668. * Store current camera state of the camera (fov, position, rotation, etc..)
  75669. * @returns the camera
  75670. */
  75671. storeState(): Camera;
  75672. /**
  75673. * Restored camera state. You must call storeState() first
  75674. * @returns whether it was successful or not
  75675. * @hidden
  75676. */
  75677. _restoreStateValues(): boolean;
  75678. /** @hidden */
  75679. _initCache(): void;
  75680. /** @hidden */
  75681. _updateCache(ignoreParentClass?: boolean): void;
  75682. /** @hidden */
  75683. _isSynchronizedViewMatrix(): boolean;
  75684. /** @hidden */
  75685. _computeLocalCameraSpeed(): number;
  75686. /**
  75687. * Defines the target the camera should look at.
  75688. * @param target Defines the new target as a Vector or a mesh
  75689. */
  75690. setTarget(target: Vector3): void;
  75691. /**
  75692. * Return the current target position of the camera. This value is expressed in local space.
  75693. * @returns the target position
  75694. */
  75695. getTarget(): Vector3;
  75696. /** @hidden */
  75697. _decideIfNeedsToMove(): boolean;
  75698. /** @hidden */
  75699. _updatePosition(): void;
  75700. /** @hidden */
  75701. _checkInputs(): void;
  75702. protected _updateCameraRotationMatrix(): void;
  75703. /**
  75704. * 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)
  75705. * @returns the current camera
  75706. */
  75707. private _rotateUpVectorWithCameraRotationMatrix;
  75708. private _cachedRotationZ;
  75709. private _cachedQuaternionRotationZ;
  75710. /** @hidden */
  75711. _getViewMatrix(): Matrix;
  75712. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75713. /**
  75714. * @hidden
  75715. */
  75716. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75717. /**
  75718. * @hidden
  75719. */
  75720. _updateRigCameras(): void;
  75721. private _getRigCamPositionAndTarget;
  75722. /**
  75723. * Gets the current object class name.
  75724. * @return the class name
  75725. */
  75726. getClassName(): string;
  75727. }
  75728. }
  75729. declare module BABYLON {
  75730. /**
  75731. * Gather the list of keyboard event types as constants.
  75732. */
  75733. export class KeyboardEventTypes {
  75734. /**
  75735. * The keydown event is fired when a key becomes active (pressed).
  75736. */
  75737. static readonly KEYDOWN: number;
  75738. /**
  75739. * The keyup event is fired when a key has been released.
  75740. */
  75741. static readonly KEYUP: number;
  75742. }
  75743. /**
  75744. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75745. */
  75746. export class KeyboardInfo {
  75747. /**
  75748. * Defines the type of event (KeyboardEventTypes)
  75749. */
  75750. type: number;
  75751. /**
  75752. * Defines the related dom event
  75753. */
  75754. event: KeyboardEvent;
  75755. /**
  75756. * Instantiates a new keyboard info.
  75757. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75758. * @param type Defines the type of event (KeyboardEventTypes)
  75759. * @param event Defines the related dom event
  75760. */
  75761. constructor(
  75762. /**
  75763. * Defines the type of event (KeyboardEventTypes)
  75764. */
  75765. type: number,
  75766. /**
  75767. * Defines the related dom event
  75768. */
  75769. event: KeyboardEvent);
  75770. }
  75771. /**
  75772. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75773. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75774. */
  75775. export class KeyboardInfoPre extends KeyboardInfo {
  75776. /**
  75777. * Defines the type of event (KeyboardEventTypes)
  75778. */
  75779. type: number;
  75780. /**
  75781. * Defines the related dom event
  75782. */
  75783. event: KeyboardEvent;
  75784. /**
  75785. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75786. */
  75787. skipOnPointerObservable: boolean;
  75788. /**
  75789. * Instantiates a new keyboard pre info.
  75790. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75791. * @param type Defines the type of event (KeyboardEventTypes)
  75792. * @param event Defines the related dom event
  75793. */
  75794. constructor(
  75795. /**
  75796. * Defines the type of event (KeyboardEventTypes)
  75797. */
  75798. type: number,
  75799. /**
  75800. * Defines the related dom event
  75801. */
  75802. event: KeyboardEvent);
  75803. }
  75804. }
  75805. declare module BABYLON {
  75806. /**
  75807. * Manage the keyboard inputs to control the movement of a free camera.
  75808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75809. */
  75810. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75811. /**
  75812. * Defines the camera the input is attached to.
  75813. */
  75814. camera: FreeCamera;
  75815. /**
  75816. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75817. */
  75818. keysUp: number[];
  75819. /**
  75820. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75821. */
  75822. keysDown: number[];
  75823. /**
  75824. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75825. */
  75826. keysLeft: number[];
  75827. /**
  75828. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75829. */
  75830. keysRight: number[];
  75831. private _keys;
  75832. private _onCanvasBlurObserver;
  75833. private _onKeyboardObserver;
  75834. private _engine;
  75835. private _scene;
  75836. /**
  75837. * Attach the input controls to a specific dom element to get the input from.
  75838. * @param element Defines the element the controls should be listened from
  75839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75840. */
  75841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75842. /**
  75843. * Detach the current controls from the specified dom element.
  75844. * @param element Defines the element to stop listening the inputs from
  75845. */
  75846. detachControl(element: Nullable<HTMLElement>): void;
  75847. /**
  75848. * Update the current camera state depending on the inputs that have been used this frame.
  75849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75850. */
  75851. checkInputs(): void;
  75852. /**
  75853. * Gets the class name of the current intput.
  75854. * @returns the class name
  75855. */
  75856. getClassName(): string;
  75857. /** @hidden */
  75858. _onLostFocus(): void;
  75859. /**
  75860. * Get the friendly name associated with the input class.
  75861. * @returns the input friendly name
  75862. */
  75863. getSimpleName(): string;
  75864. }
  75865. }
  75866. declare module BABYLON {
  75867. /**
  75868. * Interface describing all the common properties and methods a shadow light needs to implement.
  75869. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75870. * as well as binding the different shadow properties to the effects.
  75871. */
  75872. export interface IShadowLight extends Light {
  75873. /**
  75874. * The light id in the scene (used in scene.findLighById for instance)
  75875. */
  75876. id: string;
  75877. /**
  75878. * The position the shdow will be casted from.
  75879. */
  75880. position: Vector3;
  75881. /**
  75882. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75883. */
  75884. direction: Vector3;
  75885. /**
  75886. * The transformed position. Position of the light in world space taking parenting in account.
  75887. */
  75888. transformedPosition: Vector3;
  75889. /**
  75890. * The transformed direction. Direction of the light in world space taking parenting in account.
  75891. */
  75892. transformedDirection: Vector3;
  75893. /**
  75894. * The friendly name of the light in the scene.
  75895. */
  75896. name: string;
  75897. /**
  75898. * Defines the shadow projection clipping minimum z value.
  75899. */
  75900. shadowMinZ: number;
  75901. /**
  75902. * Defines the shadow projection clipping maximum z value.
  75903. */
  75904. shadowMaxZ: number;
  75905. /**
  75906. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75907. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75908. */
  75909. computeTransformedInformation(): boolean;
  75910. /**
  75911. * Gets the scene the light belongs to.
  75912. * @returns The scene
  75913. */
  75914. getScene(): Scene;
  75915. /**
  75916. * Callback defining a custom Projection Matrix Builder.
  75917. * This can be used to override the default projection matrix computation.
  75918. */
  75919. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75920. /**
  75921. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75922. * @param matrix The materix to updated with the projection information
  75923. * @param viewMatrix The transform matrix of the light
  75924. * @param renderList The list of mesh to render in the map
  75925. * @returns The current light
  75926. */
  75927. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75928. /**
  75929. * Gets the current depth scale used in ESM.
  75930. * @returns The scale
  75931. */
  75932. getDepthScale(): number;
  75933. /**
  75934. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75935. * @returns true if a cube texture needs to be use
  75936. */
  75937. needCube(): boolean;
  75938. /**
  75939. * Detects if the projection matrix requires to be recomputed this frame.
  75940. * @returns true if it requires to be recomputed otherwise, false.
  75941. */
  75942. needProjectionMatrixCompute(): boolean;
  75943. /**
  75944. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75945. */
  75946. forceProjectionMatrixCompute(): void;
  75947. /**
  75948. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75949. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75950. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75951. */
  75952. getShadowDirection(faceIndex?: number): Vector3;
  75953. /**
  75954. * Gets the minZ used for shadow according to both the scene and the light.
  75955. * @param activeCamera The camera we are returning the min for
  75956. * @returns the depth min z
  75957. */
  75958. getDepthMinZ(activeCamera: Camera): number;
  75959. /**
  75960. * Gets the maxZ used for shadow according to both the scene and the light.
  75961. * @param activeCamera The camera we are returning the max for
  75962. * @returns the depth max z
  75963. */
  75964. getDepthMaxZ(activeCamera: Camera): number;
  75965. }
  75966. /**
  75967. * Base implementation IShadowLight
  75968. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75969. */
  75970. export abstract class ShadowLight extends Light implements IShadowLight {
  75971. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75972. protected _position: Vector3;
  75973. protected _setPosition(value: Vector3): void;
  75974. /**
  75975. * Sets the position the shadow will be casted from. Also use as the light position for both
  75976. * point and spot lights.
  75977. */
  75978. /**
  75979. * Sets the position the shadow will be casted from. Also use as the light position for both
  75980. * point and spot lights.
  75981. */
  75982. position: Vector3;
  75983. protected _direction: Vector3;
  75984. protected _setDirection(value: Vector3): void;
  75985. /**
  75986. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75987. * Also use as the light direction on spot and directional lights.
  75988. */
  75989. /**
  75990. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75991. * Also use as the light direction on spot and directional lights.
  75992. */
  75993. direction: Vector3;
  75994. private _shadowMinZ;
  75995. /**
  75996. * Gets the shadow projection clipping minimum z value.
  75997. */
  75998. /**
  75999. * Sets the shadow projection clipping minimum z value.
  76000. */
  76001. shadowMinZ: number;
  76002. private _shadowMaxZ;
  76003. /**
  76004. * Sets the shadow projection clipping maximum z value.
  76005. */
  76006. /**
  76007. * Gets the shadow projection clipping maximum z value.
  76008. */
  76009. shadowMaxZ: number;
  76010. /**
  76011. * Callback defining a custom Projection Matrix Builder.
  76012. * This can be used to override the default projection matrix computation.
  76013. */
  76014. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76015. /**
  76016. * The transformed position. Position of the light in world space taking parenting in account.
  76017. */
  76018. transformedPosition: Vector3;
  76019. /**
  76020. * The transformed direction. Direction of the light in world space taking parenting in account.
  76021. */
  76022. transformedDirection: Vector3;
  76023. private _needProjectionMatrixCompute;
  76024. /**
  76025. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76026. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76027. */
  76028. computeTransformedInformation(): boolean;
  76029. /**
  76030. * Return the depth scale used for the shadow map.
  76031. * @returns the depth scale.
  76032. */
  76033. getDepthScale(): number;
  76034. /**
  76035. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76036. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76037. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76038. */
  76039. getShadowDirection(faceIndex?: number): Vector3;
  76040. /**
  76041. * Returns the ShadowLight absolute position in the World.
  76042. * @returns the position vector in world space
  76043. */
  76044. getAbsolutePosition(): Vector3;
  76045. /**
  76046. * Sets the ShadowLight direction toward the passed target.
  76047. * @param target The point to target in local space
  76048. * @returns the updated ShadowLight direction
  76049. */
  76050. setDirectionToTarget(target: Vector3): Vector3;
  76051. /**
  76052. * Returns the light rotation in euler definition.
  76053. * @returns the x y z rotation in local space.
  76054. */
  76055. getRotation(): Vector3;
  76056. /**
  76057. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76058. * @returns true if a cube texture needs to be use
  76059. */
  76060. needCube(): boolean;
  76061. /**
  76062. * Detects if the projection matrix requires to be recomputed this frame.
  76063. * @returns true if it requires to be recomputed otherwise, false.
  76064. */
  76065. needProjectionMatrixCompute(): boolean;
  76066. /**
  76067. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76068. */
  76069. forceProjectionMatrixCompute(): void;
  76070. /** @hidden */
  76071. _initCache(): void;
  76072. /** @hidden */
  76073. _isSynchronized(): boolean;
  76074. /**
  76075. * Computes the world matrix of the node
  76076. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76077. * @returns the world matrix
  76078. */
  76079. computeWorldMatrix(force?: boolean): Matrix;
  76080. /**
  76081. * Gets the minZ used for shadow according to both the scene and the light.
  76082. * @param activeCamera The camera we are returning the min for
  76083. * @returns the depth min z
  76084. */
  76085. getDepthMinZ(activeCamera: Camera): number;
  76086. /**
  76087. * Gets the maxZ used for shadow according to both the scene and the light.
  76088. * @param activeCamera The camera we are returning the max for
  76089. * @returns the depth max z
  76090. */
  76091. getDepthMaxZ(activeCamera: Camera): number;
  76092. /**
  76093. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76094. * @param matrix The materix to updated with the projection information
  76095. * @param viewMatrix The transform matrix of the light
  76096. * @param renderList The list of mesh to render in the map
  76097. * @returns The current light
  76098. */
  76099. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76100. }
  76101. }
  76102. declare module BABYLON {
  76103. /**
  76104. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76105. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76106. */
  76107. export class EffectFallbacks implements IEffectFallbacks {
  76108. private _defines;
  76109. private _currentRank;
  76110. private _maxRank;
  76111. private _mesh;
  76112. /**
  76113. * Removes the fallback from the bound mesh.
  76114. */
  76115. unBindMesh(): void;
  76116. /**
  76117. * Adds a fallback on the specified property.
  76118. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76119. * @param define The name of the define in the shader
  76120. */
  76121. addFallback(rank: number, define: string): void;
  76122. /**
  76123. * Sets the mesh to use CPU skinning when needing to fallback.
  76124. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76125. * @param mesh The mesh to use the fallbacks.
  76126. */
  76127. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76128. /**
  76129. * Checks to see if more fallbacks are still availible.
  76130. */
  76131. readonly hasMoreFallbacks: boolean;
  76132. /**
  76133. * Removes the defines that should be removed when falling back.
  76134. * @param currentDefines defines the current define statements for the shader.
  76135. * @param effect defines the current effect we try to compile
  76136. * @returns The resulting defines with defines of the current rank removed.
  76137. */
  76138. reduce(currentDefines: string, effect: Effect): string;
  76139. }
  76140. }
  76141. declare module BABYLON {
  76142. /**
  76143. * "Static Class" containing the most commonly used helper while dealing with material for
  76144. * rendering purpose.
  76145. *
  76146. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76147. *
  76148. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76149. */
  76150. export class MaterialHelper {
  76151. /**
  76152. * Bind the current view position to an effect.
  76153. * @param effect The effect to be bound
  76154. * @param scene The scene the eyes position is used from
  76155. */
  76156. static BindEyePosition(effect: Effect, scene: Scene): void;
  76157. /**
  76158. * Helps preparing the defines values about the UVs in used in the effect.
  76159. * UVs are shared as much as we can accross channels in the shaders.
  76160. * @param texture The texture we are preparing the UVs for
  76161. * @param defines The defines to update
  76162. * @param key The channel key "diffuse", "specular"... used in the shader
  76163. */
  76164. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76165. /**
  76166. * Binds a texture matrix value to its corrsponding uniform
  76167. * @param texture The texture to bind the matrix for
  76168. * @param uniformBuffer The uniform buffer receivin the data
  76169. * @param key The channel key "diffuse", "specular"... used in the shader
  76170. */
  76171. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76172. /**
  76173. * Gets the current status of the fog (should it be enabled?)
  76174. * @param mesh defines the mesh to evaluate for fog support
  76175. * @param scene defines the hosting scene
  76176. * @returns true if fog must be enabled
  76177. */
  76178. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76179. /**
  76180. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76181. * @param mesh defines the current mesh
  76182. * @param scene defines the current scene
  76183. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76184. * @param pointsCloud defines if point cloud rendering has to be turned on
  76185. * @param fogEnabled defines if fog has to be turned on
  76186. * @param alphaTest defines if alpha testing has to be turned on
  76187. * @param defines defines the current list of defines
  76188. */
  76189. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76190. /**
  76191. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76192. * @param scene defines the current scene
  76193. * @param engine defines the current engine
  76194. * @param defines specifies the list of active defines
  76195. * @param useInstances defines if instances have to be turned on
  76196. * @param useClipPlane defines if clip plane have to be turned on
  76197. */
  76198. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76199. /**
  76200. * Prepares the defines for bones
  76201. * @param mesh The mesh containing the geometry data we will draw
  76202. * @param defines The defines to update
  76203. */
  76204. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76205. /**
  76206. * Prepares the defines for morph targets
  76207. * @param mesh The mesh containing the geometry data we will draw
  76208. * @param defines The defines to update
  76209. */
  76210. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76211. /**
  76212. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76213. * @param mesh The mesh containing the geometry data we will draw
  76214. * @param defines The defines to update
  76215. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76216. * @param useBones Precise whether bones should be used or not (override mesh info)
  76217. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76218. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76219. * @returns false if defines are considered not dirty and have not been checked
  76220. */
  76221. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76222. /**
  76223. * Prepares the defines related to multiview
  76224. * @param scene The scene we are intending to draw
  76225. * @param defines The defines to update
  76226. */
  76227. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76228. /**
  76229. * Prepares the defines related to the light information passed in parameter
  76230. * @param scene The scene we are intending to draw
  76231. * @param mesh The mesh the effect is compiling for
  76232. * @param light The light the effect is compiling for
  76233. * @param lightIndex The index of the light
  76234. * @param defines The defines to update
  76235. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76236. * @param state Defines the current state regarding what is needed (normals, etc...)
  76237. */
  76238. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76239. needNormals: boolean;
  76240. needRebuild: boolean;
  76241. shadowEnabled: boolean;
  76242. specularEnabled: boolean;
  76243. lightmapMode: boolean;
  76244. }): void;
  76245. /**
  76246. * Prepares the defines related to the light information passed in parameter
  76247. * @param scene The scene we are intending to draw
  76248. * @param mesh The mesh the effect is compiling for
  76249. * @param defines The defines to update
  76250. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76251. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76252. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76253. * @returns true if normals will be required for the rest of the effect
  76254. */
  76255. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76256. /**
  76257. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76258. * @param lightIndex defines the light index
  76259. * @param uniformsList The uniform list
  76260. * @param samplersList The sampler list
  76261. * @param projectedLightTexture defines if projected texture must be used
  76262. * @param uniformBuffersList defines an optional list of uniform buffers
  76263. */
  76264. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76265. /**
  76266. * Prepares the uniforms and samplers list to be used in the effect
  76267. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76268. * @param samplersList The sampler list
  76269. * @param defines The defines helping in the list generation
  76270. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76271. */
  76272. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76273. /**
  76274. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76275. * @param defines The defines to update while falling back
  76276. * @param fallbacks The authorized effect fallbacks
  76277. * @param maxSimultaneousLights The maximum number of lights allowed
  76278. * @param rank the current rank of the Effect
  76279. * @returns The newly affected rank
  76280. */
  76281. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76282. private static _TmpMorphInfluencers;
  76283. /**
  76284. * Prepares the list of attributes required for morph targets according to the effect defines.
  76285. * @param attribs The current list of supported attribs
  76286. * @param mesh The mesh to prepare the morph targets attributes for
  76287. * @param influencers The number of influencers
  76288. */
  76289. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76290. /**
  76291. * Prepares the list of attributes required for morph targets according to the effect defines.
  76292. * @param attribs The current list of supported attribs
  76293. * @param mesh The mesh to prepare the morph targets attributes for
  76294. * @param defines The current Defines of the effect
  76295. */
  76296. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76297. /**
  76298. * Prepares the list of attributes required for bones according to the effect defines.
  76299. * @param attribs The current list of supported attribs
  76300. * @param mesh The mesh to prepare the bones attributes for
  76301. * @param defines The current Defines of the effect
  76302. * @param fallbacks The current efffect fallback strategy
  76303. */
  76304. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76305. /**
  76306. * Check and prepare the list of attributes required for instances according to the effect defines.
  76307. * @param attribs The current list of supported attribs
  76308. * @param defines The current MaterialDefines of the effect
  76309. */
  76310. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76311. /**
  76312. * Add the list of attributes required for instances to the attribs array.
  76313. * @param attribs The current list of supported attribs
  76314. */
  76315. static PushAttributesForInstances(attribs: string[]): void;
  76316. /**
  76317. * Binds the light information to the effect.
  76318. * @param light The light containing the generator
  76319. * @param effect The effect we are binding the data to
  76320. * @param lightIndex The light index in the effect used to render
  76321. */
  76322. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76323. /**
  76324. * Binds the lights information from the scene to the effect for the given mesh.
  76325. * @param light Light to bind
  76326. * @param lightIndex Light index
  76327. * @param scene The scene where the light belongs to
  76328. * @param effect The effect we are binding the data to
  76329. * @param useSpecular Defines if specular is supported
  76330. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76331. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76332. */
  76333. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76334. /**
  76335. * Binds the lights information from the scene to the effect for the given mesh.
  76336. * @param scene The scene the lights belongs to
  76337. * @param mesh The mesh we are binding the information to render
  76338. * @param effect The effect we are binding the data to
  76339. * @param defines The generated defines for the effect
  76340. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76341. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76343. */
  76344. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76345. private static _tempFogColor;
  76346. /**
  76347. * Binds the fog information from the scene to the effect for the given mesh.
  76348. * @param scene The scene the lights belongs to
  76349. * @param mesh The mesh we are binding the information to render
  76350. * @param effect The effect we are binding the data to
  76351. * @param linearSpace Defines if the fog effect is applied in linear space
  76352. */
  76353. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76354. /**
  76355. * Binds the bones information from the mesh to the effect.
  76356. * @param mesh The mesh we are binding the information to render
  76357. * @param effect The effect we are binding the data to
  76358. */
  76359. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76360. /**
  76361. * Binds the morph targets information from the mesh to the effect.
  76362. * @param abstractMesh The mesh we are binding the information to render
  76363. * @param effect The effect we are binding the data to
  76364. */
  76365. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76366. /**
  76367. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76368. * @param defines The generated defines used in the effect
  76369. * @param effect The effect we are binding the data to
  76370. * @param scene The scene we are willing to render with logarithmic scale for
  76371. */
  76372. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76373. /**
  76374. * Binds the clip plane information from the scene to the effect.
  76375. * @param scene The scene the clip plane information are extracted from
  76376. * @param effect The effect we are binding the data to
  76377. */
  76378. static BindClipPlane(effect: Effect, scene: Scene): void;
  76379. }
  76380. }
  76381. declare module BABYLON {
  76382. /** @hidden */
  76383. export var packingFunctions: {
  76384. name: string;
  76385. shader: string;
  76386. };
  76387. }
  76388. declare module BABYLON {
  76389. /** @hidden */
  76390. export var shadowMapPixelShader: {
  76391. name: string;
  76392. shader: string;
  76393. };
  76394. }
  76395. declare module BABYLON {
  76396. /** @hidden */
  76397. export var bonesDeclaration: {
  76398. name: string;
  76399. shader: string;
  76400. };
  76401. }
  76402. declare module BABYLON {
  76403. /** @hidden */
  76404. export var morphTargetsVertexGlobalDeclaration: {
  76405. name: string;
  76406. shader: string;
  76407. };
  76408. }
  76409. declare module BABYLON {
  76410. /** @hidden */
  76411. export var morphTargetsVertexDeclaration: {
  76412. name: string;
  76413. shader: string;
  76414. };
  76415. }
  76416. declare module BABYLON {
  76417. /** @hidden */
  76418. export var instancesDeclaration: {
  76419. name: string;
  76420. shader: string;
  76421. };
  76422. }
  76423. declare module BABYLON {
  76424. /** @hidden */
  76425. export var helperFunctions: {
  76426. name: string;
  76427. shader: string;
  76428. };
  76429. }
  76430. declare module BABYLON {
  76431. /** @hidden */
  76432. export var morphTargetsVertex: {
  76433. name: string;
  76434. shader: string;
  76435. };
  76436. }
  76437. declare module BABYLON {
  76438. /** @hidden */
  76439. export var instancesVertex: {
  76440. name: string;
  76441. shader: string;
  76442. };
  76443. }
  76444. declare module BABYLON {
  76445. /** @hidden */
  76446. export var bonesVertex: {
  76447. name: string;
  76448. shader: string;
  76449. };
  76450. }
  76451. declare module BABYLON {
  76452. /** @hidden */
  76453. export var shadowMapVertexShader: {
  76454. name: string;
  76455. shader: string;
  76456. };
  76457. }
  76458. declare module BABYLON {
  76459. /** @hidden */
  76460. export var depthBoxBlurPixelShader: {
  76461. name: string;
  76462. shader: string;
  76463. };
  76464. }
  76465. declare module BABYLON {
  76466. /**
  76467. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76468. */
  76469. export interface ICustomShaderOptions {
  76470. /**
  76471. * Gets or sets the custom shader name to use
  76472. */
  76473. shaderName: string;
  76474. /**
  76475. * The list of attribute names used in the shader
  76476. */
  76477. attributes?: string[];
  76478. /**
  76479. * The list of unifrom names used in the shader
  76480. */
  76481. uniforms?: string[];
  76482. /**
  76483. * The list of sampler names used in the shader
  76484. */
  76485. samplers?: string[];
  76486. /**
  76487. * The list of defines used in the shader
  76488. */
  76489. defines?: string[];
  76490. }
  76491. /**
  76492. * Interface to implement to create a shadow generator compatible with BJS.
  76493. */
  76494. export interface IShadowGenerator {
  76495. /**
  76496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76497. * @returns The render target texture if present otherwise, null
  76498. */
  76499. getShadowMap(): Nullable<RenderTargetTexture>;
  76500. /**
  76501. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76502. * @returns The render target texture if the shadow map is present otherwise, null
  76503. */
  76504. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76505. /**
  76506. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76507. * @param subMesh The submesh we want to render in the shadow map
  76508. * @param useInstances Defines wether will draw in the map using instances
  76509. * @returns true if ready otherwise, false
  76510. */
  76511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76512. /**
  76513. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76514. * @param defines Defines of the material we want to update
  76515. * @param lightIndex Index of the light in the enabled light list of the material
  76516. */
  76517. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76518. /**
  76519. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76520. * defined in the generator but impacting the effect).
  76521. * It implies the unifroms available on the materials are the standard BJS ones.
  76522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76523. * @param effect The effect we are binfing the information for
  76524. */
  76525. bindShadowLight(lightIndex: string, effect: Effect): void;
  76526. /**
  76527. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76528. * (eq to shadow prjection matrix * light transform matrix)
  76529. * @returns The transform matrix used to create the shadow map
  76530. */
  76531. getTransformMatrix(): Matrix;
  76532. /**
  76533. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76534. * Cube and 2D textures for instance.
  76535. */
  76536. recreateShadowMap(): void;
  76537. /**
  76538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76539. * @param onCompiled Callback triggered at the and of the effects compilation
  76540. * @param options Sets of optional options forcing the compilation with different modes
  76541. */
  76542. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76543. useInstances: boolean;
  76544. }>): void;
  76545. /**
  76546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76547. * @param options Sets of optional options forcing the compilation with different modes
  76548. * @returns A promise that resolves when the compilation completes
  76549. */
  76550. forceCompilationAsync(options?: Partial<{
  76551. useInstances: boolean;
  76552. }>): Promise<void>;
  76553. /**
  76554. * Serializes the shadow generator setup to a json object.
  76555. * @returns The serialized JSON object
  76556. */
  76557. serialize(): any;
  76558. /**
  76559. * Disposes the Shadow map and related Textures and effects.
  76560. */
  76561. dispose(): void;
  76562. }
  76563. /**
  76564. * Default implementation IShadowGenerator.
  76565. * This is the main object responsible of generating shadows in the framework.
  76566. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76567. */
  76568. export class ShadowGenerator implements IShadowGenerator {
  76569. /**
  76570. * Shadow generator mode None: no filtering applied.
  76571. */
  76572. static readonly FILTER_NONE: number;
  76573. /**
  76574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76576. */
  76577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76578. /**
  76579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76581. */
  76582. static readonly FILTER_POISSONSAMPLING: number;
  76583. /**
  76584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76586. */
  76587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76588. /**
  76589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76590. * edge artifacts on steep falloff.
  76591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76592. */
  76593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76594. /**
  76595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76596. * edge artifacts on steep falloff.
  76597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76598. */
  76599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76600. /**
  76601. * Shadow generator mode PCF: Percentage Closer Filtering
  76602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76604. */
  76605. static readonly FILTER_PCF: number;
  76606. /**
  76607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76609. * Contact Hardening
  76610. */
  76611. static readonly FILTER_PCSS: number;
  76612. /**
  76613. * Reserved for PCF and PCSS
  76614. * Highest Quality.
  76615. *
  76616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76617. *
  76618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76619. */
  76620. static readonly QUALITY_HIGH: number;
  76621. /**
  76622. * Reserved for PCF and PCSS
  76623. * Good tradeoff for quality/perf cross devices
  76624. *
  76625. * Execute PCF on a 3*3 kernel.
  76626. *
  76627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76628. */
  76629. static readonly QUALITY_MEDIUM: number;
  76630. /**
  76631. * Reserved for PCF and PCSS
  76632. * The lowest quality but the fastest.
  76633. *
  76634. * Execute PCF on a 1*1 kernel.
  76635. *
  76636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76637. */
  76638. static readonly QUALITY_LOW: number;
  76639. /** Gets or sets the custom shader name to use */
  76640. customShaderOptions: ICustomShaderOptions;
  76641. /**
  76642. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76643. */
  76644. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76645. /**
  76646. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76647. */
  76648. onAfterShadowMapRenderObservable: Observable<Effect>;
  76649. /**
  76650. * Observable triggered before a mesh is rendered in the shadow map.
  76651. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76652. */
  76653. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76654. /**
  76655. * Observable triggered after a mesh is rendered in the shadow map.
  76656. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76657. */
  76658. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76659. private _bias;
  76660. /**
  76661. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76662. */
  76663. /**
  76664. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76665. */
  76666. bias: number;
  76667. private _normalBias;
  76668. /**
  76669. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76670. */
  76671. /**
  76672. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76673. */
  76674. normalBias: number;
  76675. private _blurBoxOffset;
  76676. /**
  76677. * Gets the blur box offset: offset applied during the blur pass.
  76678. * Only useful if useKernelBlur = false
  76679. */
  76680. /**
  76681. * Sets the blur box offset: offset applied during the blur pass.
  76682. * Only useful if useKernelBlur = false
  76683. */
  76684. blurBoxOffset: number;
  76685. private _blurScale;
  76686. /**
  76687. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76688. * 2 means half of the size.
  76689. */
  76690. /**
  76691. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76692. * 2 means half of the size.
  76693. */
  76694. blurScale: number;
  76695. private _blurKernel;
  76696. /**
  76697. * Gets the blur kernel: kernel size of the blur pass.
  76698. * Only useful if useKernelBlur = true
  76699. */
  76700. /**
  76701. * Sets the blur kernel: kernel size of the blur pass.
  76702. * Only useful if useKernelBlur = true
  76703. */
  76704. blurKernel: number;
  76705. private _useKernelBlur;
  76706. /**
  76707. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76708. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76709. */
  76710. /**
  76711. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76712. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76713. */
  76714. useKernelBlur: boolean;
  76715. private _depthScale;
  76716. /**
  76717. * Gets the depth scale used in ESM mode.
  76718. */
  76719. /**
  76720. * Sets the depth scale used in ESM mode.
  76721. * This can override the scale stored on the light.
  76722. */
  76723. depthScale: number;
  76724. private _filter;
  76725. /**
  76726. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76727. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76728. */
  76729. /**
  76730. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76731. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76732. */
  76733. filter: number;
  76734. /**
  76735. * Gets if the current filter is set to Poisson Sampling.
  76736. */
  76737. /**
  76738. * Sets the current filter to Poisson Sampling.
  76739. */
  76740. usePoissonSampling: boolean;
  76741. /**
  76742. * Gets if the current filter is set to ESM.
  76743. */
  76744. /**
  76745. * Sets the current filter is to ESM.
  76746. */
  76747. useExponentialShadowMap: boolean;
  76748. /**
  76749. * Gets if the current filter is set to filtered ESM.
  76750. */
  76751. /**
  76752. * Gets if the current filter is set to filtered ESM.
  76753. */
  76754. useBlurExponentialShadowMap: boolean;
  76755. /**
  76756. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76757. * exponential to prevent steep falloff artifacts).
  76758. */
  76759. /**
  76760. * Sets the current filter to "close ESM" (using the inverse of the
  76761. * exponential to prevent steep falloff artifacts).
  76762. */
  76763. useCloseExponentialShadowMap: boolean;
  76764. /**
  76765. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76766. * exponential to prevent steep falloff artifacts).
  76767. */
  76768. /**
  76769. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76770. * exponential to prevent steep falloff artifacts).
  76771. */
  76772. useBlurCloseExponentialShadowMap: boolean;
  76773. /**
  76774. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76775. */
  76776. /**
  76777. * Sets the current filter to "PCF" (percentage closer filtering).
  76778. */
  76779. usePercentageCloserFiltering: boolean;
  76780. private _filteringQuality;
  76781. /**
  76782. * Gets the PCF or PCSS Quality.
  76783. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76784. */
  76785. /**
  76786. * Sets the PCF or PCSS Quality.
  76787. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76788. */
  76789. filteringQuality: number;
  76790. /**
  76791. * Gets if the current filter is set to "PCSS" (contact hardening).
  76792. */
  76793. /**
  76794. * Sets the current filter to "PCSS" (contact hardening).
  76795. */
  76796. useContactHardeningShadow: boolean;
  76797. private _contactHardeningLightSizeUVRatio;
  76798. /**
  76799. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76800. * Using a ratio helps keeping shape stability independently of the map size.
  76801. *
  76802. * It does not account for the light projection as it was having too much
  76803. * instability during the light setup or during light position changes.
  76804. *
  76805. * Only valid if useContactHardeningShadow is true.
  76806. */
  76807. /**
  76808. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76809. * Using a ratio helps keeping shape stability independently of the map size.
  76810. *
  76811. * It does not account for the light projection as it was having too much
  76812. * instability during the light setup or during light position changes.
  76813. *
  76814. * Only valid if useContactHardeningShadow is true.
  76815. */
  76816. contactHardeningLightSizeUVRatio: number;
  76817. private _darkness;
  76818. /** Gets or sets the actual darkness of a shadow */
  76819. darkness: number;
  76820. /**
  76821. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76822. * 0 means strongest and 1 would means no shadow.
  76823. * @returns the darkness.
  76824. */
  76825. getDarkness(): number;
  76826. /**
  76827. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76828. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76829. * @returns the shadow generator allowing fluent coding.
  76830. */
  76831. setDarkness(darkness: number): ShadowGenerator;
  76832. private _transparencyShadow;
  76833. /** Gets or sets the ability to have transparent shadow */
  76834. transparencyShadow: boolean;
  76835. /**
  76836. * Sets the ability to have transparent shadow (boolean).
  76837. * @param transparent True if transparent else False
  76838. * @returns the shadow generator allowing fluent coding
  76839. */
  76840. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76841. private _shadowMap;
  76842. private _shadowMap2;
  76843. /**
  76844. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76845. * @returns The render target texture if present otherwise, null
  76846. */
  76847. getShadowMap(): Nullable<RenderTargetTexture>;
  76848. /**
  76849. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76850. * @returns The render target texture if the shadow map is present otherwise, null
  76851. */
  76852. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76853. /**
  76854. * Gets the class name of that object
  76855. * @returns "ShadowGenerator"
  76856. */
  76857. getClassName(): string;
  76858. /**
  76859. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76860. * @param mesh Mesh to add
  76861. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76862. * @returns the Shadow Generator itself
  76863. */
  76864. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76865. /**
  76866. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76867. * @param mesh Mesh to remove
  76868. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76869. * @returns the Shadow Generator itself
  76870. */
  76871. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76872. /**
  76873. * Controls the extent to which the shadows fade out at the edge of the frustum
  76874. * Used only by directionals and spots
  76875. */
  76876. frustumEdgeFalloff: number;
  76877. private _light;
  76878. /**
  76879. * Returns the associated light object.
  76880. * @returns the light generating the shadow
  76881. */
  76882. getLight(): IShadowLight;
  76883. /**
  76884. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76885. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76886. * It might on the other hand introduce peter panning.
  76887. */
  76888. forceBackFacesOnly: boolean;
  76889. private _scene;
  76890. private _lightDirection;
  76891. private _effect;
  76892. private _viewMatrix;
  76893. private _projectionMatrix;
  76894. private _transformMatrix;
  76895. private _cachedPosition;
  76896. private _cachedDirection;
  76897. private _cachedDefines;
  76898. private _currentRenderID;
  76899. private _boxBlurPostprocess;
  76900. private _kernelBlurXPostprocess;
  76901. private _kernelBlurYPostprocess;
  76902. private _blurPostProcesses;
  76903. private _mapSize;
  76904. private _currentFaceIndex;
  76905. private _currentFaceIndexCache;
  76906. private _textureType;
  76907. private _defaultTextureMatrix;
  76908. private _storedUniqueId;
  76909. /** @hidden */
  76910. static _SceneComponentInitialization: (scene: Scene) => void;
  76911. /**
  76912. * Creates a ShadowGenerator object.
  76913. * A ShadowGenerator is the required tool to use the shadows.
  76914. * Each light casting shadows needs to use its own ShadowGenerator.
  76915. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76916. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76917. * @param light The light object generating the shadows.
  76918. * @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.
  76919. */
  76920. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76921. private _initializeGenerator;
  76922. private _initializeShadowMap;
  76923. private _initializeBlurRTTAndPostProcesses;
  76924. private _renderForShadowMap;
  76925. private _renderSubMeshForShadowMap;
  76926. private _applyFilterValues;
  76927. /**
  76928. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76929. * @param onCompiled Callback triggered at the and of the effects compilation
  76930. * @param options Sets of optional options forcing the compilation with different modes
  76931. */
  76932. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76933. useInstances: boolean;
  76934. }>): void;
  76935. /**
  76936. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76937. * @param options Sets of optional options forcing the compilation with different modes
  76938. * @returns A promise that resolves when the compilation completes
  76939. */
  76940. forceCompilationAsync(options?: Partial<{
  76941. useInstances: boolean;
  76942. }>): Promise<void>;
  76943. /**
  76944. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76945. * @param subMesh The submesh we want to render in the shadow map
  76946. * @param useInstances Defines wether will draw in the map using instances
  76947. * @returns true if ready otherwise, false
  76948. */
  76949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76950. /**
  76951. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76952. * @param defines Defines of the material we want to update
  76953. * @param lightIndex Index of the light in the enabled light list of the material
  76954. */
  76955. prepareDefines(defines: any, lightIndex: number): void;
  76956. /**
  76957. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76958. * defined in the generator but impacting the effect).
  76959. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76960. * @param effect The effect we are binfing the information for
  76961. */
  76962. bindShadowLight(lightIndex: string, effect: Effect): void;
  76963. /**
  76964. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76965. * (eq to shadow prjection matrix * light transform matrix)
  76966. * @returns The transform matrix used to create the shadow map
  76967. */
  76968. getTransformMatrix(): Matrix;
  76969. /**
  76970. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76971. * Cube and 2D textures for instance.
  76972. */
  76973. recreateShadowMap(): void;
  76974. private _disposeBlurPostProcesses;
  76975. private _disposeRTTandPostProcesses;
  76976. /**
  76977. * Disposes the ShadowGenerator.
  76978. * Returns nothing.
  76979. */
  76980. dispose(): void;
  76981. /**
  76982. * Serializes the shadow generator setup to a json object.
  76983. * @returns The serialized JSON object
  76984. */
  76985. serialize(): any;
  76986. /**
  76987. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76988. * @param parsedShadowGenerator The JSON object to parse
  76989. * @param scene The scene to create the shadow map for
  76990. * @returns The parsed shadow generator
  76991. */
  76992. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76993. }
  76994. }
  76995. declare module BABYLON {
  76996. /**
  76997. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76998. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76999. * 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.
  77000. */
  77001. export abstract class Light extends Node {
  77002. /**
  77003. * Falloff Default: light is falling off following the material specification:
  77004. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77005. */
  77006. static readonly FALLOFF_DEFAULT: number;
  77007. /**
  77008. * Falloff Physical: light is falling off following the inverse squared distance law.
  77009. */
  77010. static readonly FALLOFF_PHYSICAL: number;
  77011. /**
  77012. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77013. * to enhance interoperability with other engines.
  77014. */
  77015. static readonly FALLOFF_GLTF: number;
  77016. /**
  77017. * Falloff Standard: light is falling off like in the standard material
  77018. * to enhance interoperability with other materials.
  77019. */
  77020. static readonly FALLOFF_STANDARD: number;
  77021. /**
  77022. * If every light affecting the material is in this lightmapMode,
  77023. * material.lightmapTexture adds or multiplies
  77024. * (depends on material.useLightmapAsShadowmap)
  77025. * after every other light calculations.
  77026. */
  77027. static readonly LIGHTMAP_DEFAULT: number;
  77028. /**
  77029. * material.lightmapTexture as only diffuse lighting from this light
  77030. * adds only specular lighting from this light
  77031. * adds dynamic shadows
  77032. */
  77033. static readonly LIGHTMAP_SPECULAR: number;
  77034. /**
  77035. * material.lightmapTexture as only lighting
  77036. * no light calculation from this light
  77037. * only adds dynamic shadows from this light
  77038. */
  77039. static readonly LIGHTMAP_SHADOWSONLY: number;
  77040. /**
  77041. * Each light type uses the default quantity according to its type:
  77042. * point/spot lights use luminous intensity
  77043. * directional lights use illuminance
  77044. */
  77045. static readonly INTENSITYMODE_AUTOMATIC: number;
  77046. /**
  77047. * lumen (lm)
  77048. */
  77049. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77050. /**
  77051. * candela (lm/sr)
  77052. */
  77053. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77054. /**
  77055. * lux (lm/m^2)
  77056. */
  77057. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77058. /**
  77059. * nit (cd/m^2)
  77060. */
  77061. static readonly INTENSITYMODE_LUMINANCE: number;
  77062. /**
  77063. * Light type const id of the point light.
  77064. */
  77065. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77066. /**
  77067. * Light type const id of the directional light.
  77068. */
  77069. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77070. /**
  77071. * Light type const id of the spot light.
  77072. */
  77073. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77074. /**
  77075. * Light type const id of the hemispheric light.
  77076. */
  77077. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77078. /**
  77079. * Diffuse gives the basic color to an object.
  77080. */
  77081. diffuse: Color3;
  77082. /**
  77083. * Specular produces a highlight color on an object.
  77084. * Note: This is note affecting PBR materials.
  77085. */
  77086. specular: Color3;
  77087. /**
  77088. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77089. * falling off base on range or angle.
  77090. * This can be set to any values in Light.FALLOFF_x.
  77091. *
  77092. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77093. * other types of materials.
  77094. */
  77095. falloffType: number;
  77096. /**
  77097. * Strength of the light.
  77098. * Note: By default it is define in the framework own unit.
  77099. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77100. */
  77101. intensity: number;
  77102. private _range;
  77103. protected _inverseSquaredRange: number;
  77104. /**
  77105. * Defines how far from the source the light is impacting in scene units.
  77106. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77107. */
  77108. /**
  77109. * Defines how far from the source the light is impacting in scene units.
  77110. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77111. */
  77112. range: number;
  77113. /**
  77114. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77115. * of light.
  77116. */
  77117. private _photometricScale;
  77118. private _intensityMode;
  77119. /**
  77120. * Gets the photometric scale used to interpret the intensity.
  77121. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77122. */
  77123. /**
  77124. * Sets the photometric scale used to interpret the intensity.
  77125. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77126. */
  77127. intensityMode: number;
  77128. private _radius;
  77129. /**
  77130. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77131. */
  77132. /**
  77133. * sets the light radius used by PBR Materials to simulate soft area lights.
  77134. */
  77135. radius: number;
  77136. private _renderPriority;
  77137. /**
  77138. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77139. * exceeding the number allowed of the materials.
  77140. */
  77141. renderPriority: number;
  77142. private _shadowEnabled;
  77143. /**
  77144. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77145. * the current shadow generator.
  77146. */
  77147. /**
  77148. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77149. * the current shadow generator.
  77150. */
  77151. shadowEnabled: boolean;
  77152. private _includedOnlyMeshes;
  77153. /**
  77154. * Gets the only meshes impacted by this light.
  77155. */
  77156. /**
  77157. * Sets the only meshes impacted by this light.
  77158. */
  77159. includedOnlyMeshes: AbstractMesh[];
  77160. private _excludedMeshes;
  77161. /**
  77162. * Gets the meshes not impacted by this light.
  77163. */
  77164. /**
  77165. * Sets the meshes not impacted by this light.
  77166. */
  77167. excludedMeshes: AbstractMesh[];
  77168. private _excludeWithLayerMask;
  77169. /**
  77170. * Gets the layer id use to find what meshes are not impacted by the light.
  77171. * Inactive if 0
  77172. */
  77173. /**
  77174. * Sets the layer id use to find what meshes are not impacted by the light.
  77175. * Inactive if 0
  77176. */
  77177. excludeWithLayerMask: number;
  77178. private _includeOnlyWithLayerMask;
  77179. /**
  77180. * Gets the layer id use to find what meshes are impacted by the light.
  77181. * Inactive if 0
  77182. */
  77183. /**
  77184. * Sets the layer id use to find what meshes are impacted by the light.
  77185. * Inactive if 0
  77186. */
  77187. includeOnlyWithLayerMask: number;
  77188. private _lightmapMode;
  77189. /**
  77190. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77191. */
  77192. /**
  77193. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77194. */
  77195. lightmapMode: number;
  77196. /**
  77197. * Shadow generator associted to the light.
  77198. * @hidden Internal use only.
  77199. */
  77200. _shadowGenerator: Nullable<IShadowGenerator>;
  77201. /**
  77202. * @hidden Internal use only.
  77203. */
  77204. _excludedMeshesIds: string[];
  77205. /**
  77206. * @hidden Internal use only.
  77207. */
  77208. _includedOnlyMeshesIds: string[];
  77209. /**
  77210. * The current light unifom buffer.
  77211. * @hidden Internal use only.
  77212. */
  77213. _uniformBuffer: UniformBuffer;
  77214. /** @hidden */
  77215. _renderId: number;
  77216. /**
  77217. * Creates a Light object in the scene.
  77218. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77219. * @param name The firendly name of the light
  77220. * @param scene The scene the light belongs too
  77221. */
  77222. constructor(name: string, scene: Scene);
  77223. protected abstract _buildUniformLayout(): void;
  77224. /**
  77225. * Sets the passed Effect "effect" with the Light information.
  77226. * @param effect The effect to update
  77227. * @param lightIndex The index of the light in the effect to update
  77228. * @returns The light
  77229. */
  77230. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77231. /**
  77232. * Sets the passed Effect "effect" with the Light information.
  77233. * @param effect The effect to update
  77234. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77235. * @returns The light
  77236. */
  77237. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77238. /**
  77239. * Returns the string "Light".
  77240. * @returns the class name
  77241. */
  77242. getClassName(): string;
  77243. /** @hidden */
  77244. readonly _isLight: boolean;
  77245. /**
  77246. * Converts the light information to a readable string for debug purpose.
  77247. * @param fullDetails Supports for multiple levels of logging within scene loading
  77248. * @returns the human readable light info
  77249. */
  77250. toString(fullDetails?: boolean): string;
  77251. /** @hidden */
  77252. protected _syncParentEnabledState(): void;
  77253. /**
  77254. * Set the enabled state of this node.
  77255. * @param value - the new enabled state
  77256. */
  77257. setEnabled(value: boolean): void;
  77258. /**
  77259. * Returns the Light associated shadow generator if any.
  77260. * @return the associated shadow generator.
  77261. */
  77262. getShadowGenerator(): Nullable<IShadowGenerator>;
  77263. /**
  77264. * Returns a Vector3, the absolute light position in the World.
  77265. * @returns the world space position of the light
  77266. */
  77267. getAbsolutePosition(): Vector3;
  77268. /**
  77269. * Specifies if the light will affect the passed mesh.
  77270. * @param mesh The mesh to test against the light
  77271. * @return true the mesh is affected otherwise, false.
  77272. */
  77273. canAffectMesh(mesh: AbstractMesh): boolean;
  77274. /**
  77275. * Sort function to order lights for rendering.
  77276. * @param a First Light object to compare to second.
  77277. * @param b Second Light object to compare first.
  77278. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77279. */
  77280. static CompareLightsPriority(a: Light, b: Light): number;
  77281. /**
  77282. * Releases resources associated with this node.
  77283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77285. */
  77286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77287. /**
  77288. * Returns the light type ID (integer).
  77289. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77290. */
  77291. getTypeID(): number;
  77292. /**
  77293. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77294. * @returns the scaled intensity in intensity mode unit
  77295. */
  77296. getScaledIntensity(): number;
  77297. /**
  77298. * Returns a new Light object, named "name", from the current one.
  77299. * @param name The name of the cloned light
  77300. * @returns the new created light
  77301. */
  77302. clone(name: string): Nullable<Light>;
  77303. /**
  77304. * Serializes the current light into a Serialization object.
  77305. * @returns the serialized object.
  77306. */
  77307. serialize(): any;
  77308. /**
  77309. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77310. * This new light is named "name" and added to the passed scene.
  77311. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77312. * @param name The friendly name of the light
  77313. * @param scene The scene the new light will belong to
  77314. * @returns the constructor function
  77315. */
  77316. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77317. /**
  77318. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77319. * @param parsedLight The JSON representation of the light
  77320. * @param scene The scene to create the parsed light in
  77321. * @returns the created light after parsing
  77322. */
  77323. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77324. private _hookArrayForExcluded;
  77325. private _hookArrayForIncludedOnly;
  77326. private _resyncMeshes;
  77327. /**
  77328. * Forces the meshes to update their light related information in their rendering used effects
  77329. * @hidden Internal Use Only
  77330. */
  77331. _markMeshesAsLightDirty(): void;
  77332. /**
  77333. * Recomputes the cached photometric scale if needed.
  77334. */
  77335. private _computePhotometricScale;
  77336. /**
  77337. * Returns the Photometric Scale according to the light type and intensity mode.
  77338. */
  77339. private _getPhotometricScale;
  77340. /**
  77341. * Reorder the light in the scene according to their defined priority.
  77342. * @hidden Internal Use Only
  77343. */
  77344. _reorderLightsInScene(): void;
  77345. /**
  77346. * Prepares the list of defines specific to the light type.
  77347. * @param defines the list of defines
  77348. * @param lightIndex defines the index of the light for the effect
  77349. */
  77350. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77351. }
  77352. }
  77353. declare module BABYLON {
  77354. /**
  77355. * Interface used to define Action
  77356. */
  77357. export interface IAction {
  77358. /**
  77359. * Trigger for the action
  77360. */
  77361. trigger: number;
  77362. /** Options of the trigger */
  77363. triggerOptions: any;
  77364. /**
  77365. * Gets the trigger parameters
  77366. * @returns the trigger parameters
  77367. */
  77368. getTriggerParameter(): any;
  77369. /**
  77370. * Internal only - executes current action event
  77371. * @hidden
  77372. */
  77373. _executeCurrent(evt?: ActionEvent): void;
  77374. /**
  77375. * Serialize placeholder for child classes
  77376. * @param parent of child
  77377. * @returns the serialized object
  77378. */
  77379. serialize(parent: any): any;
  77380. /**
  77381. * Internal only
  77382. * @hidden
  77383. */
  77384. _prepare(): void;
  77385. /**
  77386. * Internal only - manager for action
  77387. * @hidden
  77388. */
  77389. _actionManager: AbstractActionManager;
  77390. /**
  77391. * Adds action to chain of actions, may be a DoNothingAction
  77392. * @param action defines the next action to execute
  77393. * @returns The action passed in
  77394. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77395. */
  77396. then(action: IAction): IAction;
  77397. }
  77398. /**
  77399. * The action to be carried out following a trigger
  77400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77401. */
  77402. export class Action implements IAction {
  77403. /** the trigger, with or without parameters, for the action */
  77404. triggerOptions: any;
  77405. /**
  77406. * Trigger for the action
  77407. */
  77408. trigger: number;
  77409. /**
  77410. * Internal only - manager for action
  77411. * @hidden
  77412. */
  77413. _actionManager: ActionManager;
  77414. private _nextActiveAction;
  77415. private _child;
  77416. private _condition?;
  77417. private _triggerParameter;
  77418. /**
  77419. * An event triggered prior to action being executed.
  77420. */
  77421. onBeforeExecuteObservable: Observable<Action>;
  77422. /**
  77423. * Creates a new Action
  77424. * @param triggerOptions the trigger, with or without parameters, for the action
  77425. * @param condition an optional determinant of action
  77426. */
  77427. constructor(
  77428. /** the trigger, with or without parameters, for the action */
  77429. triggerOptions: any, condition?: Condition);
  77430. /**
  77431. * Internal only
  77432. * @hidden
  77433. */
  77434. _prepare(): void;
  77435. /**
  77436. * Gets the trigger parameters
  77437. * @returns the trigger parameters
  77438. */
  77439. getTriggerParameter(): any;
  77440. /**
  77441. * Internal only - executes current action event
  77442. * @hidden
  77443. */
  77444. _executeCurrent(evt?: ActionEvent): void;
  77445. /**
  77446. * Execute placeholder for child classes
  77447. * @param evt optional action event
  77448. */
  77449. execute(evt?: ActionEvent): void;
  77450. /**
  77451. * Skips to next active action
  77452. */
  77453. skipToNextActiveAction(): void;
  77454. /**
  77455. * Adds action to chain of actions, may be a DoNothingAction
  77456. * @param action defines the next action to execute
  77457. * @returns The action passed in
  77458. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77459. */
  77460. then(action: Action): Action;
  77461. /**
  77462. * Internal only
  77463. * @hidden
  77464. */
  77465. _getProperty(propertyPath: string): string;
  77466. /**
  77467. * Internal only
  77468. * @hidden
  77469. */
  77470. _getEffectiveTarget(target: any, propertyPath: string): any;
  77471. /**
  77472. * Serialize placeholder for child classes
  77473. * @param parent of child
  77474. * @returns the serialized object
  77475. */
  77476. serialize(parent: any): any;
  77477. /**
  77478. * Internal only called by serialize
  77479. * @hidden
  77480. */
  77481. protected _serialize(serializedAction: any, parent?: any): any;
  77482. /**
  77483. * Internal only
  77484. * @hidden
  77485. */
  77486. static _SerializeValueAsString: (value: any) => string;
  77487. /**
  77488. * Internal only
  77489. * @hidden
  77490. */
  77491. static _GetTargetProperty: (target: Node | Scene) => {
  77492. name: string;
  77493. targetType: string;
  77494. value: string;
  77495. };
  77496. }
  77497. }
  77498. declare module BABYLON {
  77499. /**
  77500. * A Condition applied to an Action
  77501. */
  77502. export class Condition {
  77503. /**
  77504. * Internal only - manager for action
  77505. * @hidden
  77506. */
  77507. _actionManager: ActionManager;
  77508. /**
  77509. * Internal only
  77510. * @hidden
  77511. */
  77512. _evaluationId: number;
  77513. /**
  77514. * Internal only
  77515. * @hidden
  77516. */
  77517. _currentResult: boolean;
  77518. /**
  77519. * Creates a new Condition
  77520. * @param actionManager the manager of the action the condition is applied to
  77521. */
  77522. constructor(actionManager: ActionManager);
  77523. /**
  77524. * Check if the current condition is valid
  77525. * @returns a boolean
  77526. */
  77527. isValid(): boolean;
  77528. /**
  77529. * Internal only
  77530. * @hidden
  77531. */
  77532. _getProperty(propertyPath: string): string;
  77533. /**
  77534. * Internal only
  77535. * @hidden
  77536. */
  77537. _getEffectiveTarget(target: any, propertyPath: string): any;
  77538. /**
  77539. * Serialize placeholder for child classes
  77540. * @returns the serialized object
  77541. */
  77542. serialize(): any;
  77543. /**
  77544. * Internal only
  77545. * @hidden
  77546. */
  77547. protected _serialize(serializedCondition: any): any;
  77548. }
  77549. /**
  77550. * Defines specific conditional operators as extensions of Condition
  77551. */
  77552. export class ValueCondition extends Condition {
  77553. /** path to specify the property of the target the conditional operator uses */
  77554. propertyPath: string;
  77555. /** the value compared by the conditional operator against the current value of the property */
  77556. value: any;
  77557. /** the conditional operator, default ValueCondition.IsEqual */
  77558. operator: number;
  77559. /**
  77560. * Internal only
  77561. * @hidden
  77562. */
  77563. private static _IsEqual;
  77564. /**
  77565. * Internal only
  77566. * @hidden
  77567. */
  77568. private static _IsDifferent;
  77569. /**
  77570. * Internal only
  77571. * @hidden
  77572. */
  77573. private static _IsGreater;
  77574. /**
  77575. * Internal only
  77576. * @hidden
  77577. */
  77578. private static _IsLesser;
  77579. /**
  77580. * returns the number for IsEqual
  77581. */
  77582. static readonly IsEqual: number;
  77583. /**
  77584. * Returns the number for IsDifferent
  77585. */
  77586. static readonly IsDifferent: number;
  77587. /**
  77588. * Returns the number for IsGreater
  77589. */
  77590. static readonly IsGreater: number;
  77591. /**
  77592. * Returns the number for IsLesser
  77593. */
  77594. static readonly IsLesser: number;
  77595. /**
  77596. * Internal only The action manager for the condition
  77597. * @hidden
  77598. */
  77599. _actionManager: ActionManager;
  77600. /**
  77601. * Internal only
  77602. * @hidden
  77603. */
  77604. private _target;
  77605. /**
  77606. * Internal only
  77607. * @hidden
  77608. */
  77609. private _effectiveTarget;
  77610. /**
  77611. * Internal only
  77612. * @hidden
  77613. */
  77614. private _property;
  77615. /**
  77616. * Creates a new ValueCondition
  77617. * @param actionManager manager for the action the condition applies to
  77618. * @param target for the action
  77619. * @param propertyPath path to specify the property of the target the conditional operator uses
  77620. * @param value the value compared by the conditional operator against the current value of the property
  77621. * @param operator the conditional operator, default ValueCondition.IsEqual
  77622. */
  77623. constructor(actionManager: ActionManager, target: any,
  77624. /** path to specify the property of the target the conditional operator uses */
  77625. propertyPath: string,
  77626. /** the value compared by the conditional operator against the current value of the property */
  77627. value: any,
  77628. /** the conditional operator, default ValueCondition.IsEqual */
  77629. operator?: number);
  77630. /**
  77631. * Compares the given value with the property value for the specified conditional operator
  77632. * @returns the result of the comparison
  77633. */
  77634. isValid(): boolean;
  77635. /**
  77636. * Serialize the ValueCondition into a JSON compatible object
  77637. * @returns serialization object
  77638. */
  77639. serialize(): any;
  77640. /**
  77641. * Gets the name of the conditional operator for the ValueCondition
  77642. * @param operator the conditional operator
  77643. * @returns the name
  77644. */
  77645. static GetOperatorName(operator: number): string;
  77646. }
  77647. /**
  77648. * Defines a predicate condition as an extension of Condition
  77649. */
  77650. export class PredicateCondition extends Condition {
  77651. /** defines the predicate function used to validate the condition */
  77652. predicate: () => boolean;
  77653. /**
  77654. * Internal only - manager for action
  77655. * @hidden
  77656. */
  77657. _actionManager: ActionManager;
  77658. /**
  77659. * Creates a new PredicateCondition
  77660. * @param actionManager manager for the action the condition applies to
  77661. * @param predicate defines the predicate function used to validate the condition
  77662. */
  77663. constructor(actionManager: ActionManager,
  77664. /** defines the predicate function used to validate the condition */
  77665. predicate: () => boolean);
  77666. /**
  77667. * @returns the validity of the predicate condition
  77668. */
  77669. isValid(): boolean;
  77670. }
  77671. /**
  77672. * Defines a state condition as an extension of Condition
  77673. */
  77674. export class StateCondition extends Condition {
  77675. /** Value to compare with target state */
  77676. value: string;
  77677. /**
  77678. * Internal only - manager for action
  77679. * @hidden
  77680. */
  77681. _actionManager: ActionManager;
  77682. /**
  77683. * Internal only
  77684. * @hidden
  77685. */
  77686. private _target;
  77687. /**
  77688. * Creates a new StateCondition
  77689. * @param actionManager manager for the action the condition applies to
  77690. * @param target of the condition
  77691. * @param value to compare with target state
  77692. */
  77693. constructor(actionManager: ActionManager, target: any,
  77694. /** Value to compare with target state */
  77695. value: string);
  77696. /**
  77697. * Gets a boolean indicating if the current condition is met
  77698. * @returns the validity of the state
  77699. */
  77700. isValid(): boolean;
  77701. /**
  77702. * Serialize the StateCondition into a JSON compatible object
  77703. * @returns serialization object
  77704. */
  77705. serialize(): any;
  77706. }
  77707. }
  77708. declare module BABYLON {
  77709. /**
  77710. * This defines an action responsible to toggle a boolean once triggered.
  77711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77712. */
  77713. export class SwitchBooleanAction extends Action {
  77714. /**
  77715. * The path to the boolean property in the target object
  77716. */
  77717. propertyPath: string;
  77718. private _target;
  77719. private _effectiveTarget;
  77720. private _property;
  77721. /**
  77722. * Instantiate the action
  77723. * @param triggerOptions defines the trigger options
  77724. * @param target defines the object containing the boolean
  77725. * @param propertyPath defines the path to the boolean property in the target object
  77726. * @param condition defines the trigger related conditions
  77727. */
  77728. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77729. /** @hidden */
  77730. _prepare(): void;
  77731. /**
  77732. * Execute the action toggle the boolean value.
  77733. */
  77734. execute(): void;
  77735. /**
  77736. * Serializes the actions and its related information.
  77737. * @param parent defines the object to serialize in
  77738. * @returns the serialized object
  77739. */
  77740. serialize(parent: any): any;
  77741. }
  77742. /**
  77743. * This defines an action responsible to set a the state field of the target
  77744. * to a desired value once triggered.
  77745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77746. */
  77747. export class SetStateAction extends Action {
  77748. /**
  77749. * The value to store in the state field.
  77750. */
  77751. value: string;
  77752. private _target;
  77753. /**
  77754. * Instantiate the action
  77755. * @param triggerOptions defines the trigger options
  77756. * @param target defines the object containing the state property
  77757. * @param value defines the value to store in the state field
  77758. * @param condition defines the trigger related conditions
  77759. */
  77760. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77761. /**
  77762. * Execute the action and store the value on the target state property.
  77763. */
  77764. execute(): void;
  77765. /**
  77766. * Serializes the actions and its related information.
  77767. * @param parent defines the object to serialize in
  77768. * @returns the serialized object
  77769. */
  77770. serialize(parent: any): any;
  77771. }
  77772. /**
  77773. * This defines an action responsible to set a property of the target
  77774. * to a desired value once triggered.
  77775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77776. */
  77777. export class SetValueAction extends Action {
  77778. /**
  77779. * The path of the property to set in the target.
  77780. */
  77781. propertyPath: string;
  77782. /**
  77783. * The value to set in the property
  77784. */
  77785. value: any;
  77786. private _target;
  77787. private _effectiveTarget;
  77788. private _property;
  77789. /**
  77790. * Instantiate the action
  77791. * @param triggerOptions defines the trigger options
  77792. * @param target defines the object containing the property
  77793. * @param propertyPath defines the path of the property to set in the target
  77794. * @param value defines the value to set in the property
  77795. * @param condition defines the trigger related conditions
  77796. */
  77797. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77798. /** @hidden */
  77799. _prepare(): void;
  77800. /**
  77801. * Execute the action and set the targetted property to the desired value.
  77802. */
  77803. execute(): void;
  77804. /**
  77805. * Serializes the actions and its related information.
  77806. * @param parent defines the object to serialize in
  77807. * @returns the serialized object
  77808. */
  77809. serialize(parent: any): any;
  77810. }
  77811. /**
  77812. * This defines an action responsible to increment the target value
  77813. * to a desired value once triggered.
  77814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77815. */
  77816. export class IncrementValueAction extends Action {
  77817. /**
  77818. * The path of the property to increment in the target.
  77819. */
  77820. propertyPath: string;
  77821. /**
  77822. * The value we should increment the property by.
  77823. */
  77824. value: any;
  77825. private _target;
  77826. private _effectiveTarget;
  77827. private _property;
  77828. /**
  77829. * Instantiate the action
  77830. * @param triggerOptions defines the trigger options
  77831. * @param target defines the object containing the property
  77832. * @param propertyPath defines the path of the property to increment in the target
  77833. * @param value defines the value value we should increment the property by
  77834. * @param condition defines the trigger related conditions
  77835. */
  77836. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77837. /** @hidden */
  77838. _prepare(): void;
  77839. /**
  77840. * Execute the action and increment the target of the value amount.
  77841. */
  77842. execute(): void;
  77843. /**
  77844. * Serializes the actions and its related information.
  77845. * @param parent defines the object to serialize in
  77846. * @returns the serialized object
  77847. */
  77848. serialize(parent: any): any;
  77849. }
  77850. /**
  77851. * This defines an action responsible to start an animation once triggered.
  77852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77853. */
  77854. export class PlayAnimationAction extends Action {
  77855. /**
  77856. * Where the animation should start (animation frame)
  77857. */
  77858. from: number;
  77859. /**
  77860. * Where the animation should stop (animation frame)
  77861. */
  77862. to: number;
  77863. /**
  77864. * Define if the animation should loop or stop after the first play.
  77865. */
  77866. loop?: boolean;
  77867. private _target;
  77868. /**
  77869. * Instantiate the action
  77870. * @param triggerOptions defines the trigger options
  77871. * @param target defines the target animation or animation name
  77872. * @param from defines from where the animation should start (animation frame)
  77873. * @param end defines where the animation should stop (animation frame)
  77874. * @param loop defines if the animation should loop or stop after the first play
  77875. * @param condition defines the trigger related conditions
  77876. */
  77877. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77878. /** @hidden */
  77879. _prepare(): void;
  77880. /**
  77881. * Execute the action and play the animation.
  77882. */
  77883. execute(): void;
  77884. /**
  77885. * Serializes the actions and its related information.
  77886. * @param parent defines the object to serialize in
  77887. * @returns the serialized object
  77888. */
  77889. serialize(parent: any): any;
  77890. }
  77891. /**
  77892. * This defines an action responsible to stop an animation once triggered.
  77893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77894. */
  77895. export class StopAnimationAction extends Action {
  77896. private _target;
  77897. /**
  77898. * Instantiate the action
  77899. * @param triggerOptions defines the trigger options
  77900. * @param target defines the target animation or animation name
  77901. * @param condition defines the trigger related conditions
  77902. */
  77903. constructor(triggerOptions: any, target: any, condition?: Condition);
  77904. /** @hidden */
  77905. _prepare(): void;
  77906. /**
  77907. * Execute the action and stop the animation.
  77908. */
  77909. execute(): void;
  77910. /**
  77911. * Serializes the actions and its related information.
  77912. * @param parent defines the object to serialize in
  77913. * @returns the serialized object
  77914. */
  77915. serialize(parent: any): any;
  77916. }
  77917. /**
  77918. * This defines an action responsible that does nothing once triggered.
  77919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77920. */
  77921. export class DoNothingAction extends Action {
  77922. /**
  77923. * Instantiate the action
  77924. * @param triggerOptions defines the trigger options
  77925. * @param condition defines the trigger related conditions
  77926. */
  77927. constructor(triggerOptions?: any, condition?: Condition);
  77928. /**
  77929. * Execute the action and do nothing.
  77930. */
  77931. execute(): void;
  77932. /**
  77933. * Serializes the actions and its related information.
  77934. * @param parent defines the object to serialize in
  77935. * @returns the serialized object
  77936. */
  77937. serialize(parent: any): any;
  77938. }
  77939. /**
  77940. * This defines an action responsible to trigger several actions once triggered.
  77941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77942. */
  77943. export class CombineAction extends Action {
  77944. /**
  77945. * The list of aggregated animations to run.
  77946. */
  77947. children: Action[];
  77948. /**
  77949. * Instantiate the action
  77950. * @param triggerOptions defines the trigger options
  77951. * @param children defines the list of aggregated animations to run
  77952. * @param condition defines the trigger related conditions
  77953. */
  77954. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77955. /** @hidden */
  77956. _prepare(): void;
  77957. /**
  77958. * Execute the action and executes all the aggregated actions.
  77959. */
  77960. execute(evt: ActionEvent): void;
  77961. /**
  77962. * Serializes the actions and its related information.
  77963. * @param parent defines the object to serialize in
  77964. * @returns the serialized object
  77965. */
  77966. serialize(parent: any): any;
  77967. }
  77968. /**
  77969. * This defines an action responsible to run code (external event) once triggered.
  77970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77971. */
  77972. export class ExecuteCodeAction extends Action {
  77973. /**
  77974. * The callback function to run.
  77975. */
  77976. func: (evt: ActionEvent) => void;
  77977. /**
  77978. * Instantiate the action
  77979. * @param triggerOptions defines the trigger options
  77980. * @param func defines the callback function to run
  77981. * @param condition defines the trigger related conditions
  77982. */
  77983. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77984. /**
  77985. * Execute the action and run the attached code.
  77986. */
  77987. execute(evt: ActionEvent): void;
  77988. }
  77989. /**
  77990. * This defines an action responsible to set the parent property of the target once triggered.
  77991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77992. */
  77993. export class SetParentAction extends Action {
  77994. private _parent;
  77995. private _target;
  77996. /**
  77997. * Instantiate the action
  77998. * @param triggerOptions defines the trigger options
  77999. * @param target defines the target containing the parent property
  78000. * @param parent defines from where the animation should start (animation frame)
  78001. * @param condition defines the trigger related conditions
  78002. */
  78003. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78004. /** @hidden */
  78005. _prepare(): void;
  78006. /**
  78007. * Execute the action and set the parent property.
  78008. */
  78009. execute(): void;
  78010. /**
  78011. * Serializes the actions and its related information.
  78012. * @param parent defines the object to serialize in
  78013. * @returns the serialized object
  78014. */
  78015. serialize(parent: any): any;
  78016. }
  78017. }
  78018. declare module BABYLON {
  78019. /**
  78020. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78021. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78023. */
  78024. export class ActionManager extends AbstractActionManager {
  78025. /**
  78026. * Nothing
  78027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78028. */
  78029. static readonly NothingTrigger: number;
  78030. /**
  78031. * On pick
  78032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78033. */
  78034. static readonly OnPickTrigger: number;
  78035. /**
  78036. * On left pick
  78037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78038. */
  78039. static readonly OnLeftPickTrigger: number;
  78040. /**
  78041. * On right pick
  78042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78043. */
  78044. static readonly OnRightPickTrigger: number;
  78045. /**
  78046. * On center pick
  78047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78048. */
  78049. static readonly OnCenterPickTrigger: number;
  78050. /**
  78051. * On pick down
  78052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78053. */
  78054. static readonly OnPickDownTrigger: number;
  78055. /**
  78056. * On double pick
  78057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78058. */
  78059. static readonly OnDoublePickTrigger: number;
  78060. /**
  78061. * On pick up
  78062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78063. */
  78064. static readonly OnPickUpTrigger: number;
  78065. /**
  78066. * On pick out.
  78067. * This trigger will only be raised if you also declared a OnPickDown
  78068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78069. */
  78070. static readonly OnPickOutTrigger: number;
  78071. /**
  78072. * On long press
  78073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78074. */
  78075. static readonly OnLongPressTrigger: number;
  78076. /**
  78077. * On pointer over
  78078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78079. */
  78080. static readonly OnPointerOverTrigger: number;
  78081. /**
  78082. * On pointer out
  78083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78084. */
  78085. static readonly OnPointerOutTrigger: number;
  78086. /**
  78087. * On every frame
  78088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78089. */
  78090. static readonly OnEveryFrameTrigger: number;
  78091. /**
  78092. * On intersection enter
  78093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78094. */
  78095. static readonly OnIntersectionEnterTrigger: number;
  78096. /**
  78097. * On intersection exit
  78098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78099. */
  78100. static readonly OnIntersectionExitTrigger: number;
  78101. /**
  78102. * On key down
  78103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78104. */
  78105. static readonly OnKeyDownTrigger: number;
  78106. /**
  78107. * On key up
  78108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78109. */
  78110. static readonly OnKeyUpTrigger: number;
  78111. private _scene;
  78112. /**
  78113. * Creates a new action manager
  78114. * @param scene defines the hosting scene
  78115. */
  78116. constructor(scene: Scene);
  78117. /**
  78118. * Releases all associated resources
  78119. */
  78120. dispose(): void;
  78121. /**
  78122. * Gets hosting scene
  78123. * @returns the hosting scene
  78124. */
  78125. getScene(): Scene;
  78126. /**
  78127. * Does this action manager handles actions of any of the given triggers
  78128. * @param triggers defines the triggers to be tested
  78129. * @return a boolean indicating whether one (or more) of the triggers is handled
  78130. */
  78131. hasSpecificTriggers(triggers: number[]): boolean;
  78132. /**
  78133. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78134. * speed.
  78135. * @param triggerA defines the trigger to be tested
  78136. * @param triggerB defines the trigger to be tested
  78137. * @return a boolean indicating whether one (or more) of the triggers is handled
  78138. */
  78139. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78140. /**
  78141. * Does this action manager handles actions of a given trigger
  78142. * @param trigger defines the trigger to be tested
  78143. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78144. * @return whether the trigger is handled
  78145. */
  78146. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78147. /**
  78148. * Does this action manager has pointer triggers
  78149. */
  78150. readonly hasPointerTriggers: boolean;
  78151. /**
  78152. * Does this action manager has pick triggers
  78153. */
  78154. readonly hasPickTriggers: boolean;
  78155. /**
  78156. * Registers an action to this action manager
  78157. * @param action defines the action to be registered
  78158. * @return the action amended (prepared) after registration
  78159. */
  78160. registerAction(action: IAction): Nullable<IAction>;
  78161. /**
  78162. * Unregisters an action to this action manager
  78163. * @param action defines the action to be unregistered
  78164. * @return a boolean indicating whether the action has been unregistered
  78165. */
  78166. unregisterAction(action: IAction): Boolean;
  78167. /**
  78168. * Process a specific trigger
  78169. * @param trigger defines the trigger to process
  78170. * @param evt defines the event details to be processed
  78171. */
  78172. processTrigger(trigger: number, evt?: IActionEvent): void;
  78173. /** @hidden */
  78174. _getEffectiveTarget(target: any, propertyPath: string): any;
  78175. /** @hidden */
  78176. _getProperty(propertyPath: string): string;
  78177. /**
  78178. * Serialize this manager to a JSON object
  78179. * @param name defines the property name to store this manager
  78180. * @returns a JSON representation of this manager
  78181. */
  78182. serialize(name: string): any;
  78183. /**
  78184. * Creates a new ActionManager from a JSON data
  78185. * @param parsedActions defines the JSON data to read from
  78186. * @param object defines the hosting mesh
  78187. * @param scene defines the hosting scene
  78188. */
  78189. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78190. /**
  78191. * Get a trigger name by index
  78192. * @param trigger defines the trigger index
  78193. * @returns a trigger name
  78194. */
  78195. static GetTriggerName(trigger: number): string;
  78196. }
  78197. }
  78198. declare module BABYLON {
  78199. /**
  78200. * Class representing a ray with position and direction
  78201. */
  78202. export class Ray {
  78203. /** origin point */
  78204. origin: Vector3;
  78205. /** direction */
  78206. direction: Vector3;
  78207. /** length of the ray */
  78208. length: number;
  78209. private static readonly TmpVector3;
  78210. private _tmpRay;
  78211. /**
  78212. * Creates a new ray
  78213. * @param origin origin point
  78214. * @param direction direction
  78215. * @param length length of the ray
  78216. */
  78217. constructor(
  78218. /** origin point */
  78219. origin: Vector3,
  78220. /** direction */
  78221. direction: Vector3,
  78222. /** length of the ray */
  78223. length?: number);
  78224. /**
  78225. * Checks if the ray intersects a box
  78226. * @param minimum bound of the box
  78227. * @param maximum bound of the box
  78228. * @param intersectionTreshold extra extend to be added to the box in all direction
  78229. * @returns if the box was hit
  78230. */
  78231. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78232. /**
  78233. * Checks if the ray intersects a box
  78234. * @param box the bounding box to check
  78235. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78236. * @returns if the box was hit
  78237. */
  78238. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78239. /**
  78240. * If the ray hits a sphere
  78241. * @param sphere the bounding sphere to check
  78242. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78243. * @returns true if it hits the sphere
  78244. */
  78245. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78246. /**
  78247. * If the ray hits a triange
  78248. * @param vertex0 triangle vertex
  78249. * @param vertex1 triangle vertex
  78250. * @param vertex2 triangle vertex
  78251. * @returns intersection information if hit
  78252. */
  78253. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78254. /**
  78255. * Checks if ray intersects a plane
  78256. * @param plane the plane to check
  78257. * @returns the distance away it was hit
  78258. */
  78259. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78260. /**
  78261. * Calculate the intercept of a ray on a given axis
  78262. * @param axis to check 'x' | 'y' | 'z'
  78263. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78264. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78265. */
  78266. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78267. /**
  78268. * Checks if ray intersects a mesh
  78269. * @param mesh the mesh to check
  78270. * @param fastCheck if only the bounding box should checked
  78271. * @returns picking info of the intersecton
  78272. */
  78273. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78274. /**
  78275. * Checks if ray intersects a mesh
  78276. * @param meshes the meshes to check
  78277. * @param fastCheck if only the bounding box should checked
  78278. * @param results array to store result in
  78279. * @returns Array of picking infos
  78280. */
  78281. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78282. private _comparePickingInfo;
  78283. private static smallnum;
  78284. private static rayl;
  78285. /**
  78286. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78287. * @param sega the first point of the segment to test the intersection against
  78288. * @param segb the second point of the segment to test the intersection against
  78289. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78290. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78291. */
  78292. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78293. /**
  78294. * Update the ray from viewport position
  78295. * @param x position
  78296. * @param y y position
  78297. * @param viewportWidth viewport width
  78298. * @param viewportHeight viewport height
  78299. * @param world world matrix
  78300. * @param view view matrix
  78301. * @param projection projection matrix
  78302. * @returns this ray updated
  78303. */
  78304. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78305. /**
  78306. * Creates a ray with origin and direction of 0,0,0
  78307. * @returns the new ray
  78308. */
  78309. static Zero(): Ray;
  78310. /**
  78311. * Creates a new ray from screen space and viewport
  78312. * @param x position
  78313. * @param y y position
  78314. * @param viewportWidth viewport width
  78315. * @param viewportHeight viewport height
  78316. * @param world world matrix
  78317. * @param view view matrix
  78318. * @param projection projection matrix
  78319. * @returns new ray
  78320. */
  78321. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78322. /**
  78323. * 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
  78324. * transformed to the given world matrix.
  78325. * @param origin The origin point
  78326. * @param end The end point
  78327. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78328. * @returns the new ray
  78329. */
  78330. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78331. /**
  78332. * Transforms a ray by a matrix
  78333. * @param ray ray to transform
  78334. * @param matrix matrix to apply
  78335. * @returns the resulting new ray
  78336. */
  78337. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78338. /**
  78339. * Transforms a ray by a matrix
  78340. * @param ray ray to transform
  78341. * @param matrix matrix to apply
  78342. * @param result ray to store result in
  78343. */
  78344. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78345. /**
  78346. * Unproject a ray from screen space to object space
  78347. * @param sourceX defines the screen space x coordinate to use
  78348. * @param sourceY defines the screen space y coordinate to use
  78349. * @param viewportWidth defines the current width of the viewport
  78350. * @param viewportHeight defines the current height of the viewport
  78351. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78352. * @param view defines the view matrix to use
  78353. * @param projection defines the projection matrix to use
  78354. */
  78355. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78356. }
  78357. /**
  78358. * Type used to define predicate used to select faces when a mesh intersection is detected
  78359. */
  78360. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78361. interface Scene {
  78362. /** @hidden */
  78363. _tempPickingRay: Nullable<Ray>;
  78364. /** @hidden */
  78365. _cachedRayForTransform: Ray;
  78366. /** @hidden */
  78367. _pickWithRayInverseMatrix: Matrix;
  78368. /** @hidden */
  78369. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78370. /** @hidden */
  78371. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78372. }
  78373. }
  78374. declare module BABYLON {
  78375. /**
  78376. * Groups all the scene component constants in one place to ease maintenance.
  78377. * @hidden
  78378. */
  78379. export class SceneComponentConstants {
  78380. static readonly NAME_EFFECTLAYER: string;
  78381. static readonly NAME_LAYER: string;
  78382. static readonly NAME_LENSFLARESYSTEM: string;
  78383. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78384. static readonly NAME_PARTICLESYSTEM: string;
  78385. static readonly NAME_GAMEPAD: string;
  78386. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78387. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78388. static readonly NAME_DEPTHRENDERER: string;
  78389. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78390. static readonly NAME_SPRITE: string;
  78391. static readonly NAME_OUTLINERENDERER: string;
  78392. static readonly NAME_PROCEDURALTEXTURE: string;
  78393. static readonly NAME_SHADOWGENERATOR: string;
  78394. static readonly NAME_OCTREE: string;
  78395. static readonly NAME_PHYSICSENGINE: string;
  78396. static readonly NAME_AUDIO: string;
  78397. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78398. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78399. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78400. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78401. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78402. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78403. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78404. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78405. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78406. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78407. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78408. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78409. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78410. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78411. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78412. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78414. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78415. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78416. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78417. static readonly STEP_AFTERRENDER_AUDIO: number;
  78418. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78419. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78420. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78421. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78422. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78423. static readonly STEP_POINTERMOVE_SPRITE: number;
  78424. static readonly STEP_POINTERDOWN_SPRITE: number;
  78425. static readonly STEP_POINTERUP_SPRITE: number;
  78426. }
  78427. /**
  78428. * This represents a scene component.
  78429. *
  78430. * This is used to decouple the dependency the scene is having on the different workloads like
  78431. * layers, post processes...
  78432. */
  78433. export interface ISceneComponent {
  78434. /**
  78435. * The name of the component. Each component must have a unique name.
  78436. */
  78437. name: string;
  78438. /**
  78439. * The scene the component belongs to.
  78440. */
  78441. scene: Scene;
  78442. /**
  78443. * Register the component to one instance of a scene.
  78444. */
  78445. register(): void;
  78446. /**
  78447. * Rebuilds the elements related to this component in case of
  78448. * context lost for instance.
  78449. */
  78450. rebuild(): void;
  78451. /**
  78452. * Disposes the component and the associated ressources.
  78453. */
  78454. dispose(): void;
  78455. }
  78456. /**
  78457. * This represents a SERIALIZABLE scene component.
  78458. *
  78459. * This extends Scene Component to add Serialization methods on top.
  78460. */
  78461. export interface ISceneSerializableComponent extends ISceneComponent {
  78462. /**
  78463. * Adds all the elements from the container to the scene
  78464. * @param container the container holding the elements
  78465. */
  78466. addFromContainer(container: AbstractScene): void;
  78467. /**
  78468. * Removes all the elements in the container from the scene
  78469. * @param container contains the elements to remove
  78470. * @param dispose if the removed element should be disposed (default: false)
  78471. */
  78472. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78473. /**
  78474. * Serializes the component data to the specified json object
  78475. * @param serializationObject The object to serialize to
  78476. */
  78477. serialize(serializationObject: any): void;
  78478. }
  78479. /**
  78480. * Strong typing of a Mesh related stage step action
  78481. */
  78482. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78483. /**
  78484. * Strong typing of a Evaluate Sub Mesh related stage step action
  78485. */
  78486. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78487. /**
  78488. * Strong typing of a Active Mesh related stage step action
  78489. */
  78490. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78491. /**
  78492. * Strong typing of a Camera related stage step action
  78493. */
  78494. export type CameraStageAction = (camera: Camera) => void;
  78495. /**
  78496. * Strong typing of a Camera Frame buffer related stage step action
  78497. */
  78498. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78499. /**
  78500. * Strong typing of a Render Target related stage step action
  78501. */
  78502. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78503. /**
  78504. * Strong typing of a RenderingGroup related stage step action
  78505. */
  78506. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78507. /**
  78508. * Strong typing of a Mesh Render related stage step action
  78509. */
  78510. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78511. /**
  78512. * Strong typing of a simple stage step action
  78513. */
  78514. export type SimpleStageAction = () => void;
  78515. /**
  78516. * Strong typing of a render target action.
  78517. */
  78518. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78519. /**
  78520. * Strong typing of a pointer move action.
  78521. */
  78522. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78523. /**
  78524. * Strong typing of a pointer up/down action.
  78525. */
  78526. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78527. /**
  78528. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78529. * @hidden
  78530. */
  78531. export class Stage<T extends Function> extends Array<{
  78532. index: number;
  78533. component: ISceneComponent;
  78534. action: T;
  78535. }> {
  78536. /**
  78537. * Hide ctor from the rest of the world.
  78538. * @param items The items to add.
  78539. */
  78540. private constructor();
  78541. /**
  78542. * Creates a new Stage.
  78543. * @returns A new instance of a Stage
  78544. */
  78545. static Create<T extends Function>(): Stage<T>;
  78546. /**
  78547. * Registers a step in an ordered way in the targeted stage.
  78548. * @param index Defines the position to register the step in
  78549. * @param component Defines the component attached to the step
  78550. * @param action Defines the action to launch during the step
  78551. */
  78552. registerStep(index: number, component: ISceneComponent, action: T): void;
  78553. /**
  78554. * Clears all the steps from the stage.
  78555. */
  78556. clear(): void;
  78557. }
  78558. }
  78559. declare module BABYLON {
  78560. interface Scene {
  78561. /** @hidden */
  78562. _pointerOverSprite: Nullable<Sprite>;
  78563. /** @hidden */
  78564. _pickedDownSprite: Nullable<Sprite>;
  78565. /** @hidden */
  78566. _tempSpritePickingRay: Nullable<Ray>;
  78567. /**
  78568. * All of the sprite managers added to this scene
  78569. * @see http://doc.babylonjs.com/babylon101/sprites
  78570. */
  78571. spriteManagers: Array<ISpriteManager>;
  78572. /**
  78573. * An event triggered when sprites rendering is about to start
  78574. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78575. */
  78576. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78577. /**
  78578. * An event triggered when sprites rendering is done
  78579. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78580. */
  78581. onAfterSpritesRenderingObservable: Observable<Scene>;
  78582. /** @hidden */
  78583. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78584. /** Launch a ray to try to pick a sprite in the scene
  78585. * @param x position on screen
  78586. * @param y position on screen
  78587. * @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
  78588. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78589. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78590. * @returns a PickingInfo
  78591. */
  78592. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78593. /** Use the given ray to pick a sprite in the scene
  78594. * @param ray The ray (in world space) to use to pick meshes
  78595. * @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
  78596. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78597. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78598. * @returns a PickingInfo
  78599. */
  78600. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78601. /** @hidden */
  78602. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78603. /** Launch a ray to try to pick sprites in the scene
  78604. * @param x position on screen
  78605. * @param y position on screen
  78606. * @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
  78607. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78608. * @returns a PickingInfo array
  78609. */
  78610. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78611. /** Use the given ray to pick sprites in the scene
  78612. * @param ray The ray (in world space) to use to pick meshes
  78613. * @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
  78614. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78615. * @returns a PickingInfo array
  78616. */
  78617. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78618. /**
  78619. * Force the sprite under the pointer
  78620. * @param sprite defines the sprite to use
  78621. */
  78622. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78623. /**
  78624. * Gets the sprite under the pointer
  78625. * @returns a Sprite or null if no sprite is under the pointer
  78626. */
  78627. getPointerOverSprite(): Nullable<Sprite>;
  78628. }
  78629. /**
  78630. * Defines the sprite scene component responsible to manage sprites
  78631. * in a given scene.
  78632. */
  78633. export class SpriteSceneComponent implements ISceneComponent {
  78634. /**
  78635. * The component name helpfull to identify the component in the list of scene components.
  78636. */
  78637. readonly name: string;
  78638. /**
  78639. * The scene the component belongs to.
  78640. */
  78641. scene: Scene;
  78642. /** @hidden */
  78643. private _spritePredicate;
  78644. /**
  78645. * Creates a new instance of the component for the given scene
  78646. * @param scene Defines the scene to register the component in
  78647. */
  78648. constructor(scene: Scene);
  78649. /**
  78650. * Registers the component in a given scene
  78651. */
  78652. register(): void;
  78653. /**
  78654. * Rebuilds the elements related to this component in case of
  78655. * context lost for instance.
  78656. */
  78657. rebuild(): void;
  78658. /**
  78659. * Disposes the component and the associated ressources.
  78660. */
  78661. dispose(): void;
  78662. private _pickSpriteButKeepRay;
  78663. private _pointerMove;
  78664. private _pointerDown;
  78665. private _pointerUp;
  78666. }
  78667. }
  78668. declare module BABYLON {
  78669. /** @hidden */
  78670. export var fogFragmentDeclaration: {
  78671. name: string;
  78672. shader: string;
  78673. };
  78674. }
  78675. declare module BABYLON {
  78676. /** @hidden */
  78677. export var fogFragment: {
  78678. name: string;
  78679. shader: string;
  78680. };
  78681. }
  78682. declare module BABYLON {
  78683. /** @hidden */
  78684. export var spritesPixelShader: {
  78685. name: string;
  78686. shader: string;
  78687. };
  78688. }
  78689. declare module BABYLON {
  78690. /** @hidden */
  78691. export var fogVertexDeclaration: {
  78692. name: string;
  78693. shader: string;
  78694. };
  78695. }
  78696. declare module BABYLON {
  78697. /** @hidden */
  78698. export var spritesVertexShader: {
  78699. name: string;
  78700. shader: string;
  78701. };
  78702. }
  78703. declare module BABYLON {
  78704. /**
  78705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78706. */
  78707. export interface ISpriteManager extends IDisposable {
  78708. /**
  78709. * Restricts the camera to viewing objects with the same layerMask.
  78710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78711. */
  78712. layerMask: number;
  78713. /**
  78714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78715. */
  78716. isPickable: boolean;
  78717. /**
  78718. * Specifies the rendering group id for this mesh (0 by default)
  78719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78720. */
  78721. renderingGroupId: number;
  78722. /**
  78723. * Defines the list of sprites managed by the manager.
  78724. */
  78725. sprites: Array<Sprite>;
  78726. /**
  78727. * Tests the intersection of a sprite with a specific ray.
  78728. * @param ray The ray we are sending to test the collision
  78729. * @param camera The camera space we are sending rays in
  78730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78732. * @returns picking info or null.
  78733. */
  78734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78735. /**
  78736. * Intersects the sprites with a ray
  78737. * @param ray defines the ray to intersect with
  78738. * @param camera defines the current active camera
  78739. * @param predicate defines a predicate used to select candidate sprites
  78740. * @returns null if no hit or a PickingInfo array
  78741. */
  78742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78743. /**
  78744. * Renders the list of sprites on screen.
  78745. */
  78746. render(): void;
  78747. }
  78748. /**
  78749. * Class used to manage multiple sprites on the same spritesheet
  78750. * @see http://doc.babylonjs.com/babylon101/sprites
  78751. */
  78752. export class SpriteManager implements ISpriteManager {
  78753. /** defines the manager's name */
  78754. name: string;
  78755. /** Gets the list of sprites */
  78756. sprites: Sprite[];
  78757. /** Gets or sets the rendering group id (0 by default) */
  78758. renderingGroupId: number;
  78759. /** Gets or sets camera layer mask */
  78760. layerMask: number;
  78761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78762. fogEnabled: boolean;
  78763. /** Gets or sets a boolean indicating if the sprites are pickable */
  78764. isPickable: boolean;
  78765. /** Defines the default width of a cell in the spritesheet */
  78766. cellWidth: number;
  78767. /** Defines the default height of a cell in the spritesheet */
  78768. cellHeight: number;
  78769. /** Associative array from JSON sprite data file */
  78770. private _cellData;
  78771. /** Array of sprite names from JSON sprite data file */
  78772. private _spriteMap;
  78773. /** True when packed cell data from JSON file is ready*/
  78774. private _packedAndReady;
  78775. /**
  78776. * An event triggered when the manager is disposed.
  78777. */
  78778. onDisposeObservable: Observable<SpriteManager>;
  78779. private _onDisposeObserver;
  78780. /**
  78781. * Callback called when the manager is disposed
  78782. */
  78783. onDispose: () => void;
  78784. private _capacity;
  78785. private _fromPacked;
  78786. private _spriteTexture;
  78787. private _epsilon;
  78788. private _scene;
  78789. private _vertexData;
  78790. private _buffer;
  78791. private _vertexBuffers;
  78792. private _indexBuffer;
  78793. private _effectBase;
  78794. private _effectFog;
  78795. /**
  78796. * Gets or sets the spritesheet texture
  78797. */
  78798. texture: Texture;
  78799. /**
  78800. * Creates a new sprite manager
  78801. * @param name defines the manager's name
  78802. * @param imgUrl defines the sprite sheet url
  78803. * @param capacity defines the maximum allowed number of sprites
  78804. * @param cellSize defines the size of a sprite cell
  78805. * @param scene defines the hosting scene
  78806. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78807. * @param samplingMode defines the smapling mode to use with spritesheet
  78808. * @param fromPacked set to false; do not alter
  78809. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78810. */
  78811. constructor(
  78812. /** defines the manager's name */
  78813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78814. private _makePacked;
  78815. private _appendSpriteVertex;
  78816. /**
  78817. * Intersects the sprites with a ray
  78818. * @param ray defines the ray to intersect with
  78819. * @param camera defines the current active camera
  78820. * @param predicate defines a predicate used to select candidate sprites
  78821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78822. * @returns null if no hit or a PickingInfo
  78823. */
  78824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78825. /**
  78826. * Intersects the sprites with a ray
  78827. * @param ray defines the ray to intersect with
  78828. * @param camera defines the current active camera
  78829. * @param predicate defines a predicate used to select candidate sprites
  78830. * @returns null if no hit or a PickingInfo array
  78831. */
  78832. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78833. /**
  78834. * Render all child sprites
  78835. */
  78836. render(): void;
  78837. /**
  78838. * Release associated resources
  78839. */
  78840. dispose(): void;
  78841. }
  78842. }
  78843. declare module BABYLON {
  78844. /**
  78845. * Class used to represent a sprite
  78846. * @see http://doc.babylonjs.com/babylon101/sprites
  78847. */
  78848. export class Sprite {
  78849. /** defines the name */
  78850. name: string;
  78851. /** Gets or sets the current world position */
  78852. position: Vector3;
  78853. /** Gets or sets the main color */
  78854. color: Color4;
  78855. /** Gets or sets the width */
  78856. width: number;
  78857. /** Gets or sets the height */
  78858. height: number;
  78859. /** Gets or sets rotation angle */
  78860. angle: number;
  78861. /** Gets or sets the cell index in the sprite sheet */
  78862. cellIndex: number;
  78863. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78864. cellRef: string;
  78865. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78866. invertU: number;
  78867. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78868. invertV: number;
  78869. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78870. disposeWhenFinishedAnimating: boolean;
  78871. /** Gets the list of attached animations */
  78872. animations: Animation[];
  78873. /** Gets or sets a boolean indicating if the sprite can be picked */
  78874. isPickable: boolean;
  78875. /**
  78876. * Gets or sets the associated action manager
  78877. */
  78878. actionManager: Nullable<ActionManager>;
  78879. private _animationStarted;
  78880. private _loopAnimation;
  78881. private _fromIndex;
  78882. private _toIndex;
  78883. private _delay;
  78884. private _direction;
  78885. private _manager;
  78886. private _time;
  78887. private _onAnimationEnd;
  78888. /**
  78889. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78890. */
  78891. isVisible: boolean;
  78892. /**
  78893. * Gets or sets the sprite size
  78894. */
  78895. size: number;
  78896. /**
  78897. * Creates a new Sprite
  78898. * @param name defines the name
  78899. * @param manager defines the manager
  78900. */
  78901. constructor(
  78902. /** defines the name */
  78903. name: string, manager: ISpriteManager);
  78904. /**
  78905. * Starts an animation
  78906. * @param from defines the initial key
  78907. * @param to defines the end key
  78908. * @param loop defines if the animation must loop
  78909. * @param delay defines the start delay (in ms)
  78910. * @param onAnimationEnd defines a callback to call when animation ends
  78911. */
  78912. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78913. /** Stops current animation (if any) */
  78914. stopAnimation(): void;
  78915. /** @hidden */
  78916. _animate(deltaTime: number): void;
  78917. /** Release associated resources */
  78918. dispose(): void;
  78919. }
  78920. }
  78921. declare module BABYLON {
  78922. /**
  78923. * Information about the result of picking within a scene
  78924. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78925. */
  78926. export class PickingInfo {
  78927. /** @hidden */
  78928. _pickingUnavailable: boolean;
  78929. /**
  78930. * If the pick collided with an object
  78931. */
  78932. hit: boolean;
  78933. /**
  78934. * Distance away where the pick collided
  78935. */
  78936. distance: number;
  78937. /**
  78938. * The location of pick collision
  78939. */
  78940. pickedPoint: Nullable<Vector3>;
  78941. /**
  78942. * The mesh corresponding the the pick collision
  78943. */
  78944. pickedMesh: Nullable<AbstractMesh>;
  78945. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78946. bu: number;
  78947. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78948. bv: number;
  78949. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78950. faceId: number;
  78951. /** Id of the the submesh that was picked */
  78952. subMeshId: number;
  78953. /** If a sprite was picked, this will be the sprite the pick collided with */
  78954. pickedSprite: Nullable<Sprite>;
  78955. /**
  78956. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78957. */
  78958. originMesh: Nullable<AbstractMesh>;
  78959. /**
  78960. * The ray that was used to perform the picking.
  78961. */
  78962. ray: Nullable<Ray>;
  78963. /**
  78964. * Gets the normal correspodning to the face the pick collided with
  78965. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78966. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78967. * @returns The normal correspodning to the face the pick collided with
  78968. */
  78969. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78970. /**
  78971. * Gets the texture coordinates of where the pick occured
  78972. * @returns the vector containing the coordnates of the texture
  78973. */
  78974. getTextureCoordinates(): Nullable<Vector2>;
  78975. }
  78976. }
  78977. declare module BABYLON {
  78978. /**
  78979. * Gather the list of pointer event types as constants.
  78980. */
  78981. export class PointerEventTypes {
  78982. /**
  78983. * 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.
  78984. */
  78985. static readonly POINTERDOWN: number;
  78986. /**
  78987. * The pointerup event is fired when a pointer is no longer active.
  78988. */
  78989. static readonly POINTERUP: number;
  78990. /**
  78991. * The pointermove event is fired when a pointer changes coordinates.
  78992. */
  78993. static readonly POINTERMOVE: number;
  78994. /**
  78995. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78996. */
  78997. static readonly POINTERWHEEL: number;
  78998. /**
  78999. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79000. */
  79001. static readonly POINTERPICK: number;
  79002. /**
  79003. * The pointertap event is fired when a the object has been touched and released without drag.
  79004. */
  79005. static readonly POINTERTAP: number;
  79006. /**
  79007. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79008. */
  79009. static readonly POINTERDOUBLETAP: number;
  79010. }
  79011. /**
  79012. * Base class of pointer info types.
  79013. */
  79014. export class PointerInfoBase {
  79015. /**
  79016. * Defines the type of event (PointerEventTypes)
  79017. */
  79018. type: number;
  79019. /**
  79020. * Defines the related dom event
  79021. */
  79022. event: PointerEvent | MouseWheelEvent;
  79023. /**
  79024. * Instantiates the base class of pointers info.
  79025. * @param type Defines the type of event (PointerEventTypes)
  79026. * @param event Defines the related dom event
  79027. */
  79028. constructor(
  79029. /**
  79030. * Defines the type of event (PointerEventTypes)
  79031. */
  79032. type: number,
  79033. /**
  79034. * Defines the related dom event
  79035. */
  79036. event: PointerEvent | MouseWheelEvent);
  79037. }
  79038. /**
  79039. * This class is used to store pointer related info for the onPrePointerObservable event.
  79040. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79041. */
  79042. export class PointerInfoPre extends PointerInfoBase {
  79043. /**
  79044. * Ray from a pointer if availible (eg. 6dof controller)
  79045. */
  79046. ray: Nullable<Ray>;
  79047. /**
  79048. * Defines the local position of the pointer on the canvas.
  79049. */
  79050. localPosition: Vector2;
  79051. /**
  79052. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79053. */
  79054. skipOnPointerObservable: boolean;
  79055. /**
  79056. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79057. * @param type Defines the type of event (PointerEventTypes)
  79058. * @param event Defines the related dom event
  79059. * @param localX Defines the local x coordinates of the pointer when the event occured
  79060. * @param localY Defines the local y coordinates of the pointer when the event occured
  79061. */
  79062. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79063. }
  79064. /**
  79065. * This type contains all the data related to a pointer event in Babylon.js.
  79066. * 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.
  79067. */
  79068. export class PointerInfo extends PointerInfoBase {
  79069. /**
  79070. * Defines the picking info associated to the info (if any)\
  79071. */
  79072. pickInfo: Nullable<PickingInfo>;
  79073. /**
  79074. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79075. * @param type Defines the type of event (PointerEventTypes)
  79076. * @param event Defines the related dom event
  79077. * @param pickInfo Defines the picking info associated to the info (if any)\
  79078. */
  79079. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79080. /**
  79081. * Defines the picking info associated to the info (if any)\
  79082. */
  79083. pickInfo: Nullable<PickingInfo>);
  79084. }
  79085. /**
  79086. * Data relating to a touch event on the screen.
  79087. */
  79088. export interface PointerTouch {
  79089. /**
  79090. * X coordinate of touch.
  79091. */
  79092. x: number;
  79093. /**
  79094. * Y coordinate of touch.
  79095. */
  79096. y: number;
  79097. /**
  79098. * Id of touch. Unique for each finger.
  79099. */
  79100. pointerId: number;
  79101. /**
  79102. * Event type passed from DOM.
  79103. */
  79104. type: any;
  79105. }
  79106. }
  79107. declare module BABYLON {
  79108. /**
  79109. * Manage the mouse inputs to control the movement of a free camera.
  79110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79111. */
  79112. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79113. /**
  79114. * Define if touch is enabled in the mouse input
  79115. */
  79116. touchEnabled: boolean;
  79117. /**
  79118. * Defines the camera the input is attached to.
  79119. */
  79120. camera: FreeCamera;
  79121. /**
  79122. * Defines the buttons associated with the input to handle camera move.
  79123. */
  79124. buttons: number[];
  79125. /**
  79126. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79127. */
  79128. angularSensibility: number;
  79129. private _pointerInput;
  79130. private _onMouseMove;
  79131. private _observer;
  79132. private previousPosition;
  79133. /**
  79134. * Observable for when a pointer move event occurs containing the move offset
  79135. */
  79136. onPointerMovedObservable: Observable<{
  79137. offsetX: number;
  79138. offsetY: number;
  79139. }>;
  79140. /**
  79141. * @hidden
  79142. * If the camera should be rotated automatically based on pointer movement
  79143. */
  79144. _allowCameraRotation: boolean;
  79145. /**
  79146. * Manage the mouse inputs to control the movement of a free camera.
  79147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79148. * @param touchEnabled Defines if touch is enabled or not
  79149. */
  79150. constructor(
  79151. /**
  79152. * Define if touch is enabled in the mouse input
  79153. */
  79154. touchEnabled?: boolean);
  79155. /**
  79156. * Attach the input controls to a specific dom element to get the input from.
  79157. * @param element Defines the element the controls should be listened from
  79158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79159. */
  79160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79161. /**
  79162. * Called on JS contextmenu event.
  79163. * Override this method to provide functionality.
  79164. */
  79165. protected onContextMenu(evt: PointerEvent): void;
  79166. /**
  79167. * Detach the current controls from the specified dom element.
  79168. * @param element Defines the element to stop listening the inputs from
  79169. */
  79170. detachControl(element: Nullable<HTMLElement>): void;
  79171. /**
  79172. * Gets the class name of the current intput.
  79173. * @returns the class name
  79174. */
  79175. getClassName(): string;
  79176. /**
  79177. * Get the friendly name associated with the input class.
  79178. * @returns the input friendly name
  79179. */
  79180. getSimpleName(): string;
  79181. }
  79182. }
  79183. declare module BABYLON {
  79184. /**
  79185. * Manage the touch inputs to control the movement of a free camera.
  79186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79187. */
  79188. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79189. /**
  79190. * Defines the camera the input is attached to.
  79191. */
  79192. camera: FreeCamera;
  79193. /**
  79194. * Defines the touch sensibility for rotation.
  79195. * The higher the faster.
  79196. */
  79197. touchAngularSensibility: number;
  79198. /**
  79199. * Defines the touch sensibility for move.
  79200. * The higher the faster.
  79201. */
  79202. touchMoveSensibility: number;
  79203. private _offsetX;
  79204. private _offsetY;
  79205. private _pointerPressed;
  79206. private _pointerInput;
  79207. private _observer;
  79208. private _onLostFocus;
  79209. /**
  79210. * Attach the input controls to a specific dom element to get the input from.
  79211. * @param element Defines the element the controls should be listened from
  79212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79213. */
  79214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79215. /**
  79216. * Detach the current controls from the specified dom element.
  79217. * @param element Defines the element to stop listening the inputs from
  79218. */
  79219. detachControl(element: Nullable<HTMLElement>): void;
  79220. /**
  79221. * Update the current camera state depending on the inputs that have been used this frame.
  79222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79223. */
  79224. checkInputs(): void;
  79225. /**
  79226. * Gets the class name of the current intput.
  79227. * @returns the class name
  79228. */
  79229. getClassName(): string;
  79230. /**
  79231. * Get the friendly name associated with the input class.
  79232. * @returns the input friendly name
  79233. */
  79234. getSimpleName(): string;
  79235. }
  79236. }
  79237. declare module BABYLON {
  79238. /**
  79239. * Default Inputs manager for the FreeCamera.
  79240. * It groups all the default supported inputs for ease of use.
  79241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79242. */
  79243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79244. /**
  79245. * @hidden
  79246. */
  79247. _mouseInput: Nullable<FreeCameraMouseInput>;
  79248. /**
  79249. * Instantiates a new FreeCameraInputsManager.
  79250. * @param camera Defines the camera the inputs belong to
  79251. */
  79252. constructor(camera: FreeCamera);
  79253. /**
  79254. * Add keyboard input support to the input manager.
  79255. * @returns the current input manager
  79256. */
  79257. addKeyboard(): FreeCameraInputsManager;
  79258. /**
  79259. * Add mouse input support to the input manager.
  79260. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79261. * @returns the current input manager
  79262. */
  79263. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79264. /**
  79265. * Removes the mouse input support from the manager
  79266. * @returns the current input manager
  79267. */
  79268. removeMouse(): FreeCameraInputsManager;
  79269. /**
  79270. * Add touch input support to the input manager.
  79271. * @returns the current input manager
  79272. */
  79273. addTouch(): FreeCameraInputsManager;
  79274. /**
  79275. * Remove all attached input methods from a camera
  79276. */
  79277. clear(): void;
  79278. }
  79279. }
  79280. declare module BABYLON {
  79281. /**
  79282. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79283. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79285. */
  79286. export class FreeCamera extends TargetCamera {
  79287. /**
  79288. * Define the collision ellipsoid of the camera.
  79289. * This is helpful to simulate a camera body like the player body around the camera
  79290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79291. */
  79292. ellipsoid: Vector3;
  79293. /**
  79294. * Define an offset for the position of the ellipsoid around the camera.
  79295. * This can be helpful to determine the center of the body near the gravity center of the body
  79296. * instead of its head.
  79297. */
  79298. ellipsoidOffset: Vector3;
  79299. /**
  79300. * Enable or disable collisions of the camera with the rest of the scene objects.
  79301. */
  79302. checkCollisions: boolean;
  79303. /**
  79304. * Enable or disable gravity on the camera.
  79305. */
  79306. applyGravity: boolean;
  79307. /**
  79308. * Define the input manager associated to the camera.
  79309. */
  79310. inputs: FreeCameraInputsManager;
  79311. /**
  79312. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79313. * Higher values reduce sensitivity.
  79314. */
  79315. /**
  79316. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79317. * Higher values reduce sensitivity.
  79318. */
  79319. angularSensibility: number;
  79320. /**
  79321. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79322. */
  79323. keysUp: number[];
  79324. /**
  79325. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79326. */
  79327. keysDown: number[];
  79328. /**
  79329. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79330. */
  79331. keysLeft: number[];
  79332. /**
  79333. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79334. */
  79335. keysRight: number[];
  79336. /**
  79337. * Event raised when the camera collide with a mesh in the scene.
  79338. */
  79339. onCollide: (collidedMesh: AbstractMesh) => void;
  79340. private _collider;
  79341. private _needMoveForGravity;
  79342. private _oldPosition;
  79343. private _diffPosition;
  79344. private _newPosition;
  79345. /** @hidden */
  79346. _localDirection: Vector3;
  79347. /** @hidden */
  79348. _transformedDirection: Vector3;
  79349. /**
  79350. * Instantiates a Free Camera.
  79351. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79352. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79353. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79354. * @param name Define the name of the camera in the scene
  79355. * @param position Define the start position of the camera in the scene
  79356. * @param scene Define the scene the camera belongs to
  79357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79358. */
  79359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79360. /**
  79361. * Attached controls to the current camera.
  79362. * @param element Defines the element the controls should be listened from
  79363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79364. */
  79365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79366. /**
  79367. * Detach the current controls from the camera.
  79368. * The camera will stop reacting to inputs.
  79369. * @param element Defines the element to stop listening the inputs from
  79370. */
  79371. detachControl(element: HTMLElement): void;
  79372. private _collisionMask;
  79373. /**
  79374. * Define a collision mask to limit the list of object the camera can collide with
  79375. */
  79376. collisionMask: number;
  79377. /** @hidden */
  79378. _collideWithWorld(displacement: Vector3): void;
  79379. private _onCollisionPositionChange;
  79380. /** @hidden */
  79381. _checkInputs(): void;
  79382. /** @hidden */
  79383. _decideIfNeedsToMove(): boolean;
  79384. /** @hidden */
  79385. _updatePosition(): void;
  79386. /**
  79387. * Destroy the camera and release the current resources hold by it.
  79388. */
  79389. dispose(): void;
  79390. /**
  79391. * Gets the current object class name.
  79392. * @return the class name
  79393. */
  79394. getClassName(): string;
  79395. }
  79396. }
  79397. declare module BABYLON {
  79398. /**
  79399. * Represents a gamepad control stick position
  79400. */
  79401. export class StickValues {
  79402. /**
  79403. * The x component of the control stick
  79404. */
  79405. x: number;
  79406. /**
  79407. * The y component of the control stick
  79408. */
  79409. y: number;
  79410. /**
  79411. * Initializes the gamepad x and y control stick values
  79412. * @param x The x component of the gamepad control stick value
  79413. * @param y The y component of the gamepad control stick value
  79414. */
  79415. constructor(
  79416. /**
  79417. * The x component of the control stick
  79418. */
  79419. x: number,
  79420. /**
  79421. * The y component of the control stick
  79422. */
  79423. y: number);
  79424. }
  79425. /**
  79426. * An interface which manages callbacks for gamepad button changes
  79427. */
  79428. export interface GamepadButtonChanges {
  79429. /**
  79430. * Called when a gamepad has been changed
  79431. */
  79432. changed: boolean;
  79433. /**
  79434. * Called when a gamepad press event has been triggered
  79435. */
  79436. pressChanged: boolean;
  79437. /**
  79438. * Called when a touch event has been triggered
  79439. */
  79440. touchChanged: boolean;
  79441. /**
  79442. * Called when a value has changed
  79443. */
  79444. valueChanged: boolean;
  79445. }
  79446. /**
  79447. * Represents a gamepad
  79448. */
  79449. export class Gamepad {
  79450. /**
  79451. * The id of the gamepad
  79452. */
  79453. id: string;
  79454. /**
  79455. * The index of the gamepad
  79456. */
  79457. index: number;
  79458. /**
  79459. * The browser gamepad
  79460. */
  79461. browserGamepad: any;
  79462. /**
  79463. * Specifies what type of gamepad this represents
  79464. */
  79465. type: number;
  79466. private _leftStick;
  79467. private _rightStick;
  79468. /** @hidden */
  79469. _isConnected: boolean;
  79470. private _leftStickAxisX;
  79471. private _leftStickAxisY;
  79472. private _rightStickAxisX;
  79473. private _rightStickAxisY;
  79474. /**
  79475. * Triggered when the left control stick has been changed
  79476. */
  79477. private _onleftstickchanged;
  79478. /**
  79479. * Triggered when the right control stick has been changed
  79480. */
  79481. private _onrightstickchanged;
  79482. /**
  79483. * Represents a gamepad controller
  79484. */
  79485. static GAMEPAD: number;
  79486. /**
  79487. * Represents a generic controller
  79488. */
  79489. static GENERIC: number;
  79490. /**
  79491. * Represents an XBox controller
  79492. */
  79493. static XBOX: number;
  79494. /**
  79495. * Represents a pose-enabled controller
  79496. */
  79497. static POSE_ENABLED: number;
  79498. /**
  79499. * Represents an Dual Shock controller
  79500. */
  79501. static DUALSHOCK: number;
  79502. /**
  79503. * Specifies whether the left control stick should be Y-inverted
  79504. */
  79505. protected _invertLeftStickY: boolean;
  79506. /**
  79507. * Specifies if the gamepad has been connected
  79508. */
  79509. readonly isConnected: boolean;
  79510. /**
  79511. * Initializes the gamepad
  79512. * @param id The id of the gamepad
  79513. * @param index The index of the gamepad
  79514. * @param browserGamepad The browser gamepad
  79515. * @param leftStickX The x component of the left joystick
  79516. * @param leftStickY The y component of the left joystick
  79517. * @param rightStickX The x component of the right joystick
  79518. * @param rightStickY The y component of the right joystick
  79519. */
  79520. constructor(
  79521. /**
  79522. * The id of the gamepad
  79523. */
  79524. id: string,
  79525. /**
  79526. * The index of the gamepad
  79527. */
  79528. index: number,
  79529. /**
  79530. * The browser gamepad
  79531. */
  79532. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79533. /**
  79534. * Callback triggered when the left joystick has changed
  79535. * @param callback
  79536. */
  79537. onleftstickchanged(callback: (values: StickValues) => void): void;
  79538. /**
  79539. * Callback triggered when the right joystick has changed
  79540. * @param callback
  79541. */
  79542. onrightstickchanged(callback: (values: StickValues) => void): void;
  79543. /**
  79544. * Gets the left joystick
  79545. */
  79546. /**
  79547. * Sets the left joystick values
  79548. */
  79549. leftStick: StickValues;
  79550. /**
  79551. * Gets the right joystick
  79552. */
  79553. /**
  79554. * Sets the right joystick value
  79555. */
  79556. rightStick: StickValues;
  79557. /**
  79558. * Updates the gamepad joystick positions
  79559. */
  79560. update(): void;
  79561. /**
  79562. * Disposes the gamepad
  79563. */
  79564. dispose(): void;
  79565. }
  79566. /**
  79567. * Represents a generic gamepad
  79568. */
  79569. export class GenericPad extends Gamepad {
  79570. private _buttons;
  79571. private _onbuttondown;
  79572. private _onbuttonup;
  79573. /**
  79574. * Observable triggered when a button has been pressed
  79575. */
  79576. onButtonDownObservable: Observable<number>;
  79577. /**
  79578. * Observable triggered when a button has been released
  79579. */
  79580. onButtonUpObservable: Observable<number>;
  79581. /**
  79582. * Callback triggered when a button has been pressed
  79583. * @param callback Called when a button has been pressed
  79584. */
  79585. onbuttondown(callback: (buttonPressed: number) => void): void;
  79586. /**
  79587. * Callback triggered when a button has been released
  79588. * @param callback Called when a button has been released
  79589. */
  79590. onbuttonup(callback: (buttonReleased: number) => void): void;
  79591. /**
  79592. * Initializes the generic gamepad
  79593. * @param id The id of the generic gamepad
  79594. * @param index The index of the generic gamepad
  79595. * @param browserGamepad The browser gamepad
  79596. */
  79597. constructor(id: string, index: number, browserGamepad: any);
  79598. private _setButtonValue;
  79599. /**
  79600. * Updates the generic gamepad
  79601. */
  79602. update(): void;
  79603. /**
  79604. * Disposes the generic gamepad
  79605. */
  79606. dispose(): void;
  79607. }
  79608. }
  79609. declare module BABYLON {
  79610. interface Engine {
  79611. /**
  79612. * Creates a raw texture
  79613. * @param data defines the data to store in the texture
  79614. * @param width defines the width of the texture
  79615. * @param height defines the height of the texture
  79616. * @param format defines the format of the data
  79617. * @param generateMipMaps defines if the engine should generate the mip levels
  79618. * @param invertY defines if data must be stored with Y axis inverted
  79619. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79620. * @param compression defines the compression used (null by default)
  79621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79622. * @returns the raw texture inside an InternalTexture
  79623. */
  79624. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79625. /**
  79626. * Update a raw texture
  79627. * @param texture defines the texture to update
  79628. * @param data defines the data to store in the texture
  79629. * @param format defines the format of the data
  79630. * @param invertY defines if data must be stored with Y axis inverted
  79631. */
  79632. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79633. /**
  79634. * Update a raw texture
  79635. * @param texture defines the texture to update
  79636. * @param data defines the data to store in the texture
  79637. * @param format defines the format of the data
  79638. * @param invertY defines if data must be stored with Y axis inverted
  79639. * @param compression defines the compression used (null by default)
  79640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79641. */
  79642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79643. /**
  79644. * Creates a new raw cube texture
  79645. * @param data defines the array of data to use to create each face
  79646. * @param size defines the size of the textures
  79647. * @param format defines the format of the data
  79648. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79649. * @param generateMipMaps defines if the engine should generate the mip levels
  79650. * @param invertY defines if data must be stored with Y axis inverted
  79651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79652. * @param compression defines the compression used (null by default)
  79653. * @returns the cube texture as an InternalTexture
  79654. */
  79655. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79656. /**
  79657. * Update a raw cube texture
  79658. * @param texture defines the texture to udpdate
  79659. * @param data defines the data to store
  79660. * @param format defines the data format
  79661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79662. * @param invertY defines if data must be stored with Y axis inverted
  79663. */
  79664. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79665. /**
  79666. * Update a raw cube texture
  79667. * @param texture defines the texture to udpdate
  79668. * @param data defines the data to store
  79669. * @param format defines the data format
  79670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79671. * @param invertY defines if data must be stored with Y axis inverted
  79672. * @param compression defines the compression used (null by default)
  79673. */
  79674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79675. /**
  79676. * Update a raw cube texture
  79677. * @param texture defines the texture to udpdate
  79678. * @param data defines the data to store
  79679. * @param format defines the data format
  79680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79681. * @param invertY defines if data must be stored with Y axis inverted
  79682. * @param compression defines the compression used (null by default)
  79683. * @param level defines which level of the texture to update
  79684. */
  79685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79686. /**
  79687. * Creates a new raw cube texture from a specified url
  79688. * @param url defines the url where the data is located
  79689. * @param scene defines the current scene
  79690. * @param size defines the size of the textures
  79691. * @param format defines the format of the data
  79692. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79693. * @param noMipmap defines if the engine should avoid generating the mip levels
  79694. * @param callback defines a callback used to extract texture data from loaded data
  79695. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79696. * @param onLoad defines a callback called when texture is loaded
  79697. * @param onError defines a callback called if there is an error
  79698. * @returns the cube texture as an InternalTexture
  79699. */
  79700. 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;
  79701. /**
  79702. * Creates a new raw cube texture from a specified url
  79703. * @param url defines the url where the data is located
  79704. * @param scene defines the current scene
  79705. * @param size defines the size of the textures
  79706. * @param format defines the format of the data
  79707. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79708. * @param noMipmap defines if the engine should avoid generating the mip levels
  79709. * @param callback defines a callback used to extract texture data from loaded data
  79710. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79711. * @param onLoad defines a callback called when texture is loaded
  79712. * @param onError defines a callback called if there is an error
  79713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79714. * @param invertY defines if data must be stored with Y axis inverted
  79715. * @returns the cube texture as an InternalTexture
  79716. */
  79717. 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;
  79718. /**
  79719. * Creates a new raw 3D texture
  79720. * @param data defines the data used to create the texture
  79721. * @param width defines the width of the texture
  79722. * @param height defines the height of the texture
  79723. * @param depth defines the depth of the texture
  79724. * @param format defines the format of the texture
  79725. * @param generateMipMaps defines if the engine must generate mip levels
  79726. * @param invertY defines if data must be stored with Y axis inverted
  79727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79728. * @param compression defines the compressed used (can be null)
  79729. * @param textureType defines the compressed used (can be null)
  79730. * @returns a new raw 3D texture (stored in an InternalTexture)
  79731. */
  79732. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79733. /**
  79734. * Update a raw 3D texture
  79735. * @param texture defines the texture to update
  79736. * @param data defines the data to store
  79737. * @param format defines the data format
  79738. * @param invertY defines if data must be stored with Y axis inverted
  79739. */
  79740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79741. /**
  79742. * Update a raw 3D texture
  79743. * @param texture defines the texture to update
  79744. * @param data defines the data to store
  79745. * @param format defines the data format
  79746. * @param invertY defines if data must be stored with Y axis inverted
  79747. * @param compression defines the used compression (can be null)
  79748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79749. */
  79750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79751. }
  79752. }
  79753. declare module BABYLON {
  79754. /**
  79755. * Raw texture can help creating a texture directly from an array of data.
  79756. * This can be super useful if you either get the data from an uncompressed source or
  79757. * if you wish to create your texture pixel by pixel.
  79758. */
  79759. export class RawTexture extends Texture {
  79760. /**
  79761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79762. */
  79763. format: number;
  79764. private _engine;
  79765. /**
  79766. * Instantiates a new RawTexture.
  79767. * Raw texture can help creating a texture directly from an array of data.
  79768. * This can be super useful if you either get the data from an uncompressed source or
  79769. * if you wish to create your texture pixel by pixel.
  79770. * @param data define the array of data to use to create the texture
  79771. * @param width define the width of the texture
  79772. * @param height define the height of the texture
  79773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79774. * @param scene define the scene the texture belongs to
  79775. * @param generateMipMaps define whether mip maps should be generated or not
  79776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79779. */
  79780. constructor(data: ArrayBufferView, width: number, height: number,
  79781. /**
  79782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79783. */
  79784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79785. /**
  79786. * Updates the texture underlying data.
  79787. * @param data Define the new data of the texture
  79788. */
  79789. update(data: ArrayBufferView): void;
  79790. /**
  79791. * Creates a luminance texture from some data.
  79792. * @param data Define the texture data
  79793. * @param width Define the width of the texture
  79794. * @param height Define the height of the texture
  79795. * @param scene Define the scene the texture belongs to
  79796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79799. * @returns the luminance texture
  79800. */
  79801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79802. /**
  79803. * Creates a luminance alpha texture from some data.
  79804. * @param data Define the texture data
  79805. * @param width Define the width of the texture
  79806. * @param height Define the height of the texture
  79807. * @param scene Define the scene the texture belongs to
  79808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79811. * @returns the luminance alpha texture
  79812. */
  79813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79814. /**
  79815. * Creates an alpha texture from some data.
  79816. * @param data Define the texture data
  79817. * @param width Define the width of the texture
  79818. * @param height Define the height of the texture
  79819. * @param scene Define the scene the texture belongs to
  79820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79823. * @returns the alpha texture
  79824. */
  79825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79826. /**
  79827. * Creates a RGB texture from some data.
  79828. * @param data Define the texture data
  79829. * @param width Define the width of the texture
  79830. * @param height Define the height of the texture
  79831. * @param scene Define the scene the texture belongs to
  79832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79836. * @returns the RGB alpha texture
  79837. */
  79838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79839. /**
  79840. * Creates a RGBA texture from some data.
  79841. * @param data Define the texture data
  79842. * @param width Define the width of the texture
  79843. * @param height Define the height of the texture
  79844. * @param scene Define the scene the texture belongs to
  79845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79849. * @returns the RGBA texture
  79850. */
  79851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79852. /**
  79853. * Creates a R texture from some data.
  79854. * @param data Define the texture data
  79855. * @param width Define the width of the texture
  79856. * @param height Define the height of the texture
  79857. * @param scene Define the scene the texture belongs to
  79858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79862. * @returns the R texture
  79863. */
  79864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79865. }
  79866. }
  79867. declare module BABYLON {
  79868. /**
  79869. * Interface for the size containing width and height
  79870. */
  79871. export interface ISize {
  79872. /**
  79873. * Width
  79874. */
  79875. width: number;
  79876. /**
  79877. * Heighht
  79878. */
  79879. height: number;
  79880. }
  79881. /**
  79882. * Size containing widht and height
  79883. */
  79884. export class Size implements ISize {
  79885. /**
  79886. * Width
  79887. */
  79888. width: number;
  79889. /**
  79890. * Height
  79891. */
  79892. height: number;
  79893. /**
  79894. * Creates a Size object from the given width and height (floats).
  79895. * @param width width of the new size
  79896. * @param height height of the new size
  79897. */
  79898. constructor(width: number, height: number);
  79899. /**
  79900. * Returns a string with the Size width and height
  79901. * @returns a string with the Size width and height
  79902. */
  79903. toString(): string;
  79904. /**
  79905. * "Size"
  79906. * @returns the string "Size"
  79907. */
  79908. getClassName(): string;
  79909. /**
  79910. * Returns the Size hash code.
  79911. * @returns a hash code for a unique width and height
  79912. */
  79913. getHashCode(): number;
  79914. /**
  79915. * Updates the current size from the given one.
  79916. * @param src the given size
  79917. */
  79918. copyFrom(src: Size): void;
  79919. /**
  79920. * Updates in place the current Size from the given floats.
  79921. * @param width width of the new size
  79922. * @param height height of the new size
  79923. * @returns the updated Size.
  79924. */
  79925. copyFromFloats(width: number, height: number): Size;
  79926. /**
  79927. * Updates in place the current Size from the given floats.
  79928. * @param width width to set
  79929. * @param height height to set
  79930. * @returns the updated Size.
  79931. */
  79932. set(width: number, height: number): Size;
  79933. /**
  79934. * Multiplies the width and height by numbers
  79935. * @param w factor to multiple the width by
  79936. * @param h factor to multiple the height by
  79937. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79938. */
  79939. multiplyByFloats(w: number, h: number): Size;
  79940. /**
  79941. * Clones the size
  79942. * @returns a new Size copied from the given one.
  79943. */
  79944. clone(): Size;
  79945. /**
  79946. * True if the current Size and the given one width and height are strictly equal.
  79947. * @param other the other size to compare against
  79948. * @returns True if the current Size and the given one width and height are strictly equal.
  79949. */
  79950. equals(other: Size): boolean;
  79951. /**
  79952. * The surface of the Size : width * height (float).
  79953. */
  79954. readonly surface: number;
  79955. /**
  79956. * Create a new size of zero
  79957. * @returns a new Size set to (0.0, 0.0)
  79958. */
  79959. static Zero(): Size;
  79960. /**
  79961. * Sums the width and height of two sizes
  79962. * @param otherSize size to add to this size
  79963. * @returns a new Size set as the addition result of the current Size and the given one.
  79964. */
  79965. add(otherSize: Size): Size;
  79966. /**
  79967. * Subtracts the width and height of two
  79968. * @param otherSize size to subtract to this size
  79969. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79970. */
  79971. subtract(otherSize: Size): Size;
  79972. /**
  79973. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79974. * @param start starting size to lerp between
  79975. * @param end end size to lerp between
  79976. * @param amount amount to lerp between the start and end values
  79977. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79978. */
  79979. static Lerp(start: Size, end: Size, amount: number): Size;
  79980. }
  79981. }
  79982. declare module BABYLON {
  79983. /**
  79984. * Defines a runtime animation
  79985. */
  79986. export class RuntimeAnimation {
  79987. private _events;
  79988. /**
  79989. * The current frame of the runtime animation
  79990. */
  79991. private _currentFrame;
  79992. /**
  79993. * The animation used by the runtime animation
  79994. */
  79995. private _animation;
  79996. /**
  79997. * The target of the runtime animation
  79998. */
  79999. private _target;
  80000. /**
  80001. * The initiating animatable
  80002. */
  80003. private _host;
  80004. /**
  80005. * The original value of the runtime animation
  80006. */
  80007. private _originalValue;
  80008. /**
  80009. * The original blend value of the runtime animation
  80010. */
  80011. private _originalBlendValue;
  80012. /**
  80013. * The offsets cache of the runtime animation
  80014. */
  80015. private _offsetsCache;
  80016. /**
  80017. * The high limits cache of the runtime animation
  80018. */
  80019. private _highLimitsCache;
  80020. /**
  80021. * Specifies if the runtime animation has been stopped
  80022. */
  80023. private _stopped;
  80024. /**
  80025. * The blending factor of the runtime animation
  80026. */
  80027. private _blendingFactor;
  80028. /**
  80029. * The BabylonJS scene
  80030. */
  80031. private _scene;
  80032. /**
  80033. * The current value of the runtime animation
  80034. */
  80035. private _currentValue;
  80036. /** @hidden */
  80037. _animationState: _IAnimationState;
  80038. /**
  80039. * The active target of the runtime animation
  80040. */
  80041. private _activeTargets;
  80042. private _currentActiveTarget;
  80043. private _directTarget;
  80044. /**
  80045. * The target path of the runtime animation
  80046. */
  80047. private _targetPath;
  80048. /**
  80049. * The weight of the runtime animation
  80050. */
  80051. private _weight;
  80052. /**
  80053. * The ratio offset of the runtime animation
  80054. */
  80055. private _ratioOffset;
  80056. /**
  80057. * The previous delay of the runtime animation
  80058. */
  80059. private _previousDelay;
  80060. /**
  80061. * The previous ratio of the runtime animation
  80062. */
  80063. private _previousRatio;
  80064. private _enableBlending;
  80065. private _keys;
  80066. private _minFrame;
  80067. private _maxFrame;
  80068. private _minValue;
  80069. private _maxValue;
  80070. private _targetIsArray;
  80071. /**
  80072. * Gets the current frame of the runtime animation
  80073. */
  80074. readonly currentFrame: number;
  80075. /**
  80076. * Gets the weight of the runtime animation
  80077. */
  80078. readonly weight: number;
  80079. /**
  80080. * Gets the current value of the runtime animation
  80081. */
  80082. readonly currentValue: any;
  80083. /**
  80084. * Gets the target path of the runtime animation
  80085. */
  80086. readonly targetPath: string;
  80087. /**
  80088. * Gets the actual target of the runtime animation
  80089. */
  80090. readonly target: any;
  80091. /** @hidden */
  80092. _onLoop: () => void;
  80093. /**
  80094. * Create a new RuntimeAnimation object
  80095. * @param target defines the target of the animation
  80096. * @param animation defines the source animation object
  80097. * @param scene defines the hosting scene
  80098. * @param host defines the initiating Animatable
  80099. */
  80100. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80101. private _preparePath;
  80102. /**
  80103. * Gets the animation from the runtime animation
  80104. */
  80105. readonly animation: Animation;
  80106. /**
  80107. * Resets the runtime animation to the beginning
  80108. * @param restoreOriginal defines whether to restore the target property to the original value
  80109. */
  80110. reset(restoreOriginal?: boolean): void;
  80111. /**
  80112. * Specifies if the runtime animation is stopped
  80113. * @returns Boolean specifying if the runtime animation is stopped
  80114. */
  80115. isStopped(): boolean;
  80116. /**
  80117. * Disposes of the runtime animation
  80118. */
  80119. dispose(): void;
  80120. /**
  80121. * Apply the interpolated value to the target
  80122. * @param currentValue defines the value computed by the animation
  80123. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80124. */
  80125. setValue(currentValue: any, weight: number): void;
  80126. private _getOriginalValues;
  80127. private _setValue;
  80128. /**
  80129. * Gets the loop pmode of the runtime animation
  80130. * @returns Loop Mode
  80131. */
  80132. private _getCorrectLoopMode;
  80133. /**
  80134. * Move the current animation to a given frame
  80135. * @param frame defines the frame to move to
  80136. */
  80137. goToFrame(frame: number): void;
  80138. /**
  80139. * @hidden Internal use only
  80140. */
  80141. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80142. /**
  80143. * Execute the current animation
  80144. * @param delay defines the delay to add to the current frame
  80145. * @param from defines the lower bound of the animation range
  80146. * @param to defines the upper bound of the animation range
  80147. * @param loop defines if the current animation must loop
  80148. * @param speedRatio defines the current speed ratio
  80149. * @param weight defines the weight of the animation (default is -1 so no weight)
  80150. * @param onLoop optional callback called when animation loops
  80151. * @returns a boolean indicating if the animation is running
  80152. */
  80153. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80154. }
  80155. }
  80156. declare module BABYLON {
  80157. /**
  80158. * Class used to store an actual running animation
  80159. */
  80160. export class Animatable {
  80161. /** defines the target object */
  80162. target: any;
  80163. /** defines the starting frame number (default is 0) */
  80164. fromFrame: number;
  80165. /** defines the ending frame number (default is 100) */
  80166. toFrame: number;
  80167. /** defines if the animation must loop (default is false) */
  80168. loopAnimation: boolean;
  80169. /** defines a callback to call when animation ends if it is not looping */
  80170. onAnimationEnd?: (() => void) | null | undefined;
  80171. /** defines a callback to call when animation loops */
  80172. onAnimationLoop?: (() => void) | null | undefined;
  80173. private _localDelayOffset;
  80174. private _pausedDelay;
  80175. private _runtimeAnimations;
  80176. private _paused;
  80177. private _scene;
  80178. private _speedRatio;
  80179. private _weight;
  80180. private _syncRoot;
  80181. /**
  80182. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80183. * This will only apply for non looping animation (default is true)
  80184. */
  80185. disposeOnEnd: boolean;
  80186. /**
  80187. * Gets a boolean indicating if the animation has started
  80188. */
  80189. animationStarted: boolean;
  80190. /**
  80191. * Observer raised when the animation ends
  80192. */
  80193. onAnimationEndObservable: Observable<Animatable>;
  80194. /**
  80195. * Observer raised when the animation loops
  80196. */
  80197. onAnimationLoopObservable: Observable<Animatable>;
  80198. /**
  80199. * Gets the root Animatable used to synchronize and normalize animations
  80200. */
  80201. readonly syncRoot: Nullable<Animatable>;
  80202. /**
  80203. * Gets the current frame of the first RuntimeAnimation
  80204. * Used to synchronize Animatables
  80205. */
  80206. readonly masterFrame: number;
  80207. /**
  80208. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80209. */
  80210. weight: number;
  80211. /**
  80212. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80213. */
  80214. speedRatio: number;
  80215. /**
  80216. * Creates a new Animatable
  80217. * @param scene defines the hosting scene
  80218. * @param target defines the target object
  80219. * @param fromFrame defines the starting frame number (default is 0)
  80220. * @param toFrame defines the ending frame number (default is 100)
  80221. * @param loopAnimation defines if the animation must loop (default is false)
  80222. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80223. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80224. * @param animations defines a group of animation to add to the new Animatable
  80225. * @param onAnimationLoop defines a callback to call when animation loops
  80226. */
  80227. constructor(scene: Scene,
  80228. /** defines the target object */
  80229. target: any,
  80230. /** defines the starting frame number (default is 0) */
  80231. fromFrame?: number,
  80232. /** defines the ending frame number (default is 100) */
  80233. toFrame?: number,
  80234. /** defines if the animation must loop (default is false) */
  80235. loopAnimation?: boolean, speedRatio?: number,
  80236. /** defines a callback to call when animation ends if it is not looping */
  80237. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80238. /** defines a callback to call when animation loops */
  80239. onAnimationLoop?: (() => void) | null | undefined);
  80240. /**
  80241. * Synchronize and normalize current Animatable with a source Animatable
  80242. * This is useful when using animation weights and when animations are not of the same length
  80243. * @param root defines the root Animatable to synchronize with
  80244. * @returns the current Animatable
  80245. */
  80246. syncWith(root: Animatable): Animatable;
  80247. /**
  80248. * Gets the list of runtime animations
  80249. * @returns an array of RuntimeAnimation
  80250. */
  80251. getAnimations(): RuntimeAnimation[];
  80252. /**
  80253. * Adds more animations to the current animatable
  80254. * @param target defines the target of the animations
  80255. * @param animations defines the new animations to add
  80256. */
  80257. appendAnimations(target: any, animations: Animation[]): void;
  80258. /**
  80259. * Gets the source animation for a specific property
  80260. * @param property defines the propertyu to look for
  80261. * @returns null or the source animation for the given property
  80262. */
  80263. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80264. /**
  80265. * Gets the runtime animation for a specific property
  80266. * @param property defines the propertyu to look for
  80267. * @returns null or the runtime animation for the given property
  80268. */
  80269. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80270. /**
  80271. * Resets the animatable to its original state
  80272. */
  80273. reset(): void;
  80274. /**
  80275. * Allows the animatable to blend with current running animations
  80276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80277. * @param blendingSpeed defines the blending speed to use
  80278. */
  80279. enableBlending(blendingSpeed: number): void;
  80280. /**
  80281. * Disable animation blending
  80282. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80283. */
  80284. disableBlending(): void;
  80285. /**
  80286. * Jump directly to a given frame
  80287. * @param frame defines the frame to jump to
  80288. */
  80289. goToFrame(frame: number): void;
  80290. /**
  80291. * Pause the animation
  80292. */
  80293. pause(): void;
  80294. /**
  80295. * Restart the animation
  80296. */
  80297. restart(): void;
  80298. private _raiseOnAnimationEnd;
  80299. /**
  80300. * Stop and delete the current animation
  80301. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80302. * @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)
  80303. */
  80304. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80305. /**
  80306. * Wait asynchronously for the animation to end
  80307. * @returns a promise which will be fullfilled when the animation ends
  80308. */
  80309. waitAsync(): Promise<Animatable>;
  80310. /** @hidden */
  80311. _animate(delay: number): boolean;
  80312. }
  80313. interface Scene {
  80314. /** @hidden */
  80315. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80316. /** @hidden */
  80317. _processLateAnimationBindingsForMatrices(holder: {
  80318. totalWeight: number;
  80319. animations: RuntimeAnimation[];
  80320. originalValue: Matrix;
  80321. }): any;
  80322. /** @hidden */
  80323. _processLateAnimationBindingsForQuaternions(holder: {
  80324. totalWeight: number;
  80325. animations: RuntimeAnimation[];
  80326. originalValue: Quaternion;
  80327. }, refQuaternion: Quaternion): Quaternion;
  80328. /** @hidden */
  80329. _processLateAnimationBindings(): void;
  80330. /**
  80331. * Will start the animation sequence of a given target
  80332. * @param target defines the target
  80333. * @param from defines from which frame should animation start
  80334. * @param to defines until which frame should animation run.
  80335. * @param weight defines the weight to apply to the animation (1.0 by default)
  80336. * @param loop defines if the animation loops
  80337. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80338. * @param onAnimationEnd defines the function to be executed when the animation ends
  80339. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80340. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80341. * @param onAnimationLoop defines the callback to call when an animation loops
  80342. * @returns the animatable object created for this animation
  80343. */
  80344. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80345. /**
  80346. * Will start the animation sequence of a given target
  80347. * @param target defines the target
  80348. * @param from defines from which frame should animation start
  80349. * @param to defines until which frame should animation run.
  80350. * @param loop defines if the animation loops
  80351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80352. * @param onAnimationEnd defines the function to be executed when the animation ends
  80353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80354. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80355. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80356. * @param onAnimationLoop defines the callback to call when an animation loops
  80357. * @returns the animatable object created for this animation
  80358. */
  80359. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80360. /**
  80361. * Will start the animation sequence of a given target and its hierarchy
  80362. * @param target defines the target
  80363. * @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.
  80364. * @param from defines from which frame should animation start
  80365. * @param to defines until which frame should animation run.
  80366. * @param loop defines if the animation loops
  80367. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80368. * @param onAnimationEnd defines the function to be executed when the animation ends
  80369. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80370. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80371. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80372. * @param onAnimationLoop defines the callback to call when an animation loops
  80373. * @returns the list of created animatables
  80374. */
  80375. 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[];
  80376. /**
  80377. * Begin a new animation on a given node
  80378. * @param target defines the target where the animation will take place
  80379. * @param animations defines the list of animations to start
  80380. * @param from defines the initial value
  80381. * @param to defines the final value
  80382. * @param loop defines if you want animation to loop (off by default)
  80383. * @param speedRatio defines the speed ratio to apply to all animations
  80384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80385. * @param onAnimationLoop defines the callback to call when an animation loops
  80386. * @returns the list of created animatables
  80387. */
  80388. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80389. /**
  80390. * Begin a new animation on a given node and its hierarchy
  80391. * @param target defines the root node where the animation will take place
  80392. * @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.
  80393. * @param animations defines the list of animations to start
  80394. * @param from defines the initial value
  80395. * @param to defines the final value
  80396. * @param loop defines if you want animation to loop (off by default)
  80397. * @param speedRatio defines the speed ratio to apply to all animations
  80398. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80399. * @param onAnimationLoop defines the callback to call when an animation loops
  80400. * @returns the list of animatables created for all nodes
  80401. */
  80402. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80403. /**
  80404. * Gets the animatable associated with a specific target
  80405. * @param target defines the target of the animatable
  80406. * @returns the required animatable if found
  80407. */
  80408. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80409. /**
  80410. * Gets all animatables associated with a given target
  80411. * @param target defines the target to look animatables for
  80412. * @returns an array of Animatables
  80413. */
  80414. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80415. /**
  80416. * Stops and removes all animations that have been applied to the scene
  80417. */
  80418. stopAllAnimations(): void;
  80419. /**
  80420. * Gets the current delta time used by animation engine
  80421. */
  80422. deltaTime: number;
  80423. }
  80424. interface Bone {
  80425. /**
  80426. * Copy an animation range from another bone
  80427. * @param source defines the source bone
  80428. * @param rangeName defines the range name to copy
  80429. * @param frameOffset defines the frame offset
  80430. * @param rescaleAsRequired defines if rescaling must be applied if required
  80431. * @param skelDimensionsRatio defines the scaling ratio
  80432. * @returns true if operation was successful
  80433. */
  80434. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80435. }
  80436. }
  80437. declare module BABYLON {
  80438. /**
  80439. * Class used to override all child animations of a given target
  80440. */
  80441. export class AnimationPropertiesOverride {
  80442. /**
  80443. * Gets or sets a value indicating if animation blending must be used
  80444. */
  80445. enableBlending: boolean;
  80446. /**
  80447. * Gets or sets the blending speed to use when enableBlending is true
  80448. */
  80449. blendingSpeed: number;
  80450. /**
  80451. * Gets or sets the default loop mode to use
  80452. */
  80453. loopMode: number;
  80454. }
  80455. }
  80456. declare module BABYLON {
  80457. /**
  80458. * Class used to handle skinning animations
  80459. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80460. */
  80461. export class Skeleton implements IAnimatable {
  80462. /** defines the skeleton name */
  80463. name: string;
  80464. /** defines the skeleton Id */
  80465. id: string;
  80466. /**
  80467. * Defines the list of child bones
  80468. */
  80469. bones: Bone[];
  80470. /**
  80471. * Defines an estimate of the dimension of the skeleton at rest
  80472. */
  80473. dimensionsAtRest: Vector3;
  80474. /**
  80475. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80476. */
  80477. needInitialSkinMatrix: boolean;
  80478. /**
  80479. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80480. */
  80481. overrideMesh: Nullable<AbstractMesh>;
  80482. /**
  80483. * Gets the list of animations attached to this skeleton
  80484. */
  80485. animations: Array<Animation>;
  80486. private _scene;
  80487. private _isDirty;
  80488. private _transformMatrices;
  80489. private _transformMatrixTexture;
  80490. private _meshesWithPoseMatrix;
  80491. private _animatables;
  80492. private _identity;
  80493. private _synchronizedWithMesh;
  80494. private _ranges;
  80495. private _lastAbsoluteTransformsUpdateId;
  80496. private _canUseTextureForBones;
  80497. private _uniqueId;
  80498. /** @hidden */
  80499. _numBonesWithLinkedTransformNode: number;
  80500. /** @hidden */
  80501. _hasWaitingData: Nullable<boolean>;
  80502. /**
  80503. * Specifies if the skeleton should be serialized
  80504. */
  80505. doNotSerialize: boolean;
  80506. private _useTextureToStoreBoneMatrices;
  80507. /**
  80508. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80509. * Please note that this option is not available if the hardware does not support it
  80510. */
  80511. useTextureToStoreBoneMatrices: boolean;
  80512. private _animationPropertiesOverride;
  80513. /**
  80514. * Gets or sets the animation properties override
  80515. */
  80516. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80517. /**
  80518. * List of inspectable custom properties (used by the Inspector)
  80519. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80520. */
  80521. inspectableCustomProperties: IInspectable[];
  80522. /**
  80523. * An observable triggered before computing the skeleton's matrices
  80524. */
  80525. onBeforeComputeObservable: Observable<Skeleton>;
  80526. /**
  80527. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80528. */
  80529. readonly isUsingTextureForMatrices: boolean;
  80530. /**
  80531. * Gets the unique ID of this skeleton
  80532. */
  80533. readonly uniqueId: number;
  80534. /**
  80535. * Creates a new skeleton
  80536. * @param name defines the skeleton name
  80537. * @param id defines the skeleton Id
  80538. * @param scene defines the hosting scene
  80539. */
  80540. constructor(
  80541. /** defines the skeleton name */
  80542. name: string,
  80543. /** defines the skeleton Id */
  80544. id: string, scene: Scene);
  80545. /**
  80546. * Gets the current object class name.
  80547. * @return the class name
  80548. */
  80549. getClassName(): string;
  80550. /**
  80551. * Returns an array containing the root bones
  80552. * @returns an array containing the root bones
  80553. */
  80554. getChildren(): Array<Bone>;
  80555. /**
  80556. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80557. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80558. * @returns a Float32Array containing matrices data
  80559. */
  80560. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80561. /**
  80562. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80563. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80564. * @returns a raw texture containing the data
  80565. */
  80566. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80567. /**
  80568. * Gets the current hosting scene
  80569. * @returns a scene object
  80570. */
  80571. getScene(): Scene;
  80572. /**
  80573. * Gets a string representing the current skeleton data
  80574. * @param fullDetails defines a boolean indicating if we want a verbose version
  80575. * @returns a string representing the current skeleton data
  80576. */
  80577. toString(fullDetails?: boolean): string;
  80578. /**
  80579. * Get bone's index searching by name
  80580. * @param name defines bone's name to search for
  80581. * @return the indice of the bone. Returns -1 if not found
  80582. */
  80583. getBoneIndexByName(name: string): number;
  80584. /**
  80585. * Creater a new animation range
  80586. * @param name defines the name of the range
  80587. * @param from defines the start key
  80588. * @param to defines the end key
  80589. */
  80590. createAnimationRange(name: string, from: number, to: number): void;
  80591. /**
  80592. * Delete a specific animation range
  80593. * @param name defines the name of the range
  80594. * @param deleteFrames defines if frames must be removed as well
  80595. */
  80596. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80597. /**
  80598. * Gets a specific animation range
  80599. * @param name defines the name of the range to look for
  80600. * @returns the requested animation range or null if not found
  80601. */
  80602. getAnimationRange(name: string): Nullable<AnimationRange>;
  80603. /**
  80604. * Gets the list of all animation ranges defined on this skeleton
  80605. * @returns an array
  80606. */
  80607. getAnimationRanges(): Nullable<AnimationRange>[];
  80608. /**
  80609. * Copy animation range from a source skeleton.
  80610. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80611. * @param source defines the source skeleton
  80612. * @param name defines the name of the range to copy
  80613. * @param rescaleAsRequired defines if rescaling must be applied if required
  80614. * @returns true if operation was successful
  80615. */
  80616. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80617. /**
  80618. * Forces the skeleton to go to rest pose
  80619. */
  80620. returnToRest(): void;
  80621. private _getHighestAnimationFrame;
  80622. /**
  80623. * Begin a specific animation range
  80624. * @param name defines the name of the range to start
  80625. * @param loop defines if looping must be turned on (false by default)
  80626. * @param speedRatio defines the speed ratio to apply (1 by default)
  80627. * @param onAnimationEnd defines a callback which will be called when animation will end
  80628. * @returns a new animatable
  80629. */
  80630. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80631. /** @hidden */
  80632. _markAsDirty(): void;
  80633. /** @hidden */
  80634. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80635. /** @hidden */
  80636. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80637. private _computeTransformMatrices;
  80638. /**
  80639. * Build all resources required to render a skeleton
  80640. */
  80641. prepare(): void;
  80642. /**
  80643. * Gets the list of animatables currently running for this skeleton
  80644. * @returns an array of animatables
  80645. */
  80646. getAnimatables(): IAnimatable[];
  80647. /**
  80648. * Clone the current skeleton
  80649. * @param name defines the name of the new skeleton
  80650. * @param id defines the id of the new skeleton
  80651. * @returns the new skeleton
  80652. */
  80653. clone(name: string, id: string): Skeleton;
  80654. /**
  80655. * Enable animation blending for this skeleton
  80656. * @param blendingSpeed defines the blending speed to apply
  80657. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80658. */
  80659. enableBlending(blendingSpeed?: number): void;
  80660. /**
  80661. * Releases all resources associated with the current skeleton
  80662. */
  80663. dispose(): void;
  80664. /**
  80665. * Serialize the skeleton in a JSON object
  80666. * @returns a JSON object
  80667. */
  80668. serialize(): any;
  80669. /**
  80670. * Creates a new skeleton from serialized data
  80671. * @param parsedSkeleton defines the serialized data
  80672. * @param scene defines the hosting scene
  80673. * @returns a new skeleton
  80674. */
  80675. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80676. /**
  80677. * Compute all node absolute transforms
  80678. * @param forceUpdate defines if computation must be done even if cache is up to date
  80679. */
  80680. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80681. /**
  80682. * Gets the root pose matrix
  80683. * @returns a matrix
  80684. */
  80685. getPoseMatrix(): Nullable<Matrix>;
  80686. /**
  80687. * Sorts bones per internal index
  80688. */
  80689. sortBones(): void;
  80690. private _sortBones;
  80691. }
  80692. }
  80693. declare module BABYLON {
  80694. /**
  80695. * Class used to store bone information
  80696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80697. */
  80698. export class Bone extends Node {
  80699. /**
  80700. * defines the bone name
  80701. */
  80702. name: string;
  80703. private static _tmpVecs;
  80704. private static _tmpQuat;
  80705. private static _tmpMats;
  80706. /**
  80707. * Gets the list of child bones
  80708. */
  80709. children: Bone[];
  80710. /** Gets the animations associated with this bone */
  80711. animations: Animation[];
  80712. /**
  80713. * Gets or sets bone length
  80714. */
  80715. length: number;
  80716. /**
  80717. * @hidden Internal only
  80718. * Set this value to map this bone to a different index in the transform matrices
  80719. * Set this value to -1 to exclude the bone from the transform matrices
  80720. */
  80721. _index: Nullable<number>;
  80722. private _skeleton;
  80723. private _localMatrix;
  80724. private _restPose;
  80725. private _baseMatrix;
  80726. private _absoluteTransform;
  80727. private _invertedAbsoluteTransform;
  80728. private _parent;
  80729. private _scalingDeterminant;
  80730. private _worldTransform;
  80731. private _localScaling;
  80732. private _localRotation;
  80733. private _localPosition;
  80734. private _needToDecompose;
  80735. private _needToCompose;
  80736. /** @hidden */
  80737. _linkedTransformNode: Nullable<TransformNode>;
  80738. /** @hidden */
  80739. _waitingTransformNodeId: Nullable<string>;
  80740. /** @hidden */
  80741. /** @hidden */
  80742. _matrix: Matrix;
  80743. /**
  80744. * Create a new bone
  80745. * @param name defines the bone name
  80746. * @param skeleton defines the parent skeleton
  80747. * @param parentBone defines the parent (can be null if the bone is the root)
  80748. * @param localMatrix defines the local matrix
  80749. * @param restPose defines the rest pose matrix
  80750. * @param baseMatrix defines the base matrix
  80751. * @param index defines index of the bone in the hiearchy
  80752. */
  80753. constructor(
  80754. /**
  80755. * defines the bone name
  80756. */
  80757. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80758. /**
  80759. * Gets the current object class name.
  80760. * @return the class name
  80761. */
  80762. getClassName(): string;
  80763. /**
  80764. * Gets the parent skeleton
  80765. * @returns a skeleton
  80766. */
  80767. getSkeleton(): Skeleton;
  80768. /**
  80769. * Gets parent bone
  80770. * @returns a bone or null if the bone is the root of the bone hierarchy
  80771. */
  80772. getParent(): Nullable<Bone>;
  80773. /**
  80774. * Returns an array containing the root bones
  80775. * @returns an array containing the root bones
  80776. */
  80777. getChildren(): Array<Bone>;
  80778. /**
  80779. * Sets the parent bone
  80780. * @param parent defines the parent (can be null if the bone is the root)
  80781. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80782. */
  80783. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80784. /**
  80785. * Gets the local matrix
  80786. * @returns a matrix
  80787. */
  80788. getLocalMatrix(): Matrix;
  80789. /**
  80790. * Gets the base matrix (initial matrix which remains unchanged)
  80791. * @returns a matrix
  80792. */
  80793. getBaseMatrix(): Matrix;
  80794. /**
  80795. * Gets the rest pose matrix
  80796. * @returns a matrix
  80797. */
  80798. getRestPose(): Matrix;
  80799. /**
  80800. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80801. */
  80802. getWorldMatrix(): Matrix;
  80803. /**
  80804. * Sets the local matrix to rest pose matrix
  80805. */
  80806. returnToRest(): void;
  80807. /**
  80808. * Gets the inverse of the absolute transform matrix.
  80809. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80810. * @returns a matrix
  80811. */
  80812. getInvertedAbsoluteTransform(): Matrix;
  80813. /**
  80814. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80815. * @returns a matrix
  80816. */
  80817. getAbsoluteTransform(): Matrix;
  80818. /**
  80819. * Links with the given transform node.
  80820. * The local matrix of this bone is copied from the transform node every frame.
  80821. * @param transformNode defines the transform node to link to
  80822. */
  80823. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80824. /**
  80825. * Gets the node used to drive the bone's transformation
  80826. * @returns a transform node or null
  80827. */
  80828. getTransformNode(): Nullable<TransformNode>;
  80829. /** Gets or sets current position (in local space) */
  80830. position: Vector3;
  80831. /** Gets or sets current rotation (in local space) */
  80832. rotation: Vector3;
  80833. /** Gets or sets current rotation quaternion (in local space) */
  80834. rotationQuaternion: Quaternion;
  80835. /** Gets or sets current scaling (in local space) */
  80836. scaling: Vector3;
  80837. /**
  80838. * Gets the animation properties override
  80839. */
  80840. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80841. private _decompose;
  80842. private _compose;
  80843. /**
  80844. * Update the base and local matrices
  80845. * @param matrix defines the new base or local matrix
  80846. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80847. * @param updateLocalMatrix defines if the local matrix should be updated
  80848. */
  80849. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80850. /** @hidden */
  80851. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80852. /**
  80853. * Flag the bone as dirty (Forcing it to update everything)
  80854. */
  80855. markAsDirty(): void;
  80856. /** @hidden */
  80857. _markAsDirtyAndCompose(): void;
  80858. private _markAsDirtyAndDecompose;
  80859. /**
  80860. * Translate the bone in local or world space
  80861. * @param vec The amount to translate the bone
  80862. * @param space The space that the translation is in
  80863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80864. */
  80865. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80866. /**
  80867. * Set the postion of the bone in local or world space
  80868. * @param position The position to set the bone
  80869. * @param space The space that the position is in
  80870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80871. */
  80872. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80873. /**
  80874. * Set the absolute position of the bone (world space)
  80875. * @param position The position to set the bone
  80876. * @param mesh The mesh that this bone is attached to
  80877. */
  80878. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80879. /**
  80880. * Scale the bone on the x, y and z axes (in local space)
  80881. * @param x The amount to scale the bone on the x axis
  80882. * @param y The amount to scale the bone on the y axis
  80883. * @param z The amount to scale the bone on the z axis
  80884. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80885. */
  80886. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80887. /**
  80888. * Set the bone scaling in local space
  80889. * @param scale defines the scaling vector
  80890. */
  80891. setScale(scale: Vector3): void;
  80892. /**
  80893. * Gets the current scaling in local space
  80894. * @returns the current scaling vector
  80895. */
  80896. getScale(): Vector3;
  80897. /**
  80898. * Gets the current scaling in local space and stores it in a target vector
  80899. * @param result defines the target vector
  80900. */
  80901. getScaleToRef(result: Vector3): void;
  80902. /**
  80903. * Set the yaw, pitch, and roll of the bone in local or world space
  80904. * @param yaw The rotation of the bone on the y axis
  80905. * @param pitch The rotation of the bone on the x axis
  80906. * @param roll The rotation of the bone on the z axis
  80907. * @param space The space that the axes of rotation are in
  80908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80909. */
  80910. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80911. /**
  80912. * Add a rotation to the bone on an axis in local or world space
  80913. * @param axis The axis to rotate the bone on
  80914. * @param amount The amount to rotate the bone
  80915. * @param space The space that the axis is in
  80916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80917. */
  80918. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80919. /**
  80920. * Set the rotation of the bone to a particular axis angle in local or world space
  80921. * @param axis The axis to rotate the bone on
  80922. * @param angle The angle that the bone should be rotated to
  80923. * @param space The space that the axis is in
  80924. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80925. */
  80926. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80927. /**
  80928. * Set the euler rotation of the bone in local of world space
  80929. * @param rotation The euler rotation that the bone should be set to
  80930. * @param space The space that the rotation is in
  80931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80932. */
  80933. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80934. /**
  80935. * Set the quaternion rotation of the bone in local of world space
  80936. * @param quat The quaternion rotation that the bone should be set to
  80937. * @param space The space that the rotation is in
  80938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80939. */
  80940. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80941. /**
  80942. * Set the rotation matrix of the bone in local of world space
  80943. * @param rotMat The rotation matrix that the bone should be set to
  80944. * @param space The space that the rotation is in
  80945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80946. */
  80947. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80948. private _rotateWithMatrix;
  80949. private _getNegativeRotationToRef;
  80950. /**
  80951. * Get the position of the bone in local or world space
  80952. * @param space The space that the returned position is in
  80953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80954. * @returns The position of the bone
  80955. */
  80956. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80957. /**
  80958. * Copy the position of the bone to a vector3 in local or world space
  80959. * @param space The space that the returned position is in
  80960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80961. * @param result The vector3 to copy the position to
  80962. */
  80963. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80964. /**
  80965. * Get the absolute position of the bone (world space)
  80966. * @param mesh The mesh that this bone is attached to
  80967. * @returns The absolute position of the bone
  80968. */
  80969. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80970. /**
  80971. * Copy the absolute position of the bone (world space) to the result param
  80972. * @param mesh The mesh that this bone is attached to
  80973. * @param result The vector3 to copy the absolute position to
  80974. */
  80975. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80976. /**
  80977. * Compute the absolute transforms of this bone and its children
  80978. */
  80979. computeAbsoluteTransforms(): void;
  80980. /**
  80981. * Get the world direction from an axis that is in the local space of the bone
  80982. * @param localAxis The local direction that is used to compute the world direction
  80983. * @param mesh The mesh that this bone is attached to
  80984. * @returns The world direction
  80985. */
  80986. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80987. /**
  80988. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80989. * @param localAxis The local direction that is used to compute the world direction
  80990. * @param mesh The mesh that this bone is attached to
  80991. * @param result The vector3 that the world direction will be copied to
  80992. */
  80993. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80994. /**
  80995. * Get the euler rotation of the bone in local or world space
  80996. * @param space The space that the rotation should be in
  80997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80998. * @returns The euler rotation
  80999. */
  81000. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81001. /**
  81002. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81003. * @param space The space that the rotation should be in
  81004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81005. * @param result The vector3 that the rotation should be copied to
  81006. */
  81007. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81008. /**
  81009. * Get the quaternion rotation of the bone in either local or world space
  81010. * @param space The space that the rotation should be in
  81011. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81012. * @returns The quaternion rotation
  81013. */
  81014. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81015. /**
  81016. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81017. * @param space The space that the rotation should be in
  81018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81019. * @param result The quaternion that the rotation should be copied to
  81020. */
  81021. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81022. /**
  81023. * Get the rotation matrix of the bone in local or world space
  81024. * @param space The space that the rotation should be in
  81025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81026. * @returns The rotation matrix
  81027. */
  81028. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81029. /**
  81030. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81031. * @param space The space that the rotation should be in
  81032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81033. * @param result The quaternion that the rotation should be copied to
  81034. */
  81035. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81036. /**
  81037. * Get the world position of a point that is in the local space of the bone
  81038. * @param position The local position
  81039. * @param mesh The mesh that this bone is attached to
  81040. * @returns The world position
  81041. */
  81042. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81043. /**
  81044. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81045. * @param position The local position
  81046. * @param mesh The mesh that this bone is attached to
  81047. * @param result The vector3 that the world position should be copied to
  81048. */
  81049. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81050. /**
  81051. * Get the local position of a point that is in world space
  81052. * @param position The world position
  81053. * @param mesh The mesh that this bone is attached to
  81054. * @returns The local position
  81055. */
  81056. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81057. /**
  81058. * Get the local position of a point that is in world space and copy it to the result param
  81059. * @param position The world position
  81060. * @param mesh The mesh that this bone is attached to
  81061. * @param result The vector3 that the local position should be copied to
  81062. */
  81063. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81064. }
  81065. }
  81066. declare module BABYLON {
  81067. /**
  81068. * 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.
  81069. * @see https://doc.babylonjs.com/how_to/transformnode
  81070. */
  81071. export class TransformNode extends Node {
  81072. /**
  81073. * Object will not rotate to face the camera
  81074. */
  81075. static BILLBOARDMODE_NONE: number;
  81076. /**
  81077. * Object will rotate to face the camera but only on the x axis
  81078. */
  81079. static BILLBOARDMODE_X: number;
  81080. /**
  81081. * Object will rotate to face the camera but only on the y axis
  81082. */
  81083. static BILLBOARDMODE_Y: number;
  81084. /**
  81085. * Object will rotate to face the camera but only on the z axis
  81086. */
  81087. static BILLBOARDMODE_Z: number;
  81088. /**
  81089. * Object will rotate to face the camera
  81090. */
  81091. static BILLBOARDMODE_ALL: number;
  81092. /**
  81093. * Object will rotate to face the camera's position instead of orientation
  81094. */
  81095. static BILLBOARDMODE_USE_POSITION: number;
  81096. private _forward;
  81097. private _forwardInverted;
  81098. private _up;
  81099. private _right;
  81100. private _rightInverted;
  81101. private _position;
  81102. private _rotation;
  81103. private _rotationQuaternion;
  81104. protected _scaling: Vector3;
  81105. protected _isDirty: boolean;
  81106. private _transformToBoneReferal;
  81107. private _isAbsoluteSynced;
  81108. private _billboardMode;
  81109. /**
  81110. * Gets or sets the billboard mode. Default is 0.
  81111. *
  81112. * | Value | Type | Description |
  81113. * | --- | --- | --- |
  81114. * | 0 | BILLBOARDMODE_NONE | |
  81115. * | 1 | BILLBOARDMODE_X | |
  81116. * | 2 | BILLBOARDMODE_Y | |
  81117. * | 4 | BILLBOARDMODE_Z | |
  81118. * | 7 | BILLBOARDMODE_ALL | |
  81119. *
  81120. */
  81121. billboardMode: number;
  81122. private _preserveParentRotationForBillboard;
  81123. /**
  81124. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81125. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81126. */
  81127. preserveParentRotationForBillboard: boolean;
  81128. /**
  81129. * 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
  81130. */
  81131. scalingDeterminant: number;
  81132. private _infiniteDistance;
  81133. /**
  81134. * Gets or sets the distance of the object to max, often used by skybox
  81135. */
  81136. infiniteDistance: boolean;
  81137. /**
  81138. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81139. * By default the system will update normals to compensate
  81140. */
  81141. ignoreNonUniformScaling: boolean;
  81142. /**
  81143. * 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
  81144. */
  81145. reIntegrateRotationIntoRotationQuaternion: boolean;
  81146. /** @hidden */
  81147. _poseMatrix: Nullable<Matrix>;
  81148. /** @hidden */
  81149. _localMatrix: Matrix;
  81150. private _usePivotMatrix;
  81151. private _absolutePosition;
  81152. private _absoluteScaling;
  81153. private _absoluteRotationQuaternion;
  81154. private _pivotMatrix;
  81155. private _pivotMatrixInverse;
  81156. protected _postMultiplyPivotMatrix: boolean;
  81157. protected _isWorldMatrixFrozen: boolean;
  81158. /** @hidden */
  81159. _indexInSceneTransformNodesArray: number;
  81160. /**
  81161. * An event triggered after the world matrix is updated
  81162. */
  81163. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81164. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81165. /**
  81166. * Gets a string identifying the name of the class
  81167. * @returns "TransformNode" string
  81168. */
  81169. getClassName(): string;
  81170. /**
  81171. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81172. */
  81173. position: Vector3;
  81174. /**
  81175. * 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)).
  81176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81177. */
  81178. rotation: Vector3;
  81179. /**
  81180. * 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)).
  81181. */
  81182. scaling: Vector3;
  81183. /**
  81184. * 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).
  81185. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81186. */
  81187. rotationQuaternion: Nullable<Quaternion>;
  81188. /**
  81189. * The forward direction of that transform in world space.
  81190. */
  81191. readonly forward: Vector3;
  81192. /**
  81193. * The up direction of that transform in world space.
  81194. */
  81195. readonly up: Vector3;
  81196. /**
  81197. * The right direction of that transform in world space.
  81198. */
  81199. readonly right: Vector3;
  81200. /**
  81201. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81202. * @param matrix the matrix to copy the pose from
  81203. * @returns this TransformNode.
  81204. */
  81205. updatePoseMatrix(matrix: Matrix): TransformNode;
  81206. /**
  81207. * Returns the mesh Pose matrix.
  81208. * @returns the pose matrix
  81209. */
  81210. getPoseMatrix(): Matrix;
  81211. /** @hidden */
  81212. _isSynchronized(): boolean;
  81213. /** @hidden */
  81214. _initCache(): void;
  81215. /**
  81216. * Flag the transform node as dirty (Forcing it to update everything)
  81217. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81218. * @returns this transform node
  81219. */
  81220. markAsDirty(property: string): TransformNode;
  81221. /**
  81222. * Returns the current mesh absolute position.
  81223. * Returns a Vector3.
  81224. */
  81225. readonly absolutePosition: Vector3;
  81226. /**
  81227. * Returns the current mesh absolute scaling.
  81228. * Returns a Vector3.
  81229. */
  81230. readonly absoluteScaling: Vector3;
  81231. /**
  81232. * Returns the current mesh absolute rotation.
  81233. * Returns a Quaternion.
  81234. */
  81235. readonly absoluteRotationQuaternion: Quaternion;
  81236. /**
  81237. * Sets a new matrix to apply before all other transformation
  81238. * @param matrix defines the transform matrix
  81239. * @returns the current TransformNode
  81240. */
  81241. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81242. /**
  81243. * Sets a new pivot matrix to the current node
  81244. * @param matrix defines the new pivot matrix to use
  81245. * @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
  81246. * @returns the current TransformNode
  81247. */
  81248. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81249. /**
  81250. * Returns the mesh pivot matrix.
  81251. * Default : Identity.
  81252. * @returns the matrix
  81253. */
  81254. getPivotMatrix(): Matrix;
  81255. /**
  81256. * Instantiate (when possible) or clone that node with its hierarchy
  81257. * @param newParent defines the new parent to use for the instance (or clone)
  81258. * @returns an instance (or a clone) of the current node with its hiearchy
  81259. */
  81260. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81261. /**
  81262. * Prevents the World matrix to be computed any longer
  81263. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81264. * @returns the TransformNode.
  81265. */
  81266. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81267. /**
  81268. * Allows back the World matrix computation.
  81269. * @returns the TransformNode.
  81270. */
  81271. unfreezeWorldMatrix(): this;
  81272. /**
  81273. * True if the World matrix has been frozen.
  81274. */
  81275. readonly isWorldMatrixFrozen: boolean;
  81276. /**
  81277. * Retuns the mesh absolute position in the World.
  81278. * @returns a Vector3.
  81279. */
  81280. getAbsolutePosition(): Vector3;
  81281. /**
  81282. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81283. * @param absolutePosition the absolute position to set
  81284. * @returns the TransformNode.
  81285. */
  81286. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81287. /**
  81288. * Sets the mesh position in its local space.
  81289. * @param vector3 the position to set in localspace
  81290. * @returns the TransformNode.
  81291. */
  81292. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81293. /**
  81294. * Returns the mesh position in the local space from the current World matrix values.
  81295. * @returns a new Vector3.
  81296. */
  81297. getPositionExpressedInLocalSpace(): Vector3;
  81298. /**
  81299. * Translates the mesh along the passed Vector3 in its local space.
  81300. * @param vector3 the distance to translate in localspace
  81301. * @returns the TransformNode.
  81302. */
  81303. locallyTranslate(vector3: Vector3): TransformNode;
  81304. private static _lookAtVectorCache;
  81305. /**
  81306. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81307. * @param targetPoint the position (must be in same space as current mesh) to look at
  81308. * @param yawCor optional yaw (y-axis) correction in radians
  81309. * @param pitchCor optional pitch (x-axis) correction in radians
  81310. * @param rollCor optional roll (z-axis) correction in radians
  81311. * @param space the choosen space of the target
  81312. * @returns the TransformNode.
  81313. */
  81314. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81315. /**
  81316. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81317. * This Vector3 is expressed in the World space.
  81318. * @param localAxis axis to rotate
  81319. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81320. */
  81321. getDirection(localAxis: Vector3): Vector3;
  81322. /**
  81323. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81324. * localAxis is expressed in the mesh local space.
  81325. * result is computed in the Wordl space from the mesh World matrix.
  81326. * @param localAxis axis to rotate
  81327. * @param result the resulting transformnode
  81328. * @returns this TransformNode.
  81329. */
  81330. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81331. /**
  81332. * Sets this transform node rotation to the given local axis.
  81333. * @param localAxis the axis in local space
  81334. * @param yawCor optional yaw (y-axis) correction in radians
  81335. * @param pitchCor optional pitch (x-axis) correction in radians
  81336. * @param rollCor optional roll (z-axis) correction in radians
  81337. * @returns this TransformNode
  81338. */
  81339. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81340. /**
  81341. * Sets a new pivot point to the current node
  81342. * @param point defines the new pivot point to use
  81343. * @param space defines if the point is in world or local space (local by default)
  81344. * @returns the current TransformNode
  81345. */
  81346. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81347. /**
  81348. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81349. * @returns the pivot point
  81350. */
  81351. getPivotPoint(): Vector3;
  81352. /**
  81353. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81354. * @param result the vector3 to store the result
  81355. * @returns this TransformNode.
  81356. */
  81357. getPivotPointToRef(result: Vector3): TransformNode;
  81358. /**
  81359. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81360. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81361. */
  81362. getAbsolutePivotPoint(): Vector3;
  81363. /**
  81364. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81365. * @param result vector3 to store the result
  81366. * @returns this TransformNode.
  81367. */
  81368. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81369. /**
  81370. * Defines the passed node as the parent of the current node.
  81371. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81372. * @see https://doc.babylonjs.com/how_to/parenting
  81373. * @param node the node ot set as the parent
  81374. * @returns this TransformNode.
  81375. */
  81376. setParent(node: Nullable<Node>): TransformNode;
  81377. private _nonUniformScaling;
  81378. /**
  81379. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81380. */
  81381. readonly nonUniformScaling: boolean;
  81382. /** @hidden */
  81383. _updateNonUniformScalingState(value: boolean): boolean;
  81384. /**
  81385. * Attach the current TransformNode to another TransformNode associated with a bone
  81386. * @param bone Bone affecting the TransformNode
  81387. * @param affectedTransformNode TransformNode associated with the bone
  81388. * @returns this object
  81389. */
  81390. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81391. /**
  81392. * Detach the transform node if its associated with a bone
  81393. * @returns this object
  81394. */
  81395. detachFromBone(): TransformNode;
  81396. private static _rotationAxisCache;
  81397. /**
  81398. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81399. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81400. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81401. * The passed axis is also normalized.
  81402. * @param axis the axis to rotate around
  81403. * @param amount the amount to rotate in radians
  81404. * @param space Space to rotate in (Default: local)
  81405. * @returns the TransformNode.
  81406. */
  81407. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81408. /**
  81409. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81410. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81411. * The passed axis is also normalized. .
  81412. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81413. * @param point the point to rotate around
  81414. * @param axis the axis to rotate around
  81415. * @param amount the amount to rotate in radians
  81416. * @returns the TransformNode
  81417. */
  81418. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81419. /**
  81420. * Translates the mesh along the axis vector for the passed distance in the given space.
  81421. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81422. * @param axis the axis to translate in
  81423. * @param distance the distance to translate
  81424. * @param space Space to rotate in (Default: local)
  81425. * @returns the TransformNode.
  81426. */
  81427. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81428. /**
  81429. * Adds a rotation step to the mesh current rotation.
  81430. * x, y, z are Euler angles expressed in radians.
  81431. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81432. * This means this rotation is made in the mesh local space only.
  81433. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81434. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81435. * ```javascript
  81436. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81437. * ```
  81438. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81439. * 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.
  81440. * @param x Rotation to add
  81441. * @param y Rotation to add
  81442. * @param z Rotation to add
  81443. * @returns the TransformNode.
  81444. */
  81445. addRotation(x: number, y: number, z: number): TransformNode;
  81446. /**
  81447. * @hidden
  81448. */
  81449. protected _getEffectiveParent(): Nullable<Node>;
  81450. /**
  81451. * Computes the world matrix of the node
  81452. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81453. * @returns the world matrix
  81454. */
  81455. computeWorldMatrix(force?: boolean): Matrix;
  81456. protected _afterComputeWorldMatrix(): void;
  81457. /**
  81458. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81459. * @param func callback function to add
  81460. *
  81461. * @returns the TransformNode.
  81462. */
  81463. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81464. /**
  81465. * Removes a registered callback function.
  81466. * @param func callback function to remove
  81467. * @returns the TransformNode.
  81468. */
  81469. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81470. /**
  81471. * Gets the position of the current mesh in camera space
  81472. * @param camera defines the camera to use
  81473. * @returns a position
  81474. */
  81475. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81476. /**
  81477. * Returns the distance from the mesh to the active camera
  81478. * @param camera defines the camera to use
  81479. * @returns the distance
  81480. */
  81481. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81482. /**
  81483. * Clone the current transform node
  81484. * @param name Name of the new clone
  81485. * @param newParent New parent for the clone
  81486. * @param doNotCloneChildren Do not clone children hierarchy
  81487. * @returns the new transform node
  81488. */
  81489. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81490. /**
  81491. * Serializes the objects information.
  81492. * @param currentSerializationObject defines the object to serialize in
  81493. * @returns the serialized object
  81494. */
  81495. serialize(currentSerializationObject?: any): any;
  81496. /**
  81497. * Returns a new TransformNode object parsed from the source provided.
  81498. * @param parsedTransformNode is the source.
  81499. * @param scene the scne the object belongs to
  81500. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81501. * @returns a new TransformNode object parsed from the source provided.
  81502. */
  81503. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81504. /**
  81505. * Get all child-transformNodes of this node
  81506. * @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
  81507. * @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
  81508. * @returns an array of TransformNode
  81509. */
  81510. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81511. /**
  81512. * Releases resources associated with this transform node.
  81513. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81514. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81515. */
  81516. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81517. /**
  81518. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81519. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81520. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81521. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81522. * @returns the current mesh
  81523. */
  81524. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81525. private _syncAbsoluteScalingAndRotation;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /**
  81530. * Defines the types of pose enabled controllers that are supported
  81531. */
  81532. export enum PoseEnabledControllerType {
  81533. /**
  81534. * HTC Vive
  81535. */
  81536. VIVE = 0,
  81537. /**
  81538. * Oculus Rift
  81539. */
  81540. OCULUS = 1,
  81541. /**
  81542. * Windows mixed reality
  81543. */
  81544. WINDOWS = 2,
  81545. /**
  81546. * Samsung gear VR
  81547. */
  81548. GEAR_VR = 3,
  81549. /**
  81550. * Google Daydream
  81551. */
  81552. DAYDREAM = 4,
  81553. /**
  81554. * Generic
  81555. */
  81556. GENERIC = 5
  81557. }
  81558. /**
  81559. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81560. */
  81561. export interface MutableGamepadButton {
  81562. /**
  81563. * Value of the button/trigger
  81564. */
  81565. value: number;
  81566. /**
  81567. * If the button/trigger is currently touched
  81568. */
  81569. touched: boolean;
  81570. /**
  81571. * If the button/trigger is currently pressed
  81572. */
  81573. pressed: boolean;
  81574. }
  81575. /**
  81576. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81577. * @hidden
  81578. */
  81579. export interface ExtendedGamepadButton extends GamepadButton {
  81580. /**
  81581. * If the button/trigger is currently pressed
  81582. */
  81583. readonly pressed: boolean;
  81584. /**
  81585. * If the button/trigger is currently touched
  81586. */
  81587. readonly touched: boolean;
  81588. /**
  81589. * Value of the button/trigger
  81590. */
  81591. readonly value: number;
  81592. }
  81593. /** @hidden */
  81594. export interface _GamePadFactory {
  81595. /**
  81596. * Returns wether or not the current gamepad can be created for this type of controller.
  81597. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81598. * @returns true if it can be created, otherwise false
  81599. */
  81600. canCreate(gamepadInfo: any): boolean;
  81601. /**
  81602. * Creates a new instance of the Gamepad.
  81603. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81604. * @returns the new gamepad instance
  81605. */
  81606. create(gamepadInfo: any): Gamepad;
  81607. }
  81608. /**
  81609. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81610. */
  81611. export class PoseEnabledControllerHelper {
  81612. /** @hidden */
  81613. static _ControllerFactories: _GamePadFactory[];
  81614. /** @hidden */
  81615. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81616. /**
  81617. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81618. * @param vrGamepad the gamepad to initialized
  81619. * @returns a vr controller of the type the gamepad identified as
  81620. */
  81621. static InitiateController(vrGamepad: any): Gamepad;
  81622. }
  81623. /**
  81624. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81625. */
  81626. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81627. /**
  81628. * If the controller is used in a webXR session
  81629. */
  81630. isXR: boolean;
  81631. private _deviceRoomPosition;
  81632. private _deviceRoomRotationQuaternion;
  81633. /**
  81634. * The device position in babylon space
  81635. */
  81636. devicePosition: Vector3;
  81637. /**
  81638. * The device rotation in babylon space
  81639. */
  81640. deviceRotationQuaternion: Quaternion;
  81641. /**
  81642. * The scale factor of the device in babylon space
  81643. */
  81644. deviceScaleFactor: number;
  81645. /**
  81646. * (Likely devicePosition should be used instead) The device position in its room space
  81647. */
  81648. position: Vector3;
  81649. /**
  81650. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81651. */
  81652. rotationQuaternion: Quaternion;
  81653. /**
  81654. * The type of controller (Eg. Windows mixed reality)
  81655. */
  81656. controllerType: PoseEnabledControllerType;
  81657. protected _calculatedPosition: Vector3;
  81658. private _calculatedRotation;
  81659. /**
  81660. * The raw pose from the device
  81661. */
  81662. rawPose: DevicePose;
  81663. private _trackPosition;
  81664. private _maxRotationDistFromHeadset;
  81665. private _draggedRoomRotation;
  81666. /**
  81667. * @hidden
  81668. */
  81669. _disableTrackPosition(fixedPosition: Vector3): void;
  81670. /**
  81671. * Internal, the mesh attached to the controller
  81672. * @hidden
  81673. */
  81674. _mesh: Nullable<AbstractMesh>;
  81675. private _poseControlledCamera;
  81676. private _leftHandSystemQuaternion;
  81677. /**
  81678. * Internal, matrix used to convert room space to babylon space
  81679. * @hidden
  81680. */
  81681. _deviceToWorld: Matrix;
  81682. /**
  81683. * Node to be used when casting a ray from the controller
  81684. * @hidden
  81685. */
  81686. _pointingPoseNode: Nullable<TransformNode>;
  81687. /**
  81688. * Name of the child mesh that can be used to cast a ray from the controller
  81689. */
  81690. static readonly POINTING_POSE: string;
  81691. /**
  81692. * Creates a new PoseEnabledController from a gamepad
  81693. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81694. */
  81695. constructor(browserGamepad: any);
  81696. private _workingMatrix;
  81697. /**
  81698. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81699. */
  81700. update(): void;
  81701. /**
  81702. * Updates only the pose device and mesh without doing any button event checking
  81703. */
  81704. protected _updatePoseAndMesh(): void;
  81705. /**
  81706. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81707. * @param poseData raw pose fromthe device
  81708. */
  81709. updateFromDevice(poseData: DevicePose): void;
  81710. /**
  81711. * @hidden
  81712. */
  81713. _meshAttachedObservable: Observable<AbstractMesh>;
  81714. /**
  81715. * Attaches a mesh to the controller
  81716. * @param mesh the mesh to be attached
  81717. */
  81718. attachToMesh(mesh: AbstractMesh): void;
  81719. /**
  81720. * Attaches the controllers mesh to a camera
  81721. * @param camera the camera the mesh should be attached to
  81722. */
  81723. attachToPoseControlledCamera(camera: TargetCamera): void;
  81724. /**
  81725. * Disposes of the controller
  81726. */
  81727. dispose(): void;
  81728. /**
  81729. * The mesh that is attached to the controller
  81730. */
  81731. readonly mesh: Nullable<AbstractMesh>;
  81732. /**
  81733. * Gets the ray of the controller in the direction the controller is pointing
  81734. * @param length the length the resulting ray should be
  81735. * @returns a ray in the direction the controller is pointing
  81736. */
  81737. getForwardRay(length?: number): Ray;
  81738. }
  81739. }
  81740. declare module BABYLON {
  81741. /**
  81742. * Defines the WebVRController object that represents controllers tracked in 3D space
  81743. */
  81744. export abstract class WebVRController extends PoseEnabledController {
  81745. /**
  81746. * Internal, the default controller model for the controller
  81747. */
  81748. protected _defaultModel: Nullable<AbstractMesh>;
  81749. /**
  81750. * Fired when the trigger state has changed
  81751. */
  81752. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81753. /**
  81754. * Fired when the main button state has changed
  81755. */
  81756. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81757. /**
  81758. * Fired when the secondary button state has changed
  81759. */
  81760. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81761. /**
  81762. * Fired when the pad state has changed
  81763. */
  81764. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81765. /**
  81766. * Fired when controllers stick values have changed
  81767. */
  81768. onPadValuesChangedObservable: Observable<StickValues>;
  81769. /**
  81770. * Array of button availible on the controller
  81771. */
  81772. protected _buttons: Array<MutableGamepadButton>;
  81773. private _onButtonStateChange;
  81774. /**
  81775. * Fired when a controller button's state has changed
  81776. * @param callback the callback containing the button that was modified
  81777. */
  81778. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81779. /**
  81780. * X and Y axis corresponding to the controllers joystick
  81781. */
  81782. pad: StickValues;
  81783. /**
  81784. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81785. */
  81786. hand: string;
  81787. /**
  81788. * The default controller model for the controller
  81789. */
  81790. readonly defaultModel: Nullable<AbstractMesh>;
  81791. /**
  81792. * Creates a new WebVRController from a gamepad
  81793. * @param vrGamepad the gamepad that the WebVRController should be created from
  81794. */
  81795. constructor(vrGamepad: any);
  81796. /**
  81797. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81798. */
  81799. update(): void;
  81800. /**
  81801. * Function to be called when a button is modified
  81802. */
  81803. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81804. /**
  81805. * Loads a mesh and attaches it to the controller
  81806. * @param scene the scene the mesh should be added to
  81807. * @param meshLoaded callback for when the mesh has been loaded
  81808. */
  81809. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81810. private _setButtonValue;
  81811. private _changes;
  81812. private _checkChanges;
  81813. /**
  81814. * Disposes of th webVRCOntroller
  81815. */
  81816. dispose(): void;
  81817. }
  81818. }
  81819. declare module BABYLON {
  81820. /**
  81821. * The HemisphericLight simulates the ambient environment light,
  81822. * so the passed direction is the light reflection direction, not the incoming direction.
  81823. */
  81824. export class HemisphericLight extends Light {
  81825. /**
  81826. * The groundColor is the light in the opposite direction to the one specified during creation.
  81827. * 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.
  81828. */
  81829. groundColor: Color3;
  81830. /**
  81831. * The light reflection direction, not the incoming direction.
  81832. */
  81833. direction: Vector3;
  81834. /**
  81835. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81836. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81837. * The HemisphericLight can't cast shadows.
  81838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81839. * @param name The friendly name of the light
  81840. * @param direction The direction of the light reflection
  81841. * @param scene The scene the light belongs to
  81842. */
  81843. constructor(name: string, direction: Vector3, scene: Scene);
  81844. protected _buildUniformLayout(): void;
  81845. /**
  81846. * Returns the string "HemisphericLight".
  81847. * @return The class name
  81848. */
  81849. getClassName(): string;
  81850. /**
  81851. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81852. * Returns the updated direction.
  81853. * @param target The target the direction should point to
  81854. * @return The computed direction
  81855. */
  81856. setDirectionToTarget(target: Vector3): Vector3;
  81857. /**
  81858. * Returns the shadow generator associated to the light.
  81859. * @returns Always null for hemispheric lights because it does not support shadows.
  81860. */
  81861. getShadowGenerator(): Nullable<IShadowGenerator>;
  81862. /**
  81863. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81864. * @param effect The effect to update
  81865. * @param lightIndex The index of the light in the effect to update
  81866. * @returns The hemispheric light
  81867. */
  81868. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81869. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81870. /**
  81871. * Computes the world matrix of the node
  81872. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81873. * @param useWasUpdatedFlag defines a reserved property
  81874. * @returns the world matrix
  81875. */
  81876. computeWorldMatrix(): Matrix;
  81877. /**
  81878. * Returns the integer 3.
  81879. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81880. */
  81881. getTypeID(): number;
  81882. /**
  81883. * Prepares the list of defines specific to the light type.
  81884. * @param defines the list of defines
  81885. * @param lightIndex defines the index of the light for the effect
  81886. */
  81887. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /** @hidden */
  81892. export var vrMultiviewToSingleviewPixelShader: {
  81893. name: string;
  81894. shader: string;
  81895. };
  81896. }
  81897. declare module BABYLON {
  81898. /**
  81899. * Renders to multiple views with a single draw call
  81900. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81901. */
  81902. export class MultiviewRenderTarget extends RenderTargetTexture {
  81903. /**
  81904. * Creates a multiview render target
  81905. * @param scene scene used with the render target
  81906. * @param size the size of the render target (used for each view)
  81907. */
  81908. constructor(scene: Scene, size?: number | {
  81909. width: number;
  81910. height: number;
  81911. } | {
  81912. ratio: number;
  81913. });
  81914. /**
  81915. * @hidden
  81916. * @param faceIndex the face index, if its a cube texture
  81917. */
  81918. _bindFrameBuffer(faceIndex?: number): void;
  81919. /**
  81920. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81921. * @returns the view count
  81922. */
  81923. getViewCount(): number;
  81924. }
  81925. }
  81926. declare module BABYLON {
  81927. /**
  81928. * Represents a camera frustum
  81929. */
  81930. export class Frustum {
  81931. /**
  81932. * Gets the planes representing the frustum
  81933. * @param transform matrix to be applied to the returned planes
  81934. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81935. */
  81936. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81937. /**
  81938. * Gets the near frustum plane transformed by the transform matrix
  81939. * @param transform transformation matrix to be applied to the resulting frustum plane
  81940. * @param frustumPlane the resuling frustum plane
  81941. */
  81942. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81943. /**
  81944. * Gets the far frustum plane transformed by the transform matrix
  81945. * @param transform transformation matrix to be applied to the resulting frustum plane
  81946. * @param frustumPlane the resuling frustum plane
  81947. */
  81948. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81949. /**
  81950. * Gets the left frustum plane transformed by the transform matrix
  81951. * @param transform transformation matrix to be applied to the resulting frustum plane
  81952. * @param frustumPlane the resuling frustum plane
  81953. */
  81954. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81955. /**
  81956. * Gets the right frustum plane transformed by the transform matrix
  81957. * @param transform transformation matrix to be applied to the resulting frustum plane
  81958. * @param frustumPlane the resuling frustum plane
  81959. */
  81960. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81961. /**
  81962. * Gets the top frustum plane transformed by the transform matrix
  81963. * @param transform transformation matrix to be applied to the resulting frustum plane
  81964. * @param frustumPlane the resuling frustum plane
  81965. */
  81966. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81967. /**
  81968. * Gets the bottom frustum plane transformed by the transform matrix
  81969. * @param transform transformation matrix to be applied to the resulting frustum plane
  81970. * @param frustumPlane the resuling frustum plane
  81971. */
  81972. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81973. /**
  81974. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81975. * @param transform transformation matrix to be applied to the resulting frustum planes
  81976. * @param frustumPlanes the resuling frustum planes
  81977. */
  81978. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81979. }
  81980. }
  81981. declare module BABYLON {
  81982. interface Engine {
  81983. /**
  81984. * Creates a new multiview render target
  81985. * @param width defines the width of the texture
  81986. * @param height defines the height of the texture
  81987. * @returns the created multiview texture
  81988. */
  81989. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81990. /**
  81991. * Binds a multiview framebuffer to be drawn to
  81992. * @param multiviewTexture texture to bind
  81993. */
  81994. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81995. }
  81996. interface Camera {
  81997. /**
  81998. * @hidden
  81999. * 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)
  82000. */
  82001. _useMultiviewToSingleView: boolean;
  82002. /**
  82003. * @hidden
  82004. * 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)
  82005. */
  82006. _multiviewTexture: Nullable<RenderTargetTexture>;
  82007. /**
  82008. * @hidden
  82009. * ensures the multiview texture of the camera exists and has the specified width/height
  82010. * @param width height to set on the multiview texture
  82011. * @param height width to set on the multiview texture
  82012. */
  82013. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82014. }
  82015. interface Scene {
  82016. /** @hidden */
  82017. _transformMatrixR: Matrix;
  82018. /** @hidden */
  82019. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82020. /** @hidden */
  82021. _createMultiviewUbo(): void;
  82022. /** @hidden */
  82023. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82024. /** @hidden */
  82025. _renderMultiviewToSingleView(camera: Camera): void;
  82026. }
  82027. }
  82028. declare module BABYLON {
  82029. /**
  82030. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82031. * This will not be used for webXR as it supports displaying texture arrays directly
  82032. */
  82033. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82034. /**
  82035. * Initializes a VRMultiviewToSingleview
  82036. * @param name name of the post process
  82037. * @param camera camera to be applied to
  82038. * @param scaleFactor scaling factor to the size of the output texture
  82039. */
  82040. constructor(name: string, camera: Camera, scaleFactor: number);
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. interface Engine {
  82045. /** @hidden */
  82046. _vrDisplay: any;
  82047. /** @hidden */
  82048. _vrSupported: boolean;
  82049. /** @hidden */
  82050. _oldSize: Size;
  82051. /** @hidden */
  82052. _oldHardwareScaleFactor: number;
  82053. /** @hidden */
  82054. _vrExclusivePointerMode: boolean;
  82055. /** @hidden */
  82056. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82057. /** @hidden */
  82058. _onVRDisplayPointerRestricted: () => void;
  82059. /** @hidden */
  82060. _onVRDisplayPointerUnrestricted: () => void;
  82061. /** @hidden */
  82062. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82063. /** @hidden */
  82064. _onVrDisplayDisconnect: Nullable<() => void>;
  82065. /** @hidden */
  82066. _onVrDisplayPresentChange: Nullable<() => void>;
  82067. /**
  82068. * Observable signaled when VR display mode changes
  82069. */
  82070. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82071. /**
  82072. * Observable signaled when VR request present is complete
  82073. */
  82074. onVRRequestPresentComplete: Observable<boolean>;
  82075. /**
  82076. * Observable signaled when VR request present starts
  82077. */
  82078. onVRRequestPresentStart: Observable<Engine>;
  82079. /**
  82080. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82081. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82082. */
  82083. isInVRExclusivePointerMode: boolean;
  82084. /**
  82085. * Gets a boolean indicating if a webVR device was detected
  82086. * @returns true if a webVR device was detected
  82087. */
  82088. isVRDevicePresent(): boolean;
  82089. /**
  82090. * Gets the current webVR device
  82091. * @returns the current webVR device (or null)
  82092. */
  82093. getVRDevice(): any;
  82094. /**
  82095. * Initializes a webVR display and starts listening to display change events
  82096. * The onVRDisplayChangedObservable will be notified upon these changes
  82097. * @returns A promise containing a VRDisplay and if vr is supported
  82098. */
  82099. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82100. /** @hidden */
  82101. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82102. /**
  82103. * Call this function to switch to webVR mode
  82104. * Will do nothing if webVR is not supported or if there is no webVR device
  82105. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82106. */
  82107. enableVR(): void;
  82108. /** @hidden */
  82109. _onVRFullScreenTriggered(): void;
  82110. }
  82111. }
  82112. declare module BABYLON {
  82113. /**
  82114. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82115. * IMPORTANT!! The data is right-hand data.
  82116. * @export
  82117. * @interface DevicePose
  82118. */
  82119. export interface DevicePose {
  82120. /**
  82121. * The position of the device, values in array are [x,y,z].
  82122. */
  82123. readonly position: Nullable<Float32Array>;
  82124. /**
  82125. * The linearVelocity of the device, values in array are [x,y,z].
  82126. */
  82127. readonly linearVelocity: Nullable<Float32Array>;
  82128. /**
  82129. * The linearAcceleration of the device, values in array are [x,y,z].
  82130. */
  82131. readonly linearAcceleration: Nullable<Float32Array>;
  82132. /**
  82133. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82134. */
  82135. readonly orientation: Nullable<Float32Array>;
  82136. /**
  82137. * The angularVelocity of the device, values in array are [x,y,z].
  82138. */
  82139. readonly angularVelocity: Nullable<Float32Array>;
  82140. /**
  82141. * The angularAcceleration of the device, values in array are [x,y,z].
  82142. */
  82143. readonly angularAcceleration: Nullable<Float32Array>;
  82144. }
  82145. /**
  82146. * Interface representing a pose controlled object in Babylon.
  82147. * A pose controlled object has both regular pose values as well as pose values
  82148. * from an external device such as a VR head mounted display
  82149. */
  82150. export interface PoseControlled {
  82151. /**
  82152. * The position of the object in babylon space.
  82153. */
  82154. position: Vector3;
  82155. /**
  82156. * The rotation quaternion of the object in babylon space.
  82157. */
  82158. rotationQuaternion: Quaternion;
  82159. /**
  82160. * The position of the device in babylon space.
  82161. */
  82162. devicePosition?: Vector3;
  82163. /**
  82164. * The rotation quaternion of the device in babylon space.
  82165. */
  82166. deviceRotationQuaternion: Quaternion;
  82167. /**
  82168. * The raw pose coming from the device.
  82169. */
  82170. rawPose: Nullable<DevicePose>;
  82171. /**
  82172. * The scale of the device to be used when translating from device space to babylon space.
  82173. */
  82174. deviceScaleFactor: number;
  82175. /**
  82176. * Updates the poseControlled values based on the input device pose.
  82177. * @param poseData the pose data to update the object with
  82178. */
  82179. updateFromDevice(poseData: DevicePose): void;
  82180. }
  82181. /**
  82182. * Set of options to customize the webVRCamera
  82183. */
  82184. export interface WebVROptions {
  82185. /**
  82186. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82187. */
  82188. trackPosition?: boolean;
  82189. /**
  82190. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82191. */
  82192. positionScale?: number;
  82193. /**
  82194. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82195. */
  82196. displayName?: string;
  82197. /**
  82198. * Should the native controller meshes be initialized. (default: true)
  82199. */
  82200. controllerMeshes?: boolean;
  82201. /**
  82202. * Creating a default HemiLight only on controllers. (default: true)
  82203. */
  82204. defaultLightingOnControllers?: boolean;
  82205. /**
  82206. * If you don't want to use the default VR button of the helper. (default: false)
  82207. */
  82208. useCustomVRButton?: boolean;
  82209. /**
  82210. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82211. */
  82212. customVRButton?: HTMLButtonElement;
  82213. /**
  82214. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82215. */
  82216. rayLength?: number;
  82217. /**
  82218. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82219. */
  82220. defaultHeight?: number;
  82221. /**
  82222. * If multiview should be used if availible (default: false)
  82223. */
  82224. useMultiview?: boolean;
  82225. }
  82226. /**
  82227. * This represents a WebVR camera.
  82228. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82229. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82230. */
  82231. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82232. private webVROptions;
  82233. /**
  82234. * @hidden
  82235. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82236. */
  82237. _vrDevice: any;
  82238. /**
  82239. * The rawPose of the vrDevice.
  82240. */
  82241. rawPose: Nullable<DevicePose>;
  82242. private _onVREnabled;
  82243. private _specsVersion;
  82244. private _attached;
  82245. private _frameData;
  82246. protected _descendants: Array<Node>;
  82247. private _deviceRoomPosition;
  82248. /** @hidden */
  82249. _deviceRoomRotationQuaternion: Quaternion;
  82250. private _standingMatrix;
  82251. /**
  82252. * Represents device position in babylon space.
  82253. */
  82254. devicePosition: Vector3;
  82255. /**
  82256. * Represents device rotation in babylon space.
  82257. */
  82258. deviceRotationQuaternion: Quaternion;
  82259. /**
  82260. * The scale of the device to be used when translating from device space to babylon space.
  82261. */
  82262. deviceScaleFactor: number;
  82263. private _deviceToWorld;
  82264. private _worldToDevice;
  82265. /**
  82266. * References to the webVR controllers for the vrDevice.
  82267. */
  82268. controllers: Array<WebVRController>;
  82269. /**
  82270. * Emits an event when a controller is attached.
  82271. */
  82272. onControllersAttachedObservable: Observable<WebVRController[]>;
  82273. /**
  82274. * Emits an event when a controller's mesh has been loaded;
  82275. */
  82276. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82277. /**
  82278. * Emits an event when the HMD's pose has been updated.
  82279. */
  82280. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82281. private _poseSet;
  82282. /**
  82283. * If the rig cameras be used as parent instead of this camera.
  82284. */
  82285. rigParenting: boolean;
  82286. private _lightOnControllers;
  82287. private _defaultHeight?;
  82288. /**
  82289. * Instantiates a WebVRFreeCamera.
  82290. * @param name The name of the WebVRFreeCamera
  82291. * @param position The starting anchor position for the camera
  82292. * @param scene The scene the camera belongs to
  82293. * @param webVROptions a set of customizable options for the webVRCamera
  82294. */
  82295. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82296. /**
  82297. * Gets the device distance from the ground in meters.
  82298. * @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.
  82299. */
  82300. deviceDistanceToRoomGround(): number;
  82301. /**
  82302. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82303. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82304. */
  82305. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82306. /**
  82307. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82308. * @returns A promise with a boolean set to if the standing matrix is supported.
  82309. */
  82310. useStandingMatrixAsync(): Promise<boolean>;
  82311. /**
  82312. * Disposes the camera
  82313. */
  82314. dispose(): void;
  82315. /**
  82316. * Gets a vrController by name.
  82317. * @param name The name of the controller to retreive
  82318. * @returns the controller matching the name specified or null if not found
  82319. */
  82320. getControllerByName(name: string): Nullable<WebVRController>;
  82321. private _leftController;
  82322. /**
  82323. * The controller corresponding to the users left hand.
  82324. */
  82325. readonly leftController: Nullable<WebVRController>;
  82326. private _rightController;
  82327. /**
  82328. * The controller corresponding to the users right hand.
  82329. */
  82330. readonly rightController: Nullable<WebVRController>;
  82331. /**
  82332. * Casts a ray forward from the vrCamera's gaze.
  82333. * @param length Length of the ray (default: 100)
  82334. * @returns the ray corresponding to the gaze
  82335. */
  82336. getForwardRay(length?: number): Ray;
  82337. /**
  82338. * @hidden
  82339. * Updates the camera based on device's frame data
  82340. */
  82341. _checkInputs(): void;
  82342. /**
  82343. * Updates the poseControlled values based on the input device pose.
  82344. * @param poseData Pose coming from the device
  82345. */
  82346. updateFromDevice(poseData: DevicePose): void;
  82347. private _htmlElementAttached;
  82348. private _detachIfAttached;
  82349. /**
  82350. * WebVR's attach control will start broadcasting frames to the device.
  82351. * Note that in certain browsers (chrome for example) this function must be called
  82352. * within a user-interaction callback. Example:
  82353. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82354. *
  82355. * @param element html element to attach the vrDevice to
  82356. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82357. */
  82358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82359. /**
  82360. * Detaches the camera from the html element and disables VR
  82361. *
  82362. * @param element html element to detach from
  82363. */
  82364. detachControl(element: HTMLElement): void;
  82365. /**
  82366. * @returns the name of this class
  82367. */
  82368. getClassName(): string;
  82369. /**
  82370. * Calls resetPose on the vrDisplay
  82371. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82372. */
  82373. resetToCurrentRotation(): void;
  82374. /**
  82375. * @hidden
  82376. * Updates the rig cameras (left and right eye)
  82377. */
  82378. _updateRigCameras(): void;
  82379. private _workingVector;
  82380. private _oneVector;
  82381. private _workingMatrix;
  82382. private updateCacheCalled;
  82383. private _correctPositionIfNotTrackPosition;
  82384. /**
  82385. * @hidden
  82386. * Updates the cached values of the camera
  82387. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82388. */
  82389. _updateCache(ignoreParentClass?: boolean): void;
  82390. /**
  82391. * @hidden
  82392. * Get current device position in babylon world
  82393. */
  82394. _computeDevicePosition(): void;
  82395. /**
  82396. * Updates the current device position and rotation in the babylon world
  82397. */
  82398. update(): void;
  82399. /**
  82400. * @hidden
  82401. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82402. * @returns an identity matrix
  82403. */
  82404. _getViewMatrix(): Matrix;
  82405. private _tmpMatrix;
  82406. /**
  82407. * This function is called by the two RIG cameras.
  82408. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82409. * @hidden
  82410. */
  82411. _getWebVRViewMatrix(): Matrix;
  82412. /** @hidden */
  82413. _getWebVRProjectionMatrix(): Matrix;
  82414. private _onGamepadConnectedObserver;
  82415. private _onGamepadDisconnectedObserver;
  82416. private _updateCacheWhenTrackingDisabledObserver;
  82417. /**
  82418. * Initializes the controllers and their meshes
  82419. */
  82420. initControllers(): void;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. /**
  82425. * Size options for a post process
  82426. */
  82427. export type PostProcessOptions = {
  82428. width: number;
  82429. height: number;
  82430. };
  82431. /**
  82432. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82433. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82434. */
  82435. export class PostProcess {
  82436. /** Name of the PostProcess. */
  82437. name: string;
  82438. /**
  82439. * Gets or sets the unique id of the post process
  82440. */
  82441. uniqueId: number;
  82442. /**
  82443. * Width of the texture to apply the post process on
  82444. */
  82445. width: number;
  82446. /**
  82447. * Height of the texture to apply the post process on
  82448. */
  82449. height: number;
  82450. /**
  82451. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82452. * @hidden
  82453. */
  82454. _outputTexture: Nullable<InternalTexture>;
  82455. /**
  82456. * Sampling mode used by the shader
  82457. * See https://doc.babylonjs.com/classes/3.1/texture
  82458. */
  82459. renderTargetSamplingMode: number;
  82460. /**
  82461. * Clear color to use when screen clearing
  82462. */
  82463. clearColor: Color4;
  82464. /**
  82465. * If the buffer needs to be cleared before applying the post process. (default: true)
  82466. * Should be set to false if shader will overwrite all previous pixels.
  82467. */
  82468. autoClear: boolean;
  82469. /**
  82470. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82471. */
  82472. alphaMode: number;
  82473. /**
  82474. * Sets the setAlphaBlendConstants of the babylon engine
  82475. */
  82476. alphaConstants: Color4;
  82477. /**
  82478. * Animations to be used for the post processing
  82479. */
  82480. animations: Animation[];
  82481. /**
  82482. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82483. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82484. */
  82485. enablePixelPerfectMode: boolean;
  82486. /**
  82487. * Force the postprocess to be applied without taking in account viewport
  82488. */
  82489. forceFullscreenViewport: boolean;
  82490. /**
  82491. * List of inspectable custom properties (used by the Inspector)
  82492. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82493. */
  82494. inspectableCustomProperties: IInspectable[];
  82495. /**
  82496. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82497. *
  82498. * | Value | Type | Description |
  82499. * | ----- | ----------------------------------- | ----------- |
  82500. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82501. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82502. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82503. *
  82504. */
  82505. scaleMode: number;
  82506. /**
  82507. * Force textures to be a power of two (default: false)
  82508. */
  82509. alwaysForcePOT: boolean;
  82510. private _samples;
  82511. /**
  82512. * Number of sample textures (default: 1)
  82513. */
  82514. samples: number;
  82515. /**
  82516. * Modify the scale of the post process to be the same as the viewport (default: false)
  82517. */
  82518. adaptScaleToCurrentViewport: boolean;
  82519. private _camera;
  82520. private _scene;
  82521. private _engine;
  82522. private _options;
  82523. private _reusable;
  82524. private _textureType;
  82525. /**
  82526. * Smart array of input and output textures for the post process.
  82527. * @hidden
  82528. */
  82529. _textures: SmartArray<InternalTexture>;
  82530. /**
  82531. * The index in _textures that corresponds to the output texture.
  82532. * @hidden
  82533. */
  82534. _currentRenderTextureInd: number;
  82535. private _effect;
  82536. private _samplers;
  82537. private _fragmentUrl;
  82538. private _vertexUrl;
  82539. private _parameters;
  82540. private _scaleRatio;
  82541. protected _indexParameters: any;
  82542. private _shareOutputWithPostProcess;
  82543. private _texelSize;
  82544. private _forcedOutputTexture;
  82545. /**
  82546. * Returns the fragment url or shader name used in the post process.
  82547. * @returns the fragment url or name in the shader store.
  82548. */
  82549. getEffectName(): string;
  82550. /**
  82551. * An event triggered when the postprocess is activated.
  82552. */
  82553. onActivateObservable: Observable<Camera>;
  82554. private _onActivateObserver;
  82555. /**
  82556. * A function that is added to the onActivateObservable
  82557. */
  82558. onActivate: Nullable<(camera: Camera) => void>;
  82559. /**
  82560. * An event triggered when the postprocess changes its size.
  82561. */
  82562. onSizeChangedObservable: Observable<PostProcess>;
  82563. private _onSizeChangedObserver;
  82564. /**
  82565. * A function that is added to the onSizeChangedObservable
  82566. */
  82567. onSizeChanged: (postProcess: PostProcess) => void;
  82568. /**
  82569. * An event triggered when the postprocess applies its effect.
  82570. */
  82571. onApplyObservable: Observable<Effect>;
  82572. private _onApplyObserver;
  82573. /**
  82574. * A function that is added to the onApplyObservable
  82575. */
  82576. onApply: (effect: Effect) => void;
  82577. /**
  82578. * An event triggered before rendering the postprocess
  82579. */
  82580. onBeforeRenderObservable: Observable<Effect>;
  82581. private _onBeforeRenderObserver;
  82582. /**
  82583. * A function that is added to the onBeforeRenderObservable
  82584. */
  82585. onBeforeRender: (effect: Effect) => void;
  82586. /**
  82587. * An event triggered after rendering the postprocess
  82588. */
  82589. onAfterRenderObservable: Observable<Effect>;
  82590. private _onAfterRenderObserver;
  82591. /**
  82592. * A function that is added to the onAfterRenderObservable
  82593. */
  82594. onAfterRender: (efect: Effect) => void;
  82595. /**
  82596. * 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
  82597. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82598. */
  82599. inputTexture: InternalTexture;
  82600. /**
  82601. * Gets the camera which post process is applied to.
  82602. * @returns The camera the post process is applied to.
  82603. */
  82604. getCamera(): Camera;
  82605. /**
  82606. * Gets the texel size of the postprocess.
  82607. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82608. */
  82609. readonly texelSize: Vector2;
  82610. /**
  82611. * Creates a new instance PostProcess
  82612. * @param name The name of the PostProcess.
  82613. * @param fragmentUrl The url of the fragment shader to be used.
  82614. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82615. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82616. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82617. * @param camera The camera to apply the render pass to.
  82618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82619. * @param engine The engine which the post process will be applied. (default: current engine)
  82620. * @param reusable If the post process can be reused on the same frame. (default: false)
  82621. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82622. * @param textureType Type of textures used when performing the post process. (default: 0)
  82623. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82624. * @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
  82625. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82626. */
  82627. constructor(
  82628. /** Name of the PostProcess. */
  82629. 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);
  82630. /**
  82631. * Gets a string idenfifying the name of the class
  82632. * @returns "PostProcess" string
  82633. */
  82634. getClassName(): string;
  82635. /**
  82636. * Gets the engine which this post process belongs to.
  82637. * @returns The engine the post process was enabled with.
  82638. */
  82639. getEngine(): Engine;
  82640. /**
  82641. * The effect that is created when initializing the post process.
  82642. * @returns The created effect corresponding the the postprocess.
  82643. */
  82644. getEffect(): Effect;
  82645. /**
  82646. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82647. * @param postProcess The post process to share the output with.
  82648. * @returns This post process.
  82649. */
  82650. shareOutputWith(postProcess: PostProcess): PostProcess;
  82651. /**
  82652. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82653. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82654. */
  82655. useOwnOutput(): void;
  82656. /**
  82657. * Updates the effect with the current post process compile time values and recompiles the shader.
  82658. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82659. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82660. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82661. * @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
  82662. * @param onCompiled Called when the shader has been compiled.
  82663. * @param onError Called if there is an error when compiling a shader.
  82664. */
  82665. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82666. /**
  82667. * The post process is reusable if it can be used multiple times within one frame.
  82668. * @returns If the post process is reusable
  82669. */
  82670. isReusable(): boolean;
  82671. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82672. markTextureDirty(): void;
  82673. /**
  82674. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82675. * 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.
  82676. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82677. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82678. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82679. * @returns The target texture that was bound to be written to.
  82680. */
  82681. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82682. /**
  82683. * If the post process is supported.
  82684. */
  82685. readonly isSupported: boolean;
  82686. /**
  82687. * The aspect ratio of the output texture.
  82688. */
  82689. readonly aspectRatio: number;
  82690. /**
  82691. * Get a value indicating if the post-process is ready to be used
  82692. * @returns true if the post-process is ready (shader is compiled)
  82693. */
  82694. isReady(): boolean;
  82695. /**
  82696. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82697. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82698. */
  82699. apply(): Nullable<Effect>;
  82700. private _disposeTextures;
  82701. /**
  82702. * Disposes the post process.
  82703. * @param camera The camera to dispose the post process on.
  82704. */
  82705. dispose(camera?: Camera): void;
  82706. }
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export var kernelBlurVaryingDeclaration: {
  82711. name: string;
  82712. shader: string;
  82713. };
  82714. }
  82715. declare module BABYLON {
  82716. /** @hidden */
  82717. export var kernelBlurFragment: {
  82718. name: string;
  82719. shader: string;
  82720. };
  82721. }
  82722. declare module BABYLON {
  82723. /** @hidden */
  82724. export var kernelBlurFragment2: {
  82725. name: string;
  82726. shader: string;
  82727. };
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export var kernelBlurPixelShader: {
  82732. name: string;
  82733. shader: string;
  82734. };
  82735. }
  82736. declare module BABYLON {
  82737. /** @hidden */
  82738. export var kernelBlurVertex: {
  82739. name: string;
  82740. shader: string;
  82741. };
  82742. }
  82743. declare module BABYLON {
  82744. /** @hidden */
  82745. export var kernelBlurVertexShader: {
  82746. name: string;
  82747. shader: string;
  82748. };
  82749. }
  82750. declare module BABYLON {
  82751. /**
  82752. * The Blur Post Process which blurs an image based on a kernel and direction.
  82753. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82754. */
  82755. export class BlurPostProcess extends PostProcess {
  82756. /** The direction in which to blur the image. */
  82757. direction: Vector2;
  82758. private blockCompilation;
  82759. protected _kernel: number;
  82760. protected _idealKernel: number;
  82761. protected _packedFloat: boolean;
  82762. private _staticDefines;
  82763. /**
  82764. * Sets the length in pixels of the blur sample region
  82765. */
  82766. /**
  82767. * Gets the length in pixels of the blur sample region
  82768. */
  82769. kernel: number;
  82770. /**
  82771. * Sets wether or not the blur needs to unpack/repack floats
  82772. */
  82773. /**
  82774. * Gets wether or not the blur is unpacking/repacking floats
  82775. */
  82776. packedFloat: boolean;
  82777. /**
  82778. * Creates a new instance BlurPostProcess
  82779. * @param name The name of the effect.
  82780. * @param direction The direction in which to blur the image.
  82781. * @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.
  82782. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82783. * @param camera The camera to apply the render pass to.
  82784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82785. * @param engine The engine which the post process will be applied. (default: current engine)
  82786. * @param reusable If the post process can be reused on the same frame. (default: false)
  82787. * @param textureType Type of textures used when performing the post process. (default: 0)
  82788. * @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)
  82789. */
  82790. constructor(name: string,
  82791. /** The direction in which to blur the image. */
  82792. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82793. /**
  82794. * Updates the effect with the current post process compile time values and recompiles the shader.
  82795. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82796. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82797. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82798. * @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
  82799. * @param onCompiled Called when the shader has been compiled.
  82800. * @param onError Called if there is an error when compiling a shader.
  82801. */
  82802. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82803. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82804. /**
  82805. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82806. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82807. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82808. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82809. * The gaps between physical kernels are compensated for in the weighting of the samples
  82810. * @param idealKernel Ideal blur kernel.
  82811. * @return Nearest best kernel.
  82812. */
  82813. protected _nearestBestKernel(idealKernel: number): number;
  82814. /**
  82815. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82816. * @param x The point on the Gaussian distribution to sample.
  82817. * @return the value of the Gaussian function at x.
  82818. */
  82819. protected _gaussianWeight(x: number): number;
  82820. /**
  82821. * Generates a string that can be used as a floating point number in GLSL.
  82822. * @param x Value to print.
  82823. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82824. * @return GLSL float string.
  82825. */
  82826. protected _glslFloat(x: number, decimalFigures?: number): string;
  82827. }
  82828. }
  82829. declare module BABYLON {
  82830. /**
  82831. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82832. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82833. * You can then easily use it as a reflectionTexture on a flat surface.
  82834. * In case the surface is not a plane, please consider relying on reflection probes.
  82835. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82836. */
  82837. export class MirrorTexture extends RenderTargetTexture {
  82838. private scene;
  82839. /**
  82840. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82841. * 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.
  82842. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82843. */
  82844. mirrorPlane: Plane;
  82845. /**
  82846. * Define the blur ratio used to blur the reflection if needed.
  82847. */
  82848. blurRatio: number;
  82849. /**
  82850. * Define the adaptive blur kernel used to blur the reflection if needed.
  82851. * This will autocompute the closest best match for the `blurKernel`
  82852. */
  82853. adaptiveBlurKernel: number;
  82854. /**
  82855. * Define the blur kernel used to blur the reflection if needed.
  82856. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82857. */
  82858. blurKernel: number;
  82859. /**
  82860. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82861. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82862. */
  82863. blurKernelX: number;
  82864. /**
  82865. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82866. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82867. */
  82868. blurKernelY: number;
  82869. private _autoComputeBlurKernel;
  82870. protected _onRatioRescale(): void;
  82871. private _updateGammaSpace;
  82872. private _imageProcessingConfigChangeObserver;
  82873. private _transformMatrix;
  82874. private _mirrorMatrix;
  82875. private _savedViewMatrix;
  82876. private _blurX;
  82877. private _blurY;
  82878. private _adaptiveBlurKernel;
  82879. private _blurKernelX;
  82880. private _blurKernelY;
  82881. private _blurRatio;
  82882. /**
  82883. * Instantiates a Mirror Texture.
  82884. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82885. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82886. * You can then easily use it as a reflectionTexture on a flat surface.
  82887. * In case the surface is not a plane, please consider relying on reflection probes.
  82888. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82889. * @param name
  82890. * @param size
  82891. * @param scene
  82892. * @param generateMipMaps
  82893. * @param type
  82894. * @param samplingMode
  82895. * @param generateDepthBuffer
  82896. */
  82897. constructor(name: string, size: number | {
  82898. width: number;
  82899. height: number;
  82900. } | {
  82901. ratio: number;
  82902. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82903. private _preparePostProcesses;
  82904. /**
  82905. * Clone the mirror texture.
  82906. * @returns the cloned texture
  82907. */
  82908. clone(): MirrorTexture;
  82909. /**
  82910. * Serialize the texture to a JSON representation you could use in Parse later on
  82911. * @returns the serialized JSON representation
  82912. */
  82913. serialize(): any;
  82914. /**
  82915. * Dispose the texture and release its associated resources.
  82916. */
  82917. dispose(): void;
  82918. }
  82919. }
  82920. declare module BABYLON {
  82921. /**
  82922. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82923. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82924. */
  82925. export class Texture extends BaseTexture {
  82926. /**
  82927. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82928. */
  82929. static SerializeBuffers: boolean;
  82930. /** @hidden */
  82931. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82932. /** @hidden */
  82933. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82934. /** @hidden */
  82935. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82936. /** nearest is mag = nearest and min = nearest and mip = linear */
  82937. static readonly NEAREST_SAMPLINGMODE: number;
  82938. /** nearest is mag = nearest and min = nearest and mip = linear */
  82939. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82941. static readonly BILINEAR_SAMPLINGMODE: number;
  82942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82943. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82944. /** Trilinear is mag = linear and min = linear and mip = linear */
  82945. static readonly TRILINEAR_SAMPLINGMODE: number;
  82946. /** Trilinear is mag = linear and min = linear and mip = linear */
  82947. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82948. /** mag = nearest and min = nearest and mip = nearest */
  82949. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82950. /** mag = nearest and min = linear and mip = nearest */
  82951. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82952. /** mag = nearest and min = linear and mip = linear */
  82953. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82954. /** mag = nearest and min = linear and mip = none */
  82955. static readonly NEAREST_LINEAR: number;
  82956. /** mag = nearest and min = nearest and mip = none */
  82957. static readonly NEAREST_NEAREST: number;
  82958. /** mag = linear and min = nearest and mip = nearest */
  82959. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82960. /** mag = linear and min = nearest and mip = linear */
  82961. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82962. /** mag = linear and min = linear and mip = none */
  82963. static readonly LINEAR_LINEAR: number;
  82964. /** mag = linear and min = nearest and mip = none */
  82965. static readonly LINEAR_NEAREST: number;
  82966. /** Explicit coordinates mode */
  82967. static readonly EXPLICIT_MODE: number;
  82968. /** Spherical coordinates mode */
  82969. static readonly SPHERICAL_MODE: number;
  82970. /** Planar coordinates mode */
  82971. static readonly PLANAR_MODE: number;
  82972. /** Cubic coordinates mode */
  82973. static readonly CUBIC_MODE: number;
  82974. /** Projection coordinates mode */
  82975. static readonly PROJECTION_MODE: number;
  82976. /** Inverse Cubic coordinates mode */
  82977. static readonly SKYBOX_MODE: number;
  82978. /** Inverse Cubic coordinates mode */
  82979. static readonly INVCUBIC_MODE: number;
  82980. /** Equirectangular coordinates mode */
  82981. static readonly EQUIRECTANGULAR_MODE: number;
  82982. /** Equirectangular Fixed coordinates mode */
  82983. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82984. /** Equirectangular Fixed Mirrored coordinates mode */
  82985. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82986. /** Texture is not repeating outside of 0..1 UVs */
  82987. static readonly CLAMP_ADDRESSMODE: number;
  82988. /** Texture is repeating outside of 0..1 UVs */
  82989. static readonly WRAP_ADDRESSMODE: number;
  82990. /** Texture is repeating and mirrored */
  82991. static readonly MIRROR_ADDRESSMODE: number;
  82992. /**
  82993. * 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
  82994. */
  82995. static UseSerializedUrlIfAny: boolean;
  82996. /**
  82997. * Define the url of the texture.
  82998. */
  82999. url: Nullable<string>;
  83000. /**
  83001. * Define an offset on the texture to offset the u coordinates of the UVs
  83002. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83003. */
  83004. uOffset: number;
  83005. /**
  83006. * Define an offset on the texture to offset the v coordinates of the UVs
  83007. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83008. */
  83009. vOffset: number;
  83010. /**
  83011. * Define an offset on the texture to scale the u coordinates of the UVs
  83012. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83013. */
  83014. uScale: number;
  83015. /**
  83016. * Define an offset on the texture to scale the v coordinates of the UVs
  83017. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83018. */
  83019. vScale: number;
  83020. /**
  83021. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83022. * @see http://doc.babylonjs.com/how_to/more_materials
  83023. */
  83024. uAng: number;
  83025. /**
  83026. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83027. * @see http://doc.babylonjs.com/how_to/more_materials
  83028. */
  83029. vAng: number;
  83030. /**
  83031. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83032. * @see http://doc.babylonjs.com/how_to/more_materials
  83033. */
  83034. wAng: number;
  83035. /**
  83036. * Defines the center of rotation (U)
  83037. */
  83038. uRotationCenter: number;
  83039. /**
  83040. * Defines the center of rotation (V)
  83041. */
  83042. vRotationCenter: number;
  83043. /**
  83044. * Defines the center of rotation (W)
  83045. */
  83046. wRotationCenter: number;
  83047. /**
  83048. * Are mip maps generated for this texture or not.
  83049. */
  83050. readonly noMipmap: boolean;
  83051. /**
  83052. * List of inspectable custom properties (used by the Inspector)
  83053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83054. */
  83055. inspectableCustomProperties: Nullable<IInspectable[]>;
  83056. private _noMipmap;
  83057. /** @hidden */
  83058. _invertY: boolean;
  83059. private _rowGenerationMatrix;
  83060. private _cachedTextureMatrix;
  83061. private _projectionModeMatrix;
  83062. private _t0;
  83063. private _t1;
  83064. private _t2;
  83065. private _cachedUOffset;
  83066. private _cachedVOffset;
  83067. private _cachedUScale;
  83068. private _cachedVScale;
  83069. private _cachedUAng;
  83070. private _cachedVAng;
  83071. private _cachedWAng;
  83072. private _cachedProjectionMatrixId;
  83073. private _cachedCoordinatesMode;
  83074. /** @hidden */
  83075. protected _initialSamplingMode: number;
  83076. /** @hidden */
  83077. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83078. private _deleteBuffer;
  83079. protected _format: Nullable<number>;
  83080. private _delayedOnLoad;
  83081. private _delayedOnError;
  83082. private _mimeType?;
  83083. /**
  83084. * Observable triggered once the texture has been loaded.
  83085. */
  83086. onLoadObservable: Observable<Texture>;
  83087. protected _isBlocking: boolean;
  83088. /**
  83089. * Is the texture preventing material to render while loading.
  83090. * If false, a default texture will be used instead of the loading one during the preparation step.
  83091. */
  83092. isBlocking: boolean;
  83093. /**
  83094. * Get the current sampling mode associated with the texture.
  83095. */
  83096. readonly samplingMode: number;
  83097. /**
  83098. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83099. */
  83100. readonly invertY: boolean;
  83101. /**
  83102. * Instantiates a new texture.
  83103. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83104. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83105. * @param url defines the url of the picture to load as a texture
  83106. * @param scene defines the scene or engine the texture will belong to
  83107. * @param noMipmap defines if the texture will require mip maps or not
  83108. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83109. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83110. * @param onLoad defines a callback triggered when the texture has been loaded
  83111. * @param onError defines a callback triggered when an error occurred during the loading session
  83112. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83113. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83114. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83115. * @param mimeType defines an optional mime type information
  83116. */
  83117. 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);
  83118. /**
  83119. * Update the url (and optional buffer) of this texture if url was null during construction.
  83120. * @param url the url of the texture
  83121. * @param buffer the buffer of the texture (defaults to null)
  83122. * @param onLoad callback called when the texture is loaded (defaults to null)
  83123. */
  83124. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83125. /**
  83126. * Finish the loading sequence of a texture flagged as delayed load.
  83127. * @hidden
  83128. */
  83129. delayLoad(): void;
  83130. private _prepareRowForTextureGeneration;
  83131. /**
  83132. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83133. * @returns the transform matrix of the texture.
  83134. */
  83135. getTextureMatrix(): Matrix;
  83136. /**
  83137. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83138. * @returns The reflection texture transform
  83139. */
  83140. getReflectionTextureMatrix(): Matrix;
  83141. /**
  83142. * Clones the texture.
  83143. * @returns the cloned texture
  83144. */
  83145. clone(): Texture;
  83146. /**
  83147. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83148. * @returns The JSON representation of the texture
  83149. */
  83150. serialize(): any;
  83151. /**
  83152. * Get the current class name of the texture useful for serialization or dynamic coding.
  83153. * @returns "Texture"
  83154. */
  83155. getClassName(): string;
  83156. /**
  83157. * Dispose the texture and release its associated resources.
  83158. */
  83159. dispose(): void;
  83160. /**
  83161. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83162. * @param parsedTexture Define the JSON representation of the texture
  83163. * @param scene Define the scene the parsed texture should be instantiated in
  83164. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83165. * @returns The parsed texture if successful
  83166. */
  83167. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83168. /**
  83169. * Creates a texture from its base 64 representation.
  83170. * @param data Define the base64 payload without the data: prefix
  83171. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83172. * @param scene Define the scene the texture should belong to
  83173. * @param noMipmap Forces the texture to not create mip map information if true
  83174. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83175. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83176. * @param onLoad define a callback triggered when the texture has been loaded
  83177. * @param onError define a callback triggered when an error occurred during the loading session
  83178. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83179. * @returns the created texture
  83180. */
  83181. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83182. /**
  83183. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83184. * @param data Define the base64 payload without the data: prefix
  83185. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83186. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83187. * @param scene Define the scene the texture should belong to
  83188. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83189. * @param noMipmap Forces the texture to not create mip map information if true
  83190. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83191. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83192. * @param onLoad define a callback triggered when the texture has been loaded
  83193. * @param onError define a callback triggered when an error occurred during the loading session
  83194. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83195. * @returns the created texture
  83196. */
  83197. 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;
  83198. }
  83199. }
  83200. declare module BABYLON {
  83201. /**
  83202. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83203. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83204. */
  83205. export class PostProcessManager {
  83206. private _scene;
  83207. private _indexBuffer;
  83208. private _vertexBuffers;
  83209. /**
  83210. * Creates a new instance PostProcess
  83211. * @param scene The scene that the post process is associated with.
  83212. */
  83213. constructor(scene: Scene);
  83214. private _prepareBuffers;
  83215. private _buildIndexBuffer;
  83216. /**
  83217. * Rebuilds the vertex buffers of the manager.
  83218. * @hidden
  83219. */
  83220. _rebuild(): void;
  83221. /**
  83222. * Prepares a frame to be run through a post process.
  83223. * @param sourceTexture The input texture to the post procesess. (default: null)
  83224. * @param postProcesses An array of post processes to be run. (default: null)
  83225. * @returns True if the post processes were able to be run.
  83226. * @hidden
  83227. */
  83228. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83229. /**
  83230. * Manually render a set of post processes to a texture.
  83231. * @param postProcesses An array of post processes to be run.
  83232. * @param targetTexture The target texture to render to.
  83233. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83234. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83235. * @param lodLevel defines which lod of the texture to render to
  83236. */
  83237. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83238. /**
  83239. * Finalize the result of the output of the postprocesses.
  83240. * @param doNotPresent If true the result will not be displayed to the screen.
  83241. * @param targetTexture The target texture to render to.
  83242. * @param faceIndex The index of the face to bind the target texture to.
  83243. * @param postProcesses The array of post processes to render.
  83244. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83245. * @hidden
  83246. */
  83247. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83248. /**
  83249. * Disposes of the post process manager.
  83250. */
  83251. dispose(): void;
  83252. }
  83253. }
  83254. declare module BABYLON {
  83255. /** Interface used by value gradients (color, factor, ...) */
  83256. export interface IValueGradient {
  83257. /**
  83258. * Gets or sets the gradient value (between 0 and 1)
  83259. */
  83260. gradient: number;
  83261. }
  83262. /** Class used to store color4 gradient */
  83263. export class ColorGradient implements IValueGradient {
  83264. /**
  83265. * Gets or sets the gradient value (between 0 and 1)
  83266. */
  83267. gradient: number;
  83268. /**
  83269. * Gets or sets first associated color
  83270. */
  83271. color1: Color4;
  83272. /**
  83273. * Gets or sets second associated color
  83274. */
  83275. color2?: Color4;
  83276. /**
  83277. * Will get a color picked randomly between color1 and color2.
  83278. * If color2 is undefined then color1 will be used
  83279. * @param result defines the target Color4 to store the result in
  83280. */
  83281. getColorToRef(result: Color4): void;
  83282. }
  83283. /** Class used to store color 3 gradient */
  83284. export class Color3Gradient implements IValueGradient {
  83285. /**
  83286. * Gets or sets the gradient value (between 0 and 1)
  83287. */
  83288. gradient: number;
  83289. /**
  83290. * Gets or sets the associated color
  83291. */
  83292. color: Color3;
  83293. }
  83294. /** Class used to store factor gradient */
  83295. export class FactorGradient implements IValueGradient {
  83296. /**
  83297. * Gets or sets the gradient value (between 0 and 1)
  83298. */
  83299. gradient: number;
  83300. /**
  83301. * Gets or sets first associated factor
  83302. */
  83303. factor1: number;
  83304. /**
  83305. * Gets or sets second associated factor
  83306. */
  83307. factor2?: number;
  83308. /**
  83309. * Will get a number picked randomly between factor1 and factor2.
  83310. * If factor2 is undefined then factor1 will be used
  83311. * @returns the picked number
  83312. */
  83313. getFactor(): number;
  83314. }
  83315. /**
  83316. * Helper used to simplify some generic gradient tasks
  83317. */
  83318. export class GradientHelper {
  83319. /**
  83320. * Gets the current gradient from an array of IValueGradient
  83321. * @param ratio defines the current ratio to get
  83322. * @param gradients defines the array of IValueGradient
  83323. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83324. */
  83325. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83326. }
  83327. }
  83328. declare module BABYLON {
  83329. interface ThinEngine {
  83330. /**
  83331. * Creates a dynamic texture
  83332. * @param width defines the width of the texture
  83333. * @param height defines the height of the texture
  83334. * @param generateMipMaps defines if the engine should generate the mip levels
  83335. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83336. * @returns the dynamic texture inside an InternalTexture
  83337. */
  83338. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83339. /**
  83340. * Update the content of a dynamic texture
  83341. * @param texture defines the texture to update
  83342. * @param canvas defines the canvas containing the source
  83343. * @param invertY defines if data must be stored with Y axis inverted
  83344. * @param premulAlpha defines if alpha is stored as premultiplied
  83345. * @param format defines the format of the data
  83346. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83347. */
  83348. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83349. }
  83350. }
  83351. declare module BABYLON {
  83352. /**
  83353. * Helper class used to generate a canvas to manipulate images
  83354. */
  83355. export class CanvasGenerator {
  83356. /**
  83357. * Create a new canvas (or offscreen canvas depending on the context)
  83358. * @param width defines the expected width
  83359. * @param height defines the expected height
  83360. * @return a new canvas or offscreen canvas
  83361. */
  83362. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83363. }
  83364. }
  83365. declare module BABYLON {
  83366. /**
  83367. * A class extending Texture allowing drawing on a texture
  83368. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83369. */
  83370. export class DynamicTexture extends Texture {
  83371. private _generateMipMaps;
  83372. private _canvas;
  83373. private _context;
  83374. private _engine;
  83375. /**
  83376. * Creates a DynamicTexture
  83377. * @param name defines the name of the texture
  83378. * @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
  83379. * @param scene defines the scene where you want the texture
  83380. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83381. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83382. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83383. */
  83384. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83385. /**
  83386. * Get the current class name of the texture useful for serialization or dynamic coding.
  83387. * @returns "DynamicTexture"
  83388. */
  83389. getClassName(): string;
  83390. /**
  83391. * Gets the current state of canRescale
  83392. */
  83393. readonly canRescale: boolean;
  83394. private _recreate;
  83395. /**
  83396. * Scales the texture
  83397. * @param ratio the scale factor to apply to both width and height
  83398. */
  83399. scale(ratio: number): void;
  83400. /**
  83401. * Resizes the texture
  83402. * @param width the new width
  83403. * @param height the new height
  83404. */
  83405. scaleTo(width: number, height: number): void;
  83406. /**
  83407. * Gets the context of the canvas used by the texture
  83408. * @returns the canvas context of the dynamic texture
  83409. */
  83410. getContext(): CanvasRenderingContext2D;
  83411. /**
  83412. * Clears the texture
  83413. */
  83414. clear(): void;
  83415. /**
  83416. * Updates the texture
  83417. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83418. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83419. */
  83420. update(invertY?: boolean, premulAlpha?: boolean): void;
  83421. /**
  83422. * Draws text onto the texture
  83423. * @param text defines the text to be drawn
  83424. * @param x defines the placement of the text from the left
  83425. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83426. * @param font defines the font to be used with font-style, font-size, font-name
  83427. * @param color defines the color used for the text
  83428. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83429. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83430. * @param update defines whether texture is immediately update (default is true)
  83431. */
  83432. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83433. /**
  83434. * Clones the texture
  83435. * @returns the clone of the texture.
  83436. */
  83437. clone(): DynamicTexture;
  83438. /**
  83439. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83440. * @returns a serialized dynamic texture object
  83441. */
  83442. serialize(): any;
  83443. /** @hidden */
  83444. _rebuild(): void;
  83445. }
  83446. }
  83447. declare module BABYLON {
  83448. interface AbstractScene {
  83449. /**
  83450. * The list of procedural textures added to the scene
  83451. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83452. */
  83453. proceduralTextures: Array<ProceduralTexture>;
  83454. }
  83455. /**
  83456. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83457. * in a given scene.
  83458. */
  83459. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83460. /**
  83461. * The component name helpfull to identify the component in the list of scene components.
  83462. */
  83463. readonly name: string;
  83464. /**
  83465. * The scene the component belongs to.
  83466. */
  83467. scene: Scene;
  83468. /**
  83469. * Creates a new instance of the component for the given scene
  83470. * @param scene Defines the scene to register the component in
  83471. */
  83472. constructor(scene: Scene);
  83473. /**
  83474. * Registers the component in a given scene
  83475. */
  83476. register(): void;
  83477. /**
  83478. * Rebuilds the elements related to this component in case of
  83479. * context lost for instance.
  83480. */
  83481. rebuild(): void;
  83482. /**
  83483. * Disposes the component and the associated ressources.
  83484. */
  83485. dispose(): void;
  83486. private _beforeClear;
  83487. }
  83488. }
  83489. declare module BABYLON {
  83490. interface ThinEngine {
  83491. /**
  83492. * Creates a new render target cube texture
  83493. * @param size defines the size of the texture
  83494. * @param options defines the options used to create the texture
  83495. * @returns a new render target cube texture stored in an InternalTexture
  83496. */
  83497. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83498. }
  83499. }
  83500. declare module BABYLON {
  83501. /** @hidden */
  83502. export var proceduralVertexShader: {
  83503. name: string;
  83504. shader: string;
  83505. };
  83506. }
  83507. declare module BABYLON {
  83508. /**
  83509. * 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.
  83510. * This is the base class of any Procedural texture and contains most of the shareable code.
  83511. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83512. */
  83513. export class ProceduralTexture extends Texture {
  83514. isCube: boolean;
  83515. /**
  83516. * Define if the texture is enabled or not (disabled texture will not render)
  83517. */
  83518. isEnabled: boolean;
  83519. /**
  83520. * Define if the texture must be cleared before rendering (default is true)
  83521. */
  83522. autoClear: boolean;
  83523. /**
  83524. * Callback called when the texture is generated
  83525. */
  83526. onGenerated: () => void;
  83527. /**
  83528. * Event raised when the texture is generated
  83529. */
  83530. onGeneratedObservable: Observable<ProceduralTexture>;
  83531. /** @hidden */
  83532. _generateMipMaps: boolean;
  83533. /** @hidden **/
  83534. _effect: Effect;
  83535. /** @hidden */
  83536. _textures: {
  83537. [key: string]: Texture;
  83538. };
  83539. private _size;
  83540. private _currentRefreshId;
  83541. private _refreshRate;
  83542. private _vertexBuffers;
  83543. private _indexBuffer;
  83544. private _uniforms;
  83545. private _samplers;
  83546. private _fragment;
  83547. private _floats;
  83548. private _ints;
  83549. private _floatsArrays;
  83550. private _colors3;
  83551. private _colors4;
  83552. private _vectors2;
  83553. private _vectors3;
  83554. private _matrices;
  83555. private _fallbackTexture;
  83556. private _fallbackTextureUsed;
  83557. private _engine;
  83558. private _cachedDefines;
  83559. private _contentUpdateId;
  83560. private _contentData;
  83561. /**
  83562. * Instantiates a new procedural texture.
  83563. * 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.
  83564. * This is the base class of any Procedural texture and contains most of the shareable code.
  83565. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83566. * @param name Define the name of the texture
  83567. * @param size Define the size of the texture to create
  83568. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83569. * @param scene Define the scene the texture belongs to
  83570. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83571. * @param generateMipMaps Define if the texture should creates mip maps or not
  83572. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83573. */
  83574. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83575. /**
  83576. * The effect that is created when initializing the post process.
  83577. * @returns The created effect corresponding the the postprocess.
  83578. */
  83579. getEffect(): Effect;
  83580. /**
  83581. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83582. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83583. */
  83584. getContent(): Nullable<ArrayBufferView>;
  83585. private _createIndexBuffer;
  83586. /** @hidden */
  83587. _rebuild(): void;
  83588. /**
  83589. * Resets the texture in order to recreate its associated resources.
  83590. * This can be called in case of context loss
  83591. */
  83592. reset(): void;
  83593. protected _getDefines(): string;
  83594. /**
  83595. * Is the texture ready to be used ? (rendered at least once)
  83596. * @returns true if ready, otherwise, false.
  83597. */
  83598. isReady(): boolean;
  83599. /**
  83600. * Resets the refresh counter of the texture and start bak from scratch.
  83601. * Could be useful to regenerate the texture if it is setup to render only once.
  83602. */
  83603. resetRefreshCounter(): void;
  83604. /**
  83605. * Set the fragment shader to use in order to render the texture.
  83606. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83607. */
  83608. setFragment(fragment: any): void;
  83609. /**
  83610. * Define the refresh rate of the texture or the rendering frequency.
  83611. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83612. */
  83613. refreshRate: number;
  83614. /** @hidden */
  83615. _shouldRender(): boolean;
  83616. /**
  83617. * Get the size the texture is rendering at.
  83618. * @returns the size (texture is always squared)
  83619. */
  83620. getRenderSize(): number;
  83621. /**
  83622. * Resize the texture to new value.
  83623. * @param size Define the new size the texture should have
  83624. * @param generateMipMaps Define whether the new texture should create mip maps
  83625. */
  83626. resize(size: number, generateMipMaps: boolean): void;
  83627. private _checkUniform;
  83628. /**
  83629. * Set a texture in the shader program used to render.
  83630. * @param name Define the name of the uniform samplers as defined in the shader
  83631. * @param texture Define the texture to bind to this sampler
  83632. * @return the texture itself allowing "fluent" like uniform updates
  83633. */
  83634. setTexture(name: string, texture: Texture): ProceduralTexture;
  83635. /**
  83636. * Set a float in the shader.
  83637. * @param name Define the name of the uniform as defined in the shader
  83638. * @param value Define the value to give to the uniform
  83639. * @return the texture itself allowing "fluent" like uniform updates
  83640. */
  83641. setFloat(name: string, value: number): ProceduralTexture;
  83642. /**
  83643. * Set a int in the shader.
  83644. * @param name Define the name of the uniform as defined in the shader
  83645. * @param value Define the value to give to the uniform
  83646. * @return the texture itself allowing "fluent" like uniform updates
  83647. */
  83648. setInt(name: string, value: number): ProceduralTexture;
  83649. /**
  83650. * Set an array of floats in the shader.
  83651. * @param name Define the name of the uniform as defined in the shader
  83652. * @param value Define the value to give to the uniform
  83653. * @return the texture itself allowing "fluent" like uniform updates
  83654. */
  83655. setFloats(name: string, value: number[]): ProceduralTexture;
  83656. /**
  83657. * Set a vec3 in the shader from a Color3.
  83658. * @param name Define the name of the uniform as defined in the shader
  83659. * @param value Define the value to give to the uniform
  83660. * @return the texture itself allowing "fluent" like uniform updates
  83661. */
  83662. setColor3(name: string, value: Color3): ProceduralTexture;
  83663. /**
  83664. * Set a vec4 in the shader from a Color4.
  83665. * @param name Define the name of the uniform as defined in the shader
  83666. * @param value Define the value to give to the uniform
  83667. * @return the texture itself allowing "fluent" like uniform updates
  83668. */
  83669. setColor4(name: string, value: Color4): ProceduralTexture;
  83670. /**
  83671. * Set a vec2 in the shader from a Vector2.
  83672. * @param name Define the name of the uniform as defined in the shader
  83673. * @param value Define the value to give to the uniform
  83674. * @return the texture itself allowing "fluent" like uniform updates
  83675. */
  83676. setVector2(name: string, value: Vector2): ProceduralTexture;
  83677. /**
  83678. * Set a vec3 in the shader from a Vector3.
  83679. * @param name Define the name of the uniform as defined in the shader
  83680. * @param value Define the value to give to the uniform
  83681. * @return the texture itself allowing "fluent" like uniform updates
  83682. */
  83683. setVector3(name: string, value: Vector3): ProceduralTexture;
  83684. /**
  83685. * Set a mat4 in the shader from a MAtrix.
  83686. * @param name Define the name of the uniform as defined in the shader
  83687. * @param value Define the value to give to the uniform
  83688. * @return the texture itself allowing "fluent" like uniform updates
  83689. */
  83690. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83691. /**
  83692. * Render the texture to its associated render target.
  83693. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83694. */
  83695. render(useCameraPostProcess?: boolean): void;
  83696. /**
  83697. * Clone the texture.
  83698. * @returns the cloned texture
  83699. */
  83700. clone(): ProceduralTexture;
  83701. /**
  83702. * Dispose the texture and release its asoociated resources.
  83703. */
  83704. dispose(): void;
  83705. }
  83706. }
  83707. declare module BABYLON {
  83708. /**
  83709. * This represents the base class for particle system in Babylon.
  83710. * 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.
  83711. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83712. * @example https://doc.babylonjs.com/babylon101/particles
  83713. */
  83714. export class BaseParticleSystem {
  83715. /**
  83716. * Source color is added to the destination color without alpha affecting the result
  83717. */
  83718. static BLENDMODE_ONEONE: number;
  83719. /**
  83720. * Blend current color and particle color using particle’s alpha
  83721. */
  83722. static BLENDMODE_STANDARD: number;
  83723. /**
  83724. * Add current color and particle color multiplied by particle’s alpha
  83725. */
  83726. static BLENDMODE_ADD: number;
  83727. /**
  83728. * Multiply current color with particle color
  83729. */
  83730. static BLENDMODE_MULTIPLY: number;
  83731. /**
  83732. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83733. */
  83734. static BLENDMODE_MULTIPLYADD: number;
  83735. /**
  83736. * List of animations used by the particle system.
  83737. */
  83738. animations: Animation[];
  83739. /**
  83740. * The id of the Particle system.
  83741. */
  83742. id: string;
  83743. /**
  83744. * The friendly name of the Particle system.
  83745. */
  83746. name: string;
  83747. /**
  83748. * The rendering group used by the Particle system to chose when to render.
  83749. */
  83750. renderingGroupId: number;
  83751. /**
  83752. * The emitter represents the Mesh or position we are attaching the particle system to.
  83753. */
  83754. emitter: Nullable<AbstractMesh | Vector3>;
  83755. /**
  83756. * The maximum number of particles to emit per frame
  83757. */
  83758. emitRate: number;
  83759. /**
  83760. * If you want to launch only a few particles at once, that can be done, as well.
  83761. */
  83762. manualEmitCount: number;
  83763. /**
  83764. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83765. */
  83766. updateSpeed: number;
  83767. /**
  83768. * The amount of time the particle system is running (depends of the overall update speed).
  83769. */
  83770. targetStopDuration: number;
  83771. /**
  83772. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83773. */
  83774. disposeOnStop: boolean;
  83775. /**
  83776. * Minimum power of emitting particles.
  83777. */
  83778. minEmitPower: number;
  83779. /**
  83780. * Maximum power of emitting particles.
  83781. */
  83782. maxEmitPower: number;
  83783. /**
  83784. * Minimum life time of emitting particles.
  83785. */
  83786. minLifeTime: number;
  83787. /**
  83788. * Maximum life time of emitting particles.
  83789. */
  83790. maxLifeTime: number;
  83791. /**
  83792. * Minimum Size of emitting particles.
  83793. */
  83794. minSize: number;
  83795. /**
  83796. * Maximum Size of emitting particles.
  83797. */
  83798. maxSize: number;
  83799. /**
  83800. * Minimum scale of emitting particles on X axis.
  83801. */
  83802. minScaleX: number;
  83803. /**
  83804. * Maximum scale of emitting particles on X axis.
  83805. */
  83806. maxScaleX: number;
  83807. /**
  83808. * Minimum scale of emitting particles on Y axis.
  83809. */
  83810. minScaleY: number;
  83811. /**
  83812. * Maximum scale of emitting particles on Y axis.
  83813. */
  83814. maxScaleY: number;
  83815. /**
  83816. * Gets or sets the minimal initial rotation in radians.
  83817. */
  83818. minInitialRotation: number;
  83819. /**
  83820. * Gets or sets the maximal initial rotation in radians.
  83821. */
  83822. maxInitialRotation: number;
  83823. /**
  83824. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83825. */
  83826. minAngularSpeed: number;
  83827. /**
  83828. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83829. */
  83830. maxAngularSpeed: number;
  83831. /**
  83832. * The texture used to render each particle. (this can be a spritesheet)
  83833. */
  83834. particleTexture: Nullable<Texture>;
  83835. /**
  83836. * The layer mask we are rendering the particles through.
  83837. */
  83838. layerMask: number;
  83839. /**
  83840. * This can help using your own shader to render the particle system.
  83841. * The according effect will be created
  83842. */
  83843. customShader: any;
  83844. /**
  83845. * By default particle system starts as soon as they are created. This prevents the
  83846. * automatic start to happen and let you decide when to start emitting particles.
  83847. */
  83848. preventAutoStart: boolean;
  83849. private _noiseTexture;
  83850. /**
  83851. * Gets or sets a texture used to add random noise to particle positions
  83852. */
  83853. noiseTexture: Nullable<ProceduralTexture>;
  83854. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83855. noiseStrength: Vector3;
  83856. /**
  83857. * Callback triggered when the particle animation is ending.
  83858. */
  83859. onAnimationEnd: Nullable<() => void>;
  83860. /**
  83861. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83862. */
  83863. blendMode: number;
  83864. /**
  83865. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83866. * to override the particles.
  83867. */
  83868. forceDepthWrite: boolean;
  83869. /** 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 */
  83870. preWarmCycles: number;
  83871. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83872. preWarmStepOffset: number;
  83873. /**
  83874. * 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)
  83875. */
  83876. spriteCellChangeSpeed: number;
  83877. /**
  83878. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83879. */
  83880. startSpriteCellID: number;
  83881. /**
  83882. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83883. */
  83884. endSpriteCellID: number;
  83885. /**
  83886. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83887. */
  83888. spriteCellWidth: number;
  83889. /**
  83890. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83891. */
  83892. spriteCellHeight: number;
  83893. /**
  83894. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83895. */
  83896. spriteRandomStartCell: boolean;
  83897. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83898. translationPivot: Vector2;
  83899. /** @hidden */
  83900. protected _isAnimationSheetEnabled: boolean;
  83901. /**
  83902. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83903. */
  83904. beginAnimationOnStart: boolean;
  83905. /**
  83906. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83907. */
  83908. beginAnimationFrom: number;
  83909. /**
  83910. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83911. */
  83912. beginAnimationTo: number;
  83913. /**
  83914. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83915. */
  83916. beginAnimationLoop: boolean;
  83917. /**
  83918. * Gets or sets a world offset applied to all particles
  83919. */
  83920. worldOffset: Vector3;
  83921. /**
  83922. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83923. */
  83924. isAnimationSheetEnabled: boolean;
  83925. /**
  83926. * Get hosting scene
  83927. * @returns the scene
  83928. */
  83929. getScene(): Scene;
  83930. /**
  83931. * You can use gravity if you want to give an orientation to your particles.
  83932. */
  83933. gravity: Vector3;
  83934. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83935. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83936. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83937. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83938. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83939. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83940. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83941. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83942. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83943. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83944. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83945. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83946. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83947. /**
  83948. * Defines the delay in milliseconds before starting the system (0 by default)
  83949. */
  83950. startDelay: number;
  83951. /**
  83952. * Gets the current list of drag gradients.
  83953. * You must use addDragGradient and removeDragGradient to udpate this list
  83954. * @returns the list of drag gradients
  83955. */
  83956. getDragGradients(): Nullable<Array<FactorGradient>>;
  83957. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83958. limitVelocityDamping: number;
  83959. /**
  83960. * Gets the current list of limit velocity gradients.
  83961. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83962. * @returns the list of limit velocity gradients
  83963. */
  83964. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83965. /**
  83966. * Gets the current list of color gradients.
  83967. * You must use addColorGradient and removeColorGradient to udpate this list
  83968. * @returns the list of color gradients
  83969. */
  83970. getColorGradients(): Nullable<Array<ColorGradient>>;
  83971. /**
  83972. * Gets the current list of size gradients.
  83973. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83974. * @returns the list of size gradients
  83975. */
  83976. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83977. /**
  83978. * Gets the current list of color remap gradients.
  83979. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83980. * @returns the list of color remap gradients
  83981. */
  83982. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83983. /**
  83984. * Gets the current list of alpha remap gradients.
  83985. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83986. * @returns the list of alpha remap gradients
  83987. */
  83988. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83989. /**
  83990. * Gets the current list of life time gradients.
  83991. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83992. * @returns the list of life time gradients
  83993. */
  83994. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83995. /**
  83996. * Gets the current list of angular speed gradients.
  83997. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83998. * @returns the list of angular speed gradients
  83999. */
  84000. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84001. /**
  84002. * Gets the current list of velocity gradients.
  84003. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84004. * @returns the list of velocity gradients
  84005. */
  84006. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84007. /**
  84008. * Gets the current list of start size gradients.
  84009. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84010. * @returns the list of start size gradients
  84011. */
  84012. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84013. /**
  84014. * Gets the current list of emit rate gradients.
  84015. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84016. * @returns the list of emit rate gradients
  84017. */
  84018. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84019. /**
  84020. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84022. */
  84023. direction1: Vector3;
  84024. /**
  84025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84027. */
  84028. direction2: Vector3;
  84029. /**
  84030. * 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.
  84031. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84032. */
  84033. minEmitBox: Vector3;
  84034. /**
  84035. * 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.
  84036. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84037. */
  84038. maxEmitBox: Vector3;
  84039. /**
  84040. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84041. */
  84042. color1: Color4;
  84043. /**
  84044. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84045. */
  84046. color2: Color4;
  84047. /**
  84048. * Color the particle will have at the end of its lifetime
  84049. */
  84050. colorDead: Color4;
  84051. /**
  84052. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84053. */
  84054. textureMask: Color4;
  84055. /**
  84056. * The particle emitter type defines the emitter used by the particle system.
  84057. * It can be for example box, sphere, or cone...
  84058. */
  84059. particleEmitterType: IParticleEmitterType;
  84060. /** @hidden */
  84061. _isSubEmitter: boolean;
  84062. /**
  84063. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84064. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84065. */
  84066. billboardMode: number;
  84067. protected _isBillboardBased: boolean;
  84068. /**
  84069. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84070. */
  84071. isBillboardBased: boolean;
  84072. /**
  84073. * The scene the particle system belongs to.
  84074. */
  84075. protected _scene: Scene;
  84076. /**
  84077. * Local cache of defines for image processing.
  84078. */
  84079. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84080. /**
  84081. * Default configuration related to image processing available in the standard Material.
  84082. */
  84083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84084. /**
  84085. * Gets the image processing configuration used either in this material.
  84086. */
  84087. /**
  84088. * Sets the Default image processing configuration used either in the this material.
  84089. *
  84090. * If sets to null, the scene one is in use.
  84091. */
  84092. imageProcessingConfiguration: ImageProcessingConfiguration;
  84093. /**
  84094. * Attaches a new image processing configuration to the Standard Material.
  84095. * @param configuration
  84096. */
  84097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84098. /** @hidden */
  84099. protected _reset(): void;
  84100. /** @hidden */
  84101. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84102. /**
  84103. * Instantiates a particle system.
  84104. * 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.
  84105. * @param name The name of the particle system
  84106. */
  84107. constructor(name: string);
  84108. /**
  84109. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84110. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84111. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84112. * @returns the emitter
  84113. */
  84114. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84115. /**
  84116. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84117. * @param radius The radius of the hemisphere to emit from
  84118. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84119. * @returns the emitter
  84120. */
  84121. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84122. /**
  84123. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84124. * @param radius The radius of the sphere to emit from
  84125. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84126. * @returns the emitter
  84127. */
  84128. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84129. /**
  84130. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84131. * @param radius The radius of the sphere to emit from
  84132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84134. * @returns the emitter
  84135. */
  84136. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84137. /**
  84138. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84139. * @param radius The radius of the emission cylinder
  84140. * @param height The height of the emission cylinder
  84141. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84142. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84143. * @returns the emitter
  84144. */
  84145. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84146. /**
  84147. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84148. * @param radius The radius of the cylinder to emit from
  84149. * @param height The height of the emission cylinder
  84150. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84151. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84152. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84153. * @returns the emitter
  84154. */
  84155. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84156. /**
  84157. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84158. * @param radius The radius of the cone to emit from
  84159. * @param angle The base angle of the cone
  84160. * @returns the emitter
  84161. */
  84162. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84163. /**
  84164. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84165. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84166. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84167. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84168. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84169. * @returns the emitter
  84170. */
  84171. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84172. }
  84173. }
  84174. declare module BABYLON {
  84175. /**
  84176. * Type of sub emitter
  84177. */
  84178. export enum SubEmitterType {
  84179. /**
  84180. * Attached to the particle over it's lifetime
  84181. */
  84182. ATTACHED = 0,
  84183. /**
  84184. * Created when the particle dies
  84185. */
  84186. END = 1
  84187. }
  84188. /**
  84189. * Sub emitter class used to emit particles from an existing particle
  84190. */
  84191. export class SubEmitter {
  84192. /**
  84193. * the particle system to be used by the sub emitter
  84194. */
  84195. particleSystem: ParticleSystem;
  84196. /**
  84197. * Type of the submitter (Default: END)
  84198. */
  84199. type: SubEmitterType;
  84200. /**
  84201. * 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)
  84202. * Note: This only is supported when using an emitter of type Mesh
  84203. */
  84204. inheritDirection: boolean;
  84205. /**
  84206. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84207. */
  84208. inheritedVelocityAmount: number;
  84209. /**
  84210. * Creates a sub emitter
  84211. * @param particleSystem the particle system to be used by the sub emitter
  84212. */
  84213. constructor(
  84214. /**
  84215. * the particle system to be used by the sub emitter
  84216. */
  84217. particleSystem: ParticleSystem);
  84218. /**
  84219. * Clones the sub emitter
  84220. * @returns the cloned sub emitter
  84221. */
  84222. clone(): SubEmitter;
  84223. /**
  84224. * Serialize current object to a JSON object
  84225. * @returns the serialized object
  84226. */
  84227. serialize(): any;
  84228. /** @hidden */
  84229. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84230. /**
  84231. * Creates a new SubEmitter from a serialized JSON version
  84232. * @param serializationObject defines the JSON object to read from
  84233. * @param scene defines the hosting scene
  84234. * @param rootUrl defines the rootUrl for data loading
  84235. * @returns a new SubEmitter
  84236. */
  84237. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84238. /** Release associated resources */
  84239. dispose(): void;
  84240. }
  84241. }
  84242. declare module BABYLON {
  84243. /** @hidden */
  84244. export var clipPlaneFragmentDeclaration: {
  84245. name: string;
  84246. shader: string;
  84247. };
  84248. }
  84249. declare module BABYLON {
  84250. /** @hidden */
  84251. export var imageProcessingDeclaration: {
  84252. name: string;
  84253. shader: string;
  84254. };
  84255. }
  84256. declare module BABYLON {
  84257. /** @hidden */
  84258. export var imageProcessingFunctions: {
  84259. name: string;
  84260. shader: string;
  84261. };
  84262. }
  84263. declare module BABYLON {
  84264. /** @hidden */
  84265. export var clipPlaneFragment: {
  84266. name: string;
  84267. shader: string;
  84268. };
  84269. }
  84270. declare module BABYLON {
  84271. /** @hidden */
  84272. export var particlesPixelShader: {
  84273. name: string;
  84274. shader: string;
  84275. };
  84276. }
  84277. declare module BABYLON {
  84278. /** @hidden */
  84279. export var clipPlaneVertexDeclaration: {
  84280. name: string;
  84281. shader: string;
  84282. };
  84283. }
  84284. declare module BABYLON {
  84285. /** @hidden */
  84286. export var clipPlaneVertex: {
  84287. name: string;
  84288. shader: string;
  84289. };
  84290. }
  84291. declare module BABYLON {
  84292. /** @hidden */
  84293. export var particlesVertexShader: {
  84294. name: string;
  84295. shader: string;
  84296. };
  84297. }
  84298. declare module BABYLON {
  84299. /**
  84300. * This represents a particle system in Babylon.
  84301. * 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.
  84302. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84303. * @example https://doc.babylonjs.com/babylon101/particles
  84304. */
  84305. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84306. /**
  84307. * Billboard mode will only apply to Y axis
  84308. */
  84309. static readonly BILLBOARDMODE_Y: number;
  84310. /**
  84311. * Billboard mode will apply to all axes
  84312. */
  84313. static readonly BILLBOARDMODE_ALL: number;
  84314. /**
  84315. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84316. */
  84317. static readonly BILLBOARDMODE_STRETCHED: number;
  84318. /**
  84319. * This function can be defined to provide custom update for active particles.
  84320. * This function will be called instead of regular update (age, position, color, etc.).
  84321. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84322. */
  84323. updateFunction: (particles: Particle[]) => void;
  84324. private _emitterWorldMatrix;
  84325. /**
  84326. * This function can be defined to specify initial direction for every new particle.
  84327. * It by default use the emitterType defined function
  84328. */
  84329. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84330. /**
  84331. * This function can be defined to specify initial position for every new particle.
  84332. * It by default use the emitterType defined function
  84333. */
  84334. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84335. /**
  84336. * @hidden
  84337. */
  84338. _inheritedVelocityOffset: Vector3;
  84339. /**
  84340. * An event triggered when the system is disposed
  84341. */
  84342. onDisposeObservable: Observable<ParticleSystem>;
  84343. private _onDisposeObserver;
  84344. /**
  84345. * Sets a callback that will be triggered when the system is disposed
  84346. */
  84347. onDispose: () => void;
  84348. private _particles;
  84349. private _epsilon;
  84350. private _capacity;
  84351. private _stockParticles;
  84352. private _newPartsExcess;
  84353. private _vertexData;
  84354. private _vertexBuffer;
  84355. private _vertexBuffers;
  84356. private _spriteBuffer;
  84357. private _indexBuffer;
  84358. private _effect;
  84359. private _customEffect;
  84360. private _cachedDefines;
  84361. private _scaledColorStep;
  84362. private _colorDiff;
  84363. private _scaledDirection;
  84364. private _scaledGravity;
  84365. private _currentRenderId;
  84366. private _alive;
  84367. private _useInstancing;
  84368. private _started;
  84369. private _stopped;
  84370. private _actualFrame;
  84371. private _scaledUpdateSpeed;
  84372. private _vertexBufferSize;
  84373. /** @hidden */
  84374. _currentEmitRateGradient: Nullable<FactorGradient>;
  84375. /** @hidden */
  84376. _currentEmitRate1: number;
  84377. /** @hidden */
  84378. _currentEmitRate2: number;
  84379. /** @hidden */
  84380. _currentStartSizeGradient: Nullable<FactorGradient>;
  84381. /** @hidden */
  84382. _currentStartSize1: number;
  84383. /** @hidden */
  84384. _currentStartSize2: number;
  84385. private readonly _rawTextureWidth;
  84386. private _rampGradientsTexture;
  84387. private _useRampGradients;
  84388. /** Gets or sets a boolean indicating that ramp gradients must be used
  84389. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84390. */
  84391. useRampGradients: boolean;
  84392. /**
  84393. * 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.
  84394. * 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: [])
  84395. */
  84396. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84397. private _subEmitters;
  84398. /**
  84399. * @hidden
  84400. * If the particle systems emitter should be disposed when the particle system is disposed
  84401. */
  84402. _disposeEmitterOnDispose: boolean;
  84403. /**
  84404. * The current active Sub-systems, this property is used by the root particle system only.
  84405. */
  84406. activeSubSystems: Array<ParticleSystem>;
  84407. private _rootParticleSystem;
  84408. /**
  84409. * Gets the current list of active particles
  84410. */
  84411. readonly particles: Particle[];
  84412. /**
  84413. * Returns the string "ParticleSystem"
  84414. * @returns a string containing the class name
  84415. */
  84416. getClassName(): string;
  84417. /**
  84418. * Instantiates a particle system.
  84419. * 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.
  84420. * @param name The name of the particle system
  84421. * @param capacity The max number of particles alive at the same time
  84422. * @param scene The scene the particle system belongs to
  84423. * @param customEffect a custom effect used to change the way particles are rendered by default
  84424. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84425. * @param epsilon Offset used to render the particles
  84426. */
  84427. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84428. private _addFactorGradient;
  84429. private _removeFactorGradient;
  84430. /**
  84431. * Adds a new life time gradient
  84432. * @param gradient defines the gradient to use (between 0 and 1)
  84433. * @param factor defines the life time factor to affect to the specified gradient
  84434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84435. * @returns the current particle system
  84436. */
  84437. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84438. /**
  84439. * Remove a specific life time gradient
  84440. * @param gradient defines the gradient to remove
  84441. * @returns the current particle system
  84442. */
  84443. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84444. /**
  84445. * Adds a new size gradient
  84446. * @param gradient defines the gradient to use (between 0 and 1)
  84447. * @param factor defines the size factor to affect to the specified gradient
  84448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84449. * @returns the current particle system
  84450. */
  84451. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84452. /**
  84453. * Remove a specific size gradient
  84454. * @param gradient defines the gradient to remove
  84455. * @returns the current particle system
  84456. */
  84457. removeSizeGradient(gradient: number): IParticleSystem;
  84458. /**
  84459. * Adds a new color remap gradient
  84460. * @param gradient defines the gradient to use (between 0 and 1)
  84461. * @param min defines the color remap minimal range
  84462. * @param max defines the color remap maximal range
  84463. * @returns the current particle system
  84464. */
  84465. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84466. /**
  84467. * Remove a specific color remap gradient
  84468. * @param gradient defines the gradient to remove
  84469. * @returns the current particle system
  84470. */
  84471. removeColorRemapGradient(gradient: number): IParticleSystem;
  84472. /**
  84473. * Adds a new alpha remap gradient
  84474. * @param gradient defines the gradient to use (between 0 and 1)
  84475. * @param min defines the alpha remap minimal range
  84476. * @param max defines the alpha remap maximal range
  84477. * @returns the current particle system
  84478. */
  84479. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84480. /**
  84481. * Remove a specific alpha remap gradient
  84482. * @param gradient defines the gradient to remove
  84483. * @returns the current particle system
  84484. */
  84485. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84486. /**
  84487. * Adds a new angular speed gradient
  84488. * @param gradient defines the gradient to use (between 0 and 1)
  84489. * @param factor defines the angular speed to affect to the specified gradient
  84490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84491. * @returns the current particle system
  84492. */
  84493. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84494. /**
  84495. * Remove a specific angular speed gradient
  84496. * @param gradient defines the gradient to remove
  84497. * @returns the current particle system
  84498. */
  84499. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84500. /**
  84501. * Adds a new velocity gradient
  84502. * @param gradient defines the gradient to use (between 0 and 1)
  84503. * @param factor defines the velocity to affect to the specified gradient
  84504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84505. * @returns the current particle system
  84506. */
  84507. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84508. /**
  84509. * Remove a specific velocity gradient
  84510. * @param gradient defines the gradient to remove
  84511. * @returns the current particle system
  84512. */
  84513. removeVelocityGradient(gradient: number): IParticleSystem;
  84514. /**
  84515. * Adds a new limit velocity gradient
  84516. * @param gradient defines the gradient to use (between 0 and 1)
  84517. * @param factor defines the limit velocity value to affect to the specified gradient
  84518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84519. * @returns the current particle system
  84520. */
  84521. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84522. /**
  84523. * Remove a specific limit velocity gradient
  84524. * @param gradient defines the gradient to remove
  84525. * @returns the current particle system
  84526. */
  84527. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84528. /**
  84529. * Adds a new drag gradient
  84530. * @param gradient defines the gradient to use (between 0 and 1)
  84531. * @param factor defines the drag value to affect to the specified gradient
  84532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84533. * @returns the current particle system
  84534. */
  84535. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84536. /**
  84537. * Remove a specific drag gradient
  84538. * @param gradient defines the gradient to remove
  84539. * @returns the current particle system
  84540. */
  84541. removeDragGradient(gradient: number): IParticleSystem;
  84542. /**
  84543. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84544. * @param gradient defines the gradient to use (between 0 and 1)
  84545. * @param factor defines the emit rate value to affect to the specified gradient
  84546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84547. * @returns the current particle system
  84548. */
  84549. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84550. /**
  84551. * Remove a specific emit rate gradient
  84552. * @param gradient defines the gradient to remove
  84553. * @returns the current particle system
  84554. */
  84555. removeEmitRateGradient(gradient: number): IParticleSystem;
  84556. /**
  84557. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84558. * @param gradient defines the gradient to use (between 0 and 1)
  84559. * @param factor defines the start size value to affect to the specified gradient
  84560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84561. * @returns the current particle system
  84562. */
  84563. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84564. /**
  84565. * Remove a specific start size gradient
  84566. * @param gradient defines the gradient to remove
  84567. * @returns the current particle system
  84568. */
  84569. removeStartSizeGradient(gradient: number): IParticleSystem;
  84570. private _createRampGradientTexture;
  84571. /**
  84572. * Gets the current list of ramp gradients.
  84573. * You must use addRampGradient and removeRampGradient to udpate this list
  84574. * @returns the list of ramp gradients
  84575. */
  84576. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84577. /**
  84578. * Adds a new ramp gradient used to remap particle colors
  84579. * @param gradient defines the gradient to use (between 0 and 1)
  84580. * @param color defines the color to affect to the specified gradient
  84581. * @returns the current particle system
  84582. */
  84583. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84584. /**
  84585. * Remove a specific ramp gradient
  84586. * @param gradient defines the gradient to remove
  84587. * @returns the current particle system
  84588. */
  84589. removeRampGradient(gradient: number): ParticleSystem;
  84590. /**
  84591. * Adds a new color gradient
  84592. * @param gradient defines the gradient to use (between 0 and 1)
  84593. * @param color1 defines the color to affect to the specified gradient
  84594. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84595. * @returns this particle system
  84596. */
  84597. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84598. /**
  84599. * Remove a specific color gradient
  84600. * @param gradient defines the gradient to remove
  84601. * @returns this particle system
  84602. */
  84603. removeColorGradient(gradient: number): IParticleSystem;
  84604. private _fetchR;
  84605. protected _reset(): void;
  84606. private _resetEffect;
  84607. private _createVertexBuffers;
  84608. private _createIndexBuffer;
  84609. /**
  84610. * Gets the maximum number of particles active at the same time.
  84611. * @returns The max number of active particles.
  84612. */
  84613. getCapacity(): number;
  84614. /**
  84615. * Gets whether there are still active particles in the system.
  84616. * @returns True if it is alive, otherwise false.
  84617. */
  84618. isAlive(): boolean;
  84619. /**
  84620. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84621. * @returns True if it has been started, otherwise false.
  84622. */
  84623. isStarted(): boolean;
  84624. private _prepareSubEmitterInternalArray;
  84625. /**
  84626. * Starts the particle system and begins to emit
  84627. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84628. */
  84629. start(delay?: number): void;
  84630. /**
  84631. * Stops the particle system.
  84632. * @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.
  84633. */
  84634. stop(stopSubEmitters?: boolean): void;
  84635. /**
  84636. * Remove all active particles
  84637. */
  84638. reset(): void;
  84639. /**
  84640. * @hidden (for internal use only)
  84641. */
  84642. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84643. /**
  84644. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84645. * Its lifetime will start back at 0.
  84646. */
  84647. recycleParticle: (particle: Particle) => void;
  84648. private _stopSubEmitters;
  84649. private _createParticle;
  84650. private _removeFromRoot;
  84651. private _emitFromParticle;
  84652. private _update;
  84653. /** @hidden */
  84654. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84655. /** @hidden */
  84656. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84657. /** @hidden */
  84658. private _getEffect;
  84659. /**
  84660. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84661. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84662. */
  84663. animate(preWarmOnly?: boolean): void;
  84664. private _appendParticleVertices;
  84665. /**
  84666. * Rebuilds the particle system.
  84667. */
  84668. rebuild(): void;
  84669. /**
  84670. * Is this system ready to be used/rendered
  84671. * @return true if the system is ready
  84672. */
  84673. isReady(): boolean;
  84674. private _render;
  84675. /**
  84676. * Renders the particle system in its current state.
  84677. * @returns the current number of particles
  84678. */
  84679. render(): number;
  84680. /**
  84681. * Disposes the particle system and free the associated resources
  84682. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84683. */
  84684. dispose(disposeTexture?: boolean): void;
  84685. /**
  84686. * Clones the particle system.
  84687. * @param name The name of the cloned object
  84688. * @param newEmitter The new emitter to use
  84689. * @returns the cloned particle system
  84690. */
  84691. clone(name: string, newEmitter: any): ParticleSystem;
  84692. /**
  84693. * Serializes the particle system to a JSON object.
  84694. * @returns the JSON object
  84695. */
  84696. serialize(): any;
  84697. /** @hidden */
  84698. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84699. /** @hidden */
  84700. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84701. /**
  84702. * Parses a JSON object to create a particle system.
  84703. * @param parsedParticleSystem The JSON object to parse
  84704. * @param scene The scene to create the particle system in
  84705. * @param rootUrl The root url to use to load external dependencies like texture
  84706. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84707. * @returns the Parsed particle system
  84708. */
  84709. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84710. }
  84711. }
  84712. declare module BABYLON {
  84713. /**
  84714. * A particle represents one of the element emitted by a particle system.
  84715. * This is mainly define by its coordinates, direction, velocity and age.
  84716. */
  84717. export class Particle {
  84718. /**
  84719. * The particle system the particle belongs to.
  84720. */
  84721. particleSystem: ParticleSystem;
  84722. private static _Count;
  84723. /**
  84724. * Unique ID of the particle
  84725. */
  84726. id: number;
  84727. /**
  84728. * The world position of the particle in the scene.
  84729. */
  84730. position: Vector3;
  84731. /**
  84732. * The world direction of the particle in the scene.
  84733. */
  84734. direction: Vector3;
  84735. /**
  84736. * The color of the particle.
  84737. */
  84738. color: Color4;
  84739. /**
  84740. * The color change of the particle per step.
  84741. */
  84742. colorStep: Color4;
  84743. /**
  84744. * Defines how long will the life of the particle be.
  84745. */
  84746. lifeTime: number;
  84747. /**
  84748. * The current age of the particle.
  84749. */
  84750. age: number;
  84751. /**
  84752. * The current size of the particle.
  84753. */
  84754. size: number;
  84755. /**
  84756. * The current scale of the particle.
  84757. */
  84758. scale: Vector2;
  84759. /**
  84760. * The current angle of the particle.
  84761. */
  84762. angle: number;
  84763. /**
  84764. * Defines how fast is the angle changing.
  84765. */
  84766. angularSpeed: number;
  84767. /**
  84768. * Defines the cell index used by the particle to be rendered from a sprite.
  84769. */
  84770. cellIndex: number;
  84771. /**
  84772. * The information required to support color remapping
  84773. */
  84774. remapData: Vector4;
  84775. /** @hidden */
  84776. _randomCellOffset?: number;
  84777. /** @hidden */
  84778. _initialDirection: Nullable<Vector3>;
  84779. /** @hidden */
  84780. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84781. /** @hidden */
  84782. _initialStartSpriteCellID: number;
  84783. /** @hidden */
  84784. _initialEndSpriteCellID: number;
  84785. /** @hidden */
  84786. _currentColorGradient: Nullable<ColorGradient>;
  84787. /** @hidden */
  84788. _currentColor1: Color4;
  84789. /** @hidden */
  84790. _currentColor2: Color4;
  84791. /** @hidden */
  84792. _currentSizeGradient: Nullable<FactorGradient>;
  84793. /** @hidden */
  84794. _currentSize1: number;
  84795. /** @hidden */
  84796. _currentSize2: number;
  84797. /** @hidden */
  84798. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84799. /** @hidden */
  84800. _currentAngularSpeed1: number;
  84801. /** @hidden */
  84802. _currentAngularSpeed2: number;
  84803. /** @hidden */
  84804. _currentVelocityGradient: Nullable<FactorGradient>;
  84805. /** @hidden */
  84806. _currentVelocity1: number;
  84807. /** @hidden */
  84808. _currentVelocity2: number;
  84809. /** @hidden */
  84810. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84811. /** @hidden */
  84812. _currentLimitVelocity1: number;
  84813. /** @hidden */
  84814. _currentLimitVelocity2: number;
  84815. /** @hidden */
  84816. _currentDragGradient: Nullable<FactorGradient>;
  84817. /** @hidden */
  84818. _currentDrag1: number;
  84819. /** @hidden */
  84820. _currentDrag2: number;
  84821. /** @hidden */
  84822. _randomNoiseCoordinates1: Vector3;
  84823. /** @hidden */
  84824. _randomNoiseCoordinates2: Vector3;
  84825. /**
  84826. * Creates a new instance Particle
  84827. * @param particleSystem the particle system the particle belongs to
  84828. */
  84829. constructor(
  84830. /**
  84831. * The particle system the particle belongs to.
  84832. */
  84833. particleSystem: ParticleSystem);
  84834. private updateCellInfoFromSystem;
  84835. /**
  84836. * Defines how the sprite cell index is updated for the particle
  84837. */
  84838. updateCellIndex(): void;
  84839. /** @hidden */
  84840. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84841. /** @hidden */
  84842. _inheritParticleInfoToSubEmitters(): void;
  84843. /** @hidden */
  84844. _reset(): void;
  84845. /**
  84846. * Copy the properties of particle to another one.
  84847. * @param other the particle to copy the information to.
  84848. */
  84849. copyTo(other: Particle): void;
  84850. }
  84851. }
  84852. declare module BABYLON {
  84853. /**
  84854. * Particle emitter represents a volume emitting particles.
  84855. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84856. */
  84857. export interface IParticleEmitterType {
  84858. /**
  84859. * Called by the particle System when the direction is computed for the created particle.
  84860. * @param worldMatrix is the world matrix of the particle system
  84861. * @param directionToUpdate is the direction vector to update with the result
  84862. * @param particle is the particle we are computed the direction for
  84863. */
  84864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84865. /**
  84866. * Called by the particle System when the position is computed for the created particle.
  84867. * @param worldMatrix is the world matrix of the particle system
  84868. * @param positionToUpdate is the position vector to update with the result
  84869. * @param particle is the particle we are computed the position for
  84870. */
  84871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84872. /**
  84873. * Clones the current emitter and returns a copy of it
  84874. * @returns the new emitter
  84875. */
  84876. clone(): IParticleEmitterType;
  84877. /**
  84878. * Called by the GPUParticleSystem to setup the update shader
  84879. * @param effect defines the update shader
  84880. */
  84881. applyToShader(effect: Effect): void;
  84882. /**
  84883. * Returns a string to use to update the GPU particles update shader
  84884. * @returns the effect defines string
  84885. */
  84886. getEffectDefines(): string;
  84887. /**
  84888. * Returns a string representing the class name
  84889. * @returns a string containing the class name
  84890. */
  84891. getClassName(): string;
  84892. /**
  84893. * Serializes the particle system to a JSON object.
  84894. * @returns the JSON object
  84895. */
  84896. serialize(): any;
  84897. /**
  84898. * Parse properties from a JSON object
  84899. * @param serializationObject defines the JSON object
  84900. */
  84901. parse(serializationObject: any): void;
  84902. }
  84903. }
  84904. declare module BABYLON {
  84905. /**
  84906. * Particle emitter emitting particles from the inside of a box.
  84907. * It emits the particles randomly between 2 given directions.
  84908. */
  84909. export class BoxParticleEmitter implements IParticleEmitterType {
  84910. /**
  84911. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84912. */
  84913. direction1: Vector3;
  84914. /**
  84915. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84916. */
  84917. direction2: Vector3;
  84918. /**
  84919. * 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.
  84920. */
  84921. minEmitBox: Vector3;
  84922. /**
  84923. * 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.
  84924. */
  84925. maxEmitBox: Vector3;
  84926. /**
  84927. * Creates a new instance BoxParticleEmitter
  84928. */
  84929. constructor();
  84930. /**
  84931. * Called by the particle System when the direction is computed for the created particle.
  84932. * @param worldMatrix is the world matrix of the particle system
  84933. * @param directionToUpdate is the direction vector to update with the result
  84934. * @param particle is the particle we are computed the direction for
  84935. */
  84936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84937. /**
  84938. * Called by the particle System when the position is computed for the created particle.
  84939. * @param worldMatrix is the world matrix of the particle system
  84940. * @param positionToUpdate is the position vector to update with the result
  84941. * @param particle is the particle we are computed the position for
  84942. */
  84943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84944. /**
  84945. * Clones the current emitter and returns a copy of it
  84946. * @returns the new emitter
  84947. */
  84948. clone(): BoxParticleEmitter;
  84949. /**
  84950. * Called by the GPUParticleSystem to setup the update shader
  84951. * @param effect defines the update shader
  84952. */
  84953. applyToShader(effect: Effect): void;
  84954. /**
  84955. * Returns a string to use to update the GPU particles update shader
  84956. * @returns a string containng the defines string
  84957. */
  84958. getEffectDefines(): string;
  84959. /**
  84960. * Returns the string "BoxParticleEmitter"
  84961. * @returns a string containing the class name
  84962. */
  84963. getClassName(): string;
  84964. /**
  84965. * Serializes the particle system to a JSON object.
  84966. * @returns the JSON object
  84967. */
  84968. serialize(): any;
  84969. /**
  84970. * Parse properties from a JSON object
  84971. * @param serializationObject defines the JSON object
  84972. */
  84973. parse(serializationObject: any): void;
  84974. }
  84975. }
  84976. declare module BABYLON {
  84977. /**
  84978. * Particle emitter emitting particles from the inside of a cone.
  84979. * It emits the particles alongside the cone volume from the base to the particle.
  84980. * The emission direction might be randomized.
  84981. */
  84982. export class ConeParticleEmitter implements IParticleEmitterType {
  84983. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84984. directionRandomizer: number;
  84985. private _radius;
  84986. private _angle;
  84987. private _height;
  84988. /**
  84989. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84990. */
  84991. radiusRange: number;
  84992. /**
  84993. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84994. */
  84995. heightRange: number;
  84996. /**
  84997. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84998. */
  84999. emitFromSpawnPointOnly: boolean;
  85000. /**
  85001. * Gets or sets the radius of the emission cone
  85002. */
  85003. radius: number;
  85004. /**
  85005. * Gets or sets the angle of the emission cone
  85006. */
  85007. angle: number;
  85008. private _buildHeight;
  85009. /**
  85010. * Creates a new instance ConeParticleEmitter
  85011. * @param radius the radius of the emission cone (1 by default)
  85012. * @param angle the cone base angle (PI by default)
  85013. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85014. */
  85015. constructor(radius?: number, angle?: number,
  85016. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85017. directionRandomizer?: number);
  85018. /**
  85019. * Called by the particle System when the direction is computed for the created particle.
  85020. * @param worldMatrix is the world matrix of the particle system
  85021. * @param directionToUpdate is the direction vector to update with the result
  85022. * @param particle is the particle we are computed the direction for
  85023. */
  85024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85025. /**
  85026. * Called by the particle System when the position is computed for the created particle.
  85027. * @param worldMatrix is the world matrix of the particle system
  85028. * @param positionToUpdate is the position vector to update with the result
  85029. * @param particle is the particle we are computed the position for
  85030. */
  85031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85032. /**
  85033. * Clones the current emitter and returns a copy of it
  85034. * @returns the new emitter
  85035. */
  85036. clone(): ConeParticleEmitter;
  85037. /**
  85038. * Called by the GPUParticleSystem to setup the update shader
  85039. * @param effect defines the update shader
  85040. */
  85041. applyToShader(effect: Effect): void;
  85042. /**
  85043. * Returns a string to use to update the GPU particles update shader
  85044. * @returns a string containng the defines string
  85045. */
  85046. getEffectDefines(): string;
  85047. /**
  85048. * Returns the string "ConeParticleEmitter"
  85049. * @returns a string containing the class name
  85050. */
  85051. getClassName(): string;
  85052. /**
  85053. * Serializes the particle system to a JSON object.
  85054. * @returns the JSON object
  85055. */
  85056. serialize(): any;
  85057. /**
  85058. * Parse properties from a JSON object
  85059. * @param serializationObject defines the JSON object
  85060. */
  85061. parse(serializationObject: any): void;
  85062. }
  85063. }
  85064. declare module BABYLON {
  85065. /**
  85066. * Particle emitter emitting particles from the inside of a cylinder.
  85067. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85068. */
  85069. export class CylinderParticleEmitter implements IParticleEmitterType {
  85070. /**
  85071. * The radius of the emission cylinder.
  85072. */
  85073. radius: number;
  85074. /**
  85075. * The height of the emission cylinder.
  85076. */
  85077. height: number;
  85078. /**
  85079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85080. */
  85081. radiusRange: number;
  85082. /**
  85083. * How much to randomize the particle direction [0-1].
  85084. */
  85085. directionRandomizer: number;
  85086. /**
  85087. * Creates a new instance CylinderParticleEmitter
  85088. * @param radius the radius of the emission cylinder (1 by default)
  85089. * @param height the height of the emission cylinder (1 by default)
  85090. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85091. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85092. */
  85093. constructor(
  85094. /**
  85095. * The radius of the emission cylinder.
  85096. */
  85097. radius?: number,
  85098. /**
  85099. * The height of the emission cylinder.
  85100. */
  85101. height?: number,
  85102. /**
  85103. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85104. */
  85105. radiusRange?: number,
  85106. /**
  85107. * How much to randomize the particle direction [0-1].
  85108. */
  85109. directionRandomizer?: number);
  85110. /**
  85111. * Called by the particle System when the direction is computed for the created particle.
  85112. * @param worldMatrix is the world matrix of the particle system
  85113. * @param directionToUpdate is the direction vector to update with the result
  85114. * @param particle is the particle we are computed the direction for
  85115. */
  85116. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85117. /**
  85118. * Called by the particle System when the position is computed for the created particle.
  85119. * @param worldMatrix is the world matrix of the particle system
  85120. * @param positionToUpdate is the position vector to update with the result
  85121. * @param particle is the particle we are computed the position for
  85122. */
  85123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85124. /**
  85125. * Clones the current emitter and returns a copy of it
  85126. * @returns the new emitter
  85127. */
  85128. clone(): CylinderParticleEmitter;
  85129. /**
  85130. * Called by the GPUParticleSystem to setup the update shader
  85131. * @param effect defines the update shader
  85132. */
  85133. applyToShader(effect: Effect): void;
  85134. /**
  85135. * Returns a string to use to update the GPU particles update shader
  85136. * @returns a string containng the defines string
  85137. */
  85138. getEffectDefines(): string;
  85139. /**
  85140. * Returns the string "CylinderParticleEmitter"
  85141. * @returns a string containing the class name
  85142. */
  85143. getClassName(): string;
  85144. /**
  85145. * Serializes the particle system to a JSON object.
  85146. * @returns the JSON object
  85147. */
  85148. serialize(): any;
  85149. /**
  85150. * Parse properties from a JSON object
  85151. * @param serializationObject defines the JSON object
  85152. */
  85153. parse(serializationObject: any): void;
  85154. }
  85155. /**
  85156. * Particle emitter emitting particles from the inside of a cylinder.
  85157. * It emits the particles randomly between two vectors.
  85158. */
  85159. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85160. /**
  85161. * The min limit of the emission direction.
  85162. */
  85163. direction1: Vector3;
  85164. /**
  85165. * The max limit of the emission direction.
  85166. */
  85167. direction2: Vector3;
  85168. /**
  85169. * Creates a new instance CylinderDirectedParticleEmitter
  85170. * @param radius the radius of the emission cylinder (1 by default)
  85171. * @param height the height of the emission cylinder (1 by default)
  85172. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85173. * @param direction1 the min limit of the emission direction (up vector by default)
  85174. * @param direction2 the max limit of the emission direction (up vector by default)
  85175. */
  85176. constructor(radius?: number, height?: number, radiusRange?: number,
  85177. /**
  85178. * The min limit of the emission direction.
  85179. */
  85180. direction1?: Vector3,
  85181. /**
  85182. * The max limit of the emission direction.
  85183. */
  85184. direction2?: Vector3);
  85185. /**
  85186. * Called by the particle System when the direction is computed for the created particle.
  85187. * @param worldMatrix is the world matrix of the particle system
  85188. * @param directionToUpdate is the direction vector to update with the result
  85189. * @param particle is the particle we are computed the direction for
  85190. */
  85191. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85192. /**
  85193. * Clones the current emitter and returns a copy of it
  85194. * @returns the new emitter
  85195. */
  85196. clone(): CylinderDirectedParticleEmitter;
  85197. /**
  85198. * Called by the GPUParticleSystem to setup the update shader
  85199. * @param effect defines the update shader
  85200. */
  85201. applyToShader(effect: Effect): void;
  85202. /**
  85203. * Returns a string to use to update the GPU particles update shader
  85204. * @returns a string containng the defines string
  85205. */
  85206. getEffectDefines(): string;
  85207. /**
  85208. * Returns the string "CylinderDirectedParticleEmitter"
  85209. * @returns a string containing the class name
  85210. */
  85211. getClassName(): string;
  85212. /**
  85213. * Serializes the particle system to a JSON object.
  85214. * @returns the JSON object
  85215. */
  85216. serialize(): any;
  85217. /**
  85218. * Parse properties from a JSON object
  85219. * @param serializationObject defines the JSON object
  85220. */
  85221. parse(serializationObject: any): void;
  85222. }
  85223. }
  85224. declare module BABYLON {
  85225. /**
  85226. * Particle emitter emitting particles from the inside of a hemisphere.
  85227. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85228. */
  85229. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85230. /**
  85231. * The radius of the emission hemisphere.
  85232. */
  85233. radius: number;
  85234. /**
  85235. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85236. */
  85237. radiusRange: number;
  85238. /**
  85239. * How much to randomize the particle direction [0-1].
  85240. */
  85241. directionRandomizer: number;
  85242. /**
  85243. * Creates a new instance HemisphericParticleEmitter
  85244. * @param radius the radius of the emission hemisphere (1 by default)
  85245. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85246. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85247. */
  85248. constructor(
  85249. /**
  85250. * The radius of the emission hemisphere.
  85251. */
  85252. radius?: number,
  85253. /**
  85254. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85255. */
  85256. radiusRange?: number,
  85257. /**
  85258. * How much to randomize the particle direction [0-1].
  85259. */
  85260. directionRandomizer?: number);
  85261. /**
  85262. * Called by the particle System when the direction is computed for the created particle.
  85263. * @param worldMatrix is the world matrix of the particle system
  85264. * @param directionToUpdate is the direction vector to update with the result
  85265. * @param particle is the particle we are computed the direction for
  85266. */
  85267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85268. /**
  85269. * Called by the particle System when the position is computed for the created particle.
  85270. * @param worldMatrix is the world matrix of the particle system
  85271. * @param positionToUpdate is the position vector to update with the result
  85272. * @param particle is the particle we are computed the position for
  85273. */
  85274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85275. /**
  85276. * Clones the current emitter and returns a copy of it
  85277. * @returns the new emitter
  85278. */
  85279. clone(): HemisphericParticleEmitter;
  85280. /**
  85281. * Called by the GPUParticleSystem to setup the update shader
  85282. * @param effect defines the update shader
  85283. */
  85284. applyToShader(effect: Effect): void;
  85285. /**
  85286. * Returns a string to use to update the GPU particles update shader
  85287. * @returns a string containng the defines string
  85288. */
  85289. getEffectDefines(): string;
  85290. /**
  85291. * Returns the string "HemisphericParticleEmitter"
  85292. * @returns a string containing the class name
  85293. */
  85294. getClassName(): string;
  85295. /**
  85296. * Serializes the particle system to a JSON object.
  85297. * @returns the JSON object
  85298. */
  85299. serialize(): any;
  85300. /**
  85301. * Parse properties from a JSON object
  85302. * @param serializationObject defines the JSON object
  85303. */
  85304. parse(serializationObject: any): void;
  85305. }
  85306. }
  85307. declare module BABYLON {
  85308. /**
  85309. * Particle emitter emitting particles from a point.
  85310. * It emits the particles randomly between 2 given directions.
  85311. */
  85312. export class PointParticleEmitter implements IParticleEmitterType {
  85313. /**
  85314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85315. */
  85316. direction1: Vector3;
  85317. /**
  85318. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85319. */
  85320. direction2: Vector3;
  85321. /**
  85322. * Creates a new instance PointParticleEmitter
  85323. */
  85324. constructor();
  85325. /**
  85326. * Called by the particle System when the direction is computed for the created particle.
  85327. * @param worldMatrix is the world matrix of the particle system
  85328. * @param directionToUpdate is the direction vector to update with the result
  85329. * @param particle is the particle we are computed the direction for
  85330. */
  85331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85332. /**
  85333. * Called by the particle System when the position is computed for the created particle.
  85334. * @param worldMatrix is the world matrix of the particle system
  85335. * @param positionToUpdate is the position vector to update with the result
  85336. * @param particle is the particle we are computed the position for
  85337. */
  85338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85339. /**
  85340. * Clones the current emitter and returns a copy of it
  85341. * @returns the new emitter
  85342. */
  85343. clone(): PointParticleEmitter;
  85344. /**
  85345. * Called by the GPUParticleSystem to setup the update shader
  85346. * @param effect defines the update shader
  85347. */
  85348. applyToShader(effect: Effect): void;
  85349. /**
  85350. * Returns a string to use to update the GPU particles update shader
  85351. * @returns a string containng the defines string
  85352. */
  85353. getEffectDefines(): string;
  85354. /**
  85355. * Returns the string "PointParticleEmitter"
  85356. * @returns a string containing the class name
  85357. */
  85358. getClassName(): string;
  85359. /**
  85360. * Serializes the particle system to a JSON object.
  85361. * @returns the JSON object
  85362. */
  85363. serialize(): any;
  85364. /**
  85365. * Parse properties from a JSON object
  85366. * @param serializationObject defines the JSON object
  85367. */
  85368. parse(serializationObject: any): void;
  85369. }
  85370. }
  85371. declare module BABYLON {
  85372. /**
  85373. * Particle emitter emitting particles from the inside of a sphere.
  85374. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85375. */
  85376. export class SphereParticleEmitter implements IParticleEmitterType {
  85377. /**
  85378. * The radius of the emission sphere.
  85379. */
  85380. radius: number;
  85381. /**
  85382. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85383. */
  85384. radiusRange: number;
  85385. /**
  85386. * How much to randomize the particle direction [0-1].
  85387. */
  85388. directionRandomizer: number;
  85389. /**
  85390. * Creates a new instance SphereParticleEmitter
  85391. * @param radius the radius of the emission sphere (1 by default)
  85392. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85393. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85394. */
  85395. constructor(
  85396. /**
  85397. * The radius of the emission sphere.
  85398. */
  85399. radius?: number,
  85400. /**
  85401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85402. */
  85403. radiusRange?: number,
  85404. /**
  85405. * How much to randomize the particle direction [0-1].
  85406. */
  85407. directionRandomizer?: number);
  85408. /**
  85409. * Called by the particle System when the direction is computed for the created particle.
  85410. * @param worldMatrix is the world matrix of the particle system
  85411. * @param directionToUpdate is the direction vector to update with the result
  85412. * @param particle is the particle we are computed the direction for
  85413. */
  85414. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85415. /**
  85416. * Called by the particle System when the position is computed for the created particle.
  85417. * @param worldMatrix is the world matrix of the particle system
  85418. * @param positionToUpdate is the position vector to update with the result
  85419. * @param particle is the particle we are computed the position for
  85420. */
  85421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85422. /**
  85423. * Clones the current emitter and returns a copy of it
  85424. * @returns the new emitter
  85425. */
  85426. clone(): SphereParticleEmitter;
  85427. /**
  85428. * Called by the GPUParticleSystem to setup the update shader
  85429. * @param effect defines the update shader
  85430. */
  85431. applyToShader(effect: Effect): void;
  85432. /**
  85433. * Returns a string to use to update the GPU particles update shader
  85434. * @returns a string containng the defines string
  85435. */
  85436. getEffectDefines(): string;
  85437. /**
  85438. * Returns the string "SphereParticleEmitter"
  85439. * @returns a string containing the class name
  85440. */
  85441. getClassName(): string;
  85442. /**
  85443. * Serializes the particle system to a JSON object.
  85444. * @returns the JSON object
  85445. */
  85446. serialize(): any;
  85447. /**
  85448. * Parse properties from a JSON object
  85449. * @param serializationObject defines the JSON object
  85450. */
  85451. parse(serializationObject: any): void;
  85452. }
  85453. /**
  85454. * Particle emitter emitting particles from the inside of a sphere.
  85455. * It emits the particles randomly between two vectors.
  85456. */
  85457. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85458. /**
  85459. * The min limit of the emission direction.
  85460. */
  85461. direction1: Vector3;
  85462. /**
  85463. * The max limit of the emission direction.
  85464. */
  85465. direction2: Vector3;
  85466. /**
  85467. * Creates a new instance SphereDirectedParticleEmitter
  85468. * @param radius the radius of the emission sphere (1 by default)
  85469. * @param direction1 the min limit of the emission direction (up vector by default)
  85470. * @param direction2 the max limit of the emission direction (up vector by default)
  85471. */
  85472. constructor(radius?: number,
  85473. /**
  85474. * The min limit of the emission direction.
  85475. */
  85476. direction1?: Vector3,
  85477. /**
  85478. * The max limit of the emission direction.
  85479. */
  85480. direction2?: Vector3);
  85481. /**
  85482. * Called by the particle System when the direction is computed for the created particle.
  85483. * @param worldMatrix is the world matrix of the particle system
  85484. * @param directionToUpdate is the direction vector to update with the result
  85485. * @param particle is the particle we are computed the direction for
  85486. */
  85487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85488. /**
  85489. * Clones the current emitter and returns a copy of it
  85490. * @returns the new emitter
  85491. */
  85492. clone(): SphereDirectedParticleEmitter;
  85493. /**
  85494. * Called by the GPUParticleSystem to setup the update shader
  85495. * @param effect defines the update shader
  85496. */
  85497. applyToShader(effect: Effect): void;
  85498. /**
  85499. * Returns a string to use to update the GPU particles update shader
  85500. * @returns a string containng the defines string
  85501. */
  85502. getEffectDefines(): string;
  85503. /**
  85504. * Returns the string "SphereDirectedParticleEmitter"
  85505. * @returns a string containing the class name
  85506. */
  85507. getClassName(): string;
  85508. /**
  85509. * Serializes the particle system to a JSON object.
  85510. * @returns the JSON object
  85511. */
  85512. serialize(): any;
  85513. /**
  85514. * Parse properties from a JSON object
  85515. * @param serializationObject defines the JSON object
  85516. */
  85517. parse(serializationObject: any): void;
  85518. }
  85519. }
  85520. declare module BABYLON {
  85521. /**
  85522. * Interface representing a particle system in Babylon.js.
  85523. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85524. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85525. */
  85526. export interface IParticleSystem {
  85527. /**
  85528. * List of animations used by the particle system.
  85529. */
  85530. animations: Animation[];
  85531. /**
  85532. * The id of the Particle system.
  85533. */
  85534. id: string;
  85535. /**
  85536. * The name of the Particle system.
  85537. */
  85538. name: string;
  85539. /**
  85540. * The emitter represents the Mesh or position we are attaching the particle system to.
  85541. */
  85542. emitter: Nullable<AbstractMesh | Vector3>;
  85543. /**
  85544. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85545. */
  85546. isBillboardBased: boolean;
  85547. /**
  85548. * The rendering group used by the Particle system to chose when to render.
  85549. */
  85550. renderingGroupId: number;
  85551. /**
  85552. * The layer mask we are rendering the particles through.
  85553. */
  85554. layerMask: number;
  85555. /**
  85556. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85557. */
  85558. updateSpeed: number;
  85559. /**
  85560. * The amount of time the particle system is running (depends of the overall update speed).
  85561. */
  85562. targetStopDuration: number;
  85563. /**
  85564. * The texture used to render each particle. (this can be a spritesheet)
  85565. */
  85566. particleTexture: Nullable<Texture>;
  85567. /**
  85568. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85569. */
  85570. blendMode: number;
  85571. /**
  85572. * Minimum life time of emitting particles.
  85573. */
  85574. minLifeTime: number;
  85575. /**
  85576. * Maximum life time of emitting particles.
  85577. */
  85578. maxLifeTime: number;
  85579. /**
  85580. * Minimum Size of emitting particles.
  85581. */
  85582. minSize: number;
  85583. /**
  85584. * Maximum Size of emitting particles.
  85585. */
  85586. maxSize: number;
  85587. /**
  85588. * Minimum scale of emitting particles on X axis.
  85589. */
  85590. minScaleX: number;
  85591. /**
  85592. * Maximum scale of emitting particles on X axis.
  85593. */
  85594. maxScaleX: number;
  85595. /**
  85596. * Minimum scale of emitting particles on Y axis.
  85597. */
  85598. minScaleY: number;
  85599. /**
  85600. * Maximum scale of emitting particles on Y axis.
  85601. */
  85602. maxScaleY: number;
  85603. /**
  85604. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85605. */
  85606. color1: Color4;
  85607. /**
  85608. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85609. */
  85610. color2: Color4;
  85611. /**
  85612. * Color the particle will have at the end of its lifetime.
  85613. */
  85614. colorDead: Color4;
  85615. /**
  85616. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85617. */
  85618. emitRate: number;
  85619. /**
  85620. * You can use gravity if you want to give an orientation to your particles.
  85621. */
  85622. gravity: Vector3;
  85623. /**
  85624. * Minimum power of emitting particles.
  85625. */
  85626. minEmitPower: number;
  85627. /**
  85628. * Maximum power of emitting particles.
  85629. */
  85630. maxEmitPower: number;
  85631. /**
  85632. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85633. */
  85634. minAngularSpeed: number;
  85635. /**
  85636. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85637. */
  85638. maxAngularSpeed: number;
  85639. /**
  85640. * Gets or sets the minimal initial rotation in radians.
  85641. */
  85642. minInitialRotation: number;
  85643. /**
  85644. * Gets or sets the maximal initial rotation in radians.
  85645. */
  85646. maxInitialRotation: number;
  85647. /**
  85648. * The particle emitter type defines the emitter used by the particle system.
  85649. * It can be for example box, sphere, or cone...
  85650. */
  85651. particleEmitterType: Nullable<IParticleEmitterType>;
  85652. /**
  85653. * Defines the delay in milliseconds before starting the system (0 by default)
  85654. */
  85655. startDelay: number;
  85656. /**
  85657. * 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
  85658. */
  85659. preWarmCycles: number;
  85660. /**
  85661. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85662. */
  85663. preWarmStepOffset: number;
  85664. /**
  85665. * 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)
  85666. */
  85667. spriteCellChangeSpeed: number;
  85668. /**
  85669. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85670. */
  85671. startSpriteCellID: number;
  85672. /**
  85673. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85674. */
  85675. endSpriteCellID: number;
  85676. /**
  85677. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85678. */
  85679. spriteCellWidth: number;
  85680. /**
  85681. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85682. */
  85683. spriteCellHeight: number;
  85684. /**
  85685. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85686. */
  85687. spriteRandomStartCell: boolean;
  85688. /**
  85689. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85690. */
  85691. isAnimationSheetEnabled: boolean;
  85692. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85693. translationPivot: Vector2;
  85694. /**
  85695. * Gets or sets a texture used to add random noise to particle positions
  85696. */
  85697. noiseTexture: Nullable<BaseTexture>;
  85698. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85699. noiseStrength: Vector3;
  85700. /**
  85701. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85702. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85703. */
  85704. billboardMode: number;
  85705. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85706. limitVelocityDamping: number;
  85707. /**
  85708. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85709. */
  85710. beginAnimationOnStart: boolean;
  85711. /**
  85712. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85713. */
  85714. beginAnimationFrom: number;
  85715. /**
  85716. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85717. */
  85718. beginAnimationTo: number;
  85719. /**
  85720. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85721. */
  85722. beginAnimationLoop: boolean;
  85723. /**
  85724. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85725. */
  85726. disposeOnStop: boolean;
  85727. /**
  85728. * Gets the maximum number of particles active at the same time.
  85729. * @returns The max number of active particles.
  85730. */
  85731. getCapacity(): number;
  85732. /**
  85733. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85734. * @returns True if it has been started, otherwise false.
  85735. */
  85736. isStarted(): boolean;
  85737. /**
  85738. * Animates the particle system for this frame.
  85739. */
  85740. animate(): void;
  85741. /**
  85742. * Renders the particle system in its current state.
  85743. * @returns the current number of particles
  85744. */
  85745. render(): number;
  85746. /**
  85747. * Dispose the particle system and frees its associated resources.
  85748. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85749. */
  85750. dispose(disposeTexture?: boolean): void;
  85751. /**
  85752. * Clones the particle system.
  85753. * @param name The name of the cloned object
  85754. * @param newEmitter The new emitter to use
  85755. * @returns the cloned particle system
  85756. */
  85757. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85758. /**
  85759. * Serializes the particle system to a JSON object.
  85760. * @returns the JSON object
  85761. */
  85762. serialize(): any;
  85763. /**
  85764. * Rebuild the particle system
  85765. */
  85766. rebuild(): void;
  85767. /**
  85768. * Starts the particle system and begins to emit
  85769. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85770. */
  85771. start(delay?: number): void;
  85772. /**
  85773. * Stops the particle system.
  85774. */
  85775. stop(): void;
  85776. /**
  85777. * Remove all active particles
  85778. */
  85779. reset(): void;
  85780. /**
  85781. * Is this system ready to be used/rendered
  85782. * @return true if the system is ready
  85783. */
  85784. isReady(): boolean;
  85785. /**
  85786. * Adds a new color gradient
  85787. * @param gradient defines the gradient to use (between 0 and 1)
  85788. * @param color1 defines the color to affect to the specified gradient
  85789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85790. * @returns the current particle system
  85791. */
  85792. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85793. /**
  85794. * Remove a specific color gradient
  85795. * @param gradient defines the gradient to remove
  85796. * @returns the current particle system
  85797. */
  85798. removeColorGradient(gradient: number): IParticleSystem;
  85799. /**
  85800. * Adds a new size gradient
  85801. * @param gradient defines the gradient to use (between 0 and 1)
  85802. * @param factor defines the size factor to affect to the specified gradient
  85803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85804. * @returns the current particle system
  85805. */
  85806. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85807. /**
  85808. * Remove a specific size gradient
  85809. * @param gradient defines the gradient to remove
  85810. * @returns the current particle system
  85811. */
  85812. removeSizeGradient(gradient: number): IParticleSystem;
  85813. /**
  85814. * Gets the current list of color gradients.
  85815. * You must use addColorGradient and removeColorGradient to udpate this list
  85816. * @returns the list of color gradients
  85817. */
  85818. getColorGradients(): Nullable<Array<ColorGradient>>;
  85819. /**
  85820. * Gets the current list of size gradients.
  85821. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85822. * @returns the list of size gradients
  85823. */
  85824. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85825. /**
  85826. * Gets the current list of angular speed gradients.
  85827. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85828. * @returns the list of angular speed gradients
  85829. */
  85830. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85831. /**
  85832. * Adds a new angular speed gradient
  85833. * @param gradient defines the gradient to use (between 0 and 1)
  85834. * @param factor defines the angular speed to affect to the specified gradient
  85835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85836. * @returns the current particle system
  85837. */
  85838. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85839. /**
  85840. * Remove a specific angular speed gradient
  85841. * @param gradient defines the gradient to remove
  85842. * @returns the current particle system
  85843. */
  85844. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85845. /**
  85846. * Gets the current list of velocity gradients.
  85847. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85848. * @returns the list of velocity gradients
  85849. */
  85850. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85851. /**
  85852. * Adds a new velocity gradient
  85853. * @param gradient defines the gradient to use (between 0 and 1)
  85854. * @param factor defines the velocity to affect to the specified gradient
  85855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85856. * @returns the current particle system
  85857. */
  85858. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85859. /**
  85860. * Remove a specific velocity gradient
  85861. * @param gradient defines the gradient to remove
  85862. * @returns the current particle system
  85863. */
  85864. removeVelocityGradient(gradient: number): IParticleSystem;
  85865. /**
  85866. * Gets the current list of limit velocity gradients.
  85867. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85868. * @returns the list of limit velocity gradients
  85869. */
  85870. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85871. /**
  85872. * Adds a new limit velocity gradient
  85873. * @param gradient defines the gradient to use (between 0 and 1)
  85874. * @param factor defines the limit velocity to affect to the specified gradient
  85875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85876. * @returns the current particle system
  85877. */
  85878. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85879. /**
  85880. * Remove a specific limit velocity gradient
  85881. * @param gradient defines the gradient to remove
  85882. * @returns the current particle system
  85883. */
  85884. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85885. /**
  85886. * Adds a new drag gradient
  85887. * @param gradient defines the gradient to use (between 0 and 1)
  85888. * @param factor defines the drag to affect to the specified gradient
  85889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85890. * @returns the current particle system
  85891. */
  85892. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85893. /**
  85894. * Remove a specific drag gradient
  85895. * @param gradient defines the gradient to remove
  85896. * @returns the current particle system
  85897. */
  85898. removeDragGradient(gradient: number): IParticleSystem;
  85899. /**
  85900. * Gets the current list of drag gradients.
  85901. * You must use addDragGradient and removeDragGradient to udpate this list
  85902. * @returns the list of drag gradients
  85903. */
  85904. getDragGradients(): Nullable<Array<FactorGradient>>;
  85905. /**
  85906. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85907. * @param gradient defines the gradient to use (between 0 and 1)
  85908. * @param factor defines the emit rate to affect to the specified gradient
  85909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85910. * @returns the current particle system
  85911. */
  85912. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85913. /**
  85914. * Remove a specific emit rate gradient
  85915. * @param gradient defines the gradient to remove
  85916. * @returns the current particle system
  85917. */
  85918. removeEmitRateGradient(gradient: number): IParticleSystem;
  85919. /**
  85920. * Gets the current list of emit rate gradients.
  85921. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85922. * @returns the list of emit rate gradients
  85923. */
  85924. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85925. /**
  85926. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85927. * @param gradient defines the gradient to use (between 0 and 1)
  85928. * @param factor defines the start size to affect to the specified gradient
  85929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85930. * @returns the current particle system
  85931. */
  85932. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85933. /**
  85934. * Remove a specific start size gradient
  85935. * @param gradient defines the gradient to remove
  85936. * @returns the current particle system
  85937. */
  85938. removeStartSizeGradient(gradient: number): IParticleSystem;
  85939. /**
  85940. * Gets the current list of start size gradients.
  85941. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85942. * @returns the list of start size gradients
  85943. */
  85944. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85945. /**
  85946. * Adds a new life time gradient
  85947. * @param gradient defines the gradient to use (between 0 and 1)
  85948. * @param factor defines the life time factor to affect to the specified gradient
  85949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85950. * @returns the current particle system
  85951. */
  85952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85953. /**
  85954. * Remove a specific life time gradient
  85955. * @param gradient defines the gradient to remove
  85956. * @returns the current particle system
  85957. */
  85958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85959. /**
  85960. * Gets the current list of life time gradients.
  85961. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85962. * @returns the list of life time gradients
  85963. */
  85964. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85965. /**
  85966. * Gets the current list of color gradients.
  85967. * You must use addColorGradient and removeColorGradient to udpate this list
  85968. * @returns the list of color gradients
  85969. */
  85970. getColorGradients(): Nullable<Array<ColorGradient>>;
  85971. /**
  85972. * Adds a new ramp gradient used to remap particle colors
  85973. * @param gradient defines the gradient to use (between 0 and 1)
  85974. * @param color defines the color to affect to the specified gradient
  85975. * @returns the current particle system
  85976. */
  85977. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85978. /**
  85979. * Gets the current list of ramp gradients.
  85980. * You must use addRampGradient and removeRampGradient to udpate this list
  85981. * @returns the list of ramp gradients
  85982. */
  85983. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85984. /** Gets or sets a boolean indicating that ramp gradients must be used
  85985. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85986. */
  85987. useRampGradients: boolean;
  85988. /**
  85989. * Adds a new color remap gradient
  85990. * @param gradient defines the gradient to use (between 0 and 1)
  85991. * @param min defines the color remap minimal range
  85992. * @param max defines the color remap maximal range
  85993. * @returns the current particle system
  85994. */
  85995. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85996. /**
  85997. * Gets the current list of color remap gradients.
  85998. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85999. * @returns the list of color remap gradients
  86000. */
  86001. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86002. /**
  86003. * Adds a new alpha remap gradient
  86004. * @param gradient defines the gradient to use (between 0 and 1)
  86005. * @param min defines the alpha remap minimal range
  86006. * @param max defines the alpha remap maximal range
  86007. * @returns the current particle system
  86008. */
  86009. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86010. /**
  86011. * Gets the current list of alpha remap gradients.
  86012. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86013. * @returns the list of alpha remap gradients
  86014. */
  86015. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86016. /**
  86017. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86018. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86019. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86020. * @returns the emitter
  86021. */
  86022. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86023. /**
  86024. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86025. * @param radius The radius of the hemisphere to emit from
  86026. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86027. * @returns the emitter
  86028. */
  86029. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86030. /**
  86031. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86032. * @param radius The radius of the sphere to emit from
  86033. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86034. * @returns the emitter
  86035. */
  86036. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86037. /**
  86038. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86039. * @param radius The radius of the sphere to emit from
  86040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86042. * @returns the emitter
  86043. */
  86044. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86045. /**
  86046. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86047. * @param radius The radius of the emission cylinder
  86048. * @param height The height of the emission cylinder
  86049. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86050. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86051. * @returns the emitter
  86052. */
  86053. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86054. /**
  86055. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86056. * @param radius The radius of the cylinder to emit from
  86057. * @param height The height of the emission cylinder
  86058. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86059. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86060. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86061. * @returns the emitter
  86062. */
  86063. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86064. /**
  86065. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86066. * @param radius The radius of the cone to emit from
  86067. * @param angle The base angle of the cone
  86068. * @returns the emitter
  86069. */
  86070. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86071. /**
  86072. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86073. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86074. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86075. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86076. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86077. * @returns the emitter
  86078. */
  86079. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86080. /**
  86081. * Get hosting scene
  86082. * @returns the scene
  86083. */
  86084. getScene(): Scene;
  86085. }
  86086. }
  86087. declare module BABYLON {
  86088. /**
  86089. * Creates an instance based on a source mesh.
  86090. */
  86091. export class InstancedMesh extends AbstractMesh {
  86092. private _sourceMesh;
  86093. private _currentLOD;
  86094. /** @hidden */
  86095. _indexInSourceMeshInstanceArray: number;
  86096. constructor(name: string, source: Mesh);
  86097. /**
  86098. * Returns the string "InstancedMesh".
  86099. */
  86100. getClassName(): string;
  86101. /** Gets the list of lights affecting that mesh */
  86102. readonly lightSources: Light[];
  86103. _resyncLightSources(): void;
  86104. _resyncLighSource(light: Light): void;
  86105. _removeLightSource(light: Light, dispose: boolean): void;
  86106. /**
  86107. * If the source mesh receives shadows
  86108. */
  86109. readonly receiveShadows: boolean;
  86110. /**
  86111. * The material of the source mesh
  86112. */
  86113. readonly material: Nullable<Material>;
  86114. /**
  86115. * Visibility of the source mesh
  86116. */
  86117. readonly visibility: number;
  86118. /**
  86119. * Skeleton of the source mesh
  86120. */
  86121. readonly skeleton: Nullable<Skeleton>;
  86122. /**
  86123. * Rendering ground id of the source mesh
  86124. */
  86125. renderingGroupId: number;
  86126. /**
  86127. * Returns the total number of vertices (integer).
  86128. */
  86129. getTotalVertices(): number;
  86130. /**
  86131. * Returns a positive integer : the total number of indices in this mesh geometry.
  86132. * @returns the numner of indices or zero if the mesh has no geometry.
  86133. */
  86134. getTotalIndices(): number;
  86135. /**
  86136. * The source mesh of the instance
  86137. */
  86138. readonly sourceMesh: Mesh;
  86139. /**
  86140. * Is this node ready to be used/rendered
  86141. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86142. * @return {boolean} is it ready
  86143. */
  86144. isReady(completeCheck?: boolean): boolean;
  86145. /**
  86146. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86147. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86148. * @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.
  86149. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86150. */
  86151. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86152. /**
  86153. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86154. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86155. * The `data` are either a numeric array either a Float32Array.
  86156. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86157. * 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).
  86158. * Note that a new underlying VertexBuffer object is created each call.
  86159. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86160. *
  86161. * Possible `kind` values :
  86162. * - VertexBuffer.PositionKind
  86163. * - VertexBuffer.UVKind
  86164. * - VertexBuffer.UV2Kind
  86165. * - VertexBuffer.UV3Kind
  86166. * - VertexBuffer.UV4Kind
  86167. * - VertexBuffer.UV5Kind
  86168. * - VertexBuffer.UV6Kind
  86169. * - VertexBuffer.ColorKind
  86170. * - VertexBuffer.MatricesIndicesKind
  86171. * - VertexBuffer.MatricesIndicesExtraKind
  86172. * - VertexBuffer.MatricesWeightsKind
  86173. * - VertexBuffer.MatricesWeightsExtraKind
  86174. *
  86175. * Returns the Mesh.
  86176. */
  86177. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86178. /**
  86179. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86180. * If the mesh has no geometry, it is simply returned as it is.
  86181. * The `data` are either a numeric array either a Float32Array.
  86182. * No new underlying VertexBuffer object is created.
  86183. * 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.
  86184. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86185. *
  86186. * Possible `kind` values :
  86187. * - VertexBuffer.PositionKind
  86188. * - VertexBuffer.UVKind
  86189. * - VertexBuffer.UV2Kind
  86190. * - VertexBuffer.UV3Kind
  86191. * - VertexBuffer.UV4Kind
  86192. * - VertexBuffer.UV5Kind
  86193. * - VertexBuffer.UV6Kind
  86194. * - VertexBuffer.ColorKind
  86195. * - VertexBuffer.MatricesIndicesKind
  86196. * - VertexBuffer.MatricesIndicesExtraKind
  86197. * - VertexBuffer.MatricesWeightsKind
  86198. * - VertexBuffer.MatricesWeightsExtraKind
  86199. *
  86200. * Returns the Mesh.
  86201. */
  86202. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86203. /**
  86204. * Sets the mesh indices.
  86205. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86206. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86207. * This method creates a new index buffer each call.
  86208. * Returns the Mesh.
  86209. */
  86210. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86211. /**
  86212. * Boolean : True if the mesh owns the requested kind of data.
  86213. */
  86214. isVerticesDataPresent(kind: string): boolean;
  86215. /**
  86216. * Returns an array of indices (IndicesArray).
  86217. */
  86218. getIndices(): Nullable<IndicesArray>;
  86219. readonly _positions: Nullable<Vector3[]>;
  86220. /**
  86221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86222. * This means the mesh underlying bounding box and sphere are recomputed.
  86223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86224. * @returns the current mesh
  86225. */
  86226. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86227. /** @hidden */
  86228. _preActivate(): InstancedMesh;
  86229. /** @hidden */
  86230. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86231. /** @hidden */
  86232. _postActivate(): void;
  86233. getWorldMatrix(): Matrix;
  86234. readonly isAnInstance: boolean;
  86235. /**
  86236. * Returns the current associated LOD AbstractMesh.
  86237. */
  86238. getLOD(camera: Camera): AbstractMesh;
  86239. /** @hidden */
  86240. _syncSubMeshes(): InstancedMesh;
  86241. /** @hidden */
  86242. _generatePointsArray(): boolean;
  86243. /**
  86244. * Creates a new InstancedMesh from the current mesh.
  86245. * - name (string) : the cloned mesh name
  86246. * - newParent (optional Node) : the optional Node to parent the clone to.
  86247. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86248. *
  86249. * Returns the clone.
  86250. */
  86251. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86252. /**
  86253. * Disposes the InstancedMesh.
  86254. * Returns nothing.
  86255. */
  86256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86257. }
  86258. interface Mesh {
  86259. /**
  86260. * Register a custom buffer that will be instanced
  86261. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86262. * @param kind defines the buffer kind
  86263. * @param stride defines the stride in floats
  86264. */
  86265. registerInstancedBuffer(kind: string, stride: number): void;
  86266. /** @hidden */
  86267. _userInstancedBuffersStorage: {
  86268. data: {
  86269. [key: string]: Float32Array;
  86270. };
  86271. sizes: {
  86272. [key: string]: number;
  86273. };
  86274. vertexBuffers: {
  86275. [key: string]: Nullable<VertexBuffer>;
  86276. };
  86277. strides: {
  86278. [key: string]: number;
  86279. };
  86280. };
  86281. }
  86282. interface AbstractMesh {
  86283. /**
  86284. * Object used to store instanced buffers defined by user
  86285. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86286. */
  86287. instancedBuffers: {
  86288. [key: string]: any;
  86289. };
  86290. }
  86291. }
  86292. declare module BABYLON {
  86293. /**
  86294. * Defines the options associated with the creation of a shader material.
  86295. */
  86296. export interface IShaderMaterialOptions {
  86297. /**
  86298. * Does the material work in alpha blend mode
  86299. */
  86300. needAlphaBlending: boolean;
  86301. /**
  86302. * Does the material work in alpha test mode
  86303. */
  86304. needAlphaTesting: boolean;
  86305. /**
  86306. * The list of attribute names used in the shader
  86307. */
  86308. attributes: string[];
  86309. /**
  86310. * The list of unifrom names used in the shader
  86311. */
  86312. uniforms: string[];
  86313. /**
  86314. * The list of UBO names used in the shader
  86315. */
  86316. uniformBuffers: string[];
  86317. /**
  86318. * The list of sampler names used in the shader
  86319. */
  86320. samplers: string[];
  86321. /**
  86322. * The list of defines used in the shader
  86323. */
  86324. defines: string[];
  86325. }
  86326. /**
  86327. * 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.
  86328. *
  86329. * This returned material effects how the mesh will look based on the code in the shaders.
  86330. *
  86331. * @see http://doc.babylonjs.com/how_to/shader_material
  86332. */
  86333. export class ShaderMaterial extends Material {
  86334. private _shaderPath;
  86335. private _options;
  86336. private _textures;
  86337. private _textureArrays;
  86338. private _floats;
  86339. private _ints;
  86340. private _floatsArrays;
  86341. private _colors3;
  86342. private _colors3Arrays;
  86343. private _colors4;
  86344. private _colors4Arrays;
  86345. private _vectors2;
  86346. private _vectors3;
  86347. private _vectors4;
  86348. private _matrices;
  86349. private _matrices3x3;
  86350. private _matrices2x2;
  86351. private _vectors2Arrays;
  86352. private _vectors3Arrays;
  86353. private _vectors4Arrays;
  86354. private _cachedWorldViewMatrix;
  86355. private _cachedWorldViewProjectionMatrix;
  86356. private _renderId;
  86357. /**
  86358. * Instantiate a new shader material.
  86359. * 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.
  86360. * This returned material effects how the mesh will look based on the code in the shaders.
  86361. * @see http://doc.babylonjs.com/how_to/shader_material
  86362. * @param name Define the name of the material in the scene
  86363. * @param scene Define the scene the material belongs to
  86364. * @param shaderPath Defines the route to the shader code in one of three ways:
  86365. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86366. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86367. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86368. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86369. * @param options Define the options used to create the shader
  86370. */
  86371. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86372. /**
  86373. * Gets the options used to compile the shader.
  86374. * They can be modified to trigger a new compilation
  86375. */
  86376. readonly options: IShaderMaterialOptions;
  86377. /**
  86378. * Gets the current class name of the material e.g. "ShaderMaterial"
  86379. * Mainly use in serialization.
  86380. * @returns the class name
  86381. */
  86382. getClassName(): string;
  86383. /**
  86384. * Specifies if the material will require alpha blending
  86385. * @returns a boolean specifying if alpha blending is needed
  86386. */
  86387. needAlphaBlending(): boolean;
  86388. /**
  86389. * Specifies if this material should be rendered in alpha test mode
  86390. * @returns a boolean specifying if an alpha test is needed.
  86391. */
  86392. needAlphaTesting(): boolean;
  86393. private _checkUniform;
  86394. /**
  86395. * Set a texture in the shader.
  86396. * @param name Define the name of the uniform samplers as defined in the shader
  86397. * @param texture Define the texture to bind to this sampler
  86398. * @return the material itself allowing "fluent" like uniform updates
  86399. */
  86400. setTexture(name: string, texture: Texture): ShaderMaterial;
  86401. /**
  86402. * Set a texture array in the shader.
  86403. * @param name Define the name of the uniform sampler array as defined in the shader
  86404. * @param textures Define the list of textures to bind to this sampler
  86405. * @return the material itself allowing "fluent" like uniform updates
  86406. */
  86407. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86408. /**
  86409. * Set a float in the shader.
  86410. * @param name Define the name of the uniform as defined in the shader
  86411. * @param value Define the value to give to the uniform
  86412. * @return the material itself allowing "fluent" like uniform updates
  86413. */
  86414. setFloat(name: string, value: number): ShaderMaterial;
  86415. /**
  86416. * Set a int in the shader.
  86417. * @param name Define the name of the uniform as defined in the shader
  86418. * @param value Define the value to give to the uniform
  86419. * @return the material itself allowing "fluent" like uniform updates
  86420. */
  86421. setInt(name: string, value: number): ShaderMaterial;
  86422. /**
  86423. * Set an array of floats in the shader.
  86424. * @param name Define the name of the uniform as defined in the shader
  86425. * @param value Define the value to give to the uniform
  86426. * @return the material itself allowing "fluent" like uniform updates
  86427. */
  86428. setFloats(name: string, value: number[]): ShaderMaterial;
  86429. /**
  86430. * Set a vec3 in the shader from a Color3.
  86431. * @param name Define the name of the uniform as defined in the shader
  86432. * @param value Define the value to give to the uniform
  86433. * @return the material itself allowing "fluent" like uniform updates
  86434. */
  86435. setColor3(name: string, value: Color3): ShaderMaterial;
  86436. /**
  86437. * Set a vec3 array in the shader from a Color3 array.
  86438. * @param name Define the name of the uniform as defined in the shader
  86439. * @param value Define the value to give to the uniform
  86440. * @return the material itself allowing "fluent" like uniform updates
  86441. */
  86442. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86443. /**
  86444. * Set a vec4 in the shader from a Color4.
  86445. * @param name Define the name of the uniform as defined in the shader
  86446. * @param value Define the value to give to the uniform
  86447. * @return the material itself allowing "fluent" like uniform updates
  86448. */
  86449. setColor4(name: string, value: Color4): ShaderMaterial;
  86450. /**
  86451. * Set a vec4 array in the shader from a Color4 array.
  86452. * @param name Define the name of the uniform as defined in the shader
  86453. * @param value Define the value to give to the uniform
  86454. * @return the material itself allowing "fluent" like uniform updates
  86455. */
  86456. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86457. /**
  86458. * Set a vec2 in the shader from a Vector2.
  86459. * @param name Define the name of the uniform as defined in the shader
  86460. * @param value Define the value to give to the uniform
  86461. * @return the material itself allowing "fluent" like uniform updates
  86462. */
  86463. setVector2(name: string, value: Vector2): ShaderMaterial;
  86464. /**
  86465. * Set a vec3 in the shader from a Vector3.
  86466. * @param name Define the name of the uniform as defined in the shader
  86467. * @param value Define the value to give to the uniform
  86468. * @return the material itself allowing "fluent" like uniform updates
  86469. */
  86470. setVector3(name: string, value: Vector3): ShaderMaterial;
  86471. /**
  86472. * Set a vec4 in the shader from a Vector4.
  86473. * @param name Define the name of the uniform as defined in the shader
  86474. * @param value Define the value to give to the uniform
  86475. * @return the material itself allowing "fluent" like uniform updates
  86476. */
  86477. setVector4(name: string, value: Vector4): ShaderMaterial;
  86478. /**
  86479. * Set a mat4 in the shader from a Matrix.
  86480. * @param name Define the name of the uniform as defined in the shader
  86481. * @param value Define the value to give to the uniform
  86482. * @return the material itself allowing "fluent" like uniform updates
  86483. */
  86484. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86485. /**
  86486. * Set a mat3 in the shader from a Float32Array.
  86487. * @param name Define the name of the uniform as defined in the shader
  86488. * @param value Define the value to give to the uniform
  86489. * @return the material itself allowing "fluent" like uniform updates
  86490. */
  86491. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86492. /**
  86493. * Set a mat2 in the shader from a Float32Array.
  86494. * @param name Define the name of the uniform as defined in the shader
  86495. * @param value Define the value to give to the uniform
  86496. * @return the material itself allowing "fluent" like uniform updates
  86497. */
  86498. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86499. /**
  86500. * Set a vec2 array in the shader from a number array.
  86501. * @param name Define the name of the uniform as defined in the shader
  86502. * @param value Define the value to give to the uniform
  86503. * @return the material itself allowing "fluent" like uniform updates
  86504. */
  86505. setArray2(name: string, value: number[]): ShaderMaterial;
  86506. /**
  86507. * Set a vec3 array in the shader from a number array.
  86508. * @param name Define the name of the uniform as defined in the shader
  86509. * @param value Define the value to give to the uniform
  86510. * @return the material itself allowing "fluent" like uniform updates
  86511. */
  86512. setArray3(name: string, value: number[]): ShaderMaterial;
  86513. /**
  86514. * Set a vec4 array in the shader from a number array.
  86515. * @param name Define the name of the uniform as defined in the shader
  86516. * @param value Define the value to give to the uniform
  86517. * @return the material itself allowing "fluent" like uniform updates
  86518. */
  86519. setArray4(name: string, value: number[]): ShaderMaterial;
  86520. private _checkCache;
  86521. /**
  86522. * Specifies that the submesh is ready to be used
  86523. * @param mesh defines the mesh to check
  86524. * @param subMesh defines which submesh to check
  86525. * @param useInstances specifies that instances should be used
  86526. * @returns a boolean indicating that the submesh is ready or not
  86527. */
  86528. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86529. /**
  86530. * Checks if the material is ready to render the requested mesh
  86531. * @param mesh Define the mesh to render
  86532. * @param useInstances Define whether or not the material is used with instances
  86533. * @returns true if ready, otherwise false
  86534. */
  86535. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86536. /**
  86537. * Binds the world matrix to the material
  86538. * @param world defines the world transformation matrix
  86539. */
  86540. bindOnlyWorldMatrix(world: Matrix): void;
  86541. /**
  86542. * Binds the material to the mesh
  86543. * @param world defines the world transformation matrix
  86544. * @param mesh defines the mesh to bind the material to
  86545. */
  86546. bind(world: Matrix, mesh?: Mesh): void;
  86547. /**
  86548. * Gets the active textures from the material
  86549. * @returns an array of textures
  86550. */
  86551. getActiveTextures(): BaseTexture[];
  86552. /**
  86553. * Specifies if the material uses a texture
  86554. * @param texture defines the texture to check against the material
  86555. * @returns a boolean specifying if the material uses the texture
  86556. */
  86557. hasTexture(texture: BaseTexture): boolean;
  86558. /**
  86559. * Makes a duplicate of the material, and gives it a new name
  86560. * @param name defines the new name for the duplicated material
  86561. * @returns the cloned material
  86562. */
  86563. clone(name: string): ShaderMaterial;
  86564. /**
  86565. * Disposes the material
  86566. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86567. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86568. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86569. */
  86570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86571. /**
  86572. * Serializes this material in a JSON representation
  86573. * @returns the serialized material object
  86574. */
  86575. serialize(): any;
  86576. /**
  86577. * Creates a shader material from parsed shader material data
  86578. * @param source defines the JSON represnetation of the material
  86579. * @param scene defines the hosting scene
  86580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86581. * @returns a new material
  86582. */
  86583. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86584. }
  86585. }
  86586. declare module BABYLON {
  86587. /** @hidden */
  86588. export var colorPixelShader: {
  86589. name: string;
  86590. shader: string;
  86591. };
  86592. }
  86593. declare module BABYLON {
  86594. /** @hidden */
  86595. export var colorVertexShader: {
  86596. name: string;
  86597. shader: string;
  86598. };
  86599. }
  86600. declare module BABYLON {
  86601. /**
  86602. * Line mesh
  86603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86604. */
  86605. export class LinesMesh extends Mesh {
  86606. /**
  86607. * If vertex color should be applied to the mesh
  86608. */
  86609. readonly useVertexColor?: boolean | undefined;
  86610. /**
  86611. * If vertex alpha should be applied to the mesh
  86612. */
  86613. readonly useVertexAlpha?: boolean | undefined;
  86614. /**
  86615. * Color of the line (Default: White)
  86616. */
  86617. color: Color3;
  86618. /**
  86619. * Alpha of the line (Default: 1)
  86620. */
  86621. alpha: number;
  86622. /**
  86623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86624. * This margin is expressed in world space coordinates, so its value may vary.
  86625. * Default value is 0.1
  86626. */
  86627. intersectionThreshold: number;
  86628. private _colorShader;
  86629. private color4;
  86630. /**
  86631. * Creates a new LinesMesh
  86632. * @param name defines the name
  86633. * @param scene defines the hosting scene
  86634. * @param parent defines the parent mesh if any
  86635. * @param source defines the optional source LinesMesh used to clone data from
  86636. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86637. * When false, achieved by calling a clone(), also passing False.
  86638. * This will make creation of children, recursive.
  86639. * @param useVertexColor defines if this LinesMesh supports vertex color
  86640. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86641. */
  86642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86643. /**
  86644. * If vertex color should be applied to the mesh
  86645. */
  86646. useVertexColor?: boolean | undefined,
  86647. /**
  86648. * If vertex alpha should be applied to the mesh
  86649. */
  86650. useVertexAlpha?: boolean | undefined);
  86651. private _addClipPlaneDefine;
  86652. private _removeClipPlaneDefine;
  86653. isReady(): boolean;
  86654. /**
  86655. * Returns the string "LineMesh"
  86656. */
  86657. getClassName(): string;
  86658. /**
  86659. * @hidden
  86660. */
  86661. /**
  86662. * @hidden
  86663. */
  86664. material: Material;
  86665. /**
  86666. * @hidden
  86667. */
  86668. readonly checkCollisions: boolean;
  86669. /** @hidden */
  86670. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86671. /** @hidden */
  86672. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86673. /**
  86674. * Disposes of the line mesh
  86675. * @param doNotRecurse If children should be disposed
  86676. */
  86677. dispose(doNotRecurse?: boolean): void;
  86678. /**
  86679. * Returns a new LineMesh object cloned from the current one.
  86680. */
  86681. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86682. /**
  86683. * Creates a new InstancedLinesMesh object from the mesh model.
  86684. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86685. * @param name defines the name of the new instance
  86686. * @returns a new InstancedLinesMesh
  86687. */
  86688. createInstance(name: string): InstancedLinesMesh;
  86689. }
  86690. /**
  86691. * Creates an instance based on a source LinesMesh
  86692. */
  86693. export class InstancedLinesMesh extends InstancedMesh {
  86694. /**
  86695. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86696. * This margin is expressed in world space coordinates, so its value may vary.
  86697. * Initilized with the intersectionThreshold value of the source LinesMesh
  86698. */
  86699. intersectionThreshold: number;
  86700. constructor(name: string, source: LinesMesh);
  86701. /**
  86702. * Returns the string "InstancedLinesMesh".
  86703. */
  86704. getClassName(): string;
  86705. }
  86706. }
  86707. declare module BABYLON {
  86708. /** @hidden */
  86709. export var linePixelShader: {
  86710. name: string;
  86711. shader: string;
  86712. };
  86713. }
  86714. declare module BABYLON {
  86715. /** @hidden */
  86716. export var lineVertexShader: {
  86717. name: string;
  86718. shader: string;
  86719. };
  86720. }
  86721. declare module BABYLON {
  86722. interface AbstractMesh {
  86723. /**
  86724. * Gets the edgesRenderer associated with the mesh
  86725. */
  86726. edgesRenderer: Nullable<EdgesRenderer>;
  86727. }
  86728. interface LinesMesh {
  86729. /**
  86730. * Enables the edge rendering mode on the mesh.
  86731. * This mode makes the mesh edges visible
  86732. * @param epsilon defines the maximal distance between two angles to detect a face
  86733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86734. * @returns the currentAbstractMesh
  86735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86736. */
  86737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86738. }
  86739. interface InstancedLinesMesh {
  86740. /**
  86741. * Enables the edge rendering mode on the mesh.
  86742. * This mode makes the mesh edges visible
  86743. * @param epsilon defines the maximal distance between two angles to detect a face
  86744. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86745. * @returns the current InstancedLinesMesh
  86746. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86747. */
  86748. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86749. }
  86750. /**
  86751. * Defines the minimum contract an Edges renderer should follow.
  86752. */
  86753. export interface IEdgesRenderer extends IDisposable {
  86754. /**
  86755. * Gets or sets a boolean indicating if the edgesRenderer is active
  86756. */
  86757. isEnabled: boolean;
  86758. /**
  86759. * Renders the edges of the attached mesh,
  86760. */
  86761. render(): void;
  86762. /**
  86763. * Checks wether or not the edges renderer is ready to render.
  86764. * @return true if ready, otherwise false.
  86765. */
  86766. isReady(): boolean;
  86767. }
  86768. /**
  86769. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86770. */
  86771. export class EdgesRenderer implements IEdgesRenderer {
  86772. /**
  86773. * Define the size of the edges with an orthographic camera
  86774. */
  86775. edgesWidthScalerForOrthographic: number;
  86776. /**
  86777. * Define the size of the edges with a perspective camera
  86778. */
  86779. edgesWidthScalerForPerspective: number;
  86780. protected _source: AbstractMesh;
  86781. protected _linesPositions: number[];
  86782. protected _linesNormals: number[];
  86783. protected _linesIndices: number[];
  86784. protected _epsilon: number;
  86785. protected _indicesCount: number;
  86786. protected _lineShader: ShaderMaterial;
  86787. protected _ib: DataBuffer;
  86788. protected _buffers: {
  86789. [key: string]: Nullable<VertexBuffer>;
  86790. };
  86791. protected _checkVerticesInsteadOfIndices: boolean;
  86792. private _meshRebuildObserver;
  86793. private _meshDisposeObserver;
  86794. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86795. isEnabled: boolean;
  86796. /**
  86797. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86798. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86799. * @param source Mesh used to create edges
  86800. * @param epsilon sum of angles in adjacency to check for edge
  86801. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86802. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86803. */
  86804. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86805. protected _prepareRessources(): void;
  86806. /** @hidden */
  86807. _rebuild(): void;
  86808. /**
  86809. * Releases the required resources for the edges renderer
  86810. */
  86811. dispose(): void;
  86812. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86813. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86814. /**
  86815. * Checks if the pair of p0 and p1 is en edge
  86816. * @param faceIndex
  86817. * @param edge
  86818. * @param faceNormals
  86819. * @param p0
  86820. * @param p1
  86821. * @private
  86822. */
  86823. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86824. /**
  86825. * push line into the position, normal and index buffer
  86826. * @protected
  86827. */
  86828. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86829. /**
  86830. * Generates lines edges from adjacencjes
  86831. * @private
  86832. */
  86833. _generateEdgesLines(): void;
  86834. /**
  86835. * Checks wether or not the edges renderer is ready to render.
  86836. * @return true if ready, otherwise false.
  86837. */
  86838. isReady(): boolean;
  86839. /**
  86840. * Renders the edges of the attached mesh,
  86841. */
  86842. render(): void;
  86843. }
  86844. /**
  86845. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86846. */
  86847. export class LineEdgesRenderer extends EdgesRenderer {
  86848. /**
  86849. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86850. * @param source LineMesh used to generate edges
  86851. * @param epsilon not important (specified angle for edge detection)
  86852. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86853. */
  86854. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86855. /**
  86856. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86857. */
  86858. _generateEdgesLines(): void;
  86859. }
  86860. }
  86861. declare module BABYLON {
  86862. /**
  86863. * This represents the object necessary to create a rendering group.
  86864. * This is exclusively used and created by the rendering manager.
  86865. * To modify the behavior, you use the available helpers in your scene or meshes.
  86866. * @hidden
  86867. */
  86868. export class RenderingGroup {
  86869. index: number;
  86870. private static _zeroVector;
  86871. private _scene;
  86872. private _opaqueSubMeshes;
  86873. private _transparentSubMeshes;
  86874. private _alphaTestSubMeshes;
  86875. private _depthOnlySubMeshes;
  86876. private _particleSystems;
  86877. private _spriteManagers;
  86878. private _opaqueSortCompareFn;
  86879. private _alphaTestSortCompareFn;
  86880. private _transparentSortCompareFn;
  86881. private _renderOpaque;
  86882. private _renderAlphaTest;
  86883. private _renderTransparent;
  86884. /** @hidden */
  86885. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86886. onBeforeTransparentRendering: () => void;
  86887. /**
  86888. * Set the opaque sort comparison function.
  86889. * If null the sub meshes will be render in the order they were created
  86890. */
  86891. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86892. /**
  86893. * Set the alpha test sort comparison function.
  86894. * If null the sub meshes will be render in the order they were created
  86895. */
  86896. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86897. /**
  86898. * Set the transparent sort comparison function.
  86899. * If null the sub meshes will be render in the order they were created
  86900. */
  86901. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86902. /**
  86903. * Creates a new rendering group.
  86904. * @param index The rendering group index
  86905. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86906. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86907. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86908. */
  86909. 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>);
  86910. /**
  86911. * Render all the sub meshes contained in the group.
  86912. * @param customRenderFunction Used to override the default render behaviour of the group.
  86913. * @returns true if rendered some submeshes.
  86914. */
  86915. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86916. /**
  86917. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86918. * @param subMeshes The submeshes to render
  86919. */
  86920. private renderOpaqueSorted;
  86921. /**
  86922. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86923. * @param subMeshes The submeshes to render
  86924. */
  86925. private renderAlphaTestSorted;
  86926. /**
  86927. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86928. * @param subMeshes The submeshes to render
  86929. */
  86930. private renderTransparentSorted;
  86931. /**
  86932. * Renders the submeshes in a specified order.
  86933. * @param subMeshes The submeshes to sort before render
  86934. * @param sortCompareFn The comparison function use to sort
  86935. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86936. * @param transparent Specifies to activate blending if true
  86937. */
  86938. private static renderSorted;
  86939. /**
  86940. * Renders the submeshes in the order they were dispatched (no sort applied).
  86941. * @param subMeshes The submeshes to render
  86942. */
  86943. private static renderUnsorted;
  86944. /**
  86945. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86946. * are rendered back to front if in the same alpha index.
  86947. *
  86948. * @param a The first submesh
  86949. * @param b The second submesh
  86950. * @returns The result of the comparison
  86951. */
  86952. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86953. /**
  86954. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86955. * are rendered back to front.
  86956. *
  86957. * @param a The first submesh
  86958. * @param b The second submesh
  86959. * @returns The result of the comparison
  86960. */
  86961. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86962. /**
  86963. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86964. * are rendered front to back (prevent overdraw).
  86965. *
  86966. * @param a The first submesh
  86967. * @param b The second submesh
  86968. * @returns The result of the comparison
  86969. */
  86970. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86971. /**
  86972. * Resets the different lists of submeshes to prepare a new frame.
  86973. */
  86974. prepare(): void;
  86975. dispose(): void;
  86976. /**
  86977. * Inserts the submesh in its correct queue depending on its material.
  86978. * @param subMesh The submesh to dispatch
  86979. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86980. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86981. */
  86982. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86983. dispatchSprites(spriteManager: ISpriteManager): void;
  86984. dispatchParticles(particleSystem: IParticleSystem): void;
  86985. private _renderParticles;
  86986. private _renderSprites;
  86987. }
  86988. }
  86989. declare module BABYLON {
  86990. /**
  86991. * Interface describing the different options available in the rendering manager
  86992. * regarding Auto Clear between groups.
  86993. */
  86994. export interface IRenderingManagerAutoClearSetup {
  86995. /**
  86996. * Defines whether or not autoclear is enable.
  86997. */
  86998. autoClear: boolean;
  86999. /**
  87000. * Defines whether or not to autoclear the depth buffer.
  87001. */
  87002. depth: boolean;
  87003. /**
  87004. * Defines whether or not to autoclear the stencil buffer.
  87005. */
  87006. stencil: boolean;
  87007. }
  87008. /**
  87009. * This class is used by the onRenderingGroupObservable
  87010. */
  87011. export class RenderingGroupInfo {
  87012. /**
  87013. * The Scene that being rendered
  87014. */
  87015. scene: Scene;
  87016. /**
  87017. * The camera currently used for the rendering pass
  87018. */
  87019. camera: Nullable<Camera>;
  87020. /**
  87021. * The ID of the renderingGroup being processed
  87022. */
  87023. renderingGroupId: number;
  87024. }
  87025. /**
  87026. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87027. * It is enable to manage the different groups as well as the different necessary sort functions.
  87028. * This should not be used directly aside of the few static configurations
  87029. */
  87030. export class RenderingManager {
  87031. /**
  87032. * The max id used for rendering groups (not included)
  87033. */
  87034. static MAX_RENDERINGGROUPS: number;
  87035. /**
  87036. * The min id used for rendering groups (included)
  87037. */
  87038. static MIN_RENDERINGGROUPS: number;
  87039. /**
  87040. * Used to globally prevent autoclearing scenes.
  87041. */
  87042. static AUTOCLEAR: boolean;
  87043. /**
  87044. * @hidden
  87045. */
  87046. _useSceneAutoClearSetup: boolean;
  87047. private _scene;
  87048. private _renderingGroups;
  87049. private _depthStencilBufferAlreadyCleaned;
  87050. private _autoClearDepthStencil;
  87051. private _customOpaqueSortCompareFn;
  87052. private _customAlphaTestSortCompareFn;
  87053. private _customTransparentSortCompareFn;
  87054. private _renderingGroupInfo;
  87055. /**
  87056. * Instantiates a new rendering group for a particular scene
  87057. * @param scene Defines the scene the groups belongs to
  87058. */
  87059. constructor(scene: Scene);
  87060. private _clearDepthStencilBuffer;
  87061. /**
  87062. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87063. * @hidden
  87064. */
  87065. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87066. /**
  87067. * Resets the different information of the group to prepare a new frame
  87068. * @hidden
  87069. */
  87070. reset(): void;
  87071. /**
  87072. * Dispose and release the group and its associated resources.
  87073. * @hidden
  87074. */
  87075. dispose(): void;
  87076. /**
  87077. * Clear the info related to rendering groups preventing retention points during dispose.
  87078. */
  87079. freeRenderingGroups(): void;
  87080. private _prepareRenderingGroup;
  87081. /**
  87082. * Add a sprite manager to the rendering manager in order to render it this frame.
  87083. * @param spriteManager Define the sprite manager to render
  87084. */
  87085. dispatchSprites(spriteManager: ISpriteManager): void;
  87086. /**
  87087. * Add a particle system to the rendering manager in order to render it this frame.
  87088. * @param particleSystem Define the particle system to render
  87089. */
  87090. dispatchParticles(particleSystem: IParticleSystem): void;
  87091. /**
  87092. * Add a submesh to the manager in order to render it this frame
  87093. * @param subMesh The submesh to dispatch
  87094. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87095. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87096. */
  87097. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87098. /**
  87099. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87100. * This allowed control for front to back rendering or reversly depending of the special needs.
  87101. *
  87102. * @param renderingGroupId The rendering group id corresponding to its index
  87103. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87104. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87105. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87106. */
  87107. 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;
  87108. /**
  87109. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87110. *
  87111. * @param renderingGroupId The rendering group id corresponding to its index
  87112. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87113. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87114. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87115. */
  87116. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87117. /**
  87118. * Gets the current auto clear configuration for one rendering group of the rendering
  87119. * manager.
  87120. * @param index the rendering group index to get the information for
  87121. * @returns The auto clear setup for the requested rendering group
  87122. */
  87123. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /**
  87128. * This Helps creating a texture that will be created from a camera in your scene.
  87129. * It is basically a dynamic texture that could be used to create special effects for instance.
  87130. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87131. */
  87132. export class RenderTargetTexture extends Texture {
  87133. isCube: boolean;
  87134. /**
  87135. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87136. */
  87137. static readonly REFRESHRATE_RENDER_ONCE: number;
  87138. /**
  87139. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87140. */
  87141. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87142. /**
  87143. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87144. * the central point of your effect and can save a lot of performances.
  87145. */
  87146. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87147. /**
  87148. * Use this predicate to dynamically define the list of mesh you want to render.
  87149. * If set, the renderList property will be overwritten.
  87150. */
  87151. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87152. private _renderList;
  87153. /**
  87154. * Use this list to define the list of mesh you want to render.
  87155. */
  87156. renderList: Nullable<Array<AbstractMesh>>;
  87157. private _hookArray;
  87158. /**
  87159. * Define if particles should be rendered in your texture.
  87160. */
  87161. renderParticles: boolean;
  87162. /**
  87163. * Define if sprites should be rendered in your texture.
  87164. */
  87165. renderSprites: boolean;
  87166. /**
  87167. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87168. */
  87169. coordinatesMode: number;
  87170. /**
  87171. * Define the camera used to render the texture.
  87172. */
  87173. activeCamera: Nullable<Camera>;
  87174. /**
  87175. * Override the render function of the texture with your own one.
  87176. */
  87177. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87178. /**
  87179. * Define if camera post processes should be use while rendering the texture.
  87180. */
  87181. useCameraPostProcesses: boolean;
  87182. /**
  87183. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87184. */
  87185. ignoreCameraViewport: boolean;
  87186. private _postProcessManager;
  87187. private _postProcesses;
  87188. private _resizeObserver;
  87189. /**
  87190. * An event triggered when the texture is unbind.
  87191. */
  87192. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87193. /**
  87194. * An event triggered when the texture is unbind.
  87195. */
  87196. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87197. private _onAfterUnbindObserver;
  87198. /**
  87199. * Set a after unbind callback in the texture.
  87200. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87201. */
  87202. onAfterUnbind: () => void;
  87203. /**
  87204. * An event triggered before rendering the texture
  87205. */
  87206. onBeforeRenderObservable: Observable<number>;
  87207. private _onBeforeRenderObserver;
  87208. /**
  87209. * Set a before render callback in the texture.
  87210. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87211. */
  87212. onBeforeRender: (faceIndex: number) => void;
  87213. /**
  87214. * An event triggered after rendering the texture
  87215. */
  87216. onAfterRenderObservable: Observable<number>;
  87217. private _onAfterRenderObserver;
  87218. /**
  87219. * Set a after render callback in the texture.
  87220. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87221. */
  87222. onAfterRender: (faceIndex: number) => void;
  87223. /**
  87224. * An event triggered after the texture clear
  87225. */
  87226. onClearObservable: Observable<Engine>;
  87227. private _onClearObserver;
  87228. /**
  87229. * Set a clear callback in the texture.
  87230. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87231. */
  87232. onClear: (Engine: Engine) => void;
  87233. /**
  87234. * An event triggered when the texture is resized.
  87235. */
  87236. onResizeObservable: Observable<RenderTargetTexture>;
  87237. /**
  87238. * Define the clear color of the Render Target if it should be different from the scene.
  87239. */
  87240. clearColor: Color4;
  87241. protected _size: number | {
  87242. width: number;
  87243. height: number;
  87244. };
  87245. protected _initialSizeParameter: number | {
  87246. width: number;
  87247. height: number;
  87248. } | {
  87249. ratio: number;
  87250. };
  87251. protected _sizeRatio: Nullable<number>;
  87252. /** @hidden */
  87253. _generateMipMaps: boolean;
  87254. protected _renderingManager: RenderingManager;
  87255. /** @hidden */
  87256. _waitingRenderList: string[];
  87257. protected _doNotChangeAspectRatio: boolean;
  87258. protected _currentRefreshId: number;
  87259. protected _refreshRate: number;
  87260. protected _textureMatrix: Matrix;
  87261. protected _samples: number;
  87262. protected _renderTargetOptions: RenderTargetCreationOptions;
  87263. /**
  87264. * Gets render target creation options that were used.
  87265. */
  87266. readonly renderTargetOptions: RenderTargetCreationOptions;
  87267. protected _engine: Engine;
  87268. protected _onRatioRescale(): void;
  87269. /**
  87270. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87271. * It must define where the camera used to render the texture is set
  87272. */
  87273. boundingBoxPosition: Vector3;
  87274. private _boundingBoxSize;
  87275. /**
  87276. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87277. * When defined, the cubemap will switch to local mode
  87278. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87279. * @example https://www.babylonjs-playground.com/#RNASML
  87280. */
  87281. boundingBoxSize: Vector3;
  87282. /**
  87283. * In case the RTT has been created with a depth texture, get the associated
  87284. * depth texture.
  87285. * Otherwise, return null.
  87286. */
  87287. depthStencilTexture: Nullable<InternalTexture>;
  87288. /**
  87289. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87290. * or used a shadow, depth texture...
  87291. * @param name The friendly name of the texture
  87292. * @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)
  87293. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87294. * @param generateMipMaps True if mip maps need to be generated after render.
  87295. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87296. * @param type The type of the buffer in the RTT (int, half float, float...)
  87297. * @param isCube True if a cube texture needs to be created
  87298. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87299. * @param generateDepthBuffer True to generate a depth buffer
  87300. * @param generateStencilBuffer True to generate a stencil buffer
  87301. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87302. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87303. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87304. */
  87305. constructor(name: string, size: number | {
  87306. width: number;
  87307. height: number;
  87308. } | {
  87309. ratio: number;
  87310. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87311. /**
  87312. * Creates a depth stencil texture.
  87313. * This is only available in WebGL 2 or with the depth texture extension available.
  87314. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87315. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87316. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87317. */
  87318. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87319. private _processSizeParameter;
  87320. /**
  87321. * Define the number of samples to use in case of MSAA.
  87322. * It defaults to one meaning no MSAA has been enabled.
  87323. */
  87324. samples: number;
  87325. /**
  87326. * Resets the refresh counter of the texture and start bak from scratch.
  87327. * Could be useful to regenerate the texture if it is setup to render only once.
  87328. */
  87329. resetRefreshCounter(): void;
  87330. /**
  87331. * Define the refresh rate of the texture or the rendering frequency.
  87332. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87333. */
  87334. refreshRate: number;
  87335. /**
  87336. * Adds a post process to the render target rendering passes.
  87337. * @param postProcess define the post process to add
  87338. */
  87339. addPostProcess(postProcess: PostProcess): void;
  87340. /**
  87341. * Clear all the post processes attached to the render target
  87342. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87343. */
  87344. clearPostProcesses(dispose?: boolean): void;
  87345. /**
  87346. * Remove one of the post process from the list of attached post processes to the texture
  87347. * @param postProcess define the post process to remove from the list
  87348. */
  87349. removePostProcess(postProcess: PostProcess): void;
  87350. /** @hidden */
  87351. _shouldRender(): boolean;
  87352. /**
  87353. * Gets the actual render size of the texture.
  87354. * @returns the width of the render size
  87355. */
  87356. getRenderSize(): number;
  87357. /**
  87358. * Gets the actual render width of the texture.
  87359. * @returns the width of the render size
  87360. */
  87361. getRenderWidth(): number;
  87362. /**
  87363. * Gets the actual render height of the texture.
  87364. * @returns the height of the render size
  87365. */
  87366. getRenderHeight(): number;
  87367. /**
  87368. * Get if the texture can be rescaled or not.
  87369. */
  87370. readonly canRescale: boolean;
  87371. /**
  87372. * Resize the texture using a ratio.
  87373. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87374. */
  87375. scale(ratio: number): void;
  87376. /**
  87377. * Get the texture reflection matrix used to rotate/transform the reflection.
  87378. * @returns the reflection matrix
  87379. */
  87380. getReflectionTextureMatrix(): Matrix;
  87381. /**
  87382. * Resize the texture to a new desired size.
  87383. * Be carrefull as it will recreate all the data in the new texture.
  87384. * @param size Define the new size. It can be:
  87385. * - a number for squared texture,
  87386. * - an object containing { width: number, height: number }
  87387. * - or an object containing a ratio { ratio: number }
  87388. */
  87389. resize(size: number | {
  87390. width: number;
  87391. height: number;
  87392. } | {
  87393. ratio: number;
  87394. }): void;
  87395. /**
  87396. * Renders all the objects from the render list into the texture.
  87397. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87398. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87399. */
  87400. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87401. private _bestReflectionRenderTargetDimension;
  87402. /**
  87403. * @hidden
  87404. * @param faceIndex face index to bind to if this is a cubetexture
  87405. */
  87406. _bindFrameBuffer(faceIndex?: number): void;
  87407. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87408. private renderToTarget;
  87409. /**
  87410. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87411. * This allowed control for front to back rendering or reversly depending of the special needs.
  87412. *
  87413. * @param renderingGroupId The rendering group id corresponding to its index
  87414. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87415. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87416. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87417. */
  87418. 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;
  87419. /**
  87420. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87421. *
  87422. * @param renderingGroupId The rendering group id corresponding to its index
  87423. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87424. */
  87425. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87426. /**
  87427. * Clones the texture.
  87428. * @returns the cloned texture
  87429. */
  87430. clone(): RenderTargetTexture;
  87431. /**
  87432. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87433. * @returns The JSON representation of the texture
  87434. */
  87435. serialize(): any;
  87436. /**
  87437. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87438. */
  87439. disposeFramebufferObjects(): void;
  87440. /**
  87441. * Dispose the texture and release its associated resources.
  87442. */
  87443. dispose(): void;
  87444. /** @hidden */
  87445. _rebuild(): void;
  87446. /**
  87447. * Clear the info related to rendering groups preventing retention point in material dispose.
  87448. */
  87449. freeRenderingGroups(): void;
  87450. /**
  87451. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87452. * @returns the view count
  87453. */
  87454. getViewCount(): number;
  87455. }
  87456. }
  87457. declare module BABYLON {
  87458. /**
  87459. * Base class for the main features of a material in Babylon.js
  87460. */
  87461. export class Material implements IAnimatable {
  87462. /**
  87463. * Returns the triangle fill mode
  87464. */
  87465. static readonly TriangleFillMode: number;
  87466. /**
  87467. * Returns the wireframe mode
  87468. */
  87469. static readonly WireFrameFillMode: number;
  87470. /**
  87471. * Returns the point fill mode
  87472. */
  87473. static readonly PointFillMode: number;
  87474. /**
  87475. * Returns the point list draw mode
  87476. */
  87477. static readonly PointListDrawMode: number;
  87478. /**
  87479. * Returns the line list draw mode
  87480. */
  87481. static readonly LineListDrawMode: number;
  87482. /**
  87483. * Returns the line loop draw mode
  87484. */
  87485. static readonly LineLoopDrawMode: number;
  87486. /**
  87487. * Returns the line strip draw mode
  87488. */
  87489. static readonly LineStripDrawMode: number;
  87490. /**
  87491. * Returns the triangle strip draw mode
  87492. */
  87493. static readonly TriangleStripDrawMode: number;
  87494. /**
  87495. * Returns the triangle fan draw mode
  87496. */
  87497. static readonly TriangleFanDrawMode: number;
  87498. /**
  87499. * Stores the clock-wise side orientation
  87500. */
  87501. static readonly ClockWiseSideOrientation: number;
  87502. /**
  87503. * Stores the counter clock-wise side orientation
  87504. */
  87505. static readonly CounterClockWiseSideOrientation: number;
  87506. /**
  87507. * The dirty texture flag value
  87508. */
  87509. static readonly TextureDirtyFlag: number;
  87510. /**
  87511. * The dirty light flag value
  87512. */
  87513. static readonly LightDirtyFlag: number;
  87514. /**
  87515. * The dirty fresnel flag value
  87516. */
  87517. static readonly FresnelDirtyFlag: number;
  87518. /**
  87519. * The dirty attribute flag value
  87520. */
  87521. static readonly AttributesDirtyFlag: number;
  87522. /**
  87523. * The dirty misc flag value
  87524. */
  87525. static readonly MiscDirtyFlag: number;
  87526. /**
  87527. * The all dirty flag value
  87528. */
  87529. static readonly AllDirtyFlag: number;
  87530. /**
  87531. * The ID of the material
  87532. */
  87533. id: string;
  87534. /**
  87535. * Gets or sets the unique id of the material
  87536. */
  87537. uniqueId: number;
  87538. /**
  87539. * The name of the material
  87540. */
  87541. name: string;
  87542. /**
  87543. * Gets or sets user defined metadata
  87544. */
  87545. metadata: any;
  87546. /**
  87547. * For internal use only. Please do not use.
  87548. */
  87549. reservedDataStore: any;
  87550. /**
  87551. * Specifies if the ready state should be checked on each call
  87552. */
  87553. checkReadyOnEveryCall: boolean;
  87554. /**
  87555. * Specifies if the ready state should be checked once
  87556. */
  87557. checkReadyOnlyOnce: boolean;
  87558. /**
  87559. * The state of the material
  87560. */
  87561. state: string;
  87562. /**
  87563. * The alpha value of the material
  87564. */
  87565. protected _alpha: number;
  87566. /**
  87567. * List of inspectable custom properties (used by the Inspector)
  87568. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87569. */
  87570. inspectableCustomProperties: IInspectable[];
  87571. /**
  87572. * Sets the alpha value of the material
  87573. */
  87574. /**
  87575. * Gets the alpha value of the material
  87576. */
  87577. alpha: number;
  87578. /**
  87579. * Specifies if back face culling is enabled
  87580. */
  87581. protected _backFaceCulling: boolean;
  87582. /**
  87583. * Sets the back-face culling state
  87584. */
  87585. /**
  87586. * Gets the back-face culling state
  87587. */
  87588. backFaceCulling: boolean;
  87589. /**
  87590. * Stores the value for side orientation
  87591. */
  87592. sideOrientation: number;
  87593. /**
  87594. * Callback triggered when the material is compiled
  87595. */
  87596. onCompiled: Nullable<(effect: Effect) => void>;
  87597. /**
  87598. * Callback triggered when an error occurs
  87599. */
  87600. onError: Nullable<(effect: Effect, errors: string) => void>;
  87601. /**
  87602. * Callback triggered to get the render target textures
  87603. */
  87604. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87605. /**
  87606. * Gets a boolean indicating that current material needs to register RTT
  87607. */
  87608. readonly hasRenderTargetTextures: boolean;
  87609. /**
  87610. * Specifies if the material should be serialized
  87611. */
  87612. doNotSerialize: boolean;
  87613. /**
  87614. * @hidden
  87615. */
  87616. _storeEffectOnSubMeshes: boolean;
  87617. /**
  87618. * Stores the animations for the material
  87619. */
  87620. animations: Nullable<Array<Animation>>;
  87621. /**
  87622. * An event triggered when the material is disposed
  87623. */
  87624. onDisposeObservable: Observable<Material>;
  87625. /**
  87626. * An observer which watches for dispose events
  87627. */
  87628. private _onDisposeObserver;
  87629. private _onUnBindObservable;
  87630. /**
  87631. * Called during a dispose event
  87632. */
  87633. onDispose: () => void;
  87634. private _onBindObservable;
  87635. /**
  87636. * An event triggered when the material is bound
  87637. */
  87638. readonly onBindObservable: Observable<AbstractMesh>;
  87639. /**
  87640. * An observer which watches for bind events
  87641. */
  87642. private _onBindObserver;
  87643. /**
  87644. * Called during a bind event
  87645. */
  87646. onBind: (Mesh: AbstractMesh) => void;
  87647. /**
  87648. * An event triggered when the material is unbound
  87649. */
  87650. readonly onUnBindObservable: Observable<Material>;
  87651. /**
  87652. * Stores the value of the alpha mode
  87653. */
  87654. private _alphaMode;
  87655. /**
  87656. * Sets the value of the alpha mode.
  87657. *
  87658. * | Value | Type | Description |
  87659. * | --- | --- | --- |
  87660. * | 0 | ALPHA_DISABLE | |
  87661. * | 1 | ALPHA_ADD | |
  87662. * | 2 | ALPHA_COMBINE | |
  87663. * | 3 | ALPHA_SUBTRACT | |
  87664. * | 4 | ALPHA_MULTIPLY | |
  87665. * | 5 | ALPHA_MAXIMIZED | |
  87666. * | 6 | ALPHA_ONEONE | |
  87667. * | 7 | ALPHA_PREMULTIPLIED | |
  87668. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87669. * | 9 | ALPHA_INTERPOLATE | |
  87670. * | 10 | ALPHA_SCREENMODE | |
  87671. *
  87672. */
  87673. /**
  87674. * Gets the value of the alpha mode
  87675. */
  87676. alphaMode: number;
  87677. /**
  87678. * Stores the state of the need depth pre-pass value
  87679. */
  87680. private _needDepthPrePass;
  87681. /**
  87682. * Sets the need depth pre-pass value
  87683. */
  87684. /**
  87685. * Gets the depth pre-pass value
  87686. */
  87687. needDepthPrePass: boolean;
  87688. /**
  87689. * Specifies if depth writing should be disabled
  87690. */
  87691. disableDepthWrite: boolean;
  87692. /**
  87693. * Specifies if depth writing should be forced
  87694. */
  87695. forceDepthWrite: boolean;
  87696. /**
  87697. * Specifies if there should be a separate pass for culling
  87698. */
  87699. separateCullingPass: boolean;
  87700. /**
  87701. * Stores the state specifing if fog should be enabled
  87702. */
  87703. private _fogEnabled;
  87704. /**
  87705. * Sets the state for enabling fog
  87706. */
  87707. /**
  87708. * Gets the value of the fog enabled state
  87709. */
  87710. fogEnabled: boolean;
  87711. /**
  87712. * Stores the size of points
  87713. */
  87714. pointSize: number;
  87715. /**
  87716. * Stores the z offset value
  87717. */
  87718. zOffset: number;
  87719. /**
  87720. * Gets a value specifying if wireframe mode is enabled
  87721. */
  87722. /**
  87723. * Sets the state of wireframe mode
  87724. */
  87725. wireframe: boolean;
  87726. /**
  87727. * Gets the value specifying if point clouds are enabled
  87728. */
  87729. /**
  87730. * Sets the state of point cloud mode
  87731. */
  87732. pointsCloud: boolean;
  87733. /**
  87734. * Gets the material fill mode
  87735. */
  87736. /**
  87737. * Sets the material fill mode
  87738. */
  87739. fillMode: number;
  87740. /**
  87741. * @hidden
  87742. * Stores the effects for the material
  87743. */
  87744. _effect: Nullable<Effect>;
  87745. /**
  87746. * @hidden
  87747. * Specifies if the material was previously ready
  87748. */
  87749. _wasPreviouslyReady: boolean;
  87750. /**
  87751. * Specifies if uniform buffers should be used
  87752. */
  87753. private _useUBO;
  87754. /**
  87755. * Stores a reference to the scene
  87756. */
  87757. private _scene;
  87758. /**
  87759. * Stores the fill mode state
  87760. */
  87761. private _fillMode;
  87762. /**
  87763. * Specifies if the depth write state should be cached
  87764. */
  87765. private _cachedDepthWriteState;
  87766. /**
  87767. * Stores the uniform buffer
  87768. */
  87769. protected _uniformBuffer: UniformBuffer;
  87770. /** @hidden */
  87771. _indexInSceneMaterialArray: number;
  87772. /** @hidden */
  87773. meshMap: Nullable<{
  87774. [id: string]: AbstractMesh | undefined;
  87775. }>;
  87776. /**
  87777. * Creates a material instance
  87778. * @param name defines the name of the material
  87779. * @param scene defines the scene to reference
  87780. * @param doNotAdd specifies if the material should be added to the scene
  87781. */
  87782. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87783. /**
  87784. * Returns a string representation of the current material
  87785. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87786. * @returns a string with material information
  87787. */
  87788. toString(fullDetails?: boolean): string;
  87789. /**
  87790. * Gets the class name of the material
  87791. * @returns a string with the class name of the material
  87792. */
  87793. getClassName(): string;
  87794. /**
  87795. * Specifies if updates for the material been locked
  87796. */
  87797. readonly isFrozen: boolean;
  87798. /**
  87799. * Locks updates for the material
  87800. */
  87801. freeze(): void;
  87802. /**
  87803. * Unlocks updates for the material
  87804. */
  87805. unfreeze(): void;
  87806. /**
  87807. * Specifies if the material is ready to be used
  87808. * @param mesh defines the mesh to check
  87809. * @param useInstances specifies if instances should be used
  87810. * @returns a boolean indicating if the material is ready to be used
  87811. */
  87812. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87813. /**
  87814. * Specifies that the submesh is ready to be used
  87815. * @param mesh defines the mesh to check
  87816. * @param subMesh defines which submesh to check
  87817. * @param useInstances specifies that instances should be used
  87818. * @returns a boolean indicating that the submesh is ready or not
  87819. */
  87820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87821. /**
  87822. * Returns the material effect
  87823. * @returns the effect associated with the material
  87824. */
  87825. getEffect(): Nullable<Effect>;
  87826. /**
  87827. * Returns the current scene
  87828. * @returns a Scene
  87829. */
  87830. getScene(): Scene;
  87831. /**
  87832. * Specifies if the material will require alpha blending
  87833. * @returns a boolean specifying if alpha blending is needed
  87834. */
  87835. needAlphaBlending(): boolean;
  87836. /**
  87837. * Specifies if the mesh will require alpha blending
  87838. * @param mesh defines the mesh to check
  87839. * @returns a boolean specifying if alpha blending is needed for the mesh
  87840. */
  87841. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87842. /**
  87843. * Specifies if this material should be rendered in alpha test mode
  87844. * @returns a boolean specifying if an alpha test is needed.
  87845. */
  87846. needAlphaTesting(): boolean;
  87847. /**
  87848. * Gets the texture used for the alpha test
  87849. * @returns the texture to use for alpha testing
  87850. */
  87851. getAlphaTestTexture(): Nullable<BaseTexture>;
  87852. /**
  87853. * Marks the material to indicate that it needs to be re-calculated
  87854. */
  87855. markDirty(): void;
  87856. /** @hidden */
  87857. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87858. /**
  87859. * Binds the material to the mesh
  87860. * @param world defines the world transformation matrix
  87861. * @param mesh defines the mesh to bind the material to
  87862. */
  87863. bind(world: Matrix, mesh?: Mesh): void;
  87864. /**
  87865. * Binds the submesh to the material
  87866. * @param world defines the world transformation matrix
  87867. * @param mesh defines the mesh containing the submesh
  87868. * @param subMesh defines the submesh to bind the material to
  87869. */
  87870. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87871. /**
  87872. * Binds the world matrix to the material
  87873. * @param world defines the world transformation matrix
  87874. */
  87875. bindOnlyWorldMatrix(world: Matrix): void;
  87876. /**
  87877. * Binds the scene's uniform buffer to the effect.
  87878. * @param effect defines the effect to bind to the scene uniform buffer
  87879. * @param sceneUbo defines the uniform buffer storing scene data
  87880. */
  87881. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87882. /**
  87883. * Binds the view matrix to the effect
  87884. * @param effect defines the effect to bind the view matrix to
  87885. */
  87886. bindView(effect: Effect): void;
  87887. /**
  87888. * Binds the view projection matrix to the effect
  87889. * @param effect defines the effect to bind the view projection matrix to
  87890. */
  87891. bindViewProjection(effect: Effect): void;
  87892. /**
  87893. * Specifies if material alpha testing should be turned on for the mesh
  87894. * @param mesh defines the mesh to check
  87895. */
  87896. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87897. /**
  87898. * Processes to execute after binding the material to a mesh
  87899. * @param mesh defines the rendered mesh
  87900. */
  87901. protected _afterBind(mesh?: Mesh): void;
  87902. /**
  87903. * Unbinds the material from the mesh
  87904. */
  87905. unbind(): void;
  87906. /**
  87907. * Gets the active textures from the material
  87908. * @returns an array of textures
  87909. */
  87910. getActiveTextures(): BaseTexture[];
  87911. /**
  87912. * Specifies if the material uses a texture
  87913. * @param texture defines the texture to check against the material
  87914. * @returns a boolean specifying if the material uses the texture
  87915. */
  87916. hasTexture(texture: BaseTexture): boolean;
  87917. /**
  87918. * Makes a duplicate of the material, and gives it a new name
  87919. * @param name defines the new name for the duplicated material
  87920. * @returns the cloned material
  87921. */
  87922. clone(name: string): Nullable<Material>;
  87923. /**
  87924. * Gets the meshes bound to the material
  87925. * @returns an array of meshes bound to the material
  87926. */
  87927. getBindedMeshes(): AbstractMesh[];
  87928. /**
  87929. * Force shader compilation
  87930. * @param mesh defines the mesh associated with this material
  87931. * @param onCompiled defines a function to execute once the material is compiled
  87932. * @param options defines the options to configure the compilation
  87933. * @param onError defines a function to execute if the material fails compiling
  87934. */
  87935. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87936. clipPlane: boolean;
  87937. }>, onError?: (reason: string) => void): void;
  87938. /**
  87939. * Force shader compilation
  87940. * @param mesh defines the mesh that will use this material
  87941. * @param options defines additional options for compiling the shaders
  87942. * @returns a promise that resolves when the compilation completes
  87943. */
  87944. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87945. clipPlane: boolean;
  87946. }>): Promise<void>;
  87947. private static readonly _AllDirtyCallBack;
  87948. private static readonly _ImageProcessingDirtyCallBack;
  87949. private static readonly _TextureDirtyCallBack;
  87950. private static readonly _FresnelDirtyCallBack;
  87951. private static readonly _MiscDirtyCallBack;
  87952. private static readonly _LightsDirtyCallBack;
  87953. private static readonly _AttributeDirtyCallBack;
  87954. private static _FresnelAndMiscDirtyCallBack;
  87955. private static _TextureAndMiscDirtyCallBack;
  87956. private static readonly _DirtyCallbackArray;
  87957. private static readonly _RunDirtyCallBacks;
  87958. /**
  87959. * Marks a define in the material to indicate that it needs to be re-computed
  87960. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87961. */
  87962. markAsDirty(flag: number): void;
  87963. /**
  87964. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87965. * @param func defines a function which checks material defines against the submeshes
  87966. */
  87967. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87968. /**
  87969. * Indicates that we need to re-calculated for all submeshes
  87970. */
  87971. protected _markAllSubMeshesAsAllDirty(): void;
  87972. /**
  87973. * Indicates that image processing needs to be re-calculated for all submeshes
  87974. */
  87975. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87976. /**
  87977. * Indicates that textures need to be re-calculated for all submeshes
  87978. */
  87979. protected _markAllSubMeshesAsTexturesDirty(): void;
  87980. /**
  87981. * Indicates that fresnel needs to be re-calculated for all submeshes
  87982. */
  87983. protected _markAllSubMeshesAsFresnelDirty(): void;
  87984. /**
  87985. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87986. */
  87987. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87988. /**
  87989. * Indicates that lights need to be re-calculated for all submeshes
  87990. */
  87991. protected _markAllSubMeshesAsLightsDirty(): void;
  87992. /**
  87993. * Indicates that attributes need to be re-calculated for all submeshes
  87994. */
  87995. protected _markAllSubMeshesAsAttributesDirty(): void;
  87996. /**
  87997. * Indicates that misc needs to be re-calculated for all submeshes
  87998. */
  87999. protected _markAllSubMeshesAsMiscDirty(): void;
  88000. /**
  88001. * Indicates that textures and misc need to be re-calculated for all submeshes
  88002. */
  88003. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88004. /**
  88005. * Disposes the material
  88006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88007. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88008. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88009. */
  88010. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88011. /** @hidden */
  88012. private releaseVertexArrayObject;
  88013. /**
  88014. * Serializes this material
  88015. * @returns the serialized material object
  88016. */
  88017. serialize(): any;
  88018. /**
  88019. * Creates a material from parsed material data
  88020. * @param parsedMaterial defines parsed material data
  88021. * @param scene defines the hosting scene
  88022. * @param rootUrl defines the root URL to use to load textures
  88023. * @returns a new material
  88024. */
  88025. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /**
  88030. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88031. * separate meshes. This can be use to improve performances.
  88032. * @see http://doc.babylonjs.com/how_to/multi_materials
  88033. */
  88034. export class MultiMaterial extends Material {
  88035. private _subMaterials;
  88036. /**
  88037. * Gets or Sets the list of Materials used within the multi material.
  88038. * They need to be ordered according to the submeshes order in the associated mesh
  88039. */
  88040. subMaterials: Nullable<Material>[];
  88041. /**
  88042. * Function used to align with Node.getChildren()
  88043. * @returns the list of Materials used within the multi material
  88044. */
  88045. getChildren(): Nullable<Material>[];
  88046. /**
  88047. * Instantiates a new Multi Material
  88048. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88049. * separate meshes. This can be use to improve performances.
  88050. * @see http://doc.babylonjs.com/how_to/multi_materials
  88051. * @param name Define the name in the scene
  88052. * @param scene Define the scene the material belongs to
  88053. */
  88054. constructor(name: string, scene: Scene);
  88055. private _hookArray;
  88056. /**
  88057. * Get one of the submaterial by its index in the submaterials array
  88058. * @param index The index to look the sub material at
  88059. * @returns The Material if the index has been defined
  88060. */
  88061. getSubMaterial(index: number): Nullable<Material>;
  88062. /**
  88063. * Get the list of active textures for the whole sub materials list.
  88064. * @returns All the textures that will be used during the rendering
  88065. */
  88066. getActiveTextures(): BaseTexture[];
  88067. /**
  88068. * Gets the current class name of the material e.g. "MultiMaterial"
  88069. * Mainly use in serialization.
  88070. * @returns the class name
  88071. */
  88072. getClassName(): string;
  88073. /**
  88074. * Checks if the material is ready to render the requested sub mesh
  88075. * @param mesh Define the mesh the submesh belongs to
  88076. * @param subMesh Define the sub mesh to look readyness for
  88077. * @param useInstances Define whether or not the material is used with instances
  88078. * @returns true if ready, otherwise false
  88079. */
  88080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88081. /**
  88082. * Clones the current material and its related sub materials
  88083. * @param name Define the name of the newly cloned material
  88084. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88085. * @returns the cloned material
  88086. */
  88087. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88088. /**
  88089. * Serializes the materials into a JSON representation.
  88090. * @returns the JSON representation
  88091. */
  88092. serialize(): any;
  88093. /**
  88094. * Dispose the material and release its associated resources
  88095. * @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)
  88096. * @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)
  88097. * @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)
  88098. */
  88099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88100. /**
  88101. * Creates a MultiMaterial from parsed MultiMaterial data.
  88102. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88103. * @param scene defines the hosting scene
  88104. * @returns a new MultiMaterial
  88105. */
  88106. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88107. }
  88108. }
  88109. declare module BABYLON {
  88110. /**
  88111. * Base class for submeshes
  88112. */
  88113. export class BaseSubMesh {
  88114. /** @hidden */
  88115. _materialDefines: Nullable<MaterialDefines>;
  88116. /** @hidden */
  88117. _materialEffect: Nullable<Effect>;
  88118. /**
  88119. * Gets associated effect
  88120. */
  88121. readonly effect: Nullable<Effect>;
  88122. /**
  88123. * Sets associated effect (effect used to render this submesh)
  88124. * @param effect defines the effect to associate with
  88125. * @param defines defines the set of defines used to compile this effect
  88126. */
  88127. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88128. }
  88129. /**
  88130. * Defines a subdivision inside a mesh
  88131. */
  88132. export class SubMesh extends BaseSubMesh implements ICullable {
  88133. /** the material index to use */
  88134. materialIndex: number;
  88135. /** vertex index start */
  88136. verticesStart: number;
  88137. /** vertices count */
  88138. verticesCount: number;
  88139. /** index start */
  88140. indexStart: number;
  88141. /** indices count */
  88142. indexCount: number;
  88143. /** @hidden */
  88144. _linesIndexCount: number;
  88145. private _mesh;
  88146. private _renderingMesh;
  88147. private _boundingInfo;
  88148. private _linesIndexBuffer;
  88149. /** @hidden */
  88150. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88151. /** @hidden */
  88152. _trianglePlanes: Plane[];
  88153. /** @hidden */
  88154. _lastColliderTransformMatrix: Nullable<Matrix>;
  88155. /** @hidden */
  88156. _renderId: number;
  88157. /** @hidden */
  88158. _alphaIndex: number;
  88159. /** @hidden */
  88160. _distanceToCamera: number;
  88161. /** @hidden */
  88162. _id: number;
  88163. private _currentMaterial;
  88164. /**
  88165. * Add a new submesh to a mesh
  88166. * @param materialIndex defines the material index to use
  88167. * @param verticesStart defines vertex index start
  88168. * @param verticesCount defines vertices count
  88169. * @param indexStart defines index start
  88170. * @param indexCount defines indices count
  88171. * @param mesh defines the parent mesh
  88172. * @param renderingMesh defines an optional rendering mesh
  88173. * @param createBoundingBox defines if bounding box should be created for this submesh
  88174. * @returns the new submesh
  88175. */
  88176. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88177. /**
  88178. * Creates a new submesh
  88179. * @param materialIndex defines the material index to use
  88180. * @param verticesStart defines vertex index start
  88181. * @param verticesCount defines vertices count
  88182. * @param indexStart defines index start
  88183. * @param indexCount defines indices count
  88184. * @param mesh defines the parent mesh
  88185. * @param renderingMesh defines an optional rendering mesh
  88186. * @param createBoundingBox defines if bounding box should be created for this submesh
  88187. */
  88188. constructor(
  88189. /** the material index to use */
  88190. materialIndex: number,
  88191. /** vertex index start */
  88192. verticesStart: number,
  88193. /** vertices count */
  88194. verticesCount: number,
  88195. /** index start */
  88196. indexStart: number,
  88197. /** indices count */
  88198. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88199. /**
  88200. * Returns true if this submesh covers the entire parent mesh
  88201. * @ignorenaming
  88202. */
  88203. readonly IsGlobal: boolean;
  88204. /**
  88205. * Returns the submesh BoudingInfo object
  88206. * @returns current bounding info (or mesh's one if the submesh is global)
  88207. */
  88208. getBoundingInfo(): BoundingInfo;
  88209. /**
  88210. * Sets the submesh BoundingInfo
  88211. * @param boundingInfo defines the new bounding info to use
  88212. * @returns the SubMesh
  88213. */
  88214. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88215. /**
  88216. * Returns the mesh of the current submesh
  88217. * @return the parent mesh
  88218. */
  88219. getMesh(): AbstractMesh;
  88220. /**
  88221. * Returns the rendering mesh of the submesh
  88222. * @returns the rendering mesh (could be different from parent mesh)
  88223. */
  88224. getRenderingMesh(): Mesh;
  88225. /**
  88226. * Returns the submesh material
  88227. * @returns null or the current material
  88228. */
  88229. getMaterial(): Nullable<Material>;
  88230. /**
  88231. * Sets a new updated BoundingInfo object to the submesh
  88232. * @param data defines an optional position array to use to determine the bounding info
  88233. * @returns the SubMesh
  88234. */
  88235. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88236. /** @hidden */
  88237. _checkCollision(collider: Collider): boolean;
  88238. /**
  88239. * Updates the submesh BoundingInfo
  88240. * @param world defines the world matrix to use to update the bounding info
  88241. * @returns the submesh
  88242. */
  88243. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88244. /**
  88245. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88246. * @param frustumPlanes defines the frustum planes
  88247. * @returns true if the submesh is intersecting with the frustum
  88248. */
  88249. isInFrustum(frustumPlanes: Plane[]): boolean;
  88250. /**
  88251. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88252. * @param frustumPlanes defines the frustum planes
  88253. * @returns true if the submesh is inside the frustum
  88254. */
  88255. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88256. /**
  88257. * Renders the submesh
  88258. * @param enableAlphaMode defines if alpha needs to be used
  88259. * @returns the submesh
  88260. */
  88261. render(enableAlphaMode: boolean): SubMesh;
  88262. /**
  88263. * @hidden
  88264. */
  88265. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88266. /**
  88267. * Checks if the submesh intersects with a ray
  88268. * @param ray defines the ray to test
  88269. * @returns true is the passed ray intersects the submesh bounding box
  88270. */
  88271. canIntersects(ray: Ray): boolean;
  88272. /**
  88273. * Intersects current submesh with a ray
  88274. * @param ray defines the ray to test
  88275. * @param positions defines mesh's positions array
  88276. * @param indices defines mesh's indices array
  88277. * @param fastCheck defines if only bounding info should be used
  88278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88279. * @returns intersection info or null if no intersection
  88280. */
  88281. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88282. /** @hidden */
  88283. private _intersectLines;
  88284. /** @hidden */
  88285. private _intersectUnIndexedLines;
  88286. /** @hidden */
  88287. private _intersectTriangles;
  88288. /** @hidden */
  88289. private _intersectUnIndexedTriangles;
  88290. /** @hidden */
  88291. _rebuild(): void;
  88292. /**
  88293. * Creates a new submesh from the passed mesh
  88294. * @param newMesh defines the new hosting mesh
  88295. * @param newRenderingMesh defines an optional rendering mesh
  88296. * @returns the new submesh
  88297. */
  88298. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88299. /**
  88300. * Release associated resources
  88301. */
  88302. dispose(): void;
  88303. /**
  88304. * Gets the class name
  88305. * @returns the string "SubMesh".
  88306. */
  88307. getClassName(): string;
  88308. /**
  88309. * Creates a new submesh from indices data
  88310. * @param materialIndex the index of the main mesh material
  88311. * @param startIndex the index where to start the copy in the mesh indices array
  88312. * @param indexCount the number of indices to copy then from the startIndex
  88313. * @param mesh the main mesh to create the submesh from
  88314. * @param renderingMesh the optional rendering mesh
  88315. * @returns a new submesh
  88316. */
  88317. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88318. }
  88319. }
  88320. declare module BABYLON {
  88321. /**
  88322. * Class used to represent data loading progression
  88323. */
  88324. export class SceneLoaderFlags {
  88325. private static _ForceFullSceneLoadingForIncremental;
  88326. private static _ShowLoadingScreen;
  88327. private static _CleanBoneMatrixWeights;
  88328. private static _loggingLevel;
  88329. /**
  88330. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88331. */
  88332. static ForceFullSceneLoadingForIncremental: boolean;
  88333. /**
  88334. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88335. */
  88336. static ShowLoadingScreen: boolean;
  88337. /**
  88338. * Defines the current logging level (while loading the scene)
  88339. * @ignorenaming
  88340. */
  88341. static loggingLevel: number;
  88342. /**
  88343. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88344. */
  88345. static CleanBoneMatrixWeights: boolean;
  88346. }
  88347. }
  88348. declare module BABYLON {
  88349. /**
  88350. * Class used to store geometry data (vertex buffers + index buffer)
  88351. */
  88352. export class Geometry implements IGetSetVerticesData {
  88353. /**
  88354. * Gets or sets the ID of the geometry
  88355. */
  88356. id: string;
  88357. /**
  88358. * Gets or sets the unique ID of the geometry
  88359. */
  88360. uniqueId: number;
  88361. /**
  88362. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88363. */
  88364. delayLoadState: number;
  88365. /**
  88366. * Gets the file containing the data to load when running in delay load state
  88367. */
  88368. delayLoadingFile: Nullable<string>;
  88369. /**
  88370. * Callback called when the geometry is updated
  88371. */
  88372. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88373. private _scene;
  88374. private _engine;
  88375. private _meshes;
  88376. private _totalVertices;
  88377. /** @hidden */
  88378. _indices: IndicesArray;
  88379. /** @hidden */
  88380. _vertexBuffers: {
  88381. [key: string]: VertexBuffer;
  88382. };
  88383. private _isDisposed;
  88384. private _extend;
  88385. private _boundingBias;
  88386. /** @hidden */
  88387. _delayInfo: Array<string>;
  88388. private _indexBuffer;
  88389. private _indexBufferIsUpdatable;
  88390. /** @hidden */
  88391. _boundingInfo: Nullable<BoundingInfo>;
  88392. /** @hidden */
  88393. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88394. /** @hidden */
  88395. _softwareSkinningFrameId: number;
  88396. private _vertexArrayObjects;
  88397. private _updatable;
  88398. /** @hidden */
  88399. _positions: Nullable<Vector3[]>;
  88400. /**
  88401. * 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
  88402. */
  88403. /**
  88404. * 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
  88405. */
  88406. boundingBias: Vector2;
  88407. /**
  88408. * Static function used to attach a new empty geometry to a mesh
  88409. * @param mesh defines the mesh to attach the geometry to
  88410. * @returns the new Geometry
  88411. */
  88412. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88413. /**
  88414. * Creates a new geometry
  88415. * @param id defines the unique ID
  88416. * @param scene defines the hosting scene
  88417. * @param vertexData defines the VertexData used to get geometry data
  88418. * @param updatable defines if geometry must be updatable (false by default)
  88419. * @param mesh defines the mesh that will be associated with the geometry
  88420. */
  88421. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88422. /**
  88423. * Gets the current extend of the geometry
  88424. */
  88425. readonly extend: {
  88426. minimum: Vector3;
  88427. maximum: Vector3;
  88428. };
  88429. /**
  88430. * Gets the hosting scene
  88431. * @returns the hosting Scene
  88432. */
  88433. getScene(): Scene;
  88434. /**
  88435. * Gets the hosting engine
  88436. * @returns the hosting Engine
  88437. */
  88438. getEngine(): Engine;
  88439. /**
  88440. * Defines if the geometry is ready to use
  88441. * @returns true if the geometry is ready to be used
  88442. */
  88443. isReady(): boolean;
  88444. /**
  88445. * Gets a value indicating that the geometry should not be serialized
  88446. */
  88447. readonly doNotSerialize: boolean;
  88448. /** @hidden */
  88449. _rebuild(): void;
  88450. /**
  88451. * Affects all geometry data in one call
  88452. * @param vertexData defines the geometry data
  88453. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88454. */
  88455. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88456. /**
  88457. * Set specific vertex data
  88458. * @param kind defines the data kind (Position, normal, etc...)
  88459. * @param data defines the vertex data to use
  88460. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88461. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88462. */
  88463. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88464. /**
  88465. * Removes a specific vertex data
  88466. * @param kind defines the data kind (Position, normal, etc...)
  88467. */
  88468. removeVerticesData(kind: string): void;
  88469. /**
  88470. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88471. * @param buffer defines the vertex buffer to use
  88472. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88473. */
  88474. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88475. /**
  88476. * Update a specific vertex buffer
  88477. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88478. * It will do nothing if the buffer is not updatable
  88479. * @param kind defines the data kind (Position, normal, etc...)
  88480. * @param data defines the data to use
  88481. * @param offset defines the offset in the target buffer where to store the data
  88482. * @param useBytes set to true if the offset is in bytes
  88483. */
  88484. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88485. /**
  88486. * Update a specific vertex buffer
  88487. * This function will create a new buffer if the current one is not updatable
  88488. * @param kind defines the data kind (Position, normal, etc...)
  88489. * @param data defines the data to use
  88490. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88491. */
  88492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88493. private _updateBoundingInfo;
  88494. /** @hidden */
  88495. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88496. /**
  88497. * Gets total number of vertices
  88498. * @returns the total number of vertices
  88499. */
  88500. getTotalVertices(): number;
  88501. /**
  88502. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88503. * @param kind defines the data kind (Position, normal, etc...)
  88504. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88505. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88506. * @returns a float array containing vertex data
  88507. */
  88508. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88509. /**
  88510. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88511. * @param kind defines the data kind (Position, normal, etc...)
  88512. * @returns true if the vertex buffer with the specified kind is updatable
  88513. */
  88514. isVertexBufferUpdatable(kind: string): boolean;
  88515. /**
  88516. * Gets a specific vertex buffer
  88517. * @param kind defines the data kind (Position, normal, etc...)
  88518. * @returns a VertexBuffer
  88519. */
  88520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88521. /**
  88522. * Returns all vertex buffers
  88523. * @return an object holding all vertex buffers indexed by kind
  88524. */
  88525. getVertexBuffers(): Nullable<{
  88526. [key: string]: VertexBuffer;
  88527. }>;
  88528. /**
  88529. * Gets a boolean indicating if specific vertex buffer is present
  88530. * @param kind defines the data kind (Position, normal, etc...)
  88531. * @returns true if data is present
  88532. */
  88533. isVerticesDataPresent(kind: string): boolean;
  88534. /**
  88535. * Gets a list of all attached data kinds (Position, normal, etc...)
  88536. * @returns a list of string containing all kinds
  88537. */
  88538. getVerticesDataKinds(): string[];
  88539. /**
  88540. * Update index buffer
  88541. * @param indices defines the indices to store in the index buffer
  88542. * @param offset defines the offset in the target buffer where to store the data
  88543. * @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)
  88544. */
  88545. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88546. /**
  88547. * Creates a new index buffer
  88548. * @param indices defines the indices to store in the index buffer
  88549. * @param totalVertices defines the total number of vertices (could be null)
  88550. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88551. */
  88552. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88553. /**
  88554. * Return the total number of indices
  88555. * @returns the total number of indices
  88556. */
  88557. getTotalIndices(): number;
  88558. /**
  88559. * Gets the index buffer array
  88560. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88562. * @returns the index buffer array
  88563. */
  88564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88565. /**
  88566. * Gets the index buffer
  88567. * @return the index buffer
  88568. */
  88569. getIndexBuffer(): Nullable<DataBuffer>;
  88570. /** @hidden */
  88571. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88572. /**
  88573. * Release the associated resources for a specific mesh
  88574. * @param mesh defines the source mesh
  88575. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88576. */
  88577. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88578. /**
  88579. * Apply current geometry to a given mesh
  88580. * @param mesh defines the mesh to apply geometry to
  88581. */
  88582. applyToMesh(mesh: Mesh): void;
  88583. private _updateExtend;
  88584. private _applyToMesh;
  88585. private notifyUpdate;
  88586. /**
  88587. * Load the geometry if it was flagged as delay loaded
  88588. * @param scene defines the hosting scene
  88589. * @param onLoaded defines a callback called when the geometry is loaded
  88590. */
  88591. load(scene: Scene, onLoaded?: () => void): void;
  88592. private _queueLoad;
  88593. /**
  88594. * Invert the geometry to move from a right handed system to a left handed one.
  88595. */
  88596. toLeftHanded(): void;
  88597. /** @hidden */
  88598. _resetPointsArrayCache(): void;
  88599. /** @hidden */
  88600. _generatePointsArray(): boolean;
  88601. /**
  88602. * Gets a value indicating if the geometry is disposed
  88603. * @returns true if the geometry was disposed
  88604. */
  88605. isDisposed(): boolean;
  88606. private _disposeVertexArrayObjects;
  88607. /**
  88608. * Free all associated resources
  88609. */
  88610. dispose(): void;
  88611. /**
  88612. * Clone the current geometry into a new geometry
  88613. * @param id defines the unique ID of the new geometry
  88614. * @returns a new geometry object
  88615. */
  88616. copy(id: string): Geometry;
  88617. /**
  88618. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88619. * @return a JSON representation of the current geometry data (without the vertices data)
  88620. */
  88621. serialize(): any;
  88622. private toNumberArray;
  88623. /**
  88624. * Serialize all vertices data into a JSON oject
  88625. * @returns a JSON representation of the current geometry data
  88626. */
  88627. serializeVerticeData(): any;
  88628. /**
  88629. * Extracts a clone of a mesh geometry
  88630. * @param mesh defines the source mesh
  88631. * @param id defines the unique ID of the new geometry object
  88632. * @returns the new geometry object
  88633. */
  88634. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88635. /**
  88636. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88637. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88638. * Be aware Math.random() could cause collisions, but:
  88639. * "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"
  88640. * @returns a string containing a new GUID
  88641. */
  88642. static RandomId(): string;
  88643. /** @hidden */
  88644. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88645. private static _CleanMatricesWeights;
  88646. /**
  88647. * Create a new geometry from persisted data (Using .babylon file format)
  88648. * @param parsedVertexData defines the persisted data
  88649. * @param scene defines the hosting scene
  88650. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88651. * @returns the new geometry object
  88652. */
  88653. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88654. }
  88655. }
  88656. declare module BABYLON {
  88657. /**
  88658. * Define an interface for all classes that will get and set the data on vertices
  88659. */
  88660. export interface IGetSetVerticesData {
  88661. /**
  88662. * Gets a boolean indicating if specific vertex data is present
  88663. * @param kind defines the vertex data kind to use
  88664. * @returns true is data kind is present
  88665. */
  88666. isVerticesDataPresent(kind: string): boolean;
  88667. /**
  88668. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88669. * @param kind defines the data kind (Position, normal, etc...)
  88670. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88672. * @returns a float array containing vertex data
  88673. */
  88674. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88675. /**
  88676. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88677. * @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.
  88678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88679. * @returns the indices array or an empty array if the mesh has no geometry
  88680. */
  88681. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88682. /**
  88683. * Set specific vertex data
  88684. * @param kind defines the data kind (Position, normal, etc...)
  88685. * @param data defines the vertex data to use
  88686. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88687. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88688. */
  88689. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88690. /**
  88691. * Update a specific associated vertex buffer
  88692. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88693. * - VertexBuffer.PositionKind
  88694. * - VertexBuffer.UVKind
  88695. * - VertexBuffer.UV2Kind
  88696. * - VertexBuffer.UV3Kind
  88697. * - VertexBuffer.UV4Kind
  88698. * - VertexBuffer.UV5Kind
  88699. * - VertexBuffer.UV6Kind
  88700. * - VertexBuffer.ColorKind
  88701. * - VertexBuffer.MatricesIndicesKind
  88702. * - VertexBuffer.MatricesIndicesExtraKind
  88703. * - VertexBuffer.MatricesWeightsKind
  88704. * - VertexBuffer.MatricesWeightsExtraKind
  88705. * @param data defines the data source
  88706. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88707. * @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)
  88708. */
  88709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88710. /**
  88711. * Creates a new index buffer
  88712. * @param indices defines the indices to store in the index buffer
  88713. * @param totalVertices defines the total number of vertices (could be null)
  88714. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88715. */
  88716. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88717. }
  88718. /**
  88719. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88720. */
  88721. export class VertexData {
  88722. /**
  88723. * Mesh side orientation : usually the external or front surface
  88724. */
  88725. static readonly FRONTSIDE: number;
  88726. /**
  88727. * Mesh side orientation : usually the internal or back surface
  88728. */
  88729. static readonly BACKSIDE: number;
  88730. /**
  88731. * Mesh side orientation : both internal and external or front and back surfaces
  88732. */
  88733. static readonly DOUBLESIDE: number;
  88734. /**
  88735. * Mesh side orientation : by default, `FRONTSIDE`
  88736. */
  88737. static readonly DEFAULTSIDE: number;
  88738. /**
  88739. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88740. */
  88741. positions: Nullable<FloatArray>;
  88742. /**
  88743. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88744. */
  88745. normals: Nullable<FloatArray>;
  88746. /**
  88747. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88748. */
  88749. tangents: Nullable<FloatArray>;
  88750. /**
  88751. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88752. */
  88753. uvs: Nullable<FloatArray>;
  88754. /**
  88755. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88756. */
  88757. uvs2: Nullable<FloatArray>;
  88758. /**
  88759. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88760. */
  88761. uvs3: Nullable<FloatArray>;
  88762. /**
  88763. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88764. */
  88765. uvs4: Nullable<FloatArray>;
  88766. /**
  88767. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88768. */
  88769. uvs5: Nullable<FloatArray>;
  88770. /**
  88771. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88772. */
  88773. uvs6: Nullable<FloatArray>;
  88774. /**
  88775. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88776. */
  88777. colors: Nullable<FloatArray>;
  88778. /**
  88779. * 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).
  88780. */
  88781. matricesIndices: Nullable<FloatArray>;
  88782. /**
  88783. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88784. */
  88785. matricesWeights: Nullable<FloatArray>;
  88786. /**
  88787. * An array extending the number of possible indices
  88788. */
  88789. matricesIndicesExtra: Nullable<FloatArray>;
  88790. /**
  88791. * An array extending the number of possible weights when the number of indices is extended
  88792. */
  88793. matricesWeightsExtra: Nullable<FloatArray>;
  88794. /**
  88795. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88796. */
  88797. indices: Nullable<IndicesArray>;
  88798. /**
  88799. * Uses the passed data array to set the set the values for the specified kind of data
  88800. * @param data a linear array of floating numbers
  88801. * @param kind the type of data that is being set, eg positions, colors etc
  88802. */
  88803. set(data: FloatArray, kind: string): void;
  88804. /**
  88805. * Associates the vertexData to the passed Mesh.
  88806. * Sets it as updatable or not (default `false`)
  88807. * @param mesh the mesh the vertexData is applied to
  88808. * @param updatable when used and having the value true allows new data to update the vertexData
  88809. * @returns the VertexData
  88810. */
  88811. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88812. /**
  88813. * Associates the vertexData to the passed Geometry.
  88814. * Sets it as updatable or not (default `false`)
  88815. * @param geometry the geometry the vertexData is applied to
  88816. * @param updatable when used and having the value true allows new data to update the vertexData
  88817. * @returns VertexData
  88818. */
  88819. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88820. /**
  88821. * Updates the associated mesh
  88822. * @param mesh the mesh to be updated
  88823. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88824. * @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
  88825. * @returns VertexData
  88826. */
  88827. updateMesh(mesh: Mesh): VertexData;
  88828. /**
  88829. * Updates the associated geometry
  88830. * @param geometry the geometry to be updated
  88831. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88832. * @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
  88833. * @returns VertexData.
  88834. */
  88835. updateGeometry(geometry: Geometry): VertexData;
  88836. private _applyTo;
  88837. private _update;
  88838. /**
  88839. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88840. * @param matrix the transforming matrix
  88841. * @returns the VertexData
  88842. */
  88843. transform(matrix: Matrix): VertexData;
  88844. /**
  88845. * Merges the passed VertexData into the current one
  88846. * @param other the VertexData to be merged into the current one
  88847. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88848. * @returns the modified VertexData
  88849. */
  88850. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88851. private _mergeElement;
  88852. private _validate;
  88853. /**
  88854. * Serializes the VertexData
  88855. * @returns a serialized object
  88856. */
  88857. serialize(): any;
  88858. /**
  88859. * Extracts the vertexData from a mesh
  88860. * @param mesh the mesh from which to extract the VertexData
  88861. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88862. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88863. * @returns the object VertexData associated to the passed mesh
  88864. */
  88865. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88866. /**
  88867. * Extracts the vertexData from the geometry
  88868. * @param geometry the geometry from which to extract the VertexData
  88869. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88870. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88871. * @returns the object VertexData associated to the passed mesh
  88872. */
  88873. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88874. private static _ExtractFrom;
  88875. /**
  88876. * Creates the VertexData for a Ribbon
  88877. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88878. * * pathArray array of paths, each of which an array of successive Vector3
  88879. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88880. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88881. * * 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
  88882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88883. * * 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)
  88884. * * 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)
  88885. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88886. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88887. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88888. * @returns the VertexData of the ribbon
  88889. */
  88890. static CreateRibbon(options: {
  88891. pathArray: Vector3[][];
  88892. closeArray?: boolean;
  88893. closePath?: boolean;
  88894. offset?: number;
  88895. sideOrientation?: number;
  88896. frontUVs?: Vector4;
  88897. backUVs?: Vector4;
  88898. invertUV?: boolean;
  88899. uvs?: Vector2[];
  88900. colors?: Color4[];
  88901. }): VertexData;
  88902. /**
  88903. * Creates the VertexData for a box
  88904. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88905. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88906. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88907. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88908. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88909. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88910. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88912. * * 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)
  88913. * * 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)
  88914. * @returns the VertexData of the box
  88915. */
  88916. static CreateBox(options: {
  88917. size?: number;
  88918. width?: number;
  88919. height?: number;
  88920. depth?: number;
  88921. faceUV?: Vector4[];
  88922. faceColors?: Color4[];
  88923. sideOrientation?: number;
  88924. frontUVs?: Vector4;
  88925. backUVs?: Vector4;
  88926. }): VertexData;
  88927. /**
  88928. * Creates the VertexData for a tiled box
  88929. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88930. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88931. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88932. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88934. * @returns the VertexData of the box
  88935. */
  88936. static CreateTiledBox(options: {
  88937. pattern?: number;
  88938. width?: number;
  88939. height?: number;
  88940. depth?: number;
  88941. tileSize?: number;
  88942. tileWidth?: number;
  88943. tileHeight?: number;
  88944. alignHorizontal?: number;
  88945. alignVertical?: number;
  88946. faceUV?: Vector4[];
  88947. faceColors?: Color4[];
  88948. sideOrientation?: number;
  88949. }): VertexData;
  88950. /**
  88951. * Creates the VertexData for a tiled plane
  88952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88953. * * pattern a limited pattern arrangement depending on the number
  88954. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88955. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88956. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88958. * * 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)
  88959. * * 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)
  88960. * @returns the VertexData of the tiled plane
  88961. */
  88962. static CreateTiledPlane(options: {
  88963. pattern?: number;
  88964. tileSize?: number;
  88965. tileWidth?: number;
  88966. tileHeight?: number;
  88967. size?: number;
  88968. width?: number;
  88969. height?: number;
  88970. alignHorizontal?: number;
  88971. alignVertical?: number;
  88972. sideOrientation?: number;
  88973. frontUVs?: Vector4;
  88974. backUVs?: Vector4;
  88975. }): VertexData;
  88976. /**
  88977. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88978. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88979. * * segments sets the number of horizontal strips optional, default 32
  88980. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88981. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88982. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88983. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88984. * * 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
  88985. * * 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
  88986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88987. * * 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)
  88988. * * 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)
  88989. * @returns the VertexData of the ellipsoid
  88990. */
  88991. static CreateSphere(options: {
  88992. segments?: number;
  88993. diameter?: number;
  88994. diameterX?: number;
  88995. diameterY?: number;
  88996. diameterZ?: number;
  88997. arc?: number;
  88998. slice?: number;
  88999. sideOrientation?: number;
  89000. frontUVs?: Vector4;
  89001. backUVs?: Vector4;
  89002. }): VertexData;
  89003. /**
  89004. * Creates the VertexData for a cylinder, cone or prism
  89005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89006. * * height sets the height (y direction) of the cylinder, optional, default 2
  89007. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89008. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89009. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89010. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89011. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89012. * * 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
  89013. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89014. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89015. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89016. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89018. * * 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)
  89019. * * 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)
  89020. * @returns the VertexData of the cylinder, cone or prism
  89021. */
  89022. static CreateCylinder(options: {
  89023. height?: number;
  89024. diameterTop?: number;
  89025. diameterBottom?: number;
  89026. diameter?: number;
  89027. tessellation?: number;
  89028. subdivisions?: number;
  89029. arc?: number;
  89030. faceColors?: Color4[];
  89031. faceUV?: Vector4[];
  89032. hasRings?: boolean;
  89033. enclose?: boolean;
  89034. sideOrientation?: number;
  89035. frontUVs?: Vector4;
  89036. backUVs?: Vector4;
  89037. }): VertexData;
  89038. /**
  89039. * Creates the VertexData for a torus
  89040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89041. * * diameter the diameter of the torus, optional default 1
  89042. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89043. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89045. * * 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)
  89046. * * 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)
  89047. * @returns the VertexData of the torus
  89048. */
  89049. static CreateTorus(options: {
  89050. diameter?: number;
  89051. thickness?: number;
  89052. tessellation?: number;
  89053. sideOrientation?: number;
  89054. frontUVs?: Vector4;
  89055. backUVs?: Vector4;
  89056. }): VertexData;
  89057. /**
  89058. * Creates the VertexData of the LineSystem
  89059. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89060. * - lines an array of lines, each line being an array of successive Vector3
  89061. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89062. * @returns the VertexData of the LineSystem
  89063. */
  89064. static CreateLineSystem(options: {
  89065. lines: Vector3[][];
  89066. colors?: Nullable<Color4[][]>;
  89067. }): VertexData;
  89068. /**
  89069. * Create the VertexData for a DashedLines
  89070. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89071. * - points an array successive Vector3
  89072. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89073. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89074. * - dashNb the intended total number of dashes, optional, default 200
  89075. * @returns the VertexData for the DashedLines
  89076. */
  89077. static CreateDashedLines(options: {
  89078. points: Vector3[];
  89079. dashSize?: number;
  89080. gapSize?: number;
  89081. dashNb?: number;
  89082. }): VertexData;
  89083. /**
  89084. * Creates the VertexData for a Ground
  89085. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89086. * - width the width (x direction) of the ground, optional, default 1
  89087. * - height the height (z direction) of the ground, optional, default 1
  89088. * - subdivisions the number of subdivisions per side, optional, default 1
  89089. * @returns the VertexData of the Ground
  89090. */
  89091. static CreateGround(options: {
  89092. width?: number;
  89093. height?: number;
  89094. subdivisions?: number;
  89095. subdivisionsX?: number;
  89096. subdivisionsY?: number;
  89097. }): VertexData;
  89098. /**
  89099. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89100. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89101. * * xmin the ground minimum X coordinate, optional, default -1
  89102. * * zmin the ground minimum Z coordinate, optional, default -1
  89103. * * xmax the ground maximum X coordinate, optional, default 1
  89104. * * zmax the ground maximum Z coordinate, optional, default 1
  89105. * * 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}
  89106. * * 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}
  89107. * @returns the VertexData of the TiledGround
  89108. */
  89109. static CreateTiledGround(options: {
  89110. xmin: number;
  89111. zmin: number;
  89112. xmax: number;
  89113. zmax: number;
  89114. subdivisions?: {
  89115. w: number;
  89116. h: number;
  89117. };
  89118. precision?: {
  89119. w: number;
  89120. h: number;
  89121. };
  89122. }): VertexData;
  89123. /**
  89124. * Creates the VertexData of the Ground designed from a heightmap
  89125. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89126. * * width the width (x direction) of the ground
  89127. * * height the height (z direction) of the ground
  89128. * * subdivisions the number of subdivisions per side
  89129. * * minHeight the minimum altitude on the ground, optional, default 0
  89130. * * maxHeight the maximum altitude on the ground, optional default 1
  89131. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89132. * * buffer the array holding the image color data
  89133. * * bufferWidth the width of image
  89134. * * bufferHeight the height of image
  89135. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89136. * @returns the VertexData of the Ground designed from a heightmap
  89137. */
  89138. static CreateGroundFromHeightMap(options: {
  89139. width: number;
  89140. height: number;
  89141. subdivisions: number;
  89142. minHeight: number;
  89143. maxHeight: number;
  89144. colorFilter: Color3;
  89145. buffer: Uint8Array;
  89146. bufferWidth: number;
  89147. bufferHeight: number;
  89148. alphaFilter: number;
  89149. }): VertexData;
  89150. /**
  89151. * Creates the VertexData for a Plane
  89152. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89153. * * size sets the width and height of the plane to the value of size, optional default 1
  89154. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89155. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89157. * * 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)
  89158. * * 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)
  89159. * @returns the VertexData of the box
  89160. */
  89161. static CreatePlane(options: {
  89162. size?: number;
  89163. width?: number;
  89164. height?: number;
  89165. sideOrientation?: number;
  89166. frontUVs?: Vector4;
  89167. backUVs?: Vector4;
  89168. }): VertexData;
  89169. /**
  89170. * Creates the VertexData of the Disc or regular Polygon
  89171. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89172. * * radius the radius of the disc, optional default 0.5
  89173. * * tessellation the number of polygon sides, optional, default 64
  89174. * * 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
  89175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89176. * * 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)
  89177. * * 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)
  89178. * @returns the VertexData of the box
  89179. */
  89180. static CreateDisc(options: {
  89181. radius?: number;
  89182. tessellation?: number;
  89183. arc?: number;
  89184. sideOrientation?: number;
  89185. frontUVs?: Vector4;
  89186. backUVs?: Vector4;
  89187. }): VertexData;
  89188. /**
  89189. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89190. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89191. * @param polygon a mesh built from polygonTriangulation.build()
  89192. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89193. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89194. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89195. * @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)
  89196. * @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)
  89197. * @returns the VertexData of the Polygon
  89198. */
  89199. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89200. /**
  89201. * Creates the VertexData of the IcoSphere
  89202. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89203. * * radius the radius of the IcoSphere, optional default 1
  89204. * * radiusX allows stretching in the x direction, optional, default radius
  89205. * * radiusY allows stretching in the y direction, optional, default radius
  89206. * * radiusZ allows stretching in the z direction, optional, default radius
  89207. * * flat when true creates a flat shaded mesh, optional, default true
  89208. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89210. * * 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)
  89211. * * 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)
  89212. * @returns the VertexData of the IcoSphere
  89213. */
  89214. static CreateIcoSphere(options: {
  89215. radius?: number;
  89216. radiusX?: number;
  89217. radiusY?: number;
  89218. radiusZ?: number;
  89219. flat?: boolean;
  89220. subdivisions?: number;
  89221. sideOrientation?: number;
  89222. frontUVs?: Vector4;
  89223. backUVs?: Vector4;
  89224. }): VertexData;
  89225. /**
  89226. * Creates the VertexData for a Polyhedron
  89227. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89228. * * type provided types are:
  89229. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89230. * * 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)
  89231. * * size the size of the IcoSphere, optional default 1
  89232. * * sizeX allows stretching in the x direction, optional, default size
  89233. * * sizeY allows stretching in the y direction, optional, default size
  89234. * * sizeZ allows stretching in the z direction, optional, default size
  89235. * * 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
  89236. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89237. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89238. * * flat when true creates a flat shaded mesh, optional, default true
  89239. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89241. * * 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)
  89242. * * 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)
  89243. * @returns the VertexData of the Polyhedron
  89244. */
  89245. static CreatePolyhedron(options: {
  89246. type?: number;
  89247. size?: number;
  89248. sizeX?: number;
  89249. sizeY?: number;
  89250. sizeZ?: number;
  89251. custom?: any;
  89252. faceUV?: Vector4[];
  89253. faceColors?: Color4[];
  89254. flat?: boolean;
  89255. sideOrientation?: number;
  89256. frontUVs?: Vector4;
  89257. backUVs?: Vector4;
  89258. }): VertexData;
  89259. /**
  89260. * Creates the VertexData for a TorusKnot
  89261. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89262. * * radius the radius of the torus knot, optional, default 2
  89263. * * tube the thickness of the tube, optional, default 0.5
  89264. * * radialSegments the number of sides on each tube segments, optional, default 32
  89265. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89266. * * p the number of windings around the z axis, optional, default 2
  89267. * * q the number of windings around the x axis, optional, default 3
  89268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89269. * * 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)
  89270. * * 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)
  89271. * @returns the VertexData of the Torus Knot
  89272. */
  89273. static CreateTorusKnot(options: {
  89274. radius?: number;
  89275. tube?: number;
  89276. radialSegments?: number;
  89277. tubularSegments?: number;
  89278. p?: number;
  89279. q?: number;
  89280. sideOrientation?: number;
  89281. frontUVs?: Vector4;
  89282. backUVs?: Vector4;
  89283. }): VertexData;
  89284. /**
  89285. * Compute normals for given positions and indices
  89286. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89287. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89288. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89289. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89290. * * facetNormals : optional array of facet normals (vector3)
  89291. * * facetPositions : optional array of facet positions (vector3)
  89292. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89293. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89294. * * bInfo : optional bounding info, required for facetPartitioning computation
  89295. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89296. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89297. * * useRightHandedSystem: optional boolean to for right handed system computation
  89298. * * depthSort : optional boolean to enable the facet depth sort computation
  89299. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89300. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89301. */
  89302. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89303. facetNormals?: any;
  89304. facetPositions?: any;
  89305. facetPartitioning?: any;
  89306. ratio?: number;
  89307. bInfo?: any;
  89308. bbSize?: Vector3;
  89309. subDiv?: any;
  89310. useRightHandedSystem?: boolean;
  89311. depthSort?: boolean;
  89312. distanceTo?: Vector3;
  89313. depthSortedFacets?: any;
  89314. }): void;
  89315. /** @hidden */
  89316. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89317. /**
  89318. * Applies VertexData created from the imported parameters to the geometry
  89319. * @param parsedVertexData the parsed data from an imported file
  89320. * @param geometry the geometry to apply the VertexData to
  89321. */
  89322. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89323. }
  89324. }
  89325. declare module BABYLON {
  89326. /**
  89327. * Defines a target to use with MorphTargetManager
  89328. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89329. */
  89330. export class MorphTarget implements IAnimatable {
  89331. /** defines the name of the target */
  89332. name: string;
  89333. /**
  89334. * Gets or sets the list of animations
  89335. */
  89336. animations: Animation[];
  89337. private _scene;
  89338. private _positions;
  89339. private _normals;
  89340. private _tangents;
  89341. private _uvs;
  89342. private _influence;
  89343. /**
  89344. * Observable raised when the influence changes
  89345. */
  89346. onInfluenceChanged: Observable<boolean>;
  89347. /** @hidden */
  89348. _onDataLayoutChanged: Observable<void>;
  89349. /**
  89350. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89351. */
  89352. influence: number;
  89353. /**
  89354. * Gets or sets the id of the morph Target
  89355. */
  89356. id: string;
  89357. private _animationPropertiesOverride;
  89358. /**
  89359. * Gets or sets the animation properties override
  89360. */
  89361. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89362. /**
  89363. * Creates a new MorphTarget
  89364. * @param name defines the name of the target
  89365. * @param influence defines the influence to use
  89366. * @param scene defines the scene the morphtarget belongs to
  89367. */
  89368. constructor(
  89369. /** defines the name of the target */
  89370. name: string, influence?: number, scene?: Nullable<Scene>);
  89371. /**
  89372. * Gets a boolean defining if the target contains position data
  89373. */
  89374. readonly hasPositions: boolean;
  89375. /**
  89376. * Gets a boolean defining if the target contains normal data
  89377. */
  89378. readonly hasNormals: boolean;
  89379. /**
  89380. * Gets a boolean defining if the target contains tangent data
  89381. */
  89382. readonly hasTangents: boolean;
  89383. /**
  89384. * Gets a boolean defining if the target contains texture coordinates data
  89385. */
  89386. readonly hasUVs: boolean;
  89387. /**
  89388. * Affects position data to this target
  89389. * @param data defines the position data to use
  89390. */
  89391. setPositions(data: Nullable<FloatArray>): void;
  89392. /**
  89393. * Gets the position data stored in this target
  89394. * @returns a FloatArray containing the position data (or null if not present)
  89395. */
  89396. getPositions(): Nullable<FloatArray>;
  89397. /**
  89398. * Affects normal data to this target
  89399. * @param data defines the normal data to use
  89400. */
  89401. setNormals(data: Nullable<FloatArray>): void;
  89402. /**
  89403. * Gets the normal data stored in this target
  89404. * @returns a FloatArray containing the normal data (or null if not present)
  89405. */
  89406. getNormals(): Nullable<FloatArray>;
  89407. /**
  89408. * Affects tangent data to this target
  89409. * @param data defines the tangent data to use
  89410. */
  89411. setTangents(data: Nullable<FloatArray>): void;
  89412. /**
  89413. * Gets the tangent data stored in this target
  89414. * @returns a FloatArray containing the tangent data (or null if not present)
  89415. */
  89416. getTangents(): Nullable<FloatArray>;
  89417. /**
  89418. * Affects texture coordinates data to this target
  89419. * @param data defines the texture coordinates data to use
  89420. */
  89421. setUVs(data: Nullable<FloatArray>): void;
  89422. /**
  89423. * Gets the texture coordinates data stored in this target
  89424. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89425. */
  89426. getUVs(): Nullable<FloatArray>;
  89427. /**
  89428. * Serializes the current target into a Serialization object
  89429. * @returns the serialized object
  89430. */
  89431. serialize(): any;
  89432. /**
  89433. * Returns the string "MorphTarget"
  89434. * @returns "MorphTarget"
  89435. */
  89436. getClassName(): string;
  89437. /**
  89438. * Creates a new target from serialized data
  89439. * @param serializationObject defines the serialized data to use
  89440. * @returns a new MorphTarget
  89441. */
  89442. static Parse(serializationObject: any): MorphTarget;
  89443. /**
  89444. * Creates a MorphTarget from mesh data
  89445. * @param mesh defines the source mesh
  89446. * @param name defines the name to use for the new target
  89447. * @param influence defines the influence to attach to the target
  89448. * @returns a new MorphTarget
  89449. */
  89450. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89451. }
  89452. }
  89453. declare module BABYLON {
  89454. /**
  89455. * This class is used to deform meshes using morphing between different targets
  89456. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89457. */
  89458. export class MorphTargetManager {
  89459. private _targets;
  89460. private _targetInfluenceChangedObservers;
  89461. private _targetDataLayoutChangedObservers;
  89462. private _activeTargets;
  89463. private _scene;
  89464. private _influences;
  89465. private _supportsNormals;
  89466. private _supportsTangents;
  89467. private _supportsUVs;
  89468. private _vertexCount;
  89469. private _uniqueId;
  89470. private _tempInfluences;
  89471. /**
  89472. * Gets or sets a boolean indicating if normals must be morphed
  89473. */
  89474. enableNormalMorphing: boolean;
  89475. /**
  89476. * Gets or sets a boolean indicating if tangents must be morphed
  89477. */
  89478. enableTangentMorphing: boolean;
  89479. /**
  89480. * Gets or sets a boolean indicating if UV must be morphed
  89481. */
  89482. enableUVMorphing: boolean;
  89483. /**
  89484. * Creates a new MorphTargetManager
  89485. * @param scene defines the current scene
  89486. */
  89487. constructor(scene?: Nullable<Scene>);
  89488. /**
  89489. * Gets the unique ID of this manager
  89490. */
  89491. readonly uniqueId: number;
  89492. /**
  89493. * Gets the number of vertices handled by this manager
  89494. */
  89495. readonly vertexCount: number;
  89496. /**
  89497. * Gets a boolean indicating if this manager supports morphing of normals
  89498. */
  89499. readonly supportsNormals: boolean;
  89500. /**
  89501. * Gets a boolean indicating if this manager supports morphing of tangents
  89502. */
  89503. readonly supportsTangents: boolean;
  89504. /**
  89505. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89506. */
  89507. readonly supportsUVs: boolean;
  89508. /**
  89509. * Gets the number of targets stored in this manager
  89510. */
  89511. readonly numTargets: number;
  89512. /**
  89513. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89514. */
  89515. readonly numInfluencers: number;
  89516. /**
  89517. * Gets the list of influences (one per target)
  89518. */
  89519. readonly influences: Float32Array;
  89520. /**
  89521. * Gets the active target at specified index. An active target is a target with an influence > 0
  89522. * @param index defines the index to check
  89523. * @returns the requested target
  89524. */
  89525. getActiveTarget(index: number): MorphTarget;
  89526. /**
  89527. * Gets the target at specified index
  89528. * @param index defines the index to check
  89529. * @returns the requested target
  89530. */
  89531. getTarget(index: number): MorphTarget;
  89532. /**
  89533. * Add a new target to this manager
  89534. * @param target defines the target to add
  89535. */
  89536. addTarget(target: MorphTarget): void;
  89537. /**
  89538. * Removes a target from the manager
  89539. * @param target defines the target to remove
  89540. */
  89541. removeTarget(target: MorphTarget): void;
  89542. /**
  89543. * Serializes the current manager into a Serialization object
  89544. * @returns the serialized object
  89545. */
  89546. serialize(): any;
  89547. private _syncActiveTargets;
  89548. /**
  89549. * Syncrhonize the targets with all the meshes using this morph target manager
  89550. */
  89551. synchronize(): void;
  89552. /**
  89553. * Creates a new MorphTargetManager from serialized data
  89554. * @param serializationObject defines the serialized data
  89555. * @param scene defines the hosting scene
  89556. * @returns the new MorphTargetManager
  89557. */
  89558. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89559. }
  89560. }
  89561. declare module BABYLON {
  89562. /**
  89563. * Class used to represent a specific level of detail of a mesh
  89564. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89565. */
  89566. export class MeshLODLevel {
  89567. /** Defines the distance where this level should start being displayed */
  89568. distance: number;
  89569. /** Defines the mesh to use to render this level */
  89570. mesh: Nullable<Mesh>;
  89571. /**
  89572. * Creates a new LOD level
  89573. * @param distance defines the distance where this level should star being displayed
  89574. * @param mesh defines the mesh to use to render this level
  89575. */
  89576. constructor(
  89577. /** Defines the distance where this level should start being displayed */
  89578. distance: number,
  89579. /** Defines the mesh to use to render this level */
  89580. mesh: Nullable<Mesh>);
  89581. }
  89582. }
  89583. declare module BABYLON {
  89584. /**
  89585. * Mesh representing the gorund
  89586. */
  89587. export class GroundMesh extends Mesh {
  89588. /** If octree should be generated */
  89589. generateOctree: boolean;
  89590. private _heightQuads;
  89591. /** @hidden */
  89592. _subdivisionsX: number;
  89593. /** @hidden */
  89594. _subdivisionsY: number;
  89595. /** @hidden */
  89596. _width: number;
  89597. /** @hidden */
  89598. _height: number;
  89599. /** @hidden */
  89600. _minX: number;
  89601. /** @hidden */
  89602. _maxX: number;
  89603. /** @hidden */
  89604. _minZ: number;
  89605. /** @hidden */
  89606. _maxZ: number;
  89607. constructor(name: string, scene: Scene);
  89608. /**
  89609. * "GroundMesh"
  89610. * @returns "GroundMesh"
  89611. */
  89612. getClassName(): string;
  89613. /**
  89614. * The minimum of x and y subdivisions
  89615. */
  89616. readonly subdivisions: number;
  89617. /**
  89618. * X subdivisions
  89619. */
  89620. readonly subdivisionsX: number;
  89621. /**
  89622. * Y subdivisions
  89623. */
  89624. readonly subdivisionsY: number;
  89625. /**
  89626. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89627. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89628. * @param chunksCount the number of subdivisions for x and y
  89629. * @param octreeBlocksSize (Default: 32)
  89630. */
  89631. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89632. /**
  89633. * Returns a height (y) value in the Worl system :
  89634. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89635. * @param x x coordinate
  89636. * @param z z coordinate
  89637. * @returns the ground y position if (x, z) are outside the ground surface.
  89638. */
  89639. getHeightAtCoordinates(x: number, z: number): number;
  89640. /**
  89641. * Returns a normalized vector (Vector3) orthogonal to the ground
  89642. * at the ground coordinates (x, z) expressed in the World system.
  89643. * @param x x coordinate
  89644. * @param z z coordinate
  89645. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89646. */
  89647. getNormalAtCoordinates(x: number, z: number): Vector3;
  89648. /**
  89649. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89650. * at the ground coordinates (x, z) expressed in the World system.
  89651. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89652. * @param x x coordinate
  89653. * @param z z coordinate
  89654. * @param ref vector to store the result
  89655. * @returns the GroundMesh.
  89656. */
  89657. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89658. /**
  89659. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89660. * if the ground has been updated.
  89661. * This can be used in the render loop.
  89662. * @returns the GroundMesh.
  89663. */
  89664. updateCoordinateHeights(): GroundMesh;
  89665. private _getFacetAt;
  89666. private _initHeightQuads;
  89667. private _computeHeightQuads;
  89668. /**
  89669. * Serializes this ground mesh
  89670. * @param serializationObject object to write serialization to
  89671. */
  89672. serialize(serializationObject: any): void;
  89673. /**
  89674. * Parses a serialized ground mesh
  89675. * @param parsedMesh the serialized mesh
  89676. * @param scene the scene to create the ground mesh in
  89677. * @returns the created ground mesh
  89678. */
  89679. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89680. }
  89681. }
  89682. declare module BABYLON {
  89683. /**
  89684. * Interface for Physics-Joint data
  89685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89686. */
  89687. export interface PhysicsJointData {
  89688. /**
  89689. * The main pivot of the joint
  89690. */
  89691. mainPivot?: Vector3;
  89692. /**
  89693. * The connected pivot of the joint
  89694. */
  89695. connectedPivot?: Vector3;
  89696. /**
  89697. * The main axis of the joint
  89698. */
  89699. mainAxis?: Vector3;
  89700. /**
  89701. * The connected axis of the joint
  89702. */
  89703. connectedAxis?: Vector3;
  89704. /**
  89705. * The collision of the joint
  89706. */
  89707. collision?: boolean;
  89708. /**
  89709. * Native Oimo/Cannon/Energy data
  89710. */
  89711. nativeParams?: any;
  89712. }
  89713. /**
  89714. * This is a holder class for the physics joint created by the physics plugin
  89715. * It holds a set of functions to control the underlying joint
  89716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89717. */
  89718. export class PhysicsJoint {
  89719. /**
  89720. * The type of the physics joint
  89721. */
  89722. type: number;
  89723. /**
  89724. * The data for the physics joint
  89725. */
  89726. jointData: PhysicsJointData;
  89727. private _physicsJoint;
  89728. protected _physicsPlugin: IPhysicsEnginePlugin;
  89729. /**
  89730. * Initializes the physics joint
  89731. * @param type The type of the physics joint
  89732. * @param jointData The data for the physics joint
  89733. */
  89734. constructor(
  89735. /**
  89736. * The type of the physics joint
  89737. */
  89738. type: number,
  89739. /**
  89740. * The data for the physics joint
  89741. */
  89742. jointData: PhysicsJointData);
  89743. /**
  89744. * Gets the physics joint
  89745. */
  89746. /**
  89747. * Sets the physics joint
  89748. */
  89749. physicsJoint: any;
  89750. /**
  89751. * Sets the physics plugin
  89752. */
  89753. physicsPlugin: IPhysicsEnginePlugin;
  89754. /**
  89755. * Execute a function that is physics-plugin specific.
  89756. * @param {Function} func the function that will be executed.
  89757. * It accepts two parameters: the physics world and the physics joint
  89758. */
  89759. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89760. /**
  89761. * Distance-Joint type
  89762. */
  89763. static DistanceJoint: number;
  89764. /**
  89765. * Hinge-Joint type
  89766. */
  89767. static HingeJoint: number;
  89768. /**
  89769. * Ball-and-Socket joint type
  89770. */
  89771. static BallAndSocketJoint: number;
  89772. /**
  89773. * Wheel-Joint type
  89774. */
  89775. static WheelJoint: number;
  89776. /**
  89777. * Slider-Joint type
  89778. */
  89779. static SliderJoint: number;
  89780. /**
  89781. * Prismatic-Joint type
  89782. */
  89783. static PrismaticJoint: number;
  89784. /**
  89785. * Universal-Joint type
  89786. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89787. */
  89788. static UniversalJoint: number;
  89789. /**
  89790. * Hinge-Joint 2 type
  89791. */
  89792. static Hinge2Joint: number;
  89793. /**
  89794. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89795. */
  89796. static PointToPointJoint: number;
  89797. /**
  89798. * Spring-Joint type
  89799. */
  89800. static SpringJoint: number;
  89801. /**
  89802. * Lock-Joint type
  89803. */
  89804. static LockJoint: number;
  89805. }
  89806. /**
  89807. * A class representing a physics distance joint
  89808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89809. */
  89810. export class DistanceJoint extends PhysicsJoint {
  89811. /**
  89812. *
  89813. * @param jointData The data for the Distance-Joint
  89814. */
  89815. constructor(jointData: DistanceJointData);
  89816. /**
  89817. * Update the predefined distance.
  89818. * @param maxDistance The maximum preferred distance
  89819. * @param minDistance The minimum preferred distance
  89820. */
  89821. updateDistance(maxDistance: number, minDistance?: number): void;
  89822. }
  89823. /**
  89824. * Represents a Motor-Enabled Joint
  89825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89826. */
  89827. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89828. /**
  89829. * Initializes the Motor-Enabled Joint
  89830. * @param type The type of the joint
  89831. * @param jointData The physica joint data for the joint
  89832. */
  89833. constructor(type: number, jointData: PhysicsJointData);
  89834. /**
  89835. * Set the motor values.
  89836. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89837. * @param force the force to apply
  89838. * @param maxForce max force for this motor.
  89839. */
  89840. setMotor(force?: number, maxForce?: number): void;
  89841. /**
  89842. * Set the motor's limits.
  89843. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89844. * @param upperLimit The upper limit of the motor
  89845. * @param lowerLimit The lower limit of the motor
  89846. */
  89847. setLimit(upperLimit: number, lowerLimit?: number): void;
  89848. }
  89849. /**
  89850. * This class represents a single physics Hinge-Joint
  89851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89852. */
  89853. export class HingeJoint extends MotorEnabledJoint {
  89854. /**
  89855. * Initializes the Hinge-Joint
  89856. * @param jointData The joint data for the Hinge-Joint
  89857. */
  89858. constructor(jointData: PhysicsJointData);
  89859. /**
  89860. * Set the motor values.
  89861. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89862. * @param {number} force the force to apply
  89863. * @param {number} maxForce max force for this motor.
  89864. */
  89865. setMotor(force?: number, maxForce?: number): void;
  89866. /**
  89867. * Set the motor's limits.
  89868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89869. * @param upperLimit The upper limit of the motor
  89870. * @param lowerLimit The lower limit of the motor
  89871. */
  89872. setLimit(upperLimit: number, lowerLimit?: number): void;
  89873. }
  89874. /**
  89875. * This class represents a dual hinge physics joint (same as wheel joint)
  89876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89877. */
  89878. export class Hinge2Joint extends MotorEnabledJoint {
  89879. /**
  89880. * Initializes the Hinge2-Joint
  89881. * @param jointData The joint data for the Hinge2-Joint
  89882. */
  89883. constructor(jointData: PhysicsJointData);
  89884. /**
  89885. * Set the motor values.
  89886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89887. * @param {number} targetSpeed the speed the motor is to reach
  89888. * @param {number} maxForce max force for this motor.
  89889. * @param {motorIndex} the motor's index, 0 or 1.
  89890. */
  89891. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89892. /**
  89893. * Set the motor limits.
  89894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89895. * @param {number} upperLimit the upper limit
  89896. * @param {number} lowerLimit lower limit
  89897. * @param {motorIndex} the motor's index, 0 or 1.
  89898. */
  89899. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89900. }
  89901. /**
  89902. * Interface for a motor enabled joint
  89903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89904. */
  89905. export interface IMotorEnabledJoint {
  89906. /**
  89907. * Physics joint
  89908. */
  89909. physicsJoint: any;
  89910. /**
  89911. * Sets the motor of the motor-enabled joint
  89912. * @param force The force of the motor
  89913. * @param maxForce The maximum force of the motor
  89914. * @param motorIndex The index of the motor
  89915. */
  89916. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89917. /**
  89918. * Sets the limit of the motor
  89919. * @param upperLimit The upper limit of the motor
  89920. * @param lowerLimit The lower limit of the motor
  89921. * @param motorIndex The index of the motor
  89922. */
  89923. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89924. }
  89925. /**
  89926. * Joint data for a Distance-Joint
  89927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89928. */
  89929. export interface DistanceJointData extends PhysicsJointData {
  89930. /**
  89931. * Max distance the 2 joint objects can be apart
  89932. */
  89933. maxDistance: number;
  89934. }
  89935. /**
  89936. * Joint data from a spring joint
  89937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89938. */
  89939. export interface SpringJointData extends PhysicsJointData {
  89940. /**
  89941. * Length of the spring
  89942. */
  89943. length: number;
  89944. /**
  89945. * Stiffness of the spring
  89946. */
  89947. stiffness: number;
  89948. /**
  89949. * Damping of the spring
  89950. */
  89951. damping: number;
  89952. /** this callback will be called when applying the force to the impostors. */
  89953. forceApplicationCallback: () => void;
  89954. }
  89955. }
  89956. declare module BABYLON {
  89957. /**
  89958. * Holds the data for the raycast result
  89959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89960. */
  89961. export class PhysicsRaycastResult {
  89962. private _hasHit;
  89963. private _hitDistance;
  89964. private _hitNormalWorld;
  89965. private _hitPointWorld;
  89966. private _rayFromWorld;
  89967. private _rayToWorld;
  89968. /**
  89969. * Gets if there was a hit
  89970. */
  89971. readonly hasHit: boolean;
  89972. /**
  89973. * Gets the distance from the hit
  89974. */
  89975. readonly hitDistance: number;
  89976. /**
  89977. * Gets the hit normal/direction in the world
  89978. */
  89979. readonly hitNormalWorld: Vector3;
  89980. /**
  89981. * Gets the hit point in the world
  89982. */
  89983. readonly hitPointWorld: Vector3;
  89984. /**
  89985. * Gets the ray "start point" of the ray in the world
  89986. */
  89987. readonly rayFromWorld: Vector3;
  89988. /**
  89989. * Gets the ray "end point" of the ray in the world
  89990. */
  89991. readonly rayToWorld: Vector3;
  89992. /**
  89993. * Sets the hit data (normal & point in world space)
  89994. * @param hitNormalWorld defines the normal in world space
  89995. * @param hitPointWorld defines the point in world space
  89996. */
  89997. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89998. /**
  89999. * Sets the distance from the start point to the hit point
  90000. * @param distance
  90001. */
  90002. setHitDistance(distance: number): void;
  90003. /**
  90004. * Calculates the distance manually
  90005. */
  90006. calculateHitDistance(): void;
  90007. /**
  90008. * Resets all the values to default
  90009. * @param from The from point on world space
  90010. * @param to The to point on world space
  90011. */
  90012. reset(from?: Vector3, to?: Vector3): void;
  90013. }
  90014. /**
  90015. * Interface for the size containing width and height
  90016. */
  90017. interface IXYZ {
  90018. /**
  90019. * X
  90020. */
  90021. x: number;
  90022. /**
  90023. * Y
  90024. */
  90025. y: number;
  90026. /**
  90027. * Z
  90028. */
  90029. z: number;
  90030. }
  90031. }
  90032. declare module BABYLON {
  90033. /**
  90034. * Interface used to describe a physics joint
  90035. */
  90036. export interface PhysicsImpostorJoint {
  90037. /** Defines the main impostor to which the joint is linked */
  90038. mainImpostor: PhysicsImpostor;
  90039. /** Defines the impostor that is connected to the main impostor using this joint */
  90040. connectedImpostor: PhysicsImpostor;
  90041. /** Defines the joint itself */
  90042. joint: PhysicsJoint;
  90043. }
  90044. /** @hidden */
  90045. export interface IPhysicsEnginePlugin {
  90046. world: any;
  90047. name: string;
  90048. setGravity(gravity: Vector3): void;
  90049. setTimeStep(timeStep: number): void;
  90050. getTimeStep(): number;
  90051. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90052. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90053. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90054. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90055. removePhysicsBody(impostor: PhysicsImpostor): void;
  90056. generateJoint(joint: PhysicsImpostorJoint): void;
  90057. removeJoint(joint: PhysicsImpostorJoint): void;
  90058. isSupported(): boolean;
  90059. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90060. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90061. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90062. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90063. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90064. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90065. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90066. getBodyMass(impostor: PhysicsImpostor): number;
  90067. getBodyFriction(impostor: PhysicsImpostor): number;
  90068. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90069. getBodyRestitution(impostor: PhysicsImpostor): number;
  90070. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90071. getBodyPressure?(impostor: PhysicsImpostor): number;
  90072. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90073. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90074. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90075. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90076. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90077. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90078. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90079. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90080. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90081. sleepBody(impostor: PhysicsImpostor): void;
  90082. wakeUpBody(impostor: PhysicsImpostor): void;
  90083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90084. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90085. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90086. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90087. getRadius(impostor: PhysicsImpostor): number;
  90088. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90089. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90090. dispose(): void;
  90091. }
  90092. /**
  90093. * Interface used to define a physics engine
  90094. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90095. */
  90096. export interface IPhysicsEngine {
  90097. /**
  90098. * Gets the gravity vector used by the simulation
  90099. */
  90100. gravity: Vector3;
  90101. /**
  90102. * Sets the gravity vector used by the simulation
  90103. * @param gravity defines the gravity vector to use
  90104. */
  90105. setGravity(gravity: Vector3): void;
  90106. /**
  90107. * Set the time step of the physics engine.
  90108. * Default is 1/60.
  90109. * To slow it down, enter 1/600 for example.
  90110. * To speed it up, 1/30
  90111. * @param newTimeStep the new timestep to apply to this world.
  90112. */
  90113. setTimeStep(newTimeStep: number): void;
  90114. /**
  90115. * Get the time step of the physics engine.
  90116. * @returns the current time step
  90117. */
  90118. getTimeStep(): number;
  90119. /**
  90120. * Release all resources
  90121. */
  90122. dispose(): void;
  90123. /**
  90124. * Gets the name of the current physics plugin
  90125. * @returns the name of the plugin
  90126. */
  90127. getPhysicsPluginName(): string;
  90128. /**
  90129. * Adding a new impostor for the impostor tracking.
  90130. * This will be done by the impostor itself.
  90131. * @param impostor the impostor to add
  90132. */
  90133. addImpostor(impostor: PhysicsImpostor): void;
  90134. /**
  90135. * Remove an impostor from the engine.
  90136. * This impostor and its mesh will not longer be updated by the physics engine.
  90137. * @param impostor the impostor to remove
  90138. */
  90139. removeImpostor(impostor: PhysicsImpostor): void;
  90140. /**
  90141. * Add a joint to the physics engine
  90142. * @param mainImpostor defines the main impostor to which the joint is added.
  90143. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90144. * @param joint defines the joint that will connect both impostors.
  90145. */
  90146. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90147. /**
  90148. * Removes a joint from the simulation
  90149. * @param mainImpostor defines the impostor used with the joint
  90150. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90151. * @param joint defines the joint to remove
  90152. */
  90153. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90154. /**
  90155. * Gets the current plugin used to run the simulation
  90156. * @returns current plugin
  90157. */
  90158. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90159. /**
  90160. * Gets the list of physic impostors
  90161. * @returns an array of PhysicsImpostor
  90162. */
  90163. getImpostors(): Array<PhysicsImpostor>;
  90164. /**
  90165. * Gets the impostor for a physics enabled object
  90166. * @param object defines the object impersonated by the impostor
  90167. * @returns the PhysicsImpostor or null if not found
  90168. */
  90169. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90170. /**
  90171. * Gets the impostor for a physics body object
  90172. * @param body defines physics body used by the impostor
  90173. * @returns the PhysicsImpostor or null if not found
  90174. */
  90175. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90176. /**
  90177. * Does a raycast in the physics world
  90178. * @param from when should the ray start?
  90179. * @param to when should the ray end?
  90180. * @returns PhysicsRaycastResult
  90181. */
  90182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90183. /**
  90184. * Called by the scene. No need to call it.
  90185. * @param delta defines the timespam between frames
  90186. */
  90187. _step(delta: number): void;
  90188. }
  90189. }
  90190. declare module BABYLON {
  90191. /**
  90192. * The interface for the physics imposter parameters
  90193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90194. */
  90195. export interface PhysicsImpostorParameters {
  90196. /**
  90197. * The mass of the physics imposter
  90198. */
  90199. mass: number;
  90200. /**
  90201. * The friction of the physics imposter
  90202. */
  90203. friction?: number;
  90204. /**
  90205. * The coefficient of restitution of the physics imposter
  90206. */
  90207. restitution?: number;
  90208. /**
  90209. * The native options of the physics imposter
  90210. */
  90211. nativeOptions?: any;
  90212. /**
  90213. * Specifies if the parent should be ignored
  90214. */
  90215. ignoreParent?: boolean;
  90216. /**
  90217. * Specifies if bi-directional transformations should be disabled
  90218. */
  90219. disableBidirectionalTransformation?: boolean;
  90220. /**
  90221. * The pressure inside the physics imposter, soft object only
  90222. */
  90223. pressure?: number;
  90224. /**
  90225. * The stiffness the physics imposter, soft object only
  90226. */
  90227. stiffness?: number;
  90228. /**
  90229. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90230. */
  90231. velocityIterations?: number;
  90232. /**
  90233. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90234. */
  90235. positionIterations?: number;
  90236. /**
  90237. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90238. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90239. * Add to fix multiple points
  90240. */
  90241. fixedPoints?: number;
  90242. /**
  90243. * The collision margin around a soft object
  90244. */
  90245. margin?: number;
  90246. /**
  90247. * The collision margin around a soft object
  90248. */
  90249. damping?: number;
  90250. /**
  90251. * The path for a rope based on an extrusion
  90252. */
  90253. path?: any;
  90254. /**
  90255. * The shape of an extrusion used for a rope based on an extrusion
  90256. */
  90257. shape?: any;
  90258. }
  90259. /**
  90260. * Interface for a physics-enabled object
  90261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90262. */
  90263. export interface IPhysicsEnabledObject {
  90264. /**
  90265. * The position of the physics-enabled object
  90266. */
  90267. position: Vector3;
  90268. /**
  90269. * The rotation of the physics-enabled object
  90270. */
  90271. rotationQuaternion: Nullable<Quaternion>;
  90272. /**
  90273. * The scale of the physics-enabled object
  90274. */
  90275. scaling: Vector3;
  90276. /**
  90277. * The rotation of the physics-enabled object
  90278. */
  90279. rotation?: Vector3;
  90280. /**
  90281. * The parent of the physics-enabled object
  90282. */
  90283. parent?: any;
  90284. /**
  90285. * The bounding info of the physics-enabled object
  90286. * @returns The bounding info of the physics-enabled object
  90287. */
  90288. getBoundingInfo(): BoundingInfo;
  90289. /**
  90290. * Computes the world matrix
  90291. * @param force Specifies if the world matrix should be computed by force
  90292. * @returns A world matrix
  90293. */
  90294. computeWorldMatrix(force: boolean): Matrix;
  90295. /**
  90296. * Gets the world matrix
  90297. * @returns A world matrix
  90298. */
  90299. getWorldMatrix?(): Matrix;
  90300. /**
  90301. * Gets the child meshes
  90302. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90303. * @returns An array of abstract meshes
  90304. */
  90305. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90306. /**
  90307. * Gets the vertex data
  90308. * @param kind The type of vertex data
  90309. * @returns A nullable array of numbers, or a float32 array
  90310. */
  90311. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90312. /**
  90313. * Gets the indices from the mesh
  90314. * @returns A nullable array of index arrays
  90315. */
  90316. getIndices?(): Nullable<IndicesArray>;
  90317. /**
  90318. * Gets the scene from the mesh
  90319. * @returns the indices array or null
  90320. */
  90321. getScene?(): Scene;
  90322. /**
  90323. * Gets the absolute position from the mesh
  90324. * @returns the absolute position
  90325. */
  90326. getAbsolutePosition(): Vector3;
  90327. /**
  90328. * Gets the absolute pivot point from the mesh
  90329. * @returns the absolute pivot point
  90330. */
  90331. getAbsolutePivotPoint(): Vector3;
  90332. /**
  90333. * Rotates the mesh
  90334. * @param axis The axis of rotation
  90335. * @param amount The amount of rotation
  90336. * @param space The space of the rotation
  90337. * @returns The rotation transform node
  90338. */
  90339. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90340. /**
  90341. * Translates the mesh
  90342. * @param axis The axis of translation
  90343. * @param distance The distance of translation
  90344. * @param space The space of the translation
  90345. * @returns The transform node
  90346. */
  90347. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90348. /**
  90349. * Sets the absolute position of the mesh
  90350. * @param absolutePosition The absolute position of the mesh
  90351. * @returns The transform node
  90352. */
  90353. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90354. /**
  90355. * Gets the class name of the mesh
  90356. * @returns The class name
  90357. */
  90358. getClassName(): string;
  90359. }
  90360. /**
  90361. * Represents a physics imposter
  90362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90363. */
  90364. export class PhysicsImpostor {
  90365. /**
  90366. * The physics-enabled object used as the physics imposter
  90367. */
  90368. object: IPhysicsEnabledObject;
  90369. /**
  90370. * The type of the physics imposter
  90371. */
  90372. type: number;
  90373. private _options;
  90374. private _scene?;
  90375. /**
  90376. * The default object size of the imposter
  90377. */
  90378. static DEFAULT_OBJECT_SIZE: Vector3;
  90379. /**
  90380. * The identity quaternion of the imposter
  90381. */
  90382. static IDENTITY_QUATERNION: Quaternion;
  90383. /** @hidden */
  90384. _pluginData: any;
  90385. private _physicsEngine;
  90386. private _physicsBody;
  90387. private _bodyUpdateRequired;
  90388. private _onBeforePhysicsStepCallbacks;
  90389. private _onAfterPhysicsStepCallbacks;
  90390. /** @hidden */
  90391. _onPhysicsCollideCallbacks: Array<{
  90392. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90393. otherImpostors: Array<PhysicsImpostor>;
  90394. }>;
  90395. private _deltaPosition;
  90396. private _deltaRotation;
  90397. private _deltaRotationConjugated;
  90398. /** @hidden */
  90399. _isFromLine: boolean;
  90400. private _parent;
  90401. private _isDisposed;
  90402. private static _tmpVecs;
  90403. private static _tmpQuat;
  90404. /**
  90405. * Specifies if the physics imposter is disposed
  90406. */
  90407. readonly isDisposed: boolean;
  90408. /**
  90409. * Gets the mass of the physics imposter
  90410. */
  90411. mass: number;
  90412. /**
  90413. * Gets the coefficient of friction
  90414. */
  90415. /**
  90416. * Sets the coefficient of friction
  90417. */
  90418. friction: number;
  90419. /**
  90420. * Gets the coefficient of restitution
  90421. */
  90422. /**
  90423. * Sets the coefficient of restitution
  90424. */
  90425. restitution: number;
  90426. /**
  90427. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90428. */
  90429. /**
  90430. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90431. */
  90432. pressure: number;
  90433. /**
  90434. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90435. */
  90436. /**
  90437. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90438. */
  90439. stiffness: number;
  90440. /**
  90441. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90442. */
  90443. /**
  90444. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90445. */
  90446. velocityIterations: number;
  90447. /**
  90448. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90449. */
  90450. /**
  90451. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90452. */
  90453. positionIterations: number;
  90454. /**
  90455. * The unique id of the physics imposter
  90456. * set by the physics engine when adding this impostor to the array
  90457. */
  90458. uniqueId: number;
  90459. /**
  90460. * @hidden
  90461. */
  90462. soft: boolean;
  90463. /**
  90464. * @hidden
  90465. */
  90466. segments: number;
  90467. private _joints;
  90468. /**
  90469. * Initializes the physics imposter
  90470. * @param object The physics-enabled object used as the physics imposter
  90471. * @param type The type of the physics imposter
  90472. * @param _options The options for the physics imposter
  90473. * @param _scene The Babylon scene
  90474. */
  90475. constructor(
  90476. /**
  90477. * The physics-enabled object used as the physics imposter
  90478. */
  90479. object: IPhysicsEnabledObject,
  90480. /**
  90481. * The type of the physics imposter
  90482. */
  90483. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90484. /**
  90485. * This function will completly initialize this impostor.
  90486. * It will create a new body - but only if this mesh has no parent.
  90487. * If it has, this impostor will not be used other than to define the impostor
  90488. * of the child mesh.
  90489. * @hidden
  90490. */
  90491. _init(): void;
  90492. private _getPhysicsParent;
  90493. /**
  90494. * Should a new body be generated.
  90495. * @returns boolean specifying if body initialization is required
  90496. */
  90497. isBodyInitRequired(): boolean;
  90498. /**
  90499. * Sets the updated scaling
  90500. * @param updated Specifies if the scaling is updated
  90501. */
  90502. setScalingUpdated(): void;
  90503. /**
  90504. * Force a regeneration of this or the parent's impostor's body.
  90505. * Use under cautious - This will remove all joints already implemented.
  90506. */
  90507. forceUpdate(): void;
  90508. /**
  90509. * Gets the body that holds this impostor. Either its own, or its parent.
  90510. */
  90511. /**
  90512. * Set the physics body. Used mainly by the physics engine/plugin
  90513. */
  90514. physicsBody: any;
  90515. /**
  90516. * Get the parent of the physics imposter
  90517. * @returns Physics imposter or null
  90518. */
  90519. /**
  90520. * Sets the parent of the physics imposter
  90521. */
  90522. parent: Nullable<PhysicsImpostor>;
  90523. /**
  90524. * Resets the update flags
  90525. */
  90526. resetUpdateFlags(): void;
  90527. /**
  90528. * Gets the object extend size
  90529. * @returns the object extend size
  90530. */
  90531. getObjectExtendSize(): Vector3;
  90532. /**
  90533. * Gets the object center
  90534. * @returns The object center
  90535. */
  90536. getObjectCenter(): Vector3;
  90537. /**
  90538. * Get a specific parametes from the options parameter
  90539. * @param paramName The object parameter name
  90540. * @returns The object parameter
  90541. */
  90542. getParam(paramName: string): any;
  90543. /**
  90544. * Sets a specific parameter in the options given to the physics plugin
  90545. * @param paramName The parameter name
  90546. * @param value The value of the parameter
  90547. */
  90548. setParam(paramName: string, value: number): void;
  90549. /**
  90550. * Specifically change the body's mass option. Won't recreate the physics body object
  90551. * @param mass The mass of the physics imposter
  90552. */
  90553. setMass(mass: number): void;
  90554. /**
  90555. * Gets the linear velocity
  90556. * @returns linear velocity or null
  90557. */
  90558. getLinearVelocity(): Nullable<Vector3>;
  90559. /**
  90560. * Sets the linear velocity
  90561. * @param velocity linear velocity or null
  90562. */
  90563. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90564. /**
  90565. * Gets the angular velocity
  90566. * @returns angular velocity or null
  90567. */
  90568. getAngularVelocity(): Nullable<Vector3>;
  90569. /**
  90570. * Sets the angular velocity
  90571. * @param velocity The velocity or null
  90572. */
  90573. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90574. /**
  90575. * Execute a function with the physics plugin native code
  90576. * Provide a function the will have two variables - the world object and the physics body object
  90577. * @param func The function to execute with the physics plugin native code
  90578. */
  90579. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90580. /**
  90581. * Register a function that will be executed before the physics world is stepping forward
  90582. * @param func The function to execute before the physics world is stepped forward
  90583. */
  90584. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90585. /**
  90586. * Unregister a function that will be executed before the physics world is stepping forward
  90587. * @param func The function to execute before the physics world is stepped forward
  90588. */
  90589. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90590. /**
  90591. * Register a function that will be executed after the physics step
  90592. * @param func The function to execute after physics step
  90593. */
  90594. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90595. /**
  90596. * Unregisters a function that will be executed after the physics step
  90597. * @param func The function to execute after physics step
  90598. */
  90599. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90600. /**
  90601. * register a function that will be executed when this impostor collides against a different body
  90602. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90603. * @param func Callback that is executed on collision
  90604. */
  90605. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90606. /**
  90607. * Unregisters the physics imposter on contact
  90608. * @param collideAgainst The physics object to collide against
  90609. * @param func Callback to execute on collision
  90610. */
  90611. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90612. private _tmpQuat;
  90613. private _tmpQuat2;
  90614. /**
  90615. * Get the parent rotation
  90616. * @returns The parent rotation
  90617. */
  90618. getParentsRotation(): Quaternion;
  90619. /**
  90620. * this function is executed by the physics engine.
  90621. */
  90622. beforeStep: () => void;
  90623. /**
  90624. * this function is executed by the physics engine
  90625. */
  90626. afterStep: () => void;
  90627. /**
  90628. * Legacy collision detection event support
  90629. */
  90630. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90631. /**
  90632. * event and body object due to cannon's event-based architecture.
  90633. */
  90634. onCollide: (e: {
  90635. body: any;
  90636. }) => void;
  90637. /**
  90638. * Apply a force
  90639. * @param force The force to apply
  90640. * @param contactPoint The contact point for the force
  90641. * @returns The physics imposter
  90642. */
  90643. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90644. /**
  90645. * Apply an impulse
  90646. * @param force The impulse force
  90647. * @param contactPoint The contact point for the impulse force
  90648. * @returns The physics imposter
  90649. */
  90650. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90651. /**
  90652. * A help function to create a joint
  90653. * @param otherImpostor A physics imposter used to create a joint
  90654. * @param jointType The type of joint
  90655. * @param jointData The data for the joint
  90656. * @returns The physics imposter
  90657. */
  90658. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90659. /**
  90660. * Add a joint to this impostor with a different impostor
  90661. * @param otherImpostor A physics imposter used to add a joint
  90662. * @param joint The joint to add
  90663. * @returns The physics imposter
  90664. */
  90665. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90666. /**
  90667. * Add an anchor to a cloth impostor
  90668. * @param otherImpostor rigid impostor to anchor to
  90669. * @param width ratio across width from 0 to 1
  90670. * @param height ratio up height from 0 to 1
  90671. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90672. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90673. * @returns impostor the soft imposter
  90674. */
  90675. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90676. /**
  90677. * Add a hook to a rope impostor
  90678. * @param otherImpostor rigid impostor to anchor to
  90679. * @param length ratio across rope from 0 to 1
  90680. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90681. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90682. * @returns impostor the rope imposter
  90683. */
  90684. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90685. /**
  90686. * Will keep this body still, in a sleep mode.
  90687. * @returns the physics imposter
  90688. */
  90689. sleep(): PhysicsImpostor;
  90690. /**
  90691. * Wake the body up.
  90692. * @returns The physics imposter
  90693. */
  90694. wakeUp(): PhysicsImpostor;
  90695. /**
  90696. * Clones the physics imposter
  90697. * @param newObject The physics imposter clones to this physics-enabled object
  90698. * @returns A nullable physics imposter
  90699. */
  90700. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90701. /**
  90702. * Disposes the physics imposter
  90703. */
  90704. dispose(): void;
  90705. /**
  90706. * Sets the delta position
  90707. * @param position The delta position amount
  90708. */
  90709. setDeltaPosition(position: Vector3): void;
  90710. /**
  90711. * Sets the delta rotation
  90712. * @param rotation The delta rotation amount
  90713. */
  90714. setDeltaRotation(rotation: Quaternion): void;
  90715. /**
  90716. * Gets the box size of the physics imposter and stores the result in the input parameter
  90717. * @param result Stores the box size
  90718. * @returns The physics imposter
  90719. */
  90720. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90721. /**
  90722. * Gets the radius of the physics imposter
  90723. * @returns Radius of the physics imposter
  90724. */
  90725. getRadius(): number;
  90726. /**
  90727. * Sync a bone with this impostor
  90728. * @param bone The bone to sync to the impostor.
  90729. * @param boneMesh The mesh that the bone is influencing.
  90730. * @param jointPivot The pivot of the joint / bone in local space.
  90731. * @param distToJoint Optional distance from the impostor to the joint.
  90732. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90733. */
  90734. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90735. /**
  90736. * Sync impostor to a bone
  90737. * @param bone The bone that the impostor will be synced to.
  90738. * @param boneMesh The mesh that the bone is influencing.
  90739. * @param jointPivot The pivot of the joint / bone in local space.
  90740. * @param distToJoint Optional distance from the impostor to the joint.
  90741. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90742. * @param boneAxis Optional vector3 axis the bone is aligned with
  90743. */
  90744. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90745. /**
  90746. * No-Imposter type
  90747. */
  90748. static NoImpostor: number;
  90749. /**
  90750. * Sphere-Imposter type
  90751. */
  90752. static SphereImpostor: number;
  90753. /**
  90754. * Box-Imposter type
  90755. */
  90756. static BoxImpostor: number;
  90757. /**
  90758. * Plane-Imposter type
  90759. */
  90760. static PlaneImpostor: number;
  90761. /**
  90762. * Mesh-imposter type
  90763. */
  90764. static MeshImpostor: number;
  90765. /**
  90766. * Capsule-Impostor type (Ammo.js plugin only)
  90767. */
  90768. static CapsuleImpostor: number;
  90769. /**
  90770. * Cylinder-Imposter type
  90771. */
  90772. static CylinderImpostor: number;
  90773. /**
  90774. * Particle-Imposter type
  90775. */
  90776. static ParticleImpostor: number;
  90777. /**
  90778. * Heightmap-Imposter type
  90779. */
  90780. static HeightmapImpostor: number;
  90781. /**
  90782. * ConvexHull-Impostor type (Ammo.js plugin only)
  90783. */
  90784. static ConvexHullImpostor: number;
  90785. /**
  90786. * Rope-Imposter type
  90787. */
  90788. static RopeImpostor: number;
  90789. /**
  90790. * Cloth-Imposter type
  90791. */
  90792. static ClothImpostor: number;
  90793. /**
  90794. * Softbody-Imposter type
  90795. */
  90796. static SoftbodyImpostor: number;
  90797. }
  90798. }
  90799. declare module BABYLON {
  90800. /**
  90801. * @hidden
  90802. **/
  90803. export class _CreationDataStorage {
  90804. closePath?: boolean;
  90805. closeArray?: boolean;
  90806. idx: number[];
  90807. dashSize: number;
  90808. gapSize: number;
  90809. path3D: Path3D;
  90810. pathArray: Vector3[][];
  90811. arc: number;
  90812. radius: number;
  90813. cap: number;
  90814. tessellation: number;
  90815. }
  90816. /**
  90817. * @hidden
  90818. **/
  90819. class _InstanceDataStorage {
  90820. visibleInstances: any;
  90821. batchCache: _InstancesBatch;
  90822. instancesBufferSize: number;
  90823. instancesBuffer: Nullable<Buffer>;
  90824. instancesData: Float32Array;
  90825. overridenInstanceCount: number;
  90826. isFrozen: boolean;
  90827. previousBatch: Nullable<_InstancesBatch>;
  90828. hardwareInstancedRendering: boolean;
  90829. sideOrientation: number;
  90830. }
  90831. /**
  90832. * @hidden
  90833. **/
  90834. export class _InstancesBatch {
  90835. mustReturn: boolean;
  90836. visibleInstances: Nullable<InstancedMesh[]>[];
  90837. renderSelf: boolean[];
  90838. hardwareInstancedRendering: boolean[];
  90839. }
  90840. /**
  90841. * Class used to represent renderable models
  90842. */
  90843. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90844. /**
  90845. * Mesh side orientation : usually the external or front surface
  90846. */
  90847. static readonly FRONTSIDE: number;
  90848. /**
  90849. * Mesh side orientation : usually the internal or back surface
  90850. */
  90851. static readonly BACKSIDE: number;
  90852. /**
  90853. * Mesh side orientation : both internal and external or front and back surfaces
  90854. */
  90855. static readonly DOUBLESIDE: number;
  90856. /**
  90857. * Mesh side orientation : by default, `FRONTSIDE`
  90858. */
  90859. static readonly DEFAULTSIDE: number;
  90860. /**
  90861. * Mesh cap setting : no cap
  90862. */
  90863. static readonly NO_CAP: number;
  90864. /**
  90865. * Mesh cap setting : one cap at the beginning of the mesh
  90866. */
  90867. static readonly CAP_START: number;
  90868. /**
  90869. * Mesh cap setting : one cap at the end of the mesh
  90870. */
  90871. static readonly CAP_END: number;
  90872. /**
  90873. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90874. */
  90875. static readonly CAP_ALL: number;
  90876. /**
  90877. * Mesh pattern setting : no flip or rotate
  90878. */
  90879. static readonly NO_FLIP: number;
  90880. /**
  90881. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90882. */
  90883. static readonly FLIP_TILE: number;
  90884. /**
  90885. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90886. */
  90887. static readonly ROTATE_TILE: number;
  90888. /**
  90889. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90890. */
  90891. static readonly FLIP_ROW: number;
  90892. /**
  90893. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90894. */
  90895. static readonly ROTATE_ROW: number;
  90896. /**
  90897. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90898. */
  90899. static readonly FLIP_N_ROTATE_TILE: number;
  90900. /**
  90901. * Mesh pattern setting : rotate pattern and rotate
  90902. */
  90903. static readonly FLIP_N_ROTATE_ROW: number;
  90904. /**
  90905. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90906. */
  90907. static readonly CENTER: number;
  90908. /**
  90909. * Mesh tile positioning : part tiles on left
  90910. */
  90911. static readonly LEFT: number;
  90912. /**
  90913. * Mesh tile positioning : part tiles on right
  90914. */
  90915. static readonly RIGHT: number;
  90916. /**
  90917. * Mesh tile positioning : part tiles on top
  90918. */
  90919. static readonly TOP: number;
  90920. /**
  90921. * Mesh tile positioning : part tiles on bottom
  90922. */
  90923. static readonly BOTTOM: number;
  90924. /**
  90925. * Gets the default side orientation.
  90926. * @param orientation the orientation to value to attempt to get
  90927. * @returns the default orientation
  90928. * @hidden
  90929. */
  90930. static _GetDefaultSideOrientation(orientation?: number): number;
  90931. private _internalMeshDataInfo;
  90932. /**
  90933. * An event triggered before rendering the mesh
  90934. */
  90935. readonly onBeforeRenderObservable: Observable<Mesh>;
  90936. /**
  90937. * An event triggered before binding the mesh
  90938. */
  90939. readonly onBeforeBindObservable: Observable<Mesh>;
  90940. /**
  90941. * An event triggered after rendering the mesh
  90942. */
  90943. readonly onAfterRenderObservable: Observable<Mesh>;
  90944. /**
  90945. * An event triggered before drawing the mesh
  90946. */
  90947. readonly onBeforeDrawObservable: Observable<Mesh>;
  90948. private _onBeforeDrawObserver;
  90949. /**
  90950. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90951. */
  90952. onBeforeDraw: () => void;
  90953. readonly hasInstances: boolean;
  90954. /**
  90955. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90956. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90957. */
  90958. delayLoadState: number;
  90959. /**
  90960. * Gets the list of instances created from this mesh
  90961. * it is not supposed to be modified manually.
  90962. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90963. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90964. */
  90965. instances: InstancedMesh[];
  90966. /**
  90967. * Gets the file containing delay loading data for this mesh
  90968. */
  90969. delayLoadingFile: string;
  90970. /** @hidden */
  90971. _binaryInfo: any;
  90972. /**
  90973. * User defined function used to change how LOD level selection is done
  90974. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90975. */
  90976. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90977. /**
  90978. * Gets or sets the morph target manager
  90979. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90980. */
  90981. morphTargetManager: Nullable<MorphTargetManager>;
  90982. /** @hidden */
  90983. _creationDataStorage: Nullable<_CreationDataStorage>;
  90984. /** @hidden */
  90985. _geometry: Nullable<Geometry>;
  90986. /** @hidden */
  90987. _delayInfo: Array<string>;
  90988. /** @hidden */
  90989. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90990. /** @hidden */
  90991. _instanceDataStorage: _InstanceDataStorage;
  90992. private _effectiveMaterial;
  90993. /** @hidden */
  90994. _shouldGenerateFlatShading: boolean;
  90995. /** @hidden */
  90996. _originalBuilderSideOrientation: number;
  90997. /**
  90998. * Use this property to change the original side orientation defined at construction time
  90999. */
  91000. overrideMaterialSideOrientation: Nullable<number>;
  91001. /**
  91002. * Gets the source mesh (the one used to clone this one from)
  91003. */
  91004. readonly source: Nullable<Mesh>;
  91005. /**
  91006. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91007. */
  91008. isUnIndexed: boolean;
  91009. /**
  91010. * @constructor
  91011. * @param name The value used by scene.getMeshByName() to do a lookup.
  91012. * @param scene The scene to add this mesh to.
  91013. * @param parent The parent of this mesh, if it has one
  91014. * @param source An optional Mesh from which geometry is shared, cloned.
  91015. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91016. * When false, achieved by calling a clone(), also passing False.
  91017. * This will make creation of children, recursive.
  91018. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91019. */
  91020. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91021. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  91022. /**
  91023. * Gets the class name
  91024. * @returns the string "Mesh".
  91025. */
  91026. getClassName(): string;
  91027. /** @hidden */
  91028. readonly _isMesh: boolean;
  91029. /**
  91030. * Returns a description of this mesh
  91031. * @param fullDetails define if full details about this mesh must be used
  91032. * @returns a descriptive string representing this mesh
  91033. */
  91034. toString(fullDetails?: boolean): string;
  91035. /** @hidden */
  91036. _unBindEffect(): void;
  91037. /**
  91038. * Gets a boolean indicating if this mesh has LOD
  91039. */
  91040. readonly hasLODLevels: boolean;
  91041. /**
  91042. * Gets the list of MeshLODLevel associated with the current mesh
  91043. * @returns an array of MeshLODLevel
  91044. */
  91045. getLODLevels(): MeshLODLevel[];
  91046. private _sortLODLevels;
  91047. /**
  91048. * Add a mesh as LOD level triggered at the given distance.
  91049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91050. * @param distance The distance from the center of the object to show this level
  91051. * @param mesh The mesh to be added as LOD level (can be null)
  91052. * @return This mesh (for chaining)
  91053. */
  91054. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91055. /**
  91056. * Returns the LOD level mesh at the passed distance or null if not found.
  91057. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91058. * @param distance The distance from the center of the object to show this level
  91059. * @returns a Mesh or `null`
  91060. */
  91061. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91062. /**
  91063. * Remove a mesh from the LOD array
  91064. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91065. * @param mesh defines the mesh to be removed
  91066. * @return This mesh (for chaining)
  91067. */
  91068. removeLODLevel(mesh: Mesh): Mesh;
  91069. /**
  91070. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91072. * @param camera defines the camera to use to compute distance
  91073. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91074. * @return This mesh (for chaining)
  91075. */
  91076. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91077. /**
  91078. * Gets the mesh internal Geometry object
  91079. */
  91080. readonly geometry: Nullable<Geometry>;
  91081. /**
  91082. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91083. * @returns the total number of vertices
  91084. */
  91085. getTotalVertices(): number;
  91086. /**
  91087. * Returns the content of an associated vertex buffer
  91088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91089. * - VertexBuffer.PositionKind
  91090. * - VertexBuffer.UVKind
  91091. * - VertexBuffer.UV2Kind
  91092. * - VertexBuffer.UV3Kind
  91093. * - VertexBuffer.UV4Kind
  91094. * - VertexBuffer.UV5Kind
  91095. * - VertexBuffer.UV6Kind
  91096. * - VertexBuffer.ColorKind
  91097. * - VertexBuffer.MatricesIndicesKind
  91098. * - VertexBuffer.MatricesIndicesExtraKind
  91099. * - VertexBuffer.MatricesWeightsKind
  91100. * - VertexBuffer.MatricesWeightsExtraKind
  91101. * @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
  91102. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91103. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91104. */
  91105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91106. /**
  91107. * Returns the mesh VertexBuffer object from the requested `kind`
  91108. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91109. * - VertexBuffer.PositionKind
  91110. * - VertexBuffer.NormalKind
  91111. * - VertexBuffer.UVKind
  91112. * - VertexBuffer.UV2Kind
  91113. * - VertexBuffer.UV3Kind
  91114. * - VertexBuffer.UV4Kind
  91115. * - VertexBuffer.UV5Kind
  91116. * - VertexBuffer.UV6Kind
  91117. * - VertexBuffer.ColorKind
  91118. * - VertexBuffer.MatricesIndicesKind
  91119. * - VertexBuffer.MatricesIndicesExtraKind
  91120. * - VertexBuffer.MatricesWeightsKind
  91121. * - VertexBuffer.MatricesWeightsExtraKind
  91122. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91123. */
  91124. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91125. /**
  91126. * Tests if a specific vertex buffer is associated with this mesh
  91127. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91128. * - VertexBuffer.PositionKind
  91129. * - VertexBuffer.NormalKind
  91130. * - VertexBuffer.UVKind
  91131. * - VertexBuffer.UV2Kind
  91132. * - VertexBuffer.UV3Kind
  91133. * - VertexBuffer.UV4Kind
  91134. * - VertexBuffer.UV5Kind
  91135. * - VertexBuffer.UV6Kind
  91136. * - VertexBuffer.ColorKind
  91137. * - VertexBuffer.MatricesIndicesKind
  91138. * - VertexBuffer.MatricesIndicesExtraKind
  91139. * - VertexBuffer.MatricesWeightsKind
  91140. * - VertexBuffer.MatricesWeightsExtraKind
  91141. * @returns a boolean
  91142. */
  91143. isVerticesDataPresent(kind: string): boolean;
  91144. /**
  91145. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91146. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91147. * - VertexBuffer.PositionKind
  91148. * - VertexBuffer.UVKind
  91149. * - VertexBuffer.UV2Kind
  91150. * - VertexBuffer.UV3Kind
  91151. * - VertexBuffer.UV4Kind
  91152. * - VertexBuffer.UV5Kind
  91153. * - VertexBuffer.UV6Kind
  91154. * - VertexBuffer.ColorKind
  91155. * - VertexBuffer.MatricesIndicesKind
  91156. * - VertexBuffer.MatricesIndicesExtraKind
  91157. * - VertexBuffer.MatricesWeightsKind
  91158. * - VertexBuffer.MatricesWeightsExtraKind
  91159. * @returns a boolean
  91160. */
  91161. isVertexBufferUpdatable(kind: string): boolean;
  91162. /**
  91163. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91164. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91165. * - VertexBuffer.PositionKind
  91166. * - VertexBuffer.NormalKind
  91167. * - VertexBuffer.UVKind
  91168. * - VertexBuffer.UV2Kind
  91169. * - VertexBuffer.UV3Kind
  91170. * - VertexBuffer.UV4Kind
  91171. * - VertexBuffer.UV5Kind
  91172. * - VertexBuffer.UV6Kind
  91173. * - VertexBuffer.ColorKind
  91174. * - VertexBuffer.MatricesIndicesKind
  91175. * - VertexBuffer.MatricesIndicesExtraKind
  91176. * - VertexBuffer.MatricesWeightsKind
  91177. * - VertexBuffer.MatricesWeightsExtraKind
  91178. * @returns an array of strings
  91179. */
  91180. getVerticesDataKinds(): string[];
  91181. /**
  91182. * Returns a positive integer : the total number of indices in this mesh geometry.
  91183. * @returns the numner of indices or zero if the mesh has no geometry.
  91184. */
  91185. getTotalIndices(): number;
  91186. /**
  91187. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91188. * @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.
  91189. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91190. * @returns the indices array or an empty array if the mesh has no geometry
  91191. */
  91192. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91193. readonly isBlocked: boolean;
  91194. /**
  91195. * Determine if the current mesh is ready to be rendered
  91196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91197. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91198. * @returns true if all associated assets are ready (material, textures, shaders)
  91199. */
  91200. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91201. /**
  91202. * 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.
  91203. */
  91204. readonly areNormalsFrozen: boolean;
  91205. /**
  91206. * 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.
  91207. * @returns the current mesh
  91208. */
  91209. freezeNormals(): Mesh;
  91210. /**
  91211. * 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
  91212. * @returns the current mesh
  91213. */
  91214. unfreezeNormals(): Mesh;
  91215. /**
  91216. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91217. */
  91218. overridenInstanceCount: number;
  91219. /** @hidden */
  91220. _preActivate(): Mesh;
  91221. /** @hidden */
  91222. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91223. /** @hidden */
  91224. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91225. /**
  91226. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91227. * This means the mesh underlying bounding box and sphere are recomputed.
  91228. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91229. * @returns the current mesh
  91230. */
  91231. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91232. /** @hidden */
  91233. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91234. /**
  91235. * This function will subdivide the mesh into multiple submeshes
  91236. * @param count defines the expected number of submeshes
  91237. */
  91238. subdivide(count: number): void;
  91239. /**
  91240. * Copy a FloatArray into a specific associated vertex buffer
  91241. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91242. * - VertexBuffer.PositionKind
  91243. * - VertexBuffer.UVKind
  91244. * - VertexBuffer.UV2Kind
  91245. * - VertexBuffer.UV3Kind
  91246. * - VertexBuffer.UV4Kind
  91247. * - VertexBuffer.UV5Kind
  91248. * - VertexBuffer.UV6Kind
  91249. * - VertexBuffer.ColorKind
  91250. * - VertexBuffer.MatricesIndicesKind
  91251. * - VertexBuffer.MatricesIndicesExtraKind
  91252. * - VertexBuffer.MatricesWeightsKind
  91253. * - VertexBuffer.MatricesWeightsExtraKind
  91254. * @param data defines the data source
  91255. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91256. * @param stride defines the data stride size (can be null)
  91257. * @returns the current mesh
  91258. */
  91259. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91260. /**
  91261. * Delete a vertex buffer associated with this mesh
  91262. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91263. * - VertexBuffer.PositionKind
  91264. * - VertexBuffer.UVKind
  91265. * - VertexBuffer.UV2Kind
  91266. * - VertexBuffer.UV3Kind
  91267. * - VertexBuffer.UV4Kind
  91268. * - VertexBuffer.UV5Kind
  91269. * - VertexBuffer.UV6Kind
  91270. * - VertexBuffer.ColorKind
  91271. * - VertexBuffer.MatricesIndicesKind
  91272. * - VertexBuffer.MatricesIndicesExtraKind
  91273. * - VertexBuffer.MatricesWeightsKind
  91274. * - VertexBuffer.MatricesWeightsExtraKind
  91275. */
  91276. removeVerticesData(kind: string): void;
  91277. /**
  91278. * Flags an associated vertex buffer as updatable
  91279. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91280. * - VertexBuffer.PositionKind
  91281. * - VertexBuffer.UVKind
  91282. * - VertexBuffer.UV2Kind
  91283. * - VertexBuffer.UV3Kind
  91284. * - VertexBuffer.UV4Kind
  91285. * - VertexBuffer.UV5Kind
  91286. * - VertexBuffer.UV6Kind
  91287. * - VertexBuffer.ColorKind
  91288. * - VertexBuffer.MatricesIndicesKind
  91289. * - VertexBuffer.MatricesIndicesExtraKind
  91290. * - VertexBuffer.MatricesWeightsKind
  91291. * - VertexBuffer.MatricesWeightsExtraKind
  91292. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91293. */
  91294. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91295. /**
  91296. * Sets the mesh global Vertex Buffer
  91297. * @param buffer defines the buffer to use
  91298. * @returns the current mesh
  91299. */
  91300. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91301. /**
  91302. * Update a specific associated vertex buffer
  91303. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91304. * - VertexBuffer.PositionKind
  91305. * - VertexBuffer.UVKind
  91306. * - VertexBuffer.UV2Kind
  91307. * - VertexBuffer.UV3Kind
  91308. * - VertexBuffer.UV4Kind
  91309. * - VertexBuffer.UV5Kind
  91310. * - VertexBuffer.UV6Kind
  91311. * - VertexBuffer.ColorKind
  91312. * - VertexBuffer.MatricesIndicesKind
  91313. * - VertexBuffer.MatricesIndicesExtraKind
  91314. * - VertexBuffer.MatricesWeightsKind
  91315. * - VertexBuffer.MatricesWeightsExtraKind
  91316. * @param data defines the data source
  91317. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91318. * @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)
  91319. * @returns the current mesh
  91320. */
  91321. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91322. /**
  91323. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91324. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91325. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91326. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91327. * @returns the current mesh
  91328. */
  91329. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91330. /**
  91331. * Creates a un-shared specific occurence of the geometry for the mesh.
  91332. * @returns the current mesh
  91333. */
  91334. makeGeometryUnique(): Mesh;
  91335. /**
  91336. * Set the index buffer of this mesh
  91337. * @param indices defines the source data
  91338. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91339. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91340. * @returns the current mesh
  91341. */
  91342. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91343. /**
  91344. * Update the current index buffer
  91345. * @param indices defines the source data
  91346. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91347. * @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)
  91348. * @returns the current mesh
  91349. */
  91350. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91351. /**
  91352. * Invert the geometry to move from a right handed system to a left handed one.
  91353. * @returns the current mesh
  91354. */
  91355. toLeftHanded(): Mesh;
  91356. /** @hidden */
  91357. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91358. /** @hidden */
  91359. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91360. /**
  91361. * Registers for this mesh a javascript function called just before the rendering process
  91362. * @param func defines the function to call before rendering this mesh
  91363. * @returns the current mesh
  91364. */
  91365. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91366. /**
  91367. * Disposes a previously registered javascript function called before the rendering
  91368. * @param func defines the function to remove
  91369. * @returns the current mesh
  91370. */
  91371. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91372. /**
  91373. * Registers for this mesh a javascript function called just after the rendering is complete
  91374. * @param func defines the function to call after rendering this mesh
  91375. * @returns the current mesh
  91376. */
  91377. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91378. /**
  91379. * Disposes a previously registered javascript function called after the rendering.
  91380. * @param func defines the function to remove
  91381. * @returns the current mesh
  91382. */
  91383. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91384. /** @hidden */
  91385. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91386. /** @hidden */
  91387. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91388. /** @hidden */
  91389. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91390. /** @hidden */
  91391. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91392. /** @hidden */
  91393. _rebuild(): void;
  91394. /** @hidden */
  91395. _freeze(): void;
  91396. /** @hidden */
  91397. _unFreeze(): void;
  91398. /**
  91399. * 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
  91400. * @param subMesh defines the subMesh to render
  91401. * @param enableAlphaMode defines if alpha mode can be changed
  91402. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91403. * @returns the current mesh
  91404. */
  91405. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91406. private _onBeforeDraw;
  91407. /**
  91408. * Renormalize the mesh and patch it up if there are no weights
  91409. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91410. * However in the case of zero weights then we set just a single influence to 1.
  91411. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91412. */
  91413. cleanMatrixWeights(): void;
  91414. private normalizeSkinFourWeights;
  91415. private normalizeSkinWeightsAndExtra;
  91416. /**
  91417. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91418. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91419. * the user know there was an issue with importing the mesh
  91420. * @returns a validation object with skinned, valid and report string
  91421. */
  91422. validateSkinning(): {
  91423. skinned: boolean;
  91424. valid: boolean;
  91425. report: string;
  91426. };
  91427. /** @hidden */
  91428. _checkDelayState(): Mesh;
  91429. private _queueLoad;
  91430. /**
  91431. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91432. * A mesh is in the frustum if its bounding box intersects the frustum
  91433. * @param frustumPlanes defines the frustum to test
  91434. * @returns true if the mesh is in the frustum planes
  91435. */
  91436. isInFrustum(frustumPlanes: Plane[]): boolean;
  91437. /**
  91438. * Sets the mesh material by the material or multiMaterial `id` property
  91439. * @param id is a string identifying the material or the multiMaterial
  91440. * @returns the current mesh
  91441. */
  91442. setMaterialByID(id: string): Mesh;
  91443. /**
  91444. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91445. * @returns an array of IAnimatable
  91446. */
  91447. getAnimatables(): IAnimatable[];
  91448. /**
  91449. * Modifies the mesh geometry according to the passed transformation matrix.
  91450. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91451. * The mesh normals are modified using the same transformation.
  91452. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91453. * @param transform defines the transform matrix to use
  91454. * @see http://doc.babylonjs.com/resources/baking_transformations
  91455. * @returns the current mesh
  91456. */
  91457. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91458. /**
  91459. * Modifies the mesh geometry according to its own current World Matrix.
  91460. * The mesh World Matrix is then reset.
  91461. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91462. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91463. * @see http://doc.babylonjs.com/resources/baking_transformations
  91464. * @returns the current mesh
  91465. */
  91466. bakeCurrentTransformIntoVertices(): Mesh;
  91467. /** @hidden */
  91468. readonly _positions: Nullable<Vector3[]>;
  91469. /** @hidden */
  91470. _resetPointsArrayCache(): Mesh;
  91471. /** @hidden */
  91472. _generatePointsArray(): boolean;
  91473. /**
  91474. * Returns a new Mesh object generated from the current mesh properties.
  91475. * This method must not get confused with createInstance()
  91476. * @param name is a string, the name given to the new mesh
  91477. * @param newParent can be any Node object (default `null`)
  91478. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91479. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91480. * @returns a new mesh
  91481. */
  91482. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91483. /**
  91484. * Releases resources associated with this mesh.
  91485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91487. */
  91488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91489. /** @hidden */
  91490. _disposeInstanceSpecificData(): void;
  91491. /**
  91492. * Modifies the mesh geometry according to a displacement map.
  91493. * 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.
  91494. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91495. * @param url is a string, the URL from the image file is to be downloaded.
  91496. * @param minHeight is the lower limit of the displacement.
  91497. * @param maxHeight is the upper limit of the displacement.
  91498. * @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.
  91499. * @param uvOffset is an optional vector2 used to offset UV.
  91500. * @param uvScale is an optional vector2 used to scale UV.
  91501. * @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.
  91502. * @returns the Mesh.
  91503. */
  91504. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91505. /**
  91506. * Modifies the mesh geometry according to a displacementMap buffer.
  91507. * 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.
  91508. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91509. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91510. * @param heightMapWidth is the width of the buffer image.
  91511. * @param heightMapHeight is the height of the buffer image.
  91512. * @param minHeight is the lower limit of the displacement.
  91513. * @param maxHeight is the upper limit of the displacement.
  91514. * @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.
  91515. * @param uvOffset is an optional vector2 used to offset UV.
  91516. * @param uvScale is an optional vector2 used to scale UV.
  91517. * @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.
  91518. * @returns the Mesh.
  91519. */
  91520. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91521. /**
  91522. * Modify the mesh to get a flat shading rendering.
  91523. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91524. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91525. * @returns current mesh
  91526. */
  91527. convertToFlatShadedMesh(): Mesh;
  91528. /**
  91529. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91530. * In other words, more vertices, no more indices and a single bigger VBO.
  91531. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91532. * @returns current mesh
  91533. */
  91534. convertToUnIndexedMesh(): Mesh;
  91535. /**
  91536. * Inverses facet orientations.
  91537. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91538. * @param flipNormals will also inverts the normals
  91539. * @returns current mesh
  91540. */
  91541. flipFaces(flipNormals?: boolean): Mesh;
  91542. /**
  91543. * Increase the number of facets and hence vertices in a mesh
  91544. * Vertex normals are interpolated from existing vertex normals
  91545. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91546. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91547. */
  91548. increaseVertices(numberPerEdge: number): void;
  91549. /**
  91550. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91551. * This will undo any application of covertToFlatShadedMesh
  91552. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91553. */
  91554. forceSharedVertices(): void;
  91555. /** @hidden */
  91556. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91557. /** @hidden */
  91558. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91559. /**
  91560. * Creates a new InstancedMesh object from the mesh model.
  91561. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91562. * @param name defines the name of the new instance
  91563. * @returns a new InstancedMesh
  91564. */
  91565. createInstance(name: string): InstancedMesh;
  91566. /**
  91567. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91568. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91569. * @returns the current mesh
  91570. */
  91571. synchronizeInstances(): Mesh;
  91572. /**
  91573. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91574. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91575. * This should be used together with the simplification to avoid disappearing triangles.
  91576. * @param successCallback an optional success callback to be called after the optimization finished.
  91577. * @returns the current mesh
  91578. */
  91579. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91580. /**
  91581. * Serialize current mesh
  91582. * @param serializationObject defines the object which will receive the serialization data
  91583. */
  91584. serialize(serializationObject: any): void;
  91585. /** @hidden */
  91586. _syncGeometryWithMorphTargetManager(): void;
  91587. /** @hidden */
  91588. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91589. /**
  91590. * Returns a new Mesh object parsed from the source provided.
  91591. * @param parsedMesh is the source
  91592. * @param scene defines the hosting scene
  91593. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91594. * @returns a new Mesh
  91595. */
  91596. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91597. /**
  91598. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91599. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91600. * @param name defines the name of the mesh to create
  91601. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91602. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91603. * @param closePath creates a seam between the first and the last points of each path of the path array
  91604. * @param offset is taken in account only if the `pathArray` is containing a single path
  91605. * @param scene defines the hosting scene
  91606. * @param updatable defines if the mesh must be flagged as updatable
  91607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91608. * @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)
  91609. * @returns a new Mesh
  91610. */
  91611. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91612. /**
  91613. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91614. * @param name defines the name of the mesh to create
  91615. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91616. * @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
  91617. * @param scene defines the hosting scene
  91618. * @param updatable defines if the mesh must be flagged as updatable
  91619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91620. * @returns a new Mesh
  91621. */
  91622. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91623. /**
  91624. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91625. * @param name defines the name of the mesh to create
  91626. * @param size sets the size (float) of each box side (default 1)
  91627. * @param scene defines the hosting scene
  91628. * @param updatable defines if the mesh must be flagged as updatable
  91629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91630. * @returns a new Mesh
  91631. */
  91632. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91633. /**
  91634. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91635. * @param name defines the name of the mesh to create
  91636. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91637. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91638. * @param scene defines the hosting scene
  91639. * @param updatable defines if the mesh must be flagged as updatable
  91640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91641. * @returns a new Mesh
  91642. */
  91643. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91644. /**
  91645. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91646. * @param name defines the name of the mesh to create
  91647. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91648. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91649. * @param scene defines the hosting scene
  91650. * @returns a new Mesh
  91651. */
  91652. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91653. /**
  91654. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91655. * @param name defines the name of the mesh to create
  91656. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91657. * @param diameterTop set the top cap diameter (floats, default 1)
  91658. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91659. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91660. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91661. * @param scene defines the hosting scene
  91662. * @param updatable defines if the mesh must be flagged as updatable
  91663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91664. * @returns a new Mesh
  91665. */
  91666. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91667. /**
  91668. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91669. * @param name defines the name of the mesh to create
  91670. * @param diameter sets the diameter size (float) of the torus (default 1)
  91671. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91672. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91673. * @param scene defines the hosting scene
  91674. * @param updatable defines if the mesh must be flagged as updatable
  91675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91676. * @returns a new Mesh
  91677. */
  91678. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91679. /**
  91680. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91681. * @param name defines the name of the mesh to create
  91682. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91683. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91684. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91685. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91686. * @param p the number of windings on X axis (positive integers, default 2)
  91687. * @param q the number of windings on Y axis (positive integers, default 3)
  91688. * @param scene defines the hosting scene
  91689. * @param updatable defines if the mesh must be flagged as updatable
  91690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91691. * @returns a new Mesh
  91692. */
  91693. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91694. /**
  91695. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91696. * @param name defines the name of the mesh to create
  91697. * @param points is an array successive Vector3
  91698. * @param scene defines the hosting scene
  91699. * @param updatable defines if the mesh must be flagged as updatable
  91700. * @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).
  91701. * @returns a new Mesh
  91702. */
  91703. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91704. /**
  91705. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91706. * @param name defines the name of the mesh to create
  91707. * @param points is an array successive Vector3
  91708. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91709. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91710. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91711. * @param scene defines the hosting scene
  91712. * @param updatable defines if the mesh must be flagged as updatable
  91713. * @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)
  91714. * @returns a new Mesh
  91715. */
  91716. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91717. /**
  91718. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91719. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91720. * 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.
  91721. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91722. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91723. * Remember you can only change the shape positions, not their number when updating a polygon.
  91724. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91725. * @param name defines the name of the mesh to create
  91726. * @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
  91727. * @param scene defines the hosting scene
  91728. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91729. * @param updatable defines if the mesh must be flagged as updatable
  91730. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91731. * @param earcutInjection can be used to inject your own earcut reference
  91732. * @returns a new Mesh
  91733. */
  91734. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91735. /**
  91736. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91737. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91738. * @param name defines the name of the mesh to create
  91739. * @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
  91740. * @param depth defines the height of extrusion
  91741. * @param scene defines the hosting scene
  91742. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91743. * @param updatable defines if the mesh must be flagged as updatable
  91744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91745. * @param earcutInjection can be used to inject your own earcut reference
  91746. * @returns a new Mesh
  91747. */
  91748. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91749. /**
  91750. * Creates an extruded shape mesh.
  91751. * 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
  91752. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91753. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91754. * @param name defines the name of the mesh to create
  91755. * @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
  91756. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91757. * @param scale is the value to scale the shape
  91758. * @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
  91759. * @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
  91760. * @param scene defines the hosting scene
  91761. * @param updatable defines if the mesh must be flagged as updatable
  91762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91763. * @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)
  91764. * @returns a new Mesh
  91765. */
  91766. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91767. /**
  91768. * Creates an custom extruded shape mesh.
  91769. * The custom extrusion is a parametric shape.
  91770. * It has no predefined shape. Its final shape will depend on the input parameters.
  91771. * Please consider using the same method from the MeshBuilder class instead
  91772. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91773. * @param name defines the name of the mesh to create
  91774. * @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
  91775. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91776. * @param scaleFunction is a custom Javascript function called on each path point
  91777. * @param rotationFunction is a custom Javascript function called on each path point
  91778. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91779. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91780. * @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
  91781. * @param scene defines the hosting scene
  91782. * @param updatable defines if the mesh must be flagged as updatable
  91783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91784. * @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)
  91785. * @returns a new Mesh
  91786. */
  91787. 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;
  91788. /**
  91789. * Creates lathe mesh.
  91790. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91791. * Please consider using the same method from the MeshBuilder class instead
  91792. * @param name defines the name of the mesh to create
  91793. * @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
  91794. * @param radius is the radius value of the lathe
  91795. * @param tessellation is the side number of the lathe.
  91796. * @param scene defines the hosting scene
  91797. * @param updatable defines if the mesh must be flagged as updatable
  91798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91799. * @returns a new Mesh
  91800. */
  91801. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91802. /**
  91803. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91804. * @param name defines the name of the mesh to create
  91805. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91806. * @param scene defines the hosting scene
  91807. * @param updatable defines if the mesh must be flagged as updatable
  91808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91809. * @returns a new Mesh
  91810. */
  91811. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91812. /**
  91813. * Creates a ground mesh.
  91814. * Please consider using the same method from the MeshBuilder class instead
  91815. * @param name defines the name of the mesh to create
  91816. * @param width set the width of the ground
  91817. * @param height set the height of the ground
  91818. * @param subdivisions sets the number of subdivisions per side
  91819. * @param scene defines the hosting scene
  91820. * @param updatable defines if the mesh must be flagged as updatable
  91821. * @returns a new Mesh
  91822. */
  91823. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91824. /**
  91825. * Creates a tiled ground mesh.
  91826. * Please consider using the same method from the MeshBuilder class instead
  91827. * @param name defines the name of the mesh to create
  91828. * @param xmin set the ground minimum X coordinate
  91829. * @param zmin set the ground minimum Y coordinate
  91830. * @param xmax set the ground maximum X coordinate
  91831. * @param zmax set the ground maximum Z coordinate
  91832. * @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
  91833. * @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
  91834. * @param scene defines the hosting scene
  91835. * @param updatable defines if the mesh must be flagged as updatable
  91836. * @returns a new Mesh
  91837. */
  91838. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91839. w: number;
  91840. h: number;
  91841. }, precision: {
  91842. w: number;
  91843. h: number;
  91844. }, scene: Scene, updatable?: boolean): Mesh;
  91845. /**
  91846. * Creates a ground mesh from a height map.
  91847. * Please consider using the same method from the MeshBuilder class instead
  91848. * @see http://doc.babylonjs.com/babylon101/height_map
  91849. * @param name defines the name of the mesh to create
  91850. * @param url sets the URL of the height map image resource
  91851. * @param width set the ground width size
  91852. * @param height set the ground height size
  91853. * @param subdivisions sets the number of subdivision per side
  91854. * @param minHeight is the minimum altitude on the ground
  91855. * @param maxHeight is the maximum altitude on the ground
  91856. * @param scene defines the hosting scene
  91857. * @param updatable defines if the mesh must be flagged as updatable
  91858. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91859. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91860. * @returns a new Mesh
  91861. */
  91862. 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;
  91863. /**
  91864. * Creates a tube mesh.
  91865. * The tube is a parametric shape.
  91866. * It has no predefined shape. Its final shape will depend on the input parameters.
  91867. * Please consider using the same method from the MeshBuilder class instead
  91868. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91869. * @param name defines the name of the mesh to create
  91870. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91871. * @param radius sets the tube radius size
  91872. * @param tessellation is the number of sides on the tubular surface
  91873. * @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
  91874. * @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
  91875. * @param scene defines the hosting scene
  91876. * @param updatable defines if the mesh must be flagged as updatable
  91877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91878. * @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)
  91879. * @returns a new Mesh
  91880. */
  91881. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91882. (i: number, distance: number): number;
  91883. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91884. /**
  91885. * Creates a polyhedron mesh.
  91886. * Please consider using the same method from the MeshBuilder class instead.
  91887. * * 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
  91888. * * The parameter `size` (positive float, default 1) sets the polygon size
  91889. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91890. * * 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`
  91891. * * 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
  91892. * * 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)`)
  91893. * * 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
  91894. * * 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
  91895. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91896. * * If you create a double-sided mesh, you can choose what parts of 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
  91897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91898. * @param name defines the name of the mesh to create
  91899. * @param options defines the options used to create the mesh
  91900. * @param scene defines the hosting scene
  91901. * @returns a new Mesh
  91902. */
  91903. static CreatePolyhedron(name: string, options: {
  91904. type?: number;
  91905. size?: number;
  91906. sizeX?: number;
  91907. sizeY?: number;
  91908. sizeZ?: number;
  91909. custom?: any;
  91910. faceUV?: Vector4[];
  91911. faceColors?: Color4[];
  91912. updatable?: boolean;
  91913. sideOrientation?: number;
  91914. }, scene: Scene): Mesh;
  91915. /**
  91916. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91917. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91918. * * 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`)
  91919. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91920. * * 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
  91921. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91922. * * If you create a double-sided mesh, you can choose what parts of 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
  91923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91924. * @param name defines the name of the mesh
  91925. * @param options defines the options used to create the mesh
  91926. * @param scene defines the hosting scene
  91927. * @returns a new Mesh
  91928. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91929. */
  91930. static CreateIcoSphere(name: string, options: {
  91931. radius?: number;
  91932. flat?: boolean;
  91933. subdivisions?: number;
  91934. sideOrientation?: number;
  91935. updatable?: boolean;
  91936. }, scene: Scene): Mesh;
  91937. /**
  91938. * Creates a decal mesh.
  91939. * Please consider using the same method from the MeshBuilder class instead.
  91940. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91941. * @param name defines the name of the mesh
  91942. * @param sourceMesh defines the mesh receiving the decal
  91943. * @param position sets the position of the decal in world coordinates
  91944. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91945. * @param size sets the decal scaling
  91946. * @param angle sets the angle to rotate the decal
  91947. * @returns a new Mesh
  91948. */
  91949. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91950. /**
  91951. * Prepare internal position array for software CPU skinning
  91952. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91953. */
  91954. setPositionsForCPUSkinning(): Float32Array;
  91955. /**
  91956. * Prepare internal normal array for software CPU skinning
  91957. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91958. */
  91959. setNormalsForCPUSkinning(): Float32Array;
  91960. /**
  91961. * Updates the vertex buffer by applying transformation from the bones
  91962. * @param skeleton defines the skeleton to apply to current mesh
  91963. * @returns the current mesh
  91964. */
  91965. applySkeleton(skeleton: Skeleton): Mesh;
  91966. /**
  91967. * 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
  91968. * @param meshes defines the list of meshes to scan
  91969. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91970. */
  91971. static MinMax(meshes: AbstractMesh[]): {
  91972. min: Vector3;
  91973. max: Vector3;
  91974. };
  91975. /**
  91976. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91977. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91978. * @returns a vector3
  91979. */
  91980. static Center(meshesOrMinMaxVector: {
  91981. min: Vector3;
  91982. max: Vector3;
  91983. } | AbstractMesh[]): Vector3;
  91984. /**
  91985. * Merge the array of meshes into a single mesh for performance reasons.
  91986. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91987. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91988. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91989. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91990. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91991. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91992. * @returns a new mesh
  91993. */
  91994. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91995. /** @hidden */
  91996. addInstance(instance: InstancedMesh): void;
  91997. /** @hidden */
  91998. removeInstance(instance: InstancedMesh): void;
  91999. }
  92000. }
  92001. declare module BABYLON {
  92002. /**
  92003. * This is the base class of all the camera used in the application.
  92004. * @see http://doc.babylonjs.com/features/cameras
  92005. */
  92006. export class Camera extends Node {
  92007. /** @hidden */
  92008. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92009. /**
  92010. * This is the default projection mode used by the cameras.
  92011. * It helps recreating a feeling of perspective and better appreciate depth.
  92012. * This is the best way to simulate real life cameras.
  92013. */
  92014. static readonly PERSPECTIVE_CAMERA: number;
  92015. /**
  92016. * This helps creating camera with an orthographic mode.
  92017. * 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.
  92018. */
  92019. static readonly ORTHOGRAPHIC_CAMERA: number;
  92020. /**
  92021. * This is the default FOV mode for perspective cameras.
  92022. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92023. */
  92024. static readonly FOVMODE_VERTICAL_FIXED: number;
  92025. /**
  92026. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92027. */
  92028. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92029. /**
  92030. * This specifies ther is no need for a camera rig.
  92031. * Basically only one eye is rendered corresponding to the camera.
  92032. */
  92033. static readonly RIG_MODE_NONE: number;
  92034. /**
  92035. * Simulates a camera Rig with one blue eye and one red eye.
  92036. * This can be use with 3d blue and red glasses.
  92037. */
  92038. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92039. /**
  92040. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92041. */
  92042. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92043. /**
  92044. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92045. */
  92046. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92047. /**
  92048. * Defines that both eyes of the camera will be rendered over under each other.
  92049. */
  92050. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92051. /**
  92052. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92053. */
  92054. static readonly RIG_MODE_VR: number;
  92055. /**
  92056. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92057. */
  92058. static readonly RIG_MODE_WEBVR: number;
  92059. /**
  92060. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92061. */
  92062. static readonly RIG_MODE_CUSTOM: number;
  92063. /**
  92064. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92065. */
  92066. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92067. /**
  92068. * Define the input manager associated with the camera.
  92069. */
  92070. inputs: CameraInputsManager<Camera>;
  92071. /** @hidden */
  92072. _position: Vector3;
  92073. /**
  92074. * Define the current local position of the camera in the scene
  92075. */
  92076. position: Vector3;
  92077. /**
  92078. * The vector the camera should consider as up.
  92079. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92080. */
  92081. upVector: Vector3;
  92082. /**
  92083. * Define the current limit on the left side for an orthographic camera
  92084. * In scene unit
  92085. */
  92086. orthoLeft: Nullable<number>;
  92087. /**
  92088. * Define the current limit on the right side for an orthographic camera
  92089. * In scene unit
  92090. */
  92091. orthoRight: Nullable<number>;
  92092. /**
  92093. * Define the current limit on the bottom side for an orthographic camera
  92094. * In scene unit
  92095. */
  92096. orthoBottom: Nullable<number>;
  92097. /**
  92098. * Define the current limit on the top side for an orthographic camera
  92099. * In scene unit
  92100. */
  92101. orthoTop: Nullable<number>;
  92102. /**
  92103. * Field Of View is set in Radians. (default is 0.8)
  92104. */
  92105. fov: number;
  92106. /**
  92107. * Define the minimum distance the camera can see from.
  92108. * This is important to note that the depth buffer are not infinite and the closer it starts
  92109. * the more your scene might encounter depth fighting issue.
  92110. */
  92111. minZ: number;
  92112. /**
  92113. * Define the maximum distance the camera can see to.
  92114. * This is important to note that the depth buffer are not infinite and the further it end
  92115. * the more your scene might encounter depth fighting issue.
  92116. */
  92117. maxZ: number;
  92118. /**
  92119. * Define the default inertia of the camera.
  92120. * This helps giving a smooth feeling to the camera movement.
  92121. */
  92122. inertia: number;
  92123. /**
  92124. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92125. */
  92126. mode: number;
  92127. /**
  92128. * Define wether the camera is intermediate.
  92129. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92130. */
  92131. isIntermediate: boolean;
  92132. /**
  92133. * Define the viewport of the camera.
  92134. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92135. */
  92136. viewport: Viewport;
  92137. /**
  92138. * Restricts the camera to viewing objects with the same layerMask.
  92139. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92140. */
  92141. layerMask: number;
  92142. /**
  92143. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92144. */
  92145. fovMode: number;
  92146. /**
  92147. * Rig mode of the camera.
  92148. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92149. * This is normally controlled byt the camera themselves as internal use.
  92150. */
  92151. cameraRigMode: number;
  92152. /**
  92153. * Defines the distance between both "eyes" in case of a RIG
  92154. */
  92155. interaxialDistance: number;
  92156. /**
  92157. * Defines if stereoscopic rendering is done side by side or over under.
  92158. */
  92159. isStereoscopicSideBySide: boolean;
  92160. /**
  92161. * 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
  92162. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92163. * else in the scene. (Eg. security camera)
  92164. *
  92165. * 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)
  92166. */
  92167. customRenderTargets: RenderTargetTexture[];
  92168. /**
  92169. * When set, the camera will render to this render target instead of the default canvas
  92170. *
  92171. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92172. */
  92173. outputRenderTarget: Nullable<RenderTargetTexture>;
  92174. /**
  92175. * Observable triggered when the camera view matrix has changed.
  92176. */
  92177. onViewMatrixChangedObservable: Observable<Camera>;
  92178. /**
  92179. * Observable triggered when the camera Projection matrix has changed.
  92180. */
  92181. onProjectionMatrixChangedObservable: Observable<Camera>;
  92182. /**
  92183. * Observable triggered when the inputs have been processed.
  92184. */
  92185. onAfterCheckInputsObservable: Observable<Camera>;
  92186. /**
  92187. * Observable triggered when reset has been called and applied to the camera.
  92188. */
  92189. onRestoreStateObservable: Observable<Camera>;
  92190. /** @hidden */
  92191. _cameraRigParams: any;
  92192. /** @hidden */
  92193. _rigCameras: Camera[];
  92194. /** @hidden */
  92195. _rigPostProcess: Nullable<PostProcess>;
  92196. protected _webvrViewMatrix: Matrix;
  92197. /** @hidden */
  92198. _skipRendering: boolean;
  92199. /** @hidden */
  92200. _projectionMatrix: Matrix;
  92201. /** @hidden */
  92202. _postProcesses: Nullable<PostProcess>[];
  92203. /** @hidden */
  92204. _activeMeshes: SmartArray<AbstractMesh>;
  92205. protected _globalPosition: Vector3;
  92206. /** @hidden */
  92207. _computedViewMatrix: Matrix;
  92208. private _doNotComputeProjectionMatrix;
  92209. private _transformMatrix;
  92210. private _frustumPlanes;
  92211. private _refreshFrustumPlanes;
  92212. private _storedFov;
  92213. private _stateStored;
  92214. /**
  92215. * Instantiates a new camera object.
  92216. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92217. * @see http://doc.babylonjs.com/features/cameras
  92218. * @param name Defines the name of the camera in the scene
  92219. * @param position Defines the position of the camera
  92220. * @param scene Defines the scene the camera belongs too
  92221. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92222. */
  92223. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92224. /**
  92225. * Store current camera state (fov, position, etc..)
  92226. * @returns the camera
  92227. */
  92228. storeState(): Camera;
  92229. /**
  92230. * Restores the camera state values if it has been stored. You must call storeState() first
  92231. */
  92232. protected _restoreStateValues(): boolean;
  92233. /**
  92234. * Restored camera state. You must call storeState() first.
  92235. * @returns true if restored and false otherwise
  92236. */
  92237. restoreState(): boolean;
  92238. /**
  92239. * Gets the class name of the camera.
  92240. * @returns the class name
  92241. */
  92242. getClassName(): string;
  92243. /** @hidden */
  92244. readonly _isCamera: boolean;
  92245. /**
  92246. * Gets a string representation of the camera useful for debug purpose.
  92247. * @param fullDetails Defines that a more verboe level of logging is required
  92248. * @returns the string representation
  92249. */
  92250. toString(fullDetails?: boolean): string;
  92251. /**
  92252. * Gets the current world space position of the camera.
  92253. */
  92254. readonly globalPosition: Vector3;
  92255. /**
  92256. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92257. * @returns the active meshe list
  92258. */
  92259. getActiveMeshes(): SmartArray<AbstractMesh>;
  92260. /**
  92261. * Check wether a mesh is part of the current active mesh list of the camera
  92262. * @param mesh Defines the mesh to check
  92263. * @returns true if active, false otherwise
  92264. */
  92265. isActiveMesh(mesh: Mesh): boolean;
  92266. /**
  92267. * Is this camera ready to be used/rendered
  92268. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92269. * @return true if the camera is ready
  92270. */
  92271. isReady(completeCheck?: boolean): boolean;
  92272. /** @hidden */
  92273. _initCache(): void;
  92274. /** @hidden */
  92275. _updateCache(ignoreParentClass?: boolean): void;
  92276. /** @hidden */
  92277. _isSynchronized(): boolean;
  92278. /** @hidden */
  92279. _isSynchronizedViewMatrix(): boolean;
  92280. /** @hidden */
  92281. _isSynchronizedProjectionMatrix(): boolean;
  92282. /**
  92283. * Attach the input controls to a specific dom element to get the input from.
  92284. * @param element Defines the element the controls should be listened from
  92285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92286. */
  92287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92288. /**
  92289. * Detach the current controls from the specified dom element.
  92290. * @param element Defines the element to stop listening the inputs from
  92291. */
  92292. detachControl(element: HTMLElement): void;
  92293. /**
  92294. * Update the camera state according to the different inputs gathered during the frame.
  92295. */
  92296. update(): void;
  92297. /** @hidden */
  92298. _checkInputs(): void;
  92299. /** @hidden */
  92300. readonly rigCameras: Camera[];
  92301. /**
  92302. * Gets the post process used by the rig cameras
  92303. */
  92304. readonly rigPostProcess: Nullable<PostProcess>;
  92305. /**
  92306. * Internal, gets the first post proces.
  92307. * @returns the first post process to be run on this camera.
  92308. */
  92309. _getFirstPostProcess(): Nullable<PostProcess>;
  92310. private _cascadePostProcessesToRigCams;
  92311. /**
  92312. * Attach a post process to the camera.
  92313. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92314. * @param postProcess The post process to attach to the camera
  92315. * @param insertAt The position of the post process in case several of them are in use in the scene
  92316. * @returns the position the post process has been inserted at
  92317. */
  92318. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92319. /**
  92320. * Detach a post process to the camera.
  92321. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92322. * @param postProcess The post process to detach from the camera
  92323. */
  92324. detachPostProcess(postProcess: PostProcess): void;
  92325. /**
  92326. * Gets the current world matrix of the camera
  92327. */
  92328. getWorldMatrix(): Matrix;
  92329. /** @hidden */
  92330. _getViewMatrix(): Matrix;
  92331. /**
  92332. * Gets the current view matrix of the camera.
  92333. * @param force forces the camera to recompute the matrix without looking at the cached state
  92334. * @returns the view matrix
  92335. */
  92336. getViewMatrix(force?: boolean): Matrix;
  92337. /**
  92338. * Freeze the projection matrix.
  92339. * It will prevent the cache check of the camera projection compute and can speed up perf
  92340. * if no parameter of the camera are meant to change
  92341. * @param projection Defines manually a projection if necessary
  92342. */
  92343. freezeProjectionMatrix(projection?: Matrix): void;
  92344. /**
  92345. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92346. */
  92347. unfreezeProjectionMatrix(): void;
  92348. /**
  92349. * Gets the current projection matrix of the camera.
  92350. * @param force forces the camera to recompute the matrix without looking at the cached state
  92351. * @returns the projection matrix
  92352. */
  92353. getProjectionMatrix(force?: boolean): Matrix;
  92354. /**
  92355. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92356. * @returns a Matrix
  92357. */
  92358. getTransformationMatrix(): Matrix;
  92359. private _updateFrustumPlanes;
  92360. /**
  92361. * Checks if a cullable object (mesh...) is in the camera frustum
  92362. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92363. * @param target The object to check
  92364. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92365. * @returns true if the object is in frustum otherwise false
  92366. */
  92367. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92368. /**
  92369. * Checks if a cullable object (mesh...) is in the camera frustum
  92370. * Unlike isInFrustum this cheks the full bounding box
  92371. * @param target The object to check
  92372. * @returns true if the object is in frustum otherwise false
  92373. */
  92374. isCompletelyInFrustum(target: ICullable): boolean;
  92375. /**
  92376. * Gets a ray in the forward direction from the camera.
  92377. * @param length Defines the length of the ray to create
  92378. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92379. * @param origin Defines the start point of the ray which defaults to the camera position
  92380. * @returns the forward ray
  92381. */
  92382. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92383. /**
  92384. * Releases resources associated with this node.
  92385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92387. */
  92388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92389. /** @hidden */
  92390. _isLeftCamera: boolean;
  92391. /**
  92392. * Gets the left camera of a rig setup in case of Rigged Camera
  92393. */
  92394. readonly isLeftCamera: boolean;
  92395. /** @hidden */
  92396. _isRightCamera: boolean;
  92397. /**
  92398. * Gets the right camera of a rig setup in case of Rigged Camera
  92399. */
  92400. readonly isRightCamera: boolean;
  92401. /**
  92402. * Gets the left camera of a rig setup in case of Rigged Camera
  92403. */
  92404. readonly leftCamera: Nullable<FreeCamera>;
  92405. /**
  92406. * Gets the right camera of a rig setup in case of Rigged Camera
  92407. */
  92408. readonly rightCamera: Nullable<FreeCamera>;
  92409. /**
  92410. * Gets the left camera target of a rig setup in case of Rigged Camera
  92411. * @returns the target position
  92412. */
  92413. getLeftTarget(): Nullable<Vector3>;
  92414. /**
  92415. * Gets the right camera target of a rig setup in case of Rigged Camera
  92416. * @returns the target position
  92417. */
  92418. getRightTarget(): Nullable<Vector3>;
  92419. /**
  92420. * @hidden
  92421. */
  92422. setCameraRigMode(mode: number, rigParams: any): void;
  92423. /** @hidden */
  92424. static _setStereoscopicRigMode(camera: Camera): void;
  92425. /** @hidden */
  92426. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92427. /** @hidden */
  92428. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92429. /** @hidden */
  92430. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92431. /** @hidden */
  92432. _getVRProjectionMatrix(): Matrix;
  92433. protected _updateCameraRotationMatrix(): void;
  92434. protected _updateWebVRCameraRotationMatrix(): void;
  92435. /**
  92436. * This function MUST be overwritten by the different WebVR cameras available.
  92437. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92438. * @hidden
  92439. */
  92440. _getWebVRProjectionMatrix(): Matrix;
  92441. /**
  92442. * This function MUST be overwritten by the different WebVR cameras available.
  92443. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92444. * @hidden
  92445. */
  92446. _getWebVRViewMatrix(): Matrix;
  92447. /** @hidden */
  92448. setCameraRigParameter(name: string, value: any): void;
  92449. /**
  92450. * needs to be overridden by children so sub has required properties to be copied
  92451. * @hidden
  92452. */
  92453. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92454. /**
  92455. * May need to be overridden by children
  92456. * @hidden
  92457. */
  92458. _updateRigCameras(): void;
  92459. /** @hidden */
  92460. _setupInputs(): void;
  92461. /**
  92462. * Serialiaze the camera setup to a json represention
  92463. * @returns the JSON representation
  92464. */
  92465. serialize(): any;
  92466. /**
  92467. * Clones the current camera.
  92468. * @param name The cloned camera name
  92469. * @returns the cloned camera
  92470. */
  92471. clone(name: string): Camera;
  92472. /**
  92473. * Gets the direction of the camera relative to a given local axis.
  92474. * @param localAxis Defines the reference axis to provide a relative direction.
  92475. * @return the direction
  92476. */
  92477. getDirection(localAxis: Vector3): Vector3;
  92478. /**
  92479. * Returns the current camera absolute rotation
  92480. */
  92481. readonly absoluteRotation: Quaternion;
  92482. /**
  92483. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92484. * @param localAxis Defines the reference axis to provide a relative direction.
  92485. * @param result Defines the vector to store the result in
  92486. */
  92487. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92488. /**
  92489. * Gets a camera constructor for a given camera type
  92490. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92491. * @param name The name of the camera the result will be able to instantiate
  92492. * @param scene The scene the result will construct the camera in
  92493. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92494. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92495. * @returns a factory method to construc the camera
  92496. */
  92497. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92498. /**
  92499. * Compute the world matrix of the camera.
  92500. * @returns the camera workd matrix
  92501. */
  92502. computeWorldMatrix(): Matrix;
  92503. /**
  92504. * Parse a JSON and creates the camera from the parsed information
  92505. * @param parsedCamera The JSON to parse
  92506. * @param scene The scene to instantiate the camera in
  92507. * @returns the newly constructed camera
  92508. */
  92509. static Parse(parsedCamera: any, scene: Scene): Camera;
  92510. }
  92511. }
  92512. declare module BABYLON {
  92513. /**
  92514. * Class containing static functions to help procedurally build meshes
  92515. */
  92516. export class DiscBuilder {
  92517. /**
  92518. * Creates a plane polygonal mesh. By default, this is a disc
  92519. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92520. * * 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
  92521. * * 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
  92522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92525. * @param name defines the name of the mesh
  92526. * @param options defines the options used to create the mesh
  92527. * @param scene defines the hosting scene
  92528. * @returns the plane polygonal mesh
  92529. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92530. */
  92531. static CreateDisc(name: string, options: {
  92532. radius?: number;
  92533. tessellation?: number;
  92534. arc?: number;
  92535. updatable?: boolean;
  92536. sideOrientation?: number;
  92537. frontUVs?: Vector4;
  92538. backUVs?: Vector4;
  92539. }, scene?: Nullable<Scene>): Mesh;
  92540. }
  92541. }
  92542. declare module BABYLON {
  92543. /**
  92544. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92545. *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.
  92546. * The SPS is also a particle system. It provides some methods to manage the particles.
  92547. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92548. *
  92549. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92550. */
  92551. export class SolidParticleSystem implements IDisposable {
  92552. /**
  92553. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92554. * Example : var p = SPS.particles[i];
  92555. */
  92556. particles: SolidParticle[];
  92557. /**
  92558. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92559. */
  92560. nbParticles: number;
  92561. /**
  92562. * If the particles must ever face the camera (default false). Useful for planar particles.
  92563. */
  92564. billboard: boolean;
  92565. /**
  92566. * Recompute normals when adding a shape
  92567. */
  92568. recomputeNormals: boolean;
  92569. /**
  92570. * This a counter ofr your own usage. It's not set by any SPS functions.
  92571. */
  92572. counter: number;
  92573. /**
  92574. * The SPS name. This name is also given to the underlying mesh.
  92575. */
  92576. name: string;
  92577. /**
  92578. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92579. */
  92580. mesh: Mesh;
  92581. /**
  92582. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92583. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92584. */
  92585. vars: any;
  92586. /**
  92587. * This array is populated when the SPS is set as 'pickable'.
  92588. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92589. * Each element of this array is an object `{idx: int, faceId: int}`.
  92590. * `idx` is the picked particle index in the `SPS.particles` array
  92591. * `faceId` is the picked face index counted within this particle.
  92592. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92593. */
  92594. pickedParticles: {
  92595. idx: number;
  92596. faceId: number;
  92597. }[];
  92598. /**
  92599. * This array is populated when `enableDepthSort` is set to true.
  92600. * Each element of this array is an instance of the class DepthSortedParticle.
  92601. */
  92602. depthSortedParticles: DepthSortedParticle[];
  92603. /**
  92604. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92605. * @hidden
  92606. */
  92607. _bSphereOnly: boolean;
  92608. /**
  92609. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92610. * @hidden
  92611. */
  92612. _bSphereRadiusFactor: number;
  92613. private _scene;
  92614. private _positions;
  92615. private _indices;
  92616. private _normals;
  92617. private _colors;
  92618. private _uvs;
  92619. private _indices32;
  92620. private _positions32;
  92621. private _normals32;
  92622. private _fixedNormal32;
  92623. private _colors32;
  92624. private _uvs32;
  92625. private _index;
  92626. private _updatable;
  92627. private _pickable;
  92628. private _isVisibilityBoxLocked;
  92629. private _alwaysVisible;
  92630. private _depthSort;
  92631. private _expandable;
  92632. private _shapeCounter;
  92633. private _copy;
  92634. private _color;
  92635. private _computeParticleColor;
  92636. private _computeParticleTexture;
  92637. private _computeParticleRotation;
  92638. private _computeParticleVertex;
  92639. private _computeBoundingBox;
  92640. private _depthSortParticles;
  92641. private _camera;
  92642. private _mustUnrotateFixedNormals;
  92643. private _particlesIntersect;
  92644. private _needs32Bits;
  92645. private _isNotBuilt;
  92646. /**
  92647. * Creates a SPS (Solid Particle System) object.
  92648. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92649. * @param scene (Scene) is the scene in which the SPS is added.
  92650. * @param options defines the options of the sps e.g.
  92651. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92652. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92653. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92654. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92655. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92656. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92657. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92658. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92659. */
  92660. constructor(name: string, scene: Scene, options?: {
  92661. updatable?: boolean;
  92662. isPickable?: boolean;
  92663. enableDepthSort?: boolean;
  92664. particleIntersection?: boolean;
  92665. boundingSphereOnly?: boolean;
  92666. bSphereRadiusFactor?: number;
  92667. expandable?: boolean;
  92668. });
  92669. /**
  92670. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92671. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92672. * @returns the created mesh
  92673. */
  92674. buildMesh(): Mesh;
  92675. /**
  92676. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92677. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92678. * Thus the particles generated from `digest()` have their property `position` set yet.
  92679. * @param mesh ( Mesh ) is the mesh to be digested
  92680. * @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
  92681. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92682. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92683. * @returns the current SPS
  92684. */
  92685. digest(mesh: Mesh, options?: {
  92686. facetNb?: number;
  92687. number?: number;
  92688. delta?: number;
  92689. }): SolidParticleSystem;
  92690. private _unrotateFixedNormals;
  92691. private _resetCopy;
  92692. private _meshBuilder;
  92693. private _posToShape;
  92694. private _uvsToShapeUV;
  92695. private _addParticle;
  92696. /**
  92697. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92698. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92699. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92700. * @param nb (positive integer) the number of particles to be created from this model
  92701. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92702. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92703. * @returns the number of shapes in the system
  92704. */
  92705. addShape(mesh: Mesh, nb: number, options?: {
  92706. positionFunction?: any;
  92707. vertexFunction?: any;
  92708. }): number;
  92709. private _rebuildParticle;
  92710. /**
  92711. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92712. * @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.
  92713. * @returns the SPS.
  92714. */
  92715. rebuildMesh(reset?: boolean): SolidParticleSystem;
  92716. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  92717. * Returns an array with the removed particles.
  92718. * 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.
  92719. * The SPS can't be empty so at least one particle needs to remain in place.
  92720. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  92721. * @param start index of the first particle to remove
  92722. * @param end index of the last particle to remove (included)
  92723. * @returns an array populated with the removed particles
  92724. */
  92725. removeParticles(start: number, end: number): SolidParticle[];
  92726. /**
  92727. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92728. * This method calls `updateParticle()` for each particle of the SPS.
  92729. * For an animated SPS, it is usually called within the render loop.
  92730. * 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.
  92731. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92732. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92733. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92734. * @returns the SPS.
  92735. */
  92736. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92737. /**
  92738. * Disposes the SPS.
  92739. */
  92740. dispose(): void;
  92741. /**
  92742. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92744. * @returns the SPS.
  92745. */
  92746. refreshVisibleSize(): SolidParticleSystem;
  92747. /**
  92748. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92749. * @param size the size (float) of the visibility box
  92750. * note : this doesn't lock the SPS mesh bounding box.
  92751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92752. */
  92753. setVisibilityBox(size: number): void;
  92754. /**
  92755. * Gets whether the SPS as always visible or not
  92756. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92757. */
  92758. /**
  92759. * Sets the SPS as always visible or not
  92760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92761. */
  92762. isAlwaysVisible: boolean;
  92763. /**
  92764. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92766. */
  92767. /**
  92768. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92769. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92770. */
  92771. isVisibilityBoxLocked: boolean;
  92772. /**
  92773. * Tells to `setParticles()` to compute the particle rotations or not.
  92774. * Default value : true. The SPS is faster when it's set to false.
  92775. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92776. */
  92777. /**
  92778. * Gets if `setParticles()` computes the particle rotations or not.
  92779. * Default value : true. The SPS is faster when it's set to false.
  92780. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92781. */
  92782. computeParticleRotation: boolean;
  92783. /**
  92784. * Tells to `setParticles()` to compute the particle colors or not.
  92785. * Default value : true. The SPS is faster when it's set to false.
  92786. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92787. */
  92788. /**
  92789. * Gets if `setParticles()` computes the particle colors or not.
  92790. * Default value : true. The SPS is faster when it's set to false.
  92791. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92792. */
  92793. computeParticleColor: boolean;
  92794. /**
  92795. * Gets if `setParticles()` computes the particle textures or not.
  92796. * Default value : true. The SPS is faster when it's set to false.
  92797. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92798. */
  92799. computeParticleTexture: boolean;
  92800. /**
  92801. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92802. * Default value : false. The SPS is faster when it's set to false.
  92803. * Note : the particle custom vertex positions aren't stored values.
  92804. */
  92805. /**
  92806. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92807. * Default value : false. The SPS is faster when it's set to false.
  92808. * Note : the particle custom vertex positions aren't stored values.
  92809. */
  92810. computeParticleVertex: boolean;
  92811. /**
  92812. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92813. */
  92814. /**
  92815. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92816. */
  92817. computeBoundingBox: boolean;
  92818. /**
  92819. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92820. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92821. * Default : `true`
  92822. */
  92823. /**
  92824. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92825. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92826. * Default : `true`
  92827. */
  92828. depthSortParticles: boolean;
  92829. /**
  92830. * Gets if the SPS is created as expandable at construction time.
  92831. * Default : `false`
  92832. */
  92833. readonly expandable: boolean;
  92834. /**
  92835. * This function does nothing. It may be overwritten to set all the particle first values.
  92836. * The SPS doesn't call this function, you may have to call it by your own.
  92837. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92838. */
  92839. initParticles(): void;
  92840. /**
  92841. * This function does nothing. It may be overwritten to recycle a particle.
  92842. * The SPS doesn't call this function, you may have to call it by your own.
  92843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92844. * @param particle The particle to recycle
  92845. * @returns the recycled particle
  92846. */
  92847. recycleParticle(particle: SolidParticle): SolidParticle;
  92848. /**
  92849. * Updates a particle : this function should be overwritten by the user.
  92850. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92851. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92852. * @example : just set a particle position or velocity and recycle conditions
  92853. * @param particle The particle to update
  92854. * @returns the updated particle
  92855. */
  92856. updateParticle(particle: SolidParticle): SolidParticle;
  92857. /**
  92858. * Updates a vertex of a particle : it can be overwritten by the user.
  92859. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92860. * @param particle the current particle
  92861. * @param vertex the current index of the current particle
  92862. * @param pt the index of the current vertex in the particle shape
  92863. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92864. * @example : just set a vertex particle position
  92865. * @returns the updated vertex
  92866. */
  92867. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92868. /**
  92869. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92870. * This does nothing and may be overwritten by the user.
  92871. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92872. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92873. * @param update the boolean update value actually passed to setParticles()
  92874. */
  92875. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92876. /**
  92877. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92878. * This will be passed three parameters.
  92879. * This does nothing and may be overwritten by the user.
  92880. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92881. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92882. * @param update the boolean update value actually passed to setParticles()
  92883. */
  92884. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92885. }
  92886. }
  92887. declare module BABYLON {
  92888. /**
  92889. * Represents one particle of a solid particle system.
  92890. */
  92891. export class SolidParticle {
  92892. /**
  92893. * particle global index
  92894. */
  92895. idx: number;
  92896. /**
  92897. * The color of the particle
  92898. */
  92899. color: Nullable<Color4>;
  92900. /**
  92901. * The world space position of the particle.
  92902. */
  92903. position: Vector3;
  92904. /**
  92905. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92906. */
  92907. rotation: Vector3;
  92908. /**
  92909. * The world space rotation quaternion of the particle.
  92910. */
  92911. rotationQuaternion: Nullable<Quaternion>;
  92912. /**
  92913. * The scaling of the particle.
  92914. */
  92915. scaling: Vector3;
  92916. /**
  92917. * The uvs of the particle.
  92918. */
  92919. uvs: Vector4;
  92920. /**
  92921. * The current speed of the particle.
  92922. */
  92923. velocity: Vector3;
  92924. /**
  92925. * The pivot point in the particle local space.
  92926. */
  92927. pivot: Vector3;
  92928. /**
  92929. * Must the particle be translated from its pivot point in its local space ?
  92930. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92931. * Default : false
  92932. */
  92933. translateFromPivot: boolean;
  92934. /**
  92935. * Is the particle active or not ?
  92936. */
  92937. alive: boolean;
  92938. /**
  92939. * Is the particle visible or not ?
  92940. */
  92941. isVisible: boolean;
  92942. /**
  92943. * Index of this particle in the global "positions" array (Internal use)
  92944. * @hidden
  92945. */
  92946. _pos: number;
  92947. /**
  92948. * @hidden Index of this particle in the global "indices" array (Internal use)
  92949. */
  92950. _ind: number;
  92951. /**
  92952. * @hidden ModelShape of this particle (Internal use)
  92953. */
  92954. _model: ModelShape;
  92955. /**
  92956. * ModelShape id of this particle
  92957. */
  92958. shapeId: number;
  92959. /**
  92960. * Index of the particle in its shape id
  92961. */
  92962. idxInShape: number;
  92963. /**
  92964. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92965. */
  92966. _modelBoundingInfo: BoundingInfo;
  92967. /**
  92968. * @hidden Particle BoundingInfo object (Internal use)
  92969. */
  92970. _boundingInfo: BoundingInfo;
  92971. /**
  92972. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92973. */
  92974. _sps: SolidParticleSystem;
  92975. /**
  92976. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92977. */
  92978. _stillInvisible: boolean;
  92979. /**
  92980. * @hidden Last computed particle rotation matrix
  92981. */
  92982. _rotationMatrix: number[];
  92983. /**
  92984. * Parent particle Id, if any.
  92985. * Default null.
  92986. */
  92987. parentId: Nullable<number>;
  92988. /**
  92989. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92990. * The possible values are :
  92991. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92992. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92993. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92995. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92996. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92997. * */
  92998. cullingStrategy: number;
  92999. /**
  93000. * @hidden Internal global position in the SPS.
  93001. */
  93002. _globalPosition: Vector3;
  93003. /**
  93004. * Creates a Solid Particle object.
  93005. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93006. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93007. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93008. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93009. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93010. * @param shapeId (integer) is the model shape identifier in the SPS.
  93011. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93012. * @param sps defines the sps it is associated to
  93013. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93014. */
  93015. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93016. /**
  93017. * Legacy support, changed scale to scaling
  93018. */
  93019. /**
  93020. * Legacy support, changed scale to scaling
  93021. */
  93022. scale: Vector3;
  93023. /**
  93024. * Legacy support, changed quaternion to rotationQuaternion
  93025. */
  93026. /**
  93027. * Legacy support, changed quaternion to rotationQuaternion
  93028. */
  93029. quaternion: Nullable<Quaternion>;
  93030. /**
  93031. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93032. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93033. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93034. * @returns true if it intersects
  93035. */
  93036. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93037. /**
  93038. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93039. * A particle is in the frustum if its bounding box intersects the frustum
  93040. * @param frustumPlanes defines the frustum to test
  93041. * @returns true if the particle is in the frustum planes
  93042. */
  93043. isInFrustum(frustumPlanes: Plane[]): boolean;
  93044. /**
  93045. * get the rotation matrix of the particle
  93046. * @hidden
  93047. */
  93048. getRotationMatrix(m: Matrix): void;
  93049. }
  93050. /**
  93051. * Represents the shape of the model used by one particle of a solid particle system.
  93052. * SPS internal tool, don't use it manually.
  93053. */
  93054. export class ModelShape {
  93055. /**
  93056. * The shape id
  93057. * @hidden
  93058. */
  93059. shapeID: number;
  93060. /**
  93061. * flat array of model positions (internal use)
  93062. * @hidden
  93063. */
  93064. _shape: Vector3[];
  93065. /**
  93066. * flat array of model UVs (internal use)
  93067. * @hidden
  93068. */
  93069. _shapeUV: number[];
  93070. /**
  93071. * color array of the model
  93072. * @hidden
  93073. */
  93074. _shapeColors: number[];
  93075. /**
  93076. * indices array of the model
  93077. * @hidden
  93078. */
  93079. _indices: number[];
  93080. /**
  93081. * normals array of the model
  93082. * @hidden
  93083. */
  93084. _normals: number[];
  93085. /**
  93086. * length of the shape in the model indices array (internal use)
  93087. * @hidden
  93088. */
  93089. _indicesLength: number;
  93090. /**
  93091. * Custom position function (internal use)
  93092. * @hidden
  93093. */
  93094. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93095. /**
  93096. * Custom vertex function (internal use)
  93097. * @hidden
  93098. */
  93099. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93100. /**
  93101. * 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.
  93102. * SPS internal tool, don't use it manually.
  93103. * @hidden
  93104. */
  93105. 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>);
  93106. }
  93107. /**
  93108. * Represents a Depth Sorted Particle in the solid particle system.
  93109. */
  93110. export class DepthSortedParticle {
  93111. /**
  93112. * Index of the particle in the "indices" array
  93113. */
  93114. ind: number;
  93115. /**
  93116. * Length of the particle shape in the "indices" array
  93117. */
  93118. indicesLength: number;
  93119. /**
  93120. * Squared distance from the particle to the camera
  93121. */
  93122. sqDistance: number;
  93123. }
  93124. }
  93125. declare module BABYLON {
  93126. /**
  93127. * @hidden
  93128. */
  93129. export class _MeshCollisionData {
  93130. _checkCollisions: boolean;
  93131. _collisionMask: number;
  93132. _collisionGroup: number;
  93133. _collider: Nullable<Collider>;
  93134. _oldPositionForCollisions: Vector3;
  93135. _diffPositionForCollisions: Vector3;
  93136. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93137. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93138. }
  93139. }
  93140. declare module BABYLON {
  93141. /** @hidden */
  93142. class _FacetDataStorage {
  93143. facetPositions: Vector3[];
  93144. facetNormals: Vector3[];
  93145. facetPartitioning: number[][];
  93146. facetNb: number;
  93147. partitioningSubdivisions: number;
  93148. partitioningBBoxRatio: number;
  93149. facetDataEnabled: boolean;
  93150. facetParameters: any;
  93151. bbSize: Vector3;
  93152. subDiv: {
  93153. max: number;
  93154. X: number;
  93155. Y: number;
  93156. Z: number;
  93157. };
  93158. facetDepthSort: boolean;
  93159. facetDepthSortEnabled: boolean;
  93160. depthSortedIndices: IndicesArray;
  93161. depthSortedFacets: {
  93162. ind: number;
  93163. sqDistance: number;
  93164. }[];
  93165. facetDepthSortFunction: (f1: {
  93166. ind: number;
  93167. sqDistance: number;
  93168. }, f2: {
  93169. ind: number;
  93170. sqDistance: number;
  93171. }) => number;
  93172. facetDepthSortFrom: Vector3;
  93173. facetDepthSortOrigin: Vector3;
  93174. invertedMatrix: Matrix;
  93175. }
  93176. /**
  93177. * @hidden
  93178. **/
  93179. class _InternalAbstractMeshDataInfo {
  93180. _hasVertexAlpha: boolean;
  93181. _useVertexColors: boolean;
  93182. _numBoneInfluencers: number;
  93183. _applyFog: boolean;
  93184. _receiveShadows: boolean;
  93185. _facetData: _FacetDataStorage;
  93186. _visibility: number;
  93187. _skeleton: Nullable<Skeleton>;
  93188. _layerMask: number;
  93189. _computeBonesUsingShaders: boolean;
  93190. _isActive: boolean;
  93191. _onlyForInstances: boolean;
  93192. _isActiveIntermediate: boolean;
  93193. _onlyForInstancesIntermediate: boolean;
  93194. _actAsRegularMesh: boolean;
  93195. }
  93196. /**
  93197. * Class used to store all common mesh properties
  93198. */
  93199. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93200. /** No occlusion */
  93201. static OCCLUSION_TYPE_NONE: number;
  93202. /** Occlusion set to optimisitic */
  93203. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93204. /** Occlusion set to strict */
  93205. static OCCLUSION_TYPE_STRICT: number;
  93206. /** Use an accurante occlusion algorithm */
  93207. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93208. /** Use a conservative occlusion algorithm */
  93209. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93210. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93211. * Test order :
  93212. * Is the bounding sphere outside the frustum ?
  93213. * If not, are the bounding box vertices outside the frustum ?
  93214. * It not, then the cullable object is in the frustum.
  93215. */
  93216. static readonly CULLINGSTRATEGY_STANDARD: number;
  93217. /** Culling strategy : Bounding Sphere Only.
  93218. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93219. * It's also less accurate than the standard because some not visible objects can still be selected.
  93220. * Test : is the bounding sphere outside the frustum ?
  93221. * If not, then the cullable object is in the frustum.
  93222. */
  93223. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93224. /** Culling strategy : Optimistic Inclusion.
  93225. * This in an inclusion test first, then the standard exclusion test.
  93226. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93227. * 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.
  93228. * Anyway, it's as accurate as the standard strategy.
  93229. * Test :
  93230. * Is the cullable object bounding sphere center in the frustum ?
  93231. * If not, apply the default culling strategy.
  93232. */
  93233. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93234. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93235. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93236. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93237. * 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.
  93238. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93239. * Test :
  93240. * Is the cullable object bounding sphere center in the frustum ?
  93241. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93242. */
  93243. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93244. /**
  93245. * No billboard
  93246. */
  93247. static readonly BILLBOARDMODE_NONE: number;
  93248. /** Billboard on X axis */
  93249. static readonly BILLBOARDMODE_X: number;
  93250. /** Billboard on Y axis */
  93251. static readonly BILLBOARDMODE_Y: number;
  93252. /** Billboard on Z axis */
  93253. static readonly BILLBOARDMODE_Z: number;
  93254. /** Billboard on all axes */
  93255. static readonly BILLBOARDMODE_ALL: number;
  93256. /** Billboard on using position instead of orientation */
  93257. static readonly BILLBOARDMODE_USE_POSITION: number;
  93258. /** @hidden */
  93259. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93260. /**
  93261. * The culling strategy to use to check whether the mesh must be rendered or not.
  93262. * This value can be changed at any time and will be used on the next render mesh selection.
  93263. * The possible values are :
  93264. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93265. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93266. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93267. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93268. * Please read each static variable documentation to get details about the culling process.
  93269. * */
  93270. cullingStrategy: number;
  93271. /**
  93272. * Gets the number of facets in the mesh
  93273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93274. */
  93275. readonly facetNb: number;
  93276. /**
  93277. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93279. */
  93280. partitioningSubdivisions: number;
  93281. /**
  93282. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93283. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93285. */
  93286. partitioningBBoxRatio: number;
  93287. /**
  93288. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93289. * Works only for updatable meshes.
  93290. * Doesn't work with multi-materials
  93291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93292. */
  93293. mustDepthSortFacets: boolean;
  93294. /**
  93295. * The location (Vector3) where the facet depth sort must be computed from.
  93296. * By default, the active camera position.
  93297. * Used only when facet depth sort is enabled
  93298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93299. */
  93300. facetDepthSortFrom: Vector3;
  93301. /**
  93302. * gets a boolean indicating if facetData is enabled
  93303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93304. */
  93305. readonly isFacetDataEnabled: boolean;
  93306. /** @hidden */
  93307. _updateNonUniformScalingState(value: boolean): boolean;
  93308. /**
  93309. * An event triggered when this mesh collides with another one
  93310. */
  93311. onCollideObservable: Observable<AbstractMesh>;
  93312. /** Set a function to call when this mesh collides with another one */
  93313. onCollide: () => void;
  93314. /**
  93315. * An event triggered when the collision's position changes
  93316. */
  93317. onCollisionPositionChangeObservable: Observable<Vector3>;
  93318. /** Set a function to call when the collision's position changes */
  93319. onCollisionPositionChange: () => void;
  93320. /**
  93321. * An event triggered when material is changed
  93322. */
  93323. onMaterialChangedObservable: Observable<AbstractMesh>;
  93324. /**
  93325. * Gets or sets the orientation for POV movement & rotation
  93326. */
  93327. definedFacingForward: boolean;
  93328. /** @hidden */
  93329. _occlusionQuery: Nullable<WebGLQuery>;
  93330. /** @hidden */
  93331. _renderingGroup: Nullable<RenderingGroup>;
  93332. /**
  93333. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93334. */
  93335. /**
  93336. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93337. */
  93338. visibility: number;
  93339. /** Gets or sets the alpha index used to sort transparent meshes
  93340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93341. */
  93342. alphaIndex: number;
  93343. /**
  93344. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93345. */
  93346. isVisible: boolean;
  93347. /**
  93348. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93349. */
  93350. isPickable: boolean;
  93351. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93352. showSubMeshesBoundingBox: boolean;
  93353. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93355. */
  93356. isBlocker: boolean;
  93357. /**
  93358. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93359. */
  93360. enablePointerMoveEvents: boolean;
  93361. /**
  93362. * Specifies the rendering group id for this mesh (0 by default)
  93363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93364. */
  93365. renderingGroupId: number;
  93366. private _material;
  93367. /** Gets or sets current material */
  93368. material: Nullable<Material>;
  93369. /**
  93370. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93371. * @see http://doc.babylonjs.com/babylon101/shadows
  93372. */
  93373. receiveShadows: boolean;
  93374. /** Defines color to use when rendering outline */
  93375. outlineColor: Color3;
  93376. /** Define width to use when rendering outline */
  93377. outlineWidth: number;
  93378. /** Defines color to use when rendering overlay */
  93379. overlayColor: Color3;
  93380. /** Defines alpha to use when rendering overlay */
  93381. overlayAlpha: number;
  93382. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93383. hasVertexAlpha: boolean;
  93384. /** 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) */
  93385. useVertexColors: boolean;
  93386. /**
  93387. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93388. */
  93389. computeBonesUsingShaders: boolean;
  93390. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93391. numBoneInfluencers: number;
  93392. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93393. applyFog: boolean;
  93394. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93395. useOctreeForRenderingSelection: boolean;
  93396. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93397. useOctreeForPicking: boolean;
  93398. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93399. useOctreeForCollisions: boolean;
  93400. /**
  93401. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93402. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93403. */
  93404. layerMask: number;
  93405. /**
  93406. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93407. */
  93408. alwaysSelectAsActiveMesh: boolean;
  93409. /**
  93410. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93411. */
  93412. doNotSyncBoundingInfo: boolean;
  93413. /**
  93414. * Gets or sets the current action manager
  93415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93416. */
  93417. actionManager: Nullable<AbstractActionManager>;
  93418. private _meshCollisionData;
  93419. /**
  93420. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93421. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93422. */
  93423. ellipsoid: Vector3;
  93424. /**
  93425. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93426. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93427. */
  93428. ellipsoidOffset: Vector3;
  93429. /**
  93430. * Gets or sets a collision mask used to mask collisions (default is -1).
  93431. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93432. */
  93433. collisionMask: number;
  93434. /**
  93435. * Gets or sets the current collision group mask (-1 by default).
  93436. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93437. */
  93438. collisionGroup: number;
  93439. /**
  93440. * Defines edge width used when edgesRenderer is enabled
  93441. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93442. */
  93443. edgesWidth: number;
  93444. /**
  93445. * Defines edge color used when edgesRenderer is enabled
  93446. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93447. */
  93448. edgesColor: Color4;
  93449. /** @hidden */
  93450. _edgesRenderer: Nullable<IEdgesRenderer>;
  93451. /** @hidden */
  93452. _masterMesh: Nullable<AbstractMesh>;
  93453. /** @hidden */
  93454. _boundingInfo: Nullable<BoundingInfo>;
  93455. /** @hidden */
  93456. _renderId: number;
  93457. /**
  93458. * Gets or sets the list of subMeshes
  93459. * @see http://doc.babylonjs.com/how_to/multi_materials
  93460. */
  93461. subMeshes: SubMesh[];
  93462. /** @hidden */
  93463. _intersectionsInProgress: AbstractMesh[];
  93464. /** @hidden */
  93465. _unIndexed: boolean;
  93466. /** @hidden */
  93467. _lightSources: Light[];
  93468. /** Gets the list of lights affecting that mesh */
  93469. readonly lightSources: Light[];
  93470. /** @hidden */
  93471. readonly _positions: Nullable<Vector3[]>;
  93472. /** @hidden */
  93473. _waitingData: {
  93474. lods: Nullable<any>;
  93475. actions: Nullable<any>;
  93476. freezeWorldMatrix: Nullable<boolean>;
  93477. };
  93478. /** @hidden */
  93479. _bonesTransformMatrices: Nullable<Float32Array>;
  93480. /** @hidden */
  93481. _transformMatrixTexture: Nullable<RawTexture>;
  93482. /**
  93483. * Gets or sets a skeleton to apply skining transformations
  93484. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93485. */
  93486. skeleton: Nullable<Skeleton>;
  93487. /**
  93488. * An event triggered when the mesh is rebuilt.
  93489. */
  93490. onRebuildObservable: Observable<AbstractMesh>;
  93491. /**
  93492. * Creates a new AbstractMesh
  93493. * @param name defines the name of the mesh
  93494. * @param scene defines the hosting scene
  93495. */
  93496. constructor(name: string, scene?: Nullable<Scene>);
  93497. /**
  93498. * Returns the string "AbstractMesh"
  93499. * @returns "AbstractMesh"
  93500. */
  93501. getClassName(): string;
  93502. /**
  93503. * Gets a string representation of the current mesh
  93504. * @param fullDetails defines a boolean indicating if full details must be included
  93505. * @returns a string representation of the current mesh
  93506. */
  93507. toString(fullDetails?: boolean): string;
  93508. /**
  93509. * @hidden
  93510. */
  93511. protected _getEffectiveParent(): Nullable<Node>;
  93512. /** @hidden */
  93513. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93514. /** @hidden */
  93515. _rebuild(): void;
  93516. /** @hidden */
  93517. _resyncLightSources(): void;
  93518. /** @hidden */
  93519. _resyncLighSource(light: Light): void;
  93520. /** @hidden */
  93521. _unBindEffect(): void;
  93522. /** @hidden */
  93523. _removeLightSource(light: Light, dispose: boolean): void;
  93524. private _markSubMeshesAsDirty;
  93525. /** @hidden */
  93526. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93527. /** @hidden */
  93528. _markSubMeshesAsAttributesDirty(): void;
  93529. /** @hidden */
  93530. _markSubMeshesAsMiscDirty(): void;
  93531. /**
  93532. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93533. */
  93534. scaling: Vector3;
  93535. /**
  93536. * Returns true if the mesh is blocked. Implemented by child classes
  93537. */
  93538. readonly isBlocked: boolean;
  93539. /**
  93540. * Returns the mesh itself by default. Implemented by child classes
  93541. * @param camera defines the camera to use to pick the right LOD level
  93542. * @returns the currentAbstractMesh
  93543. */
  93544. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93545. /**
  93546. * Returns 0 by default. Implemented by child classes
  93547. * @returns an integer
  93548. */
  93549. getTotalVertices(): number;
  93550. /**
  93551. * Returns a positive integer : the total number of indices in this mesh geometry.
  93552. * @returns the numner of indices or zero if the mesh has no geometry.
  93553. */
  93554. getTotalIndices(): number;
  93555. /**
  93556. * Returns null by default. Implemented by child classes
  93557. * @returns null
  93558. */
  93559. getIndices(): Nullable<IndicesArray>;
  93560. /**
  93561. * Returns the array of the requested vertex data kind. Implemented by child classes
  93562. * @param kind defines the vertex data kind to use
  93563. * @returns null
  93564. */
  93565. getVerticesData(kind: string): Nullable<FloatArray>;
  93566. /**
  93567. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93568. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93569. * Note that a new underlying VertexBuffer object is created each call.
  93570. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93571. * @param kind defines vertex data kind:
  93572. * * VertexBuffer.PositionKind
  93573. * * VertexBuffer.UVKind
  93574. * * VertexBuffer.UV2Kind
  93575. * * VertexBuffer.UV3Kind
  93576. * * VertexBuffer.UV4Kind
  93577. * * VertexBuffer.UV5Kind
  93578. * * VertexBuffer.UV6Kind
  93579. * * VertexBuffer.ColorKind
  93580. * * VertexBuffer.MatricesIndicesKind
  93581. * * VertexBuffer.MatricesIndicesExtraKind
  93582. * * VertexBuffer.MatricesWeightsKind
  93583. * * VertexBuffer.MatricesWeightsExtraKind
  93584. * @param data defines the data source
  93585. * @param updatable defines if the data must be flagged as updatable (or static)
  93586. * @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
  93587. * @returns the current mesh
  93588. */
  93589. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93590. /**
  93591. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93592. * If the mesh has no geometry, it is simply returned as it is.
  93593. * @param kind defines vertex data kind:
  93594. * * VertexBuffer.PositionKind
  93595. * * VertexBuffer.UVKind
  93596. * * VertexBuffer.UV2Kind
  93597. * * VertexBuffer.UV3Kind
  93598. * * VertexBuffer.UV4Kind
  93599. * * VertexBuffer.UV5Kind
  93600. * * VertexBuffer.UV6Kind
  93601. * * VertexBuffer.ColorKind
  93602. * * VertexBuffer.MatricesIndicesKind
  93603. * * VertexBuffer.MatricesIndicesExtraKind
  93604. * * VertexBuffer.MatricesWeightsKind
  93605. * * VertexBuffer.MatricesWeightsExtraKind
  93606. * @param data defines the data source
  93607. * @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
  93608. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93609. * @returns the current mesh
  93610. */
  93611. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93612. /**
  93613. * Sets the mesh indices,
  93614. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93615. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93616. * @param totalVertices Defines the total number of vertices
  93617. * @returns the current mesh
  93618. */
  93619. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93620. /**
  93621. * Gets a boolean indicating if specific vertex data is present
  93622. * @param kind defines the vertex data kind to use
  93623. * @returns true is data kind is present
  93624. */
  93625. isVerticesDataPresent(kind: string): boolean;
  93626. /**
  93627. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93628. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93629. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93630. * @returns a BoundingInfo
  93631. */
  93632. getBoundingInfo(): BoundingInfo;
  93633. /**
  93634. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93635. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93636. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93637. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93638. * @returns the current mesh
  93639. */
  93640. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93641. /**
  93642. * Overwrite the current bounding info
  93643. * @param boundingInfo defines the new bounding info
  93644. * @returns the current mesh
  93645. */
  93646. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93647. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93648. readonly useBones: boolean;
  93649. /** @hidden */
  93650. _preActivate(): void;
  93651. /** @hidden */
  93652. _preActivateForIntermediateRendering(renderId: number): void;
  93653. /** @hidden */
  93654. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93655. /** @hidden */
  93656. _postActivate(): void;
  93657. /** @hidden */
  93658. _freeze(): void;
  93659. /** @hidden */
  93660. _unFreeze(): void;
  93661. /**
  93662. * Gets the current world matrix
  93663. * @returns a Matrix
  93664. */
  93665. getWorldMatrix(): Matrix;
  93666. /** @hidden */
  93667. _getWorldMatrixDeterminant(): number;
  93668. /**
  93669. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93670. */
  93671. readonly isAnInstance: boolean;
  93672. /**
  93673. * Gets a boolean indicating if this mesh has instances
  93674. */
  93675. readonly hasInstances: boolean;
  93676. /**
  93677. * Perform relative position change from the point of view of behind the front of the mesh.
  93678. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93679. * Supports definition of mesh facing forward or backward
  93680. * @param amountRight defines the distance on the right axis
  93681. * @param amountUp defines the distance on the up axis
  93682. * @param amountForward defines the distance on the forward axis
  93683. * @returns the current mesh
  93684. */
  93685. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93686. /**
  93687. * Calculate relative position change from the point of view of behind the front of the mesh.
  93688. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93689. * Supports definition of mesh facing forward or backward
  93690. * @param amountRight defines the distance on the right axis
  93691. * @param amountUp defines the distance on the up axis
  93692. * @param amountForward defines the distance on the forward axis
  93693. * @returns the new displacement vector
  93694. */
  93695. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93696. /**
  93697. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93698. * Supports definition of mesh facing forward or backward
  93699. * @param flipBack defines the flip
  93700. * @param twirlClockwise defines the twirl
  93701. * @param tiltRight defines the tilt
  93702. * @returns the current mesh
  93703. */
  93704. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93705. /**
  93706. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93707. * Supports definition of mesh facing forward or backward.
  93708. * @param flipBack defines the flip
  93709. * @param twirlClockwise defines the twirl
  93710. * @param tiltRight defines the tilt
  93711. * @returns the new rotation vector
  93712. */
  93713. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93714. /**
  93715. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93716. * This means the mesh underlying bounding box and sphere are recomputed.
  93717. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93718. * @returns the current mesh
  93719. */
  93720. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93721. /** @hidden */
  93722. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93723. /** @hidden */
  93724. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93725. /** @hidden */
  93726. _updateBoundingInfo(): AbstractMesh;
  93727. /** @hidden */
  93728. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93729. /** @hidden */
  93730. protected _afterComputeWorldMatrix(): void;
  93731. /** @hidden */
  93732. readonly _effectiveMesh: AbstractMesh;
  93733. /**
  93734. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93735. * A mesh is in the frustum if its bounding box intersects the frustum
  93736. * @param frustumPlanes defines the frustum to test
  93737. * @returns true if the mesh is in the frustum planes
  93738. */
  93739. isInFrustum(frustumPlanes: Plane[]): boolean;
  93740. /**
  93741. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93742. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93743. * @param frustumPlanes defines the frustum to test
  93744. * @returns true if the mesh is completely in the frustum planes
  93745. */
  93746. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93747. /**
  93748. * True if the mesh intersects another mesh or a SolidParticle object
  93749. * @param mesh defines a target mesh or SolidParticle to test
  93750. * @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)
  93751. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93752. * @returns true if there is an intersection
  93753. */
  93754. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93755. /**
  93756. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93757. * @param point defines the point to test
  93758. * @returns true if there is an intersection
  93759. */
  93760. intersectsPoint(point: Vector3): boolean;
  93761. /**
  93762. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93763. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93764. */
  93765. checkCollisions: boolean;
  93766. /**
  93767. * Gets Collider object used to compute collisions (not physics)
  93768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93769. */
  93770. readonly collider: Nullable<Collider>;
  93771. /**
  93772. * Move the mesh using collision engine
  93773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93774. * @param displacement defines the requested displacement vector
  93775. * @returns the current mesh
  93776. */
  93777. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93778. private _onCollisionPositionChange;
  93779. /** @hidden */
  93780. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93781. /** @hidden */
  93782. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93783. /** @hidden */
  93784. _checkCollision(collider: Collider): AbstractMesh;
  93785. /** @hidden */
  93786. _generatePointsArray(): boolean;
  93787. /**
  93788. * Checks if the passed Ray intersects with the mesh
  93789. * @param ray defines the ray to use
  93790. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93792. * @returns the picking info
  93793. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93794. */
  93795. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93796. /**
  93797. * Clones the current mesh
  93798. * @param name defines the mesh name
  93799. * @param newParent defines the new mesh parent
  93800. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93801. * @returns the new mesh
  93802. */
  93803. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93804. /**
  93805. * Disposes all the submeshes of the current meshnp
  93806. * @returns the current mesh
  93807. */
  93808. releaseSubMeshes(): AbstractMesh;
  93809. /**
  93810. * Releases resources associated with this abstract mesh.
  93811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93813. */
  93814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93815. /**
  93816. * Adds the passed mesh as a child to the current mesh
  93817. * @param mesh defines the child mesh
  93818. * @returns the current mesh
  93819. */
  93820. addChild(mesh: AbstractMesh): AbstractMesh;
  93821. /**
  93822. * Removes the passed mesh from the current mesh children list
  93823. * @param mesh defines the child mesh
  93824. * @returns the current mesh
  93825. */
  93826. removeChild(mesh: AbstractMesh): AbstractMesh;
  93827. /** @hidden */
  93828. private _initFacetData;
  93829. /**
  93830. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93831. * This method can be called within the render loop.
  93832. * 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
  93833. * @returns the current mesh
  93834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93835. */
  93836. updateFacetData(): AbstractMesh;
  93837. /**
  93838. * Returns the facetLocalNormals array.
  93839. * The normals are expressed in the mesh local spac
  93840. * @returns an array of Vector3
  93841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93842. */
  93843. getFacetLocalNormals(): Vector3[];
  93844. /**
  93845. * Returns the facetLocalPositions array.
  93846. * The facet positions are expressed in the mesh local space
  93847. * @returns an array of Vector3
  93848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93849. */
  93850. getFacetLocalPositions(): Vector3[];
  93851. /**
  93852. * Returns the facetLocalPartioning array
  93853. * @returns an array of array of numbers
  93854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93855. */
  93856. getFacetLocalPartitioning(): number[][];
  93857. /**
  93858. * Returns the i-th facet position in the world system.
  93859. * This method allocates a new Vector3 per call
  93860. * @param i defines the facet index
  93861. * @returns a new Vector3
  93862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93863. */
  93864. getFacetPosition(i: number): Vector3;
  93865. /**
  93866. * Sets the reference Vector3 with the i-th facet position in the world system
  93867. * @param i defines the facet index
  93868. * @param ref defines the target vector
  93869. * @returns the current mesh
  93870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93871. */
  93872. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93873. /**
  93874. * Returns the i-th facet normal in the world system.
  93875. * This method allocates a new Vector3 per call
  93876. * @param i defines the facet index
  93877. * @returns a new Vector3
  93878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93879. */
  93880. getFacetNormal(i: number): Vector3;
  93881. /**
  93882. * Sets the reference Vector3 with the i-th facet normal in the world system
  93883. * @param i defines the facet index
  93884. * @param ref defines the target vector
  93885. * @returns the current mesh
  93886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93887. */
  93888. getFacetNormalToRef(i: number, ref: Vector3): this;
  93889. /**
  93890. * 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)
  93891. * @param x defines x coordinate
  93892. * @param y defines y coordinate
  93893. * @param z defines z coordinate
  93894. * @returns the array of facet indexes
  93895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93896. */
  93897. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93898. /**
  93899. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93900. * @param projected sets as the (x,y,z) world projection on the facet
  93901. * @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
  93902. * @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
  93903. * @param x defines x coordinate
  93904. * @param y defines y coordinate
  93905. * @param z defines z coordinate
  93906. * @returns the face index if found (or null instead)
  93907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93908. */
  93909. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93910. /**
  93911. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93912. * @param projected sets as the (x,y,z) local projection on the facet
  93913. * @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
  93914. * @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
  93915. * @param x defines x coordinate
  93916. * @param y defines y coordinate
  93917. * @param z defines z coordinate
  93918. * @returns the face index if found (or null instead)
  93919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93920. */
  93921. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93922. /**
  93923. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93924. * @returns the parameters
  93925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93926. */
  93927. getFacetDataParameters(): any;
  93928. /**
  93929. * Disables the feature FacetData and frees the related memory
  93930. * @returns the current mesh
  93931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93932. */
  93933. disableFacetData(): AbstractMesh;
  93934. /**
  93935. * Updates the AbstractMesh indices array
  93936. * @param indices defines the data source
  93937. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93938. * @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)
  93939. * @returns the current mesh
  93940. */
  93941. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93942. /**
  93943. * Creates new normals data for the mesh
  93944. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93945. * @returns the current mesh
  93946. */
  93947. createNormals(updatable: boolean): AbstractMesh;
  93948. /**
  93949. * Align the mesh with a normal
  93950. * @param normal defines the normal to use
  93951. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93952. * @returns the current mesh
  93953. */
  93954. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93955. /** @hidden */
  93956. _checkOcclusionQuery(): boolean;
  93957. /**
  93958. * Disables the mesh edge rendering mode
  93959. * @returns the currentAbstractMesh
  93960. */
  93961. disableEdgesRendering(): AbstractMesh;
  93962. /**
  93963. * Enables the edge rendering mode on the mesh.
  93964. * This mode makes the mesh edges visible
  93965. * @param epsilon defines the maximal distance between two angles to detect a face
  93966. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93967. * @returns the currentAbstractMesh
  93968. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93969. */
  93970. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93971. }
  93972. }
  93973. declare module BABYLON {
  93974. /**
  93975. * Interface used to define ActionEvent
  93976. */
  93977. export interface IActionEvent {
  93978. /** The mesh or sprite that triggered the action */
  93979. source: any;
  93980. /** The X mouse cursor position at the time of the event */
  93981. pointerX: number;
  93982. /** The Y mouse cursor position at the time of the event */
  93983. pointerY: number;
  93984. /** The mesh that is currently pointed at (can be null) */
  93985. meshUnderPointer: Nullable<AbstractMesh>;
  93986. /** the original (browser) event that triggered the ActionEvent */
  93987. sourceEvent?: any;
  93988. /** additional data for the event */
  93989. additionalData?: any;
  93990. }
  93991. /**
  93992. * ActionEvent is the event being sent when an action is triggered.
  93993. */
  93994. export class ActionEvent implements IActionEvent {
  93995. /** The mesh or sprite that triggered the action */
  93996. source: any;
  93997. /** The X mouse cursor position at the time of the event */
  93998. pointerX: number;
  93999. /** The Y mouse cursor position at the time of the event */
  94000. pointerY: number;
  94001. /** The mesh that is currently pointed at (can be null) */
  94002. meshUnderPointer: Nullable<AbstractMesh>;
  94003. /** the original (browser) event that triggered the ActionEvent */
  94004. sourceEvent?: any;
  94005. /** additional data for the event */
  94006. additionalData?: any;
  94007. /**
  94008. * Creates a new ActionEvent
  94009. * @param source The mesh or sprite that triggered the action
  94010. * @param pointerX The X mouse cursor position at the time of the event
  94011. * @param pointerY The Y mouse cursor position at the time of the event
  94012. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94013. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94014. * @param additionalData additional data for the event
  94015. */
  94016. constructor(
  94017. /** The mesh or sprite that triggered the action */
  94018. source: any,
  94019. /** The X mouse cursor position at the time of the event */
  94020. pointerX: number,
  94021. /** The Y mouse cursor position at the time of the event */
  94022. pointerY: number,
  94023. /** The mesh that is currently pointed at (can be null) */
  94024. meshUnderPointer: Nullable<AbstractMesh>,
  94025. /** the original (browser) event that triggered the ActionEvent */
  94026. sourceEvent?: any,
  94027. /** additional data for the event */
  94028. additionalData?: any);
  94029. /**
  94030. * Helper function to auto-create an ActionEvent from a source mesh.
  94031. * @param source The source mesh that triggered the event
  94032. * @param evt The original (browser) event
  94033. * @param additionalData additional data for the event
  94034. * @returns the new ActionEvent
  94035. */
  94036. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94037. /**
  94038. * Helper function to auto-create an ActionEvent from a source sprite
  94039. * @param source The source sprite that triggered the event
  94040. * @param scene Scene associated with the sprite
  94041. * @param evt The original (browser) event
  94042. * @param additionalData additional data for the event
  94043. * @returns the new ActionEvent
  94044. */
  94045. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94046. /**
  94047. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94048. * @param scene the scene where the event occurred
  94049. * @param evt The original (browser) event
  94050. * @returns the new ActionEvent
  94051. */
  94052. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94053. /**
  94054. * Helper function to auto-create an ActionEvent from a primitive
  94055. * @param prim defines the target primitive
  94056. * @param pointerPos defines the pointer position
  94057. * @param evt The original (browser) event
  94058. * @param additionalData additional data for the event
  94059. * @returns the new ActionEvent
  94060. */
  94061. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94062. }
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Abstract class used to decouple action Manager from scene and meshes.
  94067. * Do not instantiate.
  94068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94069. */
  94070. export abstract class AbstractActionManager implements IDisposable {
  94071. /** Gets the list of active triggers */
  94072. static Triggers: {
  94073. [key: string]: number;
  94074. };
  94075. /** Gets the cursor to use when hovering items */
  94076. hoverCursor: string;
  94077. /** Gets the list of actions */
  94078. actions: IAction[];
  94079. /**
  94080. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94081. */
  94082. isRecursive: boolean;
  94083. /**
  94084. * Releases all associated resources
  94085. */
  94086. abstract dispose(): void;
  94087. /**
  94088. * Does this action manager has pointer triggers
  94089. */
  94090. abstract readonly hasPointerTriggers: boolean;
  94091. /**
  94092. * Does this action manager has pick triggers
  94093. */
  94094. abstract readonly hasPickTriggers: boolean;
  94095. /**
  94096. * Process a specific trigger
  94097. * @param trigger defines the trigger to process
  94098. * @param evt defines the event details to be processed
  94099. */
  94100. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94101. /**
  94102. * Does this action manager handles actions of any of the given triggers
  94103. * @param triggers defines the triggers to be tested
  94104. * @return a boolean indicating whether one (or more) of the triggers is handled
  94105. */
  94106. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94107. /**
  94108. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94109. * speed.
  94110. * @param triggerA defines the trigger to be tested
  94111. * @param triggerB defines the trigger to be tested
  94112. * @return a boolean indicating whether one (or more) of the triggers is handled
  94113. */
  94114. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94115. /**
  94116. * Does this action manager handles actions of a given trigger
  94117. * @param trigger defines the trigger to be tested
  94118. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94119. * @return whether the trigger is handled
  94120. */
  94121. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94122. /**
  94123. * Serialize this manager to a JSON object
  94124. * @param name defines the property name to store this manager
  94125. * @returns a JSON representation of this manager
  94126. */
  94127. abstract serialize(name: string): any;
  94128. /**
  94129. * Registers an action to this action manager
  94130. * @param action defines the action to be registered
  94131. * @return the action amended (prepared) after registration
  94132. */
  94133. abstract registerAction(action: IAction): Nullable<IAction>;
  94134. /**
  94135. * Unregisters an action to this action manager
  94136. * @param action defines the action to be unregistered
  94137. * @return a boolean indicating whether the action has been unregistered
  94138. */
  94139. abstract unregisterAction(action: IAction): Boolean;
  94140. /**
  94141. * Does exist one action manager with at least one trigger
  94142. **/
  94143. static readonly HasTriggers: boolean;
  94144. /**
  94145. * Does exist one action manager with at least one pick trigger
  94146. **/
  94147. static readonly HasPickTriggers: boolean;
  94148. /**
  94149. * Does exist one action manager that handles actions of a given trigger
  94150. * @param trigger defines the trigger to be tested
  94151. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94152. **/
  94153. static HasSpecificTrigger(trigger: number): boolean;
  94154. }
  94155. }
  94156. declare module BABYLON {
  94157. /**
  94158. * Defines how a node can be built from a string name.
  94159. */
  94160. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94161. /**
  94162. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94163. */
  94164. export class Node implements IBehaviorAware<Node> {
  94165. /** @hidden */
  94166. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94167. private static _NodeConstructors;
  94168. /**
  94169. * Add a new node constructor
  94170. * @param type defines the type name of the node to construct
  94171. * @param constructorFunc defines the constructor function
  94172. */
  94173. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94174. /**
  94175. * Returns a node constructor based on type name
  94176. * @param type defines the type name
  94177. * @param name defines the new node name
  94178. * @param scene defines the hosting scene
  94179. * @param options defines optional options to transmit to constructors
  94180. * @returns the new constructor or null
  94181. */
  94182. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94183. /**
  94184. * Gets or sets the name of the node
  94185. */
  94186. name: string;
  94187. /**
  94188. * Gets or sets the id of the node
  94189. */
  94190. id: string;
  94191. /**
  94192. * Gets or sets the unique id of the node
  94193. */
  94194. uniqueId: number;
  94195. /**
  94196. * Gets or sets a string used to store user defined state for the node
  94197. */
  94198. state: string;
  94199. /**
  94200. * Gets or sets an object used to store user defined information for the node
  94201. */
  94202. metadata: any;
  94203. /**
  94204. * For internal use only. Please do not use.
  94205. */
  94206. reservedDataStore: any;
  94207. /**
  94208. * List of inspectable custom properties (used by the Inspector)
  94209. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94210. */
  94211. inspectableCustomProperties: IInspectable[];
  94212. private _doNotSerialize;
  94213. /**
  94214. * Gets or sets a boolean used to define if the node must be serialized
  94215. */
  94216. doNotSerialize: boolean;
  94217. /** @hidden */
  94218. _isDisposed: boolean;
  94219. /**
  94220. * Gets a list of Animations associated with the node
  94221. */
  94222. animations: Animation[];
  94223. protected _ranges: {
  94224. [name: string]: Nullable<AnimationRange>;
  94225. };
  94226. /**
  94227. * Callback raised when the node is ready to be used
  94228. */
  94229. onReady: Nullable<(node: Node) => void>;
  94230. private _isEnabled;
  94231. private _isParentEnabled;
  94232. private _isReady;
  94233. /** @hidden */
  94234. _currentRenderId: number;
  94235. private _parentUpdateId;
  94236. /** @hidden */
  94237. _childUpdateId: number;
  94238. /** @hidden */
  94239. _waitingParentId: Nullable<string>;
  94240. /** @hidden */
  94241. _scene: Scene;
  94242. /** @hidden */
  94243. _cache: any;
  94244. private _parentNode;
  94245. private _children;
  94246. /** @hidden */
  94247. _worldMatrix: Matrix;
  94248. /** @hidden */
  94249. _worldMatrixDeterminant: number;
  94250. /** @hidden */
  94251. _worldMatrixDeterminantIsDirty: boolean;
  94252. /** @hidden */
  94253. private _sceneRootNodesIndex;
  94254. /**
  94255. * Gets a boolean indicating if the node has been disposed
  94256. * @returns true if the node was disposed
  94257. */
  94258. isDisposed(): boolean;
  94259. /**
  94260. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94261. * @see https://doc.babylonjs.com/how_to/parenting
  94262. */
  94263. parent: Nullable<Node>;
  94264. private addToSceneRootNodes;
  94265. private removeFromSceneRootNodes;
  94266. private _animationPropertiesOverride;
  94267. /**
  94268. * Gets or sets the animation properties override
  94269. */
  94270. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94271. /**
  94272. * Gets a string idenfifying the name of the class
  94273. * @returns "Node" string
  94274. */
  94275. getClassName(): string;
  94276. /** @hidden */
  94277. readonly _isNode: boolean;
  94278. /**
  94279. * An event triggered when the mesh is disposed
  94280. */
  94281. onDisposeObservable: Observable<Node>;
  94282. private _onDisposeObserver;
  94283. /**
  94284. * Sets a callback that will be raised when the node will be disposed
  94285. */
  94286. onDispose: () => void;
  94287. /**
  94288. * Creates a new Node
  94289. * @param name the name and id to be given to this node
  94290. * @param scene the scene this node will be added to
  94291. * @param addToRootNodes the node will be added to scene.rootNodes
  94292. */
  94293. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94294. /**
  94295. * Gets the scene of the node
  94296. * @returns a scene
  94297. */
  94298. getScene(): Scene;
  94299. /**
  94300. * Gets the engine of the node
  94301. * @returns a Engine
  94302. */
  94303. getEngine(): Engine;
  94304. private _behaviors;
  94305. /**
  94306. * Attach a behavior to the node
  94307. * @see http://doc.babylonjs.com/features/behaviour
  94308. * @param behavior defines the behavior to attach
  94309. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94310. * @returns the current Node
  94311. */
  94312. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94313. /**
  94314. * Remove an attached behavior
  94315. * @see http://doc.babylonjs.com/features/behaviour
  94316. * @param behavior defines the behavior to attach
  94317. * @returns the current Node
  94318. */
  94319. removeBehavior(behavior: Behavior<Node>): Node;
  94320. /**
  94321. * Gets the list of attached behaviors
  94322. * @see http://doc.babylonjs.com/features/behaviour
  94323. */
  94324. readonly behaviors: Behavior<Node>[];
  94325. /**
  94326. * Gets an attached behavior by name
  94327. * @param name defines the name of the behavior to look for
  94328. * @see http://doc.babylonjs.com/features/behaviour
  94329. * @returns null if behavior was not found else the requested behavior
  94330. */
  94331. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94332. /**
  94333. * Returns the latest update of the World matrix
  94334. * @returns a Matrix
  94335. */
  94336. getWorldMatrix(): Matrix;
  94337. /** @hidden */
  94338. _getWorldMatrixDeterminant(): number;
  94339. /**
  94340. * Returns directly the latest state of the mesh World matrix.
  94341. * A Matrix is returned.
  94342. */
  94343. readonly worldMatrixFromCache: Matrix;
  94344. /** @hidden */
  94345. _initCache(): void;
  94346. /** @hidden */
  94347. updateCache(force?: boolean): void;
  94348. /** @hidden */
  94349. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94350. /** @hidden */
  94351. _updateCache(ignoreParentClass?: boolean): void;
  94352. /** @hidden */
  94353. _isSynchronized(): boolean;
  94354. /** @hidden */
  94355. _markSyncedWithParent(): void;
  94356. /** @hidden */
  94357. isSynchronizedWithParent(): boolean;
  94358. /** @hidden */
  94359. isSynchronized(): boolean;
  94360. /**
  94361. * Is this node ready to be used/rendered
  94362. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94363. * @return true if the node is ready
  94364. */
  94365. isReady(completeCheck?: boolean): boolean;
  94366. /**
  94367. * Is this node enabled?
  94368. * 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
  94369. * @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
  94370. * @return whether this node (and its parent) is enabled
  94371. */
  94372. isEnabled(checkAncestors?: boolean): boolean;
  94373. /** @hidden */
  94374. protected _syncParentEnabledState(): void;
  94375. /**
  94376. * Set the enabled state of this node
  94377. * @param value defines the new enabled state
  94378. */
  94379. setEnabled(value: boolean): void;
  94380. /**
  94381. * Is this node a descendant of the given node?
  94382. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94383. * @param ancestor defines the parent node to inspect
  94384. * @returns a boolean indicating if this node is a descendant of the given node
  94385. */
  94386. isDescendantOf(ancestor: Node): boolean;
  94387. /** @hidden */
  94388. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94389. /**
  94390. * Will return all nodes that have this node as ascendant
  94391. * @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
  94392. * @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
  94393. * @return all children nodes of all types
  94394. */
  94395. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94396. /**
  94397. * Get all child-meshes of this node
  94398. * @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)
  94399. * @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
  94400. * @returns an array of AbstractMesh
  94401. */
  94402. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94403. /**
  94404. * Get all direct children of this node
  94405. * @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
  94406. * @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)
  94407. * @returns an array of Node
  94408. */
  94409. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94410. /** @hidden */
  94411. _setReady(state: boolean): void;
  94412. /**
  94413. * Get an animation by name
  94414. * @param name defines the name of the animation to look for
  94415. * @returns null if not found else the requested animation
  94416. */
  94417. getAnimationByName(name: string): Nullable<Animation>;
  94418. /**
  94419. * Creates an animation range for this node
  94420. * @param name defines the name of the range
  94421. * @param from defines the starting key
  94422. * @param to defines the end key
  94423. */
  94424. createAnimationRange(name: string, from: number, to: number): void;
  94425. /**
  94426. * Delete a specific animation range
  94427. * @param name defines the name of the range to delete
  94428. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94429. */
  94430. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94431. /**
  94432. * Get an animation range by name
  94433. * @param name defines the name of the animation range to look for
  94434. * @returns null if not found else the requested animation range
  94435. */
  94436. getAnimationRange(name: string): Nullable<AnimationRange>;
  94437. /**
  94438. * Gets the list of all animation ranges defined on this node
  94439. * @returns an array
  94440. */
  94441. getAnimationRanges(): Nullable<AnimationRange>[];
  94442. /**
  94443. * Will start the animation sequence
  94444. * @param name defines the range frames for animation sequence
  94445. * @param loop defines if the animation should loop (false by default)
  94446. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94447. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94448. * @returns the object created for this animation. If range does not exist, it will return null
  94449. */
  94450. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94451. /**
  94452. * Serialize animation ranges into a JSON compatible object
  94453. * @returns serialization object
  94454. */
  94455. serializeAnimationRanges(): any;
  94456. /**
  94457. * Computes the world matrix of the node
  94458. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94459. * @returns the world matrix
  94460. */
  94461. computeWorldMatrix(force?: boolean): Matrix;
  94462. /**
  94463. * Releases resources associated with this node.
  94464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94466. */
  94467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94468. /**
  94469. * Parse animation range data from a serialization object and store them into a given node
  94470. * @param node defines where to store the animation ranges
  94471. * @param parsedNode defines the serialization object to read data from
  94472. * @param scene defines the hosting scene
  94473. */
  94474. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94475. /**
  94476. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94477. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94478. * @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
  94479. * @returns the new bounding vectors
  94480. */
  94481. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94482. min: Vector3;
  94483. max: Vector3;
  94484. };
  94485. }
  94486. }
  94487. declare module BABYLON {
  94488. /**
  94489. * @hidden
  94490. */
  94491. export class _IAnimationState {
  94492. key: number;
  94493. repeatCount: number;
  94494. workValue?: any;
  94495. loopMode?: number;
  94496. offsetValue?: any;
  94497. highLimitValue?: any;
  94498. }
  94499. /**
  94500. * Class used to store any kind of animation
  94501. */
  94502. export class Animation {
  94503. /**Name of the animation */
  94504. name: string;
  94505. /**Property to animate */
  94506. targetProperty: string;
  94507. /**The frames per second of the animation */
  94508. framePerSecond: number;
  94509. /**The data type of the animation */
  94510. dataType: number;
  94511. /**The loop mode of the animation */
  94512. loopMode?: number | undefined;
  94513. /**Specifies if blending should be enabled */
  94514. enableBlending?: boolean | undefined;
  94515. /**
  94516. * Use matrix interpolation instead of using direct key value when animating matrices
  94517. */
  94518. static AllowMatricesInterpolation: boolean;
  94519. /**
  94520. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94521. */
  94522. static AllowMatrixDecomposeForInterpolation: boolean;
  94523. /**
  94524. * Stores the key frames of the animation
  94525. */
  94526. private _keys;
  94527. /**
  94528. * Stores the easing function of the animation
  94529. */
  94530. private _easingFunction;
  94531. /**
  94532. * @hidden Internal use only
  94533. */
  94534. _runtimeAnimations: RuntimeAnimation[];
  94535. /**
  94536. * The set of event that will be linked to this animation
  94537. */
  94538. private _events;
  94539. /**
  94540. * Stores an array of target property paths
  94541. */
  94542. targetPropertyPath: string[];
  94543. /**
  94544. * Stores the blending speed of the animation
  94545. */
  94546. blendingSpeed: number;
  94547. /**
  94548. * Stores the animation ranges for the animation
  94549. */
  94550. private _ranges;
  94551. /**
  94552. * @hidden Internal use
  94553. */
  94554. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94555. /**
  94556. * Sets up an animation
  94557. * @param property The property to animate
  94558. * @param animationType The animation type to apply
  94559. * @param framePerSecond The frames per second of the animation
  94560. * @param easingFunction The easing function used in the animation
  94561. * @returns The created animation
  94562. */
  94563. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94564. /**
  94565. * Create and start an animation on a node
  94566. * @param name defines the name of the global animation that will be run on all nodes
  94567. * @param node defines the root node where the animation will take place
  94568. * @param targetProperty defines property to animate
  94569. * @param framePerSecond defines the number of frame per second yo use
  94570. * @param totalFrame defines the number of frames in total
  94571. * @param from defines the initial value
  94572. * @param to defines the final value
  94573. * @param loopMode defines which loop mode you want to use (off by default)
  94574. * @param easingFunction defines the easing function to use (linear by default)
  94575. * @param onAnimationEnd defines the callback to call when animation end
  94576. * @returns the animatable created for this animation
  94577. */
  94578. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94579. /**
  94580. * Create and start an animation on a node and its descendants
  94581. * @param name defines the name of the global animation that will be run on all nodes
  94582. * @param node defines the root node where the animation will take place
  94583. * @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
  94584. * @param targetProperty defines property to animate
  94585. * @param framePerSecond defines the number of frame per second to use
  94586. * @param totalFrame defines the number of frames in total
  94587. * @param from defines the initial value
  94588. * @param to defines the final value
  94589. * @param loopMode defines which loop mode you want to use (off by default)
  94590. * @param easingFunction defines the easing function to use (linear by default)
  94591. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94592. * @returns the list of animatables created for all nodes
  94593. * @example https://www.babylonjs-playground.com/#MH0VLI
  94594. */
  94595. 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[]>;
  94596. /**
  94597. * Creates a new animation, merges it with the existing animations and starts it
  94598. * @param name Name of the animation
  94599. * @param node Node which contains the scene that begins the animations
  94600. * @param targetProperty Specifies which property to animate
  94601. * @param framePerSecond The frames per second of the animation
  94602. * @param totalFrame The total number of frames
  94603. * @param from The frame at the beginning of the animation
  94604. * @param to The frame at the end of the animation
  94605. * @param loopMode Specifies the loop mode of the animation
  94606. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94607. * @param onAnimationEnd Callback to run once the animation is complete
  94608. * @returns Nullable animation
  94609. */
  94610. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94611. /**
  94612. * Transition property of an host to the target Value
  94613. * @param property The property to transition
  94614. * @param targetValue The target Value of the property
  94615. * @param host The object where the property to animate belongs
  94616. * @param scene Scene used to run the animation
  94617. * @param frameRate Framerate (in frame/s) to use
  94618. * @param transition The transition type we want to use
  94619. * @param duration The duration of the animation, in milliseconds
  94620. * @param onAnimationEnd Callback trigger at the end of the animation
  94621. * @returns Nullable animation
  94622. */
  94623. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94624. /**
  94625. * Return the array of runtime animations currently using this animation
  94626. */
  94627. readonly runtimeAnimations: RuntimeAnimation[];
  94628. /**
  94629. * Specifies if any of the runtime animations are currently running
  94630. */
  94631. readonly hasRunningRuntimeAnimations: boolean;
  94632. /**
  94633. * Initializes the animation
  94634. * @param name Name of the animation
  94635. * @param targetProperty Property to animate
  94636. * @param framePerSecond The frames per second of the animation
  94637. * @param dataType The data type of the animation
  94638. * @param loopMode The loop mode of the animation
  94639. * @param enableBlending Specifies if blending should be enabled
  94640. */
  94641. constructor(
  94642. /**Name of the animation */
  94643. name: string,
  94644. /**Property to animate */
  94645. targetProperty: string,
  94646. /**The frames per second of the animation */
  94647. framePerSecond: number,
  94648. /**The data type of the animation */
  94649. dataType: number,
  94650. /**The loop mode of the animation */
  94651. loopMode?: number | undefined,
  94652. /**Specifies if blending should be enabled */
  94653. enableBlending?: boolean | undefined);
  94654. /**
  94655. * Converts the animation to a string
  94656. * @param fullDetails support for multiple levels of logging within scene loading
  94657. * @returns String form of the animation
  94658. */
  94659. toString(fullDetails?: boolean): string;
  94660. /**
  94661. * Add an event to this animation
  94662. * @param event Event to add
  94663. */
  94664. addEvent(event: AnimationEvent): void;
  94665. /**
  94666. * Remove all events found at the given frame
  94667. * @param frame The frame to remove events from
  94668. */
  94669. removeEvents(frame: number): void;
  94670. /**
  94671. * Retrieves all the events from the animation
  94672. * @returns Events from the animation
  94673. */
  94674. getEvents(): AnimationEvent[];
  94675. /**
  94676. * Creates an animation range
  94677. * @param name Name of the animation range
  94678. * @param from Starting frame of the animation range
  94679. * @param to Ending frame of the animation
  94680. */
  94681. createRange(name: string, from: number, to: number): void;
  94682. /**
  94683. * Deletes an animation range by name
  94684. * @param name Name of the animation range to delete
  94685. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94686. */
  94687. deleteRange(name: string, deleteFrames?: boolean): void;
  94688. /**
  94689. * Gets the animation range by name, or null if not defined
  94690. * @param name Name of the animation range
  94691. * @returns Nullable animation range
  94692. */
  94693. getRange(name: string): Nullable<AnimationRange>;
  94694. /**
  94695. * Gets the key frames from the animation
  94696. * @returns The key frames of the animation
  94697. */
  94698. getKeys(): Array<IAnimationKey>;
  94699. /**
  94700. * Gets the highest frame rate of the animation
  94701. * @returns Highest frame rate of the animation
  94702. */
  94703. getHighestFrame(): number;
  94704. /**
  94705. * Gets the easing function of the animation
  94706. * @returns Easing function of the animation
  94707. */
  94708. getEasingFunction(): IEasingFunction;
  94709. /**
  94710. * Sets the easing function of the animation
  94711. * @param easingFunction A custom mathematical formula for animation
  94712. */
  94713. setEasingFunction(easingFunction: EasingFunction): void;
  94714. /**
  94715. * Interpolates a scalar linearly
  94716. * @param startValue Start value of the animation curve
  94717. * @param endValue End value of the animation curve
  94718. * @param gradient Scalar amount to interpolate
  94719. * @returns Interpolated scalar value
  94720. */
  94721. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94722. /**
  94723. * Interpolates a scalar cubically
  94724. * @param startValue Start value of the animation curve
  94725. * @param outTangent End tangent of the animation
  94726. * @param endValue End value of the animation curve
  94727. * @param inTangent Start tangent of the animation curve
  94728. * @param gradient Scalar amount to interpolate
  94729. * @returns Interpolated scalar value
  94730. */
  94731. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94732. /**
  94733. * Interpolates a quaternion using a spherical linear interpolation
  94734. * @param startValue Start value of the animation curve
  94735. * @param endValue End value of the animation curve
  94736. * @param gradient Scalar amount to interpolate
  94737. * @returns Interpolated quaternion value
  94738. */
  94739. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94740. /**
  94741. * Interpolates a quaternion cubically
  94742. * @param startValue Start value of the animation curve
  94743. * @param outTangent End tangent of the animation curve
  94744. * @param endValue End value of the animation curve
  94745. * @param inTangent Start tangent of the animation curve
  94746. * @param gradient Scalar amount to interpolate
  94747. * @returns Interpolated quaternion value
  94748. */
  94749. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94750. /**
  94751. * Interpolates a Vector3 linearl
  94752. * @param startValue Start value of the animation curve
  94753. * @param endValue End value of the animation curve
  94754. * @param gradient Scalar amount to interpolate
  94755. * @returns Interpolated scalar value
  94756. */
  94757. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94758. /**
  94759. * Interpolates a Vector3 cubically
  94760. * @param startValue Start value of the animation curve
  94761. * @param outTangent End tangent of the animation
  94762. * @param endValue End value of the animation curve
  94763. * @param inTangent Start tangent of the animation curve
  94764. * @param gradient Scalar amount to interpolate
  94765. * @returns InterpolatedVector3 value
  94766. */
  94767. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94768. /**
  94769. * Interpolates a Vector2 linearly
  94770. * @param startValue Start value of the animation curve
  94771. * @param endValue End value of the animation curve
  94772. * @param gradient Scalar amount to interpolate
  94773. * @returns Interpolated Vector2 value
  94774. */
  94775. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94776. /**
  94777. * Interpolates a Vector2 cubically
  94778. * @param startValue Start value of the animation curve
  94779. * @param outTangent End tangent of the animation
  94780. * @param endValue End value of the animation curve
  94781. * @param inTangent Start tangent of the animation curve
  94782. * @param gradient Scalar amount to interpolate
  94783. * @returns Interpolated Vector2 value
  94784. */
  94785. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94786. /**
  94787. * Interpolates a size linearly
  94788. * @param startValue Start value of the animation curve
  94789. * @param endValue End value of the animation curve
  94790. * @param gradient Scalar amount to interpolate
  94791. * @returns Interpolated Size value
  94792. */
  94793. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94794. /**
  94795. * Interpolates a Color3 linearly
  94796. * @param startValue Start value of the animation curve
  94797. * @param endValue End value of the animation curve
  94798. * @param gradient Scalar amount to interpolate
  94799. * @returns Interpolated Color3 value
  94800. */
  94801. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94802. /**
  94803. * @hidden Internal use only
  94804. */
  94805. _getKeyValue(value: any): any;
  94806. /**
  94807. * @hidden Internal use only
  94808. */
  94809. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94810. /**
  94811. * Defines the function to use to interpolate matrices
  94812. * @param startValue defines the start matrix
  94813. * @param endValue defines the end matrix
  94814. * @param gradient defines the gradient between both matrices
  94815. * @param result defines an optional target matrix where to store the interpolation
  94816. * @returns the interpolated matrix
  94817. */
  94818. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94819. /**
  94820. * Makes a copy of the animation
  94821. * @returns Cloned animation
  94822. */
  94823. clone(): Animation;
  94824. /**
  94825. * Sets the key frames of the animation
  94826. * @param values The animation key frames to set
  94827. */
  94828. setKeys(values: Array<IAnimationKey>): void;
  94829. /**
  94830. * Serializes the animation to an object
  94831. * @returns Serialized object
  94832. */
  94833. serialize(): any;
  94834. /**
  94835. * Float animation type
  94836. */
  94837. private static _ANIMATIONTYPE_FLOAT;
  94838. /**
  94839. * Vector3 animation type
  94840. */
  94841. private static _ANIMATIONTYPE_VECTOR3;
  94842. /**
  94843. * Quaternion animation type
  94844. */
  94845. private static _ANIMATIONTYPE_QUATERNION;
  94846. /**
  94847. * Matrix animation type
  94848. */
  94849. private static _ANIMATIONTYPE_MATRIX;
  94850. /**
  94851. * Color3 animation type
  94852. */
  94853. private static _ANIMATIONTYPE_COLOR3;
  94854. /**
  94855. * Vector2 animation type
  94856. */
  94857. private static _ANIMATIONTYPE_VECTOR2;
  94858. /**
  94859. * Size animation type
  94860. */
  94861. private static _ANIMATIONTYPE_SIZE;
  94862. /**
  94863. * Relative Loop Mode
  94864. */
  94865. private static _ANIMATIONLOOPMODE_RELATIVE;
  94866. /**
  94867. * Cycle Loop Mode
  94868. */
  94869. private static _ANIMATIONLOOPMODE_CYCLE;
  94870. /**
  94871. * Constant Loop Mode
  94872. */
  94873. private static _ANIMATIONLOOPMODE_CONSTANT;
  94874. /**
  94875. * Get the float animation type
  94876. */
  94877. static readonly ANIMATIONTYPE_FLOAT: number;
  94878. /**
  94879. * Get the Vector3 animation type
  94880. */
  94881. static readonly ANIMATIONTYPE_VECTOR3: number;
  94882. /**
  94883. * Get the Vector2 animation type
  94884. */
  94885. static readonly ANIMATIONTYPE_VECTOR2: number;
  94886. /**
  94887. * Get the Size animation type
  94888. */
  94889. static readonly ANIMATIONTYPE_SIZE: number;
  94890. /**
  94891. * Get the Quaternion animation type
  94892. */
  94893. static readonly ANIMATIONTYPE_QUATERNION: number;
  94894. /**
  94895. * Get the Matrix animation type
  94896. */
  94897. static readonly ANIMATIONTYPE_MATRIX: number;
  94898. /**
  94899. * Get the Color3 animation type
  94900. */
  94901. static readonly ANIMATIONTYPE_COLOR3: number;
  94902. /**
  94903. * Get the Relative Loop Mode
  94904. */
  94905. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94906. /**
  94907. * Get the Cycle Loop Mode
  94908. */
  94909. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94910. /**
  94911. * Get the Constant Loop Mode
  94912. */
  94913. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94914. /** @hidden */
  94915. static _UniversalLerp(left: any, right: any, amount: number): any;
  94916. /**
  94917. * Parses an animation object and creates an animation
  94918. * @param parsedAnimation Parsed animation object
  94919. * @returns Animation object
  94920. */
  94921. static Parse(parsedAnimation: any): Animation;
  94922. /**
  94923. * Appends the serialized animations from the source animations
  94924. * @param source Source containing the animations
  94925. * @param destination Target to store the animations
  94926. */
  94927. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94928. }
  94929. }
  94930. declare module BABYLON {
  94931. /**
  94932. * Interface containing an array of animations
  94933. */
  94934. export interface IAnimatable {
  94935. /**
  94936. * Array of animations
  94937. */
  94938. animations: Nullable<Array<Animation>>;
  94939. }
  94940. }
  94941. declare module BABYLON {
  94942. /**
  94943. * This represents all the required information to add a fresnel effect on a material:
  94944. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94945. */
  94946. export class FresnelParameters {
  94947. private _isEnabled;
  94948. /**
  94949. * Define if the fresnel effect is enable or not.
  94950. */
  94951. isEnabled: boolean;
  94952. /**
  94953. * Define the color used on edges (grazing angle)
  94954. */
  94955. leftColor: Color3;
  94956. /**
  94957. * Define the color used on center
  94958. */
  94959. rightColor: Color3;
  94960. /**
  94961. * Define bias applied to computed fresnel term
  94962. */
  94963. bias: number;
  94964. /**
  94965. * Defined the power exponent applied to fresnel term
  94966. */
  94967. power: number;
  94968. /**
  94969. * Clones the current fresnel and its valuues
  94970. * @returns a clone fresnel configuration
  94971. */
  94972. clone(): FresnelParameters;
  94973. /**
  94974. * Serializes the current fresnel parameters to a JSON representation.
  94975. * @return the JSON serialization
  94976. */
  94977. serialize(): any;
  94978. /**
  94979. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94980. * @param parsedFresnelParameters Define the JSON representation
  94981. * @returns the parsed parameters
  94982. */
  94983. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94984. }
  94985. }
  94986. declare module BABYLON {
  94987. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94988. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94989. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94990. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94991. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94992. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94993. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94994. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94995. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94996. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94997. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94998. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94999. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95000. /**
  95001. * Decorator used to define property that can be serialized as reference to a camera
  95002. * @param sourceName defines the name of the property to decorate
  95003. */
  95004. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95005. /**
  95006. * Class used to help serialization objects
  95007. */
  95008. export class SerializationHelper {
  95009. /** @hidden */
  95010. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95011. /** @hidden */
  95012. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95013. /** @hidden */
  95014. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95015. /** @hidden */
  95016. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95017. /**
  95018. * Appends the serialized animations from the source animations
  95019. * @param source Source containing the animations
  95020. * @param destination Target to store the animations
  95021. */
  95022. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95023. /**
  95024. * Static function used to serialized a specific entity
  95025. * @param entity defines the entity to serialize
  95026. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95027. * @returns a JSON compatible object representing the serialization of the entity
  95028. */
  95029. static Serialize<T>(entity: T, serializationObject?: any): any;
  95030. /**
  95031. * Creates a new entity from a serialization data object
  95032. * @param creationFunction defines a function used to instanciated the new entity
  95033. * @param source defines the source serialization data
  95034. * @param scene defines the hosting scene
  95035. * @param rootUrl defines the root url for resources
  95036. * @returns a new entity
  95037. */
  95038. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95039. /**
  95040. * Clones an object
  95041. * @param creationFunction defines the function used to instanciate the new object
  95042. * @param source defines the source object
  95043. * @returns the cloned object
  95044. */
  95045. static Clone<T>(creationFunction: () => T, source: T): T;
  95046. /**
  95047. * Instanciates a new object based on a source one (some data will be shared between both object)
  95048. * @param creationFunction defines the function used to instanciate the new object
  95049. * @param source defines the source object
  95050. * @returns the new object
  95051. */
  95052. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95053. }
  95054. }
  95055. declare module BABYLON {
  95056. /**
  95057. * Class used to manipulate GUIDs
  95058. */
  95059. export class GUID {
  95060. /**
  95061. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95062. * Be aware Math.random() could cause collisions, but:
  95063. * "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"
  95064. * @returns a pseudo random id
  95065. */
  95066. static RandomId(): string;
  95067. }
  95068. }
  95069. declare module BABYLON {
  95070. /**
  95071. * Base class of all the textures in babylon.
  95072. * It groups all the common properties the materials, post process, lights... might need
  95073. * in order to make a correct use of the texture.
  95074. */
  95075. export class BaseTexture implements IAnimatable {
  95076. /**
  95077. * Default anisotropic filtering level for the application.
  95078. * It is set to 4 as a good tradeoff between perf and quality.
  95079. */
  95080. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95081. /**
  95082. * Gets or sets the unique id of the texture
  95083. */
  95084. uniqueId: number;
  95085. /**
  95086. * Define the name of the texture.
  95087. */
  95088. name: string;
  95089. /**
  95090. * Gets or sets an object used to store user defined information.
  95091. */
  95092. metadata: any;
  95093. /**
  95094. * For internal use only. Please do not use.
  95095. */
  95096. reservedDataStore: any;
  95097. private _hasAlpha;
  95098. /**
  95099. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95100. */
  95101. hasAlpha: boolean;
  95102. /**
  95103. * Defines if the alpha value should be determined via the rgb values.
  95104. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95105. */
  95106. getAlphaFromRGB: boolean;
  95107. /**
  95108. * Intensity or strength of the texture.
  95109. * It is commonly used by materials to fine tune the intensity of the texture
  95110. */
  95111. level: number;
  95112. /**
  95113. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95114. * This is part of the texture as textures usually maps to one uv set.
  95115. */
  95116. coordinatesIndex: number;
  95117. private _coordinatesMode;
  95118. /**
  95119. * How a texture is mapped.
  95120. *
  95121. * | Value | Type | Description |
  95122. * | ----- | ----------------------------------- | ----------- |
  95123. * | 0 | EXPLICIT_MODE | |
  95124. * | 1 | SPHERICAL_MODE | |
  95125. * | 2 | PLANAR_MODE | |
  95126. * | 3 | CUBIC_MODE | |
  95127. * | 4 | PROJECTION_MODE | |
  95128. * | 5 | SKYBOX_MODE | |
  95129. * | 6 | INVCUBIC_MODE | |
  95130. * | 7 | EQUIRECTANGULAR_MODE | |
  95131. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95132. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95133. */
  95134. coordinatesMode: number;
  95135. /**
  95136. * | Value | Type | Description |
  95137. * | ----- | ------------------ | ----------- |
  95138. * | 0 | CLAMP_ADDRESSMODE | |
  95139. * | 1 | WRAP_ADDRESSMODE | |
  95140. * | 2 | MIRROR_ADDRESSMODE | |
  95141. */
  95142. wrapU: number;
  95143. /**
  95144. * | Value | Type | Description |
  95145. * | ----- | ------------------ | ----------- |
  95146. * | 0 | CLAMP_ADDRESSMODE | |
  95147. * | 1 | WRAP_ADDRESSMODE | |
  95148. * | 2 | MIRROR_ADDRESSMODE | |
  95149. */
  95150. wrapV: number;
  95151. /**
  95152. * | Value | Type | Description |
  95153. * | ----- | ------------------ | ----------- |
  95154. * | 0 | CLAMP_ADDRESSMODE | |
  95155. * | 1 | WRAP_ADDRESSMODE | |
  95156. * | 2 | MIRROR_ADDRESSMODE | |
  95157. */
  95158. wrapR: number;
  95159. /**
  95160. * With compliant hardware and browser (supporting anisotropic filtering)
  95161. * this defines the level of anisotropic filtering in the texture.
  95162. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95163. */
  95164. anisotropicFilteringLevel: number;
  95165. /**
  95166. * Define if the texture is a cube texture or if false a 2d texture.
  95167. */
  95168. isCube: boolean;
  95169. /**
  95170. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95171. */
  95172. is3D: boolean;
  95173. /**
  95174. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95175. * HDR texture are usually stored in linear space.
  95176. * This only impacts the PBR and Background materials
  95177. */
  95178. gammaSpace: boolean;
  95179. /**
  95180. * Gets or sets whether or not the texture contains RGBD data.
  95181. */
  95182. isRGBD: boolean;
  95183. /**
  95184. * Is Z inverted in the texture (useful in a cube texture).
  95185. */
  95186. invertZ: boolean;
  95187. /**
  95188. * Are mip maps generated for this texture or not.
  95189. */
  95190. readonly noMipmap: boolean;
  95191. /**
  95192. * @hidden
  95193. */
  95194. lodLevelInAlpha: boolean;
  95195. /**
  95196. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95197. */
  95198. lodGenerationOffset: number;
  95199. /**
  95200. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95201. */
  95202. lodGenerationScale: number;
  95203. /**
  95204. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95205. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95206. * average roughness values.
  95207. */
  95208. linearSpecularLOD: boolean;
  95209. /**
  95210. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95211. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95212. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95213. */
  95214. irradianceTexture: Nullable<BaseTexture>;
  95215. /**
  95216. * Define if the texture is a render target.
  95217. */
  95218. isRenderTarget: boolean;
  95219. /**
  95220. * Define the unique id of the texture in the scene.
  95221. */
  95222. readonly uid: string;
  95223. /**
  95224. * Return a string representation of the texture.
  95225. * @returns the texture as a string
  95226. */
  95227. toString(): string;
  95228. /**
  95229. * Get the class name of the texture.
  95230. * @returns "BaseTexture"
  95231. */
  95232. getClassName(): string;
  95233. /**
  95234. * Define the list of animation attached to the texture.
  95235. */
  95236. animations: Animation[];
  95237. /**
  95238. * An event triggered when the texture is disposed.
  95239. */
  95240. onDisposeObservable: Observable<BaseTexture>;
  95241. private _onDisposeObserver;
  95242. /**
  95243. * Callback triggered when the texture has been disposed.
  95244. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95245. */
  95246. onDispose: () => void;
  95247. /**
  95248. * Define the current state of the loading sequence when in delayed load mode.
  95249. */
  95250. delayLoadState: number;
  95251. private _scene;
  95252. /** @hidden */
  95253. _texture: Nullable<InternalTexture>;
  95254. private _uid;
  95255. /**
  95256. * Define if the texture is preventinga material to render or not.
  95257. * If not and the texture is not ready, the engine will use a default black texture instead.
  95258. */
  95259. readonly isBlocking: boolean;
  95260. /**
  95261. * Instantiates a new BaseTexture.
  95262. * Base class of all the textures in babylon.
  95263. * It groups all the common properties the materials, post process, lights... might need
  95264. * in order to make a correct use of the texture.
  95265. * @param scene Define the scene the texture blongs to
  95266. */
  95267. constructor(scene: Nullable<Scene>);
  95268. /**
  95269. * Get the scene the texture belongs to.
  95270. * @returns the scene or null if undefined
  95271. */
  95272. getScene(): Nullable<Scene>;
  95273. /**
  95274. * Get the texture transform matrix used to offset tile the texture for istance.
  95275. * @returns the transformation matrix
  95276. */
  95277. getTextureMatrix(): Matrix;
  95278. /**
  95279. * Get the texture reflection matrix used to rotate/transform the reflection.
  95280. * @returns the reflection matrix
  95281. */
  95282. getReflectionTextureMatrix(): Matrix;
  95283. /**
  95284. * Get the underlying lower level texture from Babylon.
  95285. * @returns the insternal texture
  95286. */
  95287. getInternalTexture(): Nullable<InternalTexture>;
  95288. /**
  95289. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95290. * @returns true if ready or not blocking
  95291. */
  95292. isReadyOrNotBlocking(): boolean;
  95293. /**
  95294. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95295. * @returns true if fully ready
  95296. */
  95297. isReady(): boolean;
  95298. private _cachedSize;
  95299. /**
  95300. * Get the size of the texture.
  95301. * @returns the texture size.
  95302. */
  95303. getSize(): ISize;
  95304. /**
  95305. * Get the base size of the texture.
  95306. * It can be different from the size if the texture has been resized for POT for instance
  95307. * @returns the base size
  95308. */
  95309. getBaseSize(): ISize;
  95310. /**
  95311. * Update the sampling mode of the texture.
  95312. * Default is Trilinear mode.
  95313. *
  95314. * | Value | Type | Description |
  95315. * | ----- | ------------------ | ----------- |
  95316. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95317. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95318. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95319. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95320. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95321. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95322. * | 7 | NEAREST_LINEAR | |
  95323. * | 8 | NEAREST_NEAREST | |
  95324. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95325. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95326. * | 11 | LINEAR_LINEAR | |
  95327. * | 12 | LINEAR_NEAREST | |
  95328. *
  95329. * > _mag_: magnification filter (close to the viewer)
  95330. * > _min_: minification filter (far from the viewer)
  95331. * > _mip_: filter used between mip map levels
  95332. *@param samplingMode Define the new sampling mode of the texture
  95333. */
  95334. updateSamplingMode(samplingMode: number): void;
  95335. /**
  95336. * Scales the texture if is `canRescale()`
  95337. * @param ratio the resize factor we want to use to rescale
  95338. */
  95339. scale(ratio: number): void;
  95340. /**
  95341. * Get if the texture can rescale.
  95342. */
  95343. readonly canRescale: boolean;
  95344. /** @hidden */
  95345. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95346. /** @hidden */
  95347. _rebuild(): void;
  95348. /**
  95349. * Triggers the load sequence in delayed load mode.
  95350. */
  95351. delayLoad(): void;
  95352. /**
  95353. * Clones the texture.
  95354. * @returns the cloned texture
  95355. */
  95356. clone(): Nullable<BaseTexture>;
  95357. /**
  95358. * Get the texture underlying type (INT, FLOAT...)
  95359. */
  95360. readonly textureType: number;
  95361. /**
  95362. * Get the texture underlying format (RGB, RGBA...)
  95363. */
  95364. readonly textureFormat: number;
  95365. /**
  95366. * Indicates that textures need to be re-calculated for all materials
  95367. */
  95368. protected _markAllSubMeshesAsTexturesDirty(): void;
  95369. /**
  95370. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95371. * This will returns an RGBA array buffer containing either in values (0-255) or
  95372. * float values (0-1) depending of the underlying buffer type.
  95373. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95374. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95375. * @param buffer defines a user defined buffer to fill with data (can be null)
  95376. * @returns The Array buffer containing the pixels data.
  95377. */
  95378. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95379. /**
  95380. * Release and destroy the underlying lower level texture aka internalTexture.
  95381. */
  95382. releaseInternalTexture(): void;
  95383. /** @hidden */
  95384. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95385. /** @hidden */
  95386. readonly _lodTextureMid: Nullable<BaseTexture>;
  95387. /** @hidden */
  95388. readonly _lodTextureLow: Nullable<BaseTexture>;
  95389. /**
  95390. * Dispose the texture and release its associated resources.
  95391. */
  95392. dispose(): void;
  95393. /**
  95394. * Serialize the texture into a JSON representation that can be parsed later on.
  95395. * @returns the JSON representation of the texture
  95396. */
  95397. serialize(): any;
  95398. /**
  95399. * Helper function to be called back once a list of texture contains only ready textures.
  95400. * @param textures Define the list of textures to wait for
  95401. * @param callback Define the callback triggered once the entire list will be ready
  95402. */
  95403. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95404. }
  95405. }
  95406. declare module BABYLON {
  95407. /**
  95408. * Options to be used when creating an effect.
  95409. */
  95410. export interface IEffectCreationOptions {
  95411. /**
  95412. * Atrributes that will be used in the shader.
  95413. */
  95414. attributes: string[];
  95415. /**
  95416. * Uniform varible names that will be set in the shader.
  95417. */
  95418. uniformsNames: string[];
  95419. /**
  95420. * Uniform buffer varible names that will be set in the shader.
  95421. */
  95422. uniformBuffersNames: string[];
  95423. /**
  95424. * Sampler texture variable names that will be set in the shader.
  95425. */
  95426. samplers: string[];
  95427. /**
  95428. * Define statements that will be set in the shader.
  95429. */
  95430. defines: any;
  95431. /**
  95432. * Possible fallbacks for this effect to improve performance when needed.
  95433. */
  95434. fallbacks: Nullable<IEffectFallbacks>;
  95435. /**
  95436. * Callback that will be called when the shader is compiled.
  95437. */
  95438. onCompiled: Nullable<(effect: Effect) => void>;
  95439. /**
  95440. * Callback that will be called if an error occurs during shader compilation.
  95441. */
  95442. onError: Nullable<(effect: Effect, errors: string) => void>;
  95443. /**
  95444. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95445. */
  95446. indexParameters?: any;
  95447. /**
  95448. * Max number of lights that can be used in the shader.
  95449. */
  95450. maxSimultaneousLights?: number;
  95451. /**
  95452. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95453. */
  95454. transformFeedbackVaryings?: Nullable<string[]>;
  95455. }
  95456. /**
  95457. * Effect containing vertex and fragment shader that can be executed on an object.
  95458. */
  95459. export class Effect implements IDisposable {
  95460. /**
  95461. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95462. */
  95463. static ShadersRepository: string;
  95464. /**
  95465. * Name of the effect.
  95466. */
  95467. name: any;
  95468. /**
  95469. * String container all the define statements that should be set on the shader.
  95470. */
  95471. defines: string;
  95472. /**
  95473. * Callback that will be called when the shader is compiled.
  95474. */
  95475. onCompiled: Nullable<(effect: Effect) => void>;
  95476. /**
  95477. * Callback that will be called if an error occurs during shader compilation.
  95478. */
  95479. onError: Nullable<(effect: Effect, errors: string) => void>;
  95480. /**
  95481. * Callback that will be called when effect is bound.
  95482. */
  95483. onBind: Nullable<(effect: Effect) => void>;
  95484. /**
  95485. * Unique ID of the effect.
  95486. */
  95487. uniqueId: number;
  95488. /**
  95489. * Observable that will be called when the shader is compiled.
  95490. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95491. */
  95492. onCompileObservable: Observable<Effect>;
  95493. /**
  95494. * Observable that will be called if an error occurs during shader compilation.
  95495. */
  95496. onErrorObservable: Observable<Effect>;
  95497. /** @hidden */
  95498. _onBindObservable: Nullable<Observable<Effect>>;
  95499. /**
  95500. * Observable that will be called when effect is bound.
  95501. */
  95502. readonly onBindObservable: Observable<Effect>;
  95503. /** @hidden */
  95504. _bonesComputationForcedToCPU: boolean;
  95505. private static _uniqueIdSeed;
  95506. private _engine;
  95507. private _uniformBuffersNames;
  95508. private _uniformsNames;
  95509. private _samplerList;
  95510. private _samplers;
  95511. private _isReady;
  95512. private _compilationError;
  95513. private _allFallbacksProcessed;
  95514. private _attributesNames;
  95515. private _attributes;
  95516. private _uniforms;
  95517. /**
  95518. * Key for the effect.
  95519. * @hidden
  95520. */
  95521. _key: string;
  95522. private _indexParameters;
  95523. private _fallbacks;
  95524. private _vertexSourceCode;
  95525. private _fragmentSourceCode;
  95526. private _vertexSourceCodeOverride;
  95527. private _fragmentSourceCodeOverride;
  95528. private _transformFeedbackVaryings;
  95529. /**
  95530. * Compiled shader to webGL program.
  95531. * @hidden
  95532. */
  95533. _pipelineContext: Nullable<IPipelineContext>;
  95534. private _valueCache;
  95535. private static _baseCache;
  95536. /**
  95537. * Instantiates an effect.
  95538. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95539. * @param baseName Name of the effect.
  95540. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95541. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95542. * @param samplers List of sampler variables that will be passed to the shader.
  95543. * @param engine Engine to be used to render the effect
  95544. * @param defines Define statements to be added to the shader.
  95545. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95546. * @param onCompiled Callback that will be called when the shader is compiled.
  95547. * @param onError Callback that will be called if an error occurs during shader compilation.
  95548. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95549. */
  95550. 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);
  95551. private _useFinalCode;
  95552. /**
  95553. * Unique key for this effect
  95554. */
  95555. readonly key: string;
  95556. /**
  95557. * If the effect has been compiled and prepared.
  95558. * @returns if the effect is compiled and prepared.
  95559. */
  95560. isReady(): boolean;
  95561. private _isReadyInternal;
  95562. /**
  95563. * The engine the effect was initialized with.
  95564. * @returns the engine.
  95565. */
  95566. getEngine(): Engine;
  95567. /**
  95568. * The pipeline context for this effect
  95569. * @returns the associated pipeline context
  95570. */
  95571. getPipelineContext(): Nullable<IPipelineContext>;
  95572. /**
  95573. * The set of names of attribute variables for the shader.
  95574. * @returns An array of attribute names.
  95575. */
  95576. getAttributesNames(): string[];
  95577. /**
  95578. * Returns the attribute at the given index.
  95579. * @param index The index of the attribute.
  95580. * @returns The location of the attribute.
  95581. */
  95582. getAttributeLocation(index: number): number;
  95583. /**
  95584. * Returns the attribute based on the name of the variable.
  95585. * @param name of the attribute to look up.
  95586. * @returns the attribute location.
  95587. */
  95588. getAttributeLocationByName(name: string): number;
  95589. /**
  95590. * The number of attributes.
  95591. * @returns the numnber of attributes.
  95592. */
  95593. getAttributesCount(): number;
  95594. /**
  95595. * Gets the index of a uniform variable.
  95596. * @param uniformName of the uniform to look up.
  95597. * @returns the index.
  95598. */
  95599. getUniformIndex(uniformName: string): number;
  95600. /**
  95601. * Returns the attribute based on the name of the variable.
  95602. * @param uniformName of the uniform to look up.
  95603. * @returns the location of the uniform.
  95604. */
  95605. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95606. /**
  95607. * Returns an array of sampler variable names
  95608. * @returns The array of sampler variable neames.
  95609. */
  95610. getSamplers(): string[];
  95611. /**
  95612. * The error from the last compilation.
  95613. * @returns the error string.
  95614. */
  95615. getCompilationError(): string;
  95616. /**
  95617. * Gets a boolean indicating that all fallbacks were used during compilation
  95618. * @returns true if all fallbacks were used
  95619. */
  95620. allFallbacksProcessed(): boolean;
  95621. /**
  95622. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95623. * @param func The callback to be used.
  95624. */
  95625. executeWhenCompiled(func: (effect: Effect) => void): void;
  95626. private _checkIsReady;
  95627. private _loadShader;
  95628. /**
  95629. * Recompiles the webGL program
  95630. * @param vertexSourceCode The source code for the vertex shader.
  95631. * @param fragmentSourceCode The source code for the fragment shader.
  95632. * @param onCompiled Callback called when completed.
  95633. * @param onError Callback called on error.
  95634. * @hidden
  95635. */
  95636. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95637. /**
  95638. * Prepares the effect
  95639. * @hidden
  95640. */
  95641. _prepareEffect(): void;
  95642. private _processCompilationErrors;
  95643. /**
  95644. * Checks if the effect is supported. (Must be called after compilation)
  95645. */
  95646. readonly isSupported: boolean;
  95647. /**
  95648. * Binds a texture to the engine to be used as output of the shader.
  95649. * @param channel Name of the output variable.
  95650. * @param texture Texture to bind.
  95651. * @hidden
  95652. */
  95653. _bindTexture(channel: string, texture: InternalTexture): void;
  95654. /**
  95655. * Sets a texture on the engine to be used in the shader.
  95656. * @param channel Name of the sampler variable.
  95657. * @param texture Texture to set.
  95658. */
  95659. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95660. /**
  95661. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95662. * @param channel Name of the sampler variable.
  95663. * @param texture Texture to set.
  95664. */
  95665. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95666. /**
  95667. * Sets an array of textures on the engine to be used in the shader.
  95668. * @param channel Name of the variable.
  95669. * @param textures Textures to set.
  95670. */
  95671. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95672. /**
  95673. * 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)
  95674. * @param channel Name of the sampler variable.
  95675. * @param postProcess Post process to get the input texture from.
  95676. */
  95677. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95678. /**
  95679. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95680. * 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)
  95681. * @param channel Name of the sampler variable.
  95682. * @param postProcess Post process to get the output texture from.
  95683. */
  95684. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95685. /** @hidden */
  95686. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95687. /** @hidden */
  95688. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95689. /** @hidden */
  95690. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95691. /** @hidden */
  95692. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95693. /**
  95694. * Binds a buffer to a uniform.
  95695. * @param buffer Buffer to bind.
  95696. * @param name Name of the uniform variable to bind to.
  95697. */
  95698. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95699. /**
  95700. * Binds block to a uniform.
  95701. * @param blockName Name of the block to bind.
  95702. * @param index Index to bind.
  95703. */
  95704. bindUniformBlock(blockName: string, index: number): void;
  95705. /**
  95706. * Sets an interger value on a uniform variable.
  95707. * @param uniformName Name of the variable.
  95708. * @param value Value to be set.
  95709. * @returns this effect.
  95710. */
  95711. setInt(uniformName: string, value: number): Effect;
  95712. /**
  95713. * Sets an int array on a uniform variable.
  95714. * @param uniformName Name of the variable.
  95715. * @param array array to be set.
  95716. * @returns this effect.
  95717. */
  95718. setIntArray(uniformName: string, array: Int32Array): Effect;
  95719. /**
  95720. * 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)
  95721. * @param uniformName Name of the variable.
  95722. * @param array array to be set.
  95723. * @returns this effect.
  95724. */
  95725. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95726. /**
  95727. * 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)
  95728. * @param uniformName Name of the variable.
  95729. * @param array array to be set.
  95730. * @returns this effect.
  95731. */
  95732. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95733. /**
  95734. * 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)
  95735. * @param uniformName Name of the variable.
  95736. * @param array array to be set.
  95737. * @returns this effect.
  95738. */
  95739. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95740. /**
  95741. * Sets an float array on a uniform variable.
  95742. * @param uniformName Name of the variable.
  95743. * @param array array to be set.
  95744. * @returns this effect.
  95745. */
  95746. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95747. /**
  95748. * 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)
  95749. * @param uniformName Name of the variable.
  95750. * @param array array to be set.
  95751. * @returns this effect.
  95752. */
  95753. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95754. /**
  95755. * 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)
  95756. * @param uniformName Name of the variable.
  95757. * @param array array to be set.
  95758. * @returns this effect.
  95759. */
  95760. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95761. /**
  95762. * 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)
  95763. * @param uniformName Name of the variable.
  95764. * @param array array to be set.
  95765. * @returns this effect.
  95766. */
  95767. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95768. /**
  95769. * Sets an array on a uniform variable.
  95770. * @param uniformName Name of the variable.
  95771. * @param array array to be set.
  95772. * @returns this effect.
  95773. */
  95774. setArray(uniformName: string, array: number[]): Effect;
  95775. /**
  95776. * 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)
  95777. * @param uniformName Name of the variable.
  95778. * @param array array to be set.
  95779. * @returns this effect.
  95780. */
  95781. setArray2(uniformName: string, array: number[]): Effect;
  95782. /**
  95783. * 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)
  95784. * @param uniformName Name of the variable.
  95785. * @param array array to be set.
  95786. * @returns this effect.
  95787. */
  95788. setArray3(uniformName: string, array: number[]): Effect;
  95789. /**
  95790. * 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)
  95791. * @param uniformName Name of the variable.
  95792. * @param array array to be set.
  95793. * @returns this effect.
  95794. */
  95795. setArray4(uniformName: string, array: number[]): Effect;
  95796. /**
  95797. * Sets matrices on a uniform variable.
  95798. * @param uniformName Name of the variable.
  95799. * @param matrices matrices to be set.
  95800. * @returns this effect.
  95801. */
  95802. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95803. /**
  95804. * Sets matrix on a uniform variable.
  95805. * @param uniformName Name of the variable.
  95806. * @param matrix matrix to be set.
  95807. * @returns this effect.
  95808. */
  95809. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95810. /**
  95811. * 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)
  95812. * @param uniformName Name of the variable.
  95813. * @param matrix matrix to be set.
  95814. * @returns this effect.
  95815. */
  95816. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95817. /**
  95818. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95819. * @param uniformName Name of the variable.
  95820. * @param matrix matrix to be set.
  95821. * @returns this effect.
  95822. */
  95823. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95824. /**
  95825. * Sets a float on a uniform variable.
  95826. * @param uniformName Name of the variable.
  95827. * @param value value to be set.
  95828. * @returns this effect.
  95829. */
  95830. setFloat(uniformName: string, value: number): Effect;
  95831. /**
  95832. * Sets a boolean on a uniform variable.
  95833. * @param uniformName Name of the variable.
  95834. * @param bool value to be set.
  95835. * @returns this effect.
  95836. */
  95837. setBool(uniformName: string, bool: boolean): Effect;
  95838. /**
  95839. * Sets a Vector2 on a uniform variable.
  95840. * @param uniformName Name of the variable.
  95841. * @param vector2 vector2 to be set.
  95842. * @returns this effect.
  95843. */
  95844. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95845. /**
  95846. * Sets a float2 on a uniform variable.
  95847. * @param uniformName Name of the variable.
  95848. * @param x First float in float2.
  95849. * @param y Second float in float2.
  95850. * @returns this effect.
  95851. */
  95852. setFloat2(uniformName: string, x: number, y: number): Effect;
  95853. /**
  95854. * Sets a Vector3 on a uniform variable.
  95855. * @param uniformName Name of the variable.
  95856. * @param vector3 Value to be set.
  95857. * @returns this effect.
  95858. */
  95859. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95860. /**
  95861. * Sets a float3 on a uniform variable.
  95862. * @param uniformName Name of the variable.
  95863. * @param x First float in float3.
  95864. * @param y Second float in float3.
  95865. * @param z Third float in float3.
  95866. * @returns this effect.
  95867. */
  95868. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95869. /**
  95870. * Sets a Vector4 on a uniform variable.
  95871. * @param uniformName Name of the variable.
  95872. * @param vector4 Value to be set.
  95873. * @returns this effect.
  95874. */
  95875. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95876. /**
  95877. * Sets a float4 on a uniform variable.
  95878. * @param uniformName Name of the variable.
  95879. * @param x First float in float4.
  95880. * @param y Second float in float4.
  95881. * @param z Third float in float4.
  95882. * @param w Fourth float in float4.
  95883. * @returns this effect.
  95884. */
  95885. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95886. /**
  95887. * Sets a Color3 on a uniform variable.
  95888. * @param uniformName Name of the variable.
  95889. * @param color3 Value to be set.
  95890. * @returns this effect.
  95891. */
  95892. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95893. /**
  95894. * Sets a Color4 on a uniform variable.
  95895. * @param uniformName Name of the variable.
  95896. * @param color3 Value to be set.
  95897. * @param alpha Alpha value to be set.
  95898. * @returns this effect.
  95899. */
  95900. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95901. /**
  95902. * Sets a Color4 on a uniform variable
  95903. * @param uniformName defines the name of the variable
  95904. * @param color4 defines the value to be set
  95905. * @returns this effect.
  95906. */
  95907. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95908. /** Release all associated resources */
  95909. dispose(): void;
  95910. /**
  95911. * This function will add a new shader to the shader store
  95912. * @param name the name of the shader
  95913. * @param pixelShader optional pixel shader content
  95914. * @param vertexShader optional vertex shader content
  95915. */
  95916. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95917. /**
  95918. * Store of each shader (The can be looked up using effect.key)
  95919. */
  95920. static ShadersStore: {
  95921. [key: string]: string;
  95922. };
  95923. /**
  95924. * Store of each included file for a shader (The can be looked up using effect.key)
  95925. */
  95926. static IncludesShadersStore: {
  95927. [key: string]: string;
  95928. };
  95929. /**
  95930. * Resets the cache of effects.
  95931. */
  95932. static ResetCache(): void;
  95933. }
  95934. }
  95935. declare module BABYLON {
  95936. /**
  95937. * Class used to describe the capabilities of the engine relatively to the current browser
  95938. */
  95939. export class EngineCapabilities {
  95940. /** Maximum textures units per fragment shader */
  95941. maxTexturesImageUnits: number;
  95942. /** Maximum texture units per vertex shader */
  95943. maxVertexTextureImageUnits: number;
  95944. /** Maximum textures units in the entire pipeline */
  95945. maxCombinedTexturesImageUnits: number;
  95946. /** Maximum texture size */
  95947. maxTextureSize: number;
  95948. /** Maximum cube texture size */
  95949. maxCubemapTextureSize: number;
  95950. /** Maximum render texture size */
  95951. maxRenderTextureSize: number;
  95952. /** Maximum number of vertex attributes */
  95953. maxVertexAttribs: number;
  95954. /** Maximum number of varyings */
  95955. maxVaryingVectors: number;
  95956. /** Maximum number of uniforms per vertex shader */
  95957. maxVertexUniformVectors: number;
  95958. /** Maximum number of uniforms per fragment shader */
  95959. maxFragmentUniformVectors: number;
  95960. /** Defines if standard derivates (dx/dy) are supported */
  95961. standardDerivatives: boolean;
  95962. /** Defines if s3tc texture compression is supported */
  95963. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95964. /** Defines if pvrtc texture compression is supported */
  95965. pvrtc: any;
  95966. /** Defines if etc1 texture compression is supported */
  95967. etc1: any;
  95968. /** Defines if etc2 texture compression is supported */
  95969. etc2: any;
  95970. /** Defines if astc texture compression is supported */
  95971. astc: any;
  95972. /** Defines if float textures are supported */
  95973. textureFloat: boolean;
  95974. /** Defines if vertex array objects are supported */
  95975. vertexArrayObject: boolean;
  95976. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95977. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95978. /** Gets the maximum level of anisotropy supported */
  95979. maxAnisotropy: number;
  95980. /** Defines if instancing is supported */
  95981. instancedArrays: boolean;
  95982. /** Defines if 32 bits indices are supported */
  95983. uintIndices: boolean;
  95984. /** Defines if high precision shaders are supported */
  95985. highPrecisionShaderSupported: boolean;
  95986. /** Defines if depth reading in the fragment shader is supported */
  95987. fragmentDepthSupported: boolean;
  95988. /** Defines if float texture linear filtering is supported*/
  95989. textureFloatLinearFiltering: boolean;
  95990. /** Defines if rendering to float textures is supported */
  95991. textureFloatRender: boolean;
  95992. /** Defines if half float textures are supported*/
  95993. textureHalfFloat: boolean;
  95994. /** Defines if half float texture linear filtering is supported*/
  95995. textureHalfFloatLinearFiltering: boolean;
  95996. /** Defines if rendering to half float textures is supported */
  95997. textureHalfFloatRender: boolean;
  95998. /** Defines if textureLOD shader command is supported */
  95999. textureLOD: boolean;
  96000. /** Defines if draw buffers extension is supported */
  96001. drawBuffersExtension: boolean;
  96002. /** Defines if depth textures are supported */
  96003. depthTextureExtension: boolean;
  96004. /** Defines if float color buffer are supported */
  96005. colorBufferFloat: boolean;
  96006. /** Gets disjoint timer query extension (null if not supported) */
  96007. timerQuery: EXT_disjoint_timer_query;
  96008. /** Defines if timestamp can be used with timer query */
  96009. canUseTimestampForTimerQuery: boolean;
  96010. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96011. multiview: any;
  96012. /** Function used to let the system compiles shaders in background */
  96013. parallelShaderCompile: {
  96014. COMPLETION_STATUS_KHR: number;
  96015. };
  96016. /** Max number of texture samples for MSAA */
  96017. maxMSAASamples: number;
  96018. /** Defines if the blend min max extension is supported */
  96019. blendMinMax: boolean;
  96020. }
  96021. }
  96022. declare module BABYLON {
  96023. /**
  96024. * @hidden
  96025. **/
  96026. export class DepthCullingState {
  96027. private _isDepthTestDirty;
  96028. private _isDepthMaskDirty;
  96029. private _isDepthFuncDirty;
  96030. private _isCullFaceDirty;
  96031. private _isCullDirty;
  96032. private _isZOffsetDirty;
  96033. private _isFrontFaceDirty;
  96034. private _depthTest;
  96035. private _depthMask;
  96036. private _depthFunc;
  96037. private _cull;
  96038. private _cullFace;
  96039. private _zOffset;
  96040. private _frontFace;
  96041. /**
  96042. * Initializes the state.
  96043. */
  96044. constructor();
  96045. readonly isDirty: boolean;
  96046. zOffset: number;
  96047. cullFace: Nullable<number>;
  96048. cull: Nullable<boolean>;
  96049. depthFunc: Nullable<number>;
  96050. depthMask: boolean;
  96051. depthTest: boolean;
  96052. frontFace: Nullable<number>;
  96053. reset(): void;
  96054. apply(gl: WebGLRenderingContext): void;
  96055. }
  96056. }
  96057. declare module BABYLON {
  96058. /**
  96059. * @hidden
  96060. **/
  96061. export class StencilState {
  96062. /** 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 */
  96063. static readonly ALWAYS: number;
  96064. /** Passed to stencilOperation to specify that stencil value must be kept */
  96065. static readonly KEEP: number;
  96066. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96067. static readonly REPLACE: number;
  96068. private _isStencilTestDirty;
  96069. private _isStencilMaskDirty;
  96070. private _isStencilFuncDirty;
  96071. private _isStencilOpDirty;
  96072. private _stencilTest;
  96073. private _stencilMask;
  96074. private _stencilFunc;
  96075. private _stencilFuncRef;
  96076. private _stencilFuncMask;
  96077. private _stencilOpStencilFail;
  96078. private _stencilOpDepthFail;
  96079. private _stencilOpStencilDepthPass;
  96080. readonly isDirty: boolean;
  96081. stencilFunc: number;
  96082. stencilFuncRef: number;
  96083. stencilFuncMask: number;
  96084. stencilOpStencilFail: number;
  96085. stencilOpDepthFail: number;
  96086. stencilOpStencilDepthPass: number;
  96087. stencilMask: number;
  96088. stencilTest: boolean;
  96089. constructor();
  96090. reset(): void;
  96091. apply(gl: WebGLRenderingContext): void;
  96092. }
  96093. }
  96094. declare module BABYLON {
  96095. /**
  96096. * @hidden
  96097. **/
  96098. export class AlphaState {
  96099. private _isAlphaBlendDirty;
  96100. private _isBlendFunctionParametersDirty;
  96101. private _isBlendEquationParametersDirty;
  96102. private _isBlendConstantsDirty;
  96103. private _alphaBlend;
  96104. private _blendFunctionParameters;
  96105. private _blendEquationParameters;
  96106. private _blendConstants;
  96107. /**
  96108. * Initializes the state.
  96109. */
  96110. constructor();
  96111. readonly isDirty: boolean;
  96112. alphaBlend: boolean;
  96113. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96114. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96115. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96116. reset(): void;
  96117. apply(gl: WebGLRenderingContext): void;
  96118. }
  96119. }
  96120. declare module BABYLON {
  96121. /** @hidden */
  96122. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96123. attributeProcessor(attribute: string): string;
  96124. varyingProcessor(varying: string, isFragment: boolean): string;
  96125. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96126. }
  96127. }
  96128. declare module BABYLON {
  96129. /**
  96130. * Interface for attribute information associated with buffer instanciation
  96131. */
  96132. export class InstancingAttributeInfo {
  96133. /**
  96134. * Index/offset of the attribute in the vertex shader
  96135. */
  96136. index: number;
  96137. /**
  96138. * size of the attribute, 1, 2, 3 or 4
  96139. */
  96140. attributeSize: number;
  96141. /**
  96142. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96143. * default is FLOAT
  96144. */
  96145. attribyteType: number;
  96146. /**
  96147. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96148. */
  96149. normalized: boolean;
  96150. /**
  96151. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96152. */
  96153. offset: number;
  96154. /**
  96155. * Name of the GLSL attribute, for debugging purpose only
  96156. */
  96157. attributeName: string;
  96158. }
  96159. }
  96160. declare module BABYLON {
  96161. interface ThinEngine {
  96162. /**
  96163. * Update a video texture
  96164. * @param texture defines the texture to update
  96165. * @param video defines the video element to use
  96166. * @param invertY defines if data must be stored with Y axis inverted
  96167. */
  96168. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96169. }
  96170. }
  96171. declare module BABYLON {
  96172. /**
  96173. * Settings for finer control over video usage
  96174. */
  96175. export interface VideoTextureSettings {
  96176. /**
  96177. * Applies `autoplay` to video, if specified
  96178. */
  96179. autoPlay?: boolean;
  96180. /**
  96181. * Applies `loop` to video, if specified
  96182. */
  96183. loop?: boolean;
  96184. /**
  96185. * Automatically updates internal texture from video at every frame in the render loop
  96186. */
  96187. autoUpdateTexture: boolean;
  96188. /**
  96189. * Image src displayed during the video loading or until the user interacts with the video.
  96190. */
  96191. poster?: string;
  96192. }
  96193. /**
  96194. * If you want to display a video in your scene, this is the special texture for that.
  96195. * This special texture works similar to other textures, with the exception of a few parameters.
  96196. * @see https://doc.babylonjs.com/how_to/video_texture
  96197. */
  96198. export class VideoTexture extends Texture {
  96199. /**
  96200. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96201. */
  96202. readonly autoUpdateTexture: boolean;
  96203. /**
  96204. * The video instance used by the texture internally
  96205. */
  96206. readonly video: HTMLVideoElement;
  96207. private _onUserActionRequestedObservable;
  96208. /**
  96209. * Event triggerd when a dom action is required by the user to play the video.
  96210. * This happens due to recent changes in browser policies preventing video to auto start.
  96211. */
  96212. readonly onUserActionRequestedObservable: Observable<Texture>;
  96213. private _generateMipMaps;
  96214. private _engine;
  96215. private _stillImageCaptured;
  96216. private _displayingPosterTexture;
  96217. private _settings;
  96218. private _createInternalTextureOnEvent;
  96219. private _frameId;
  96220. /**
  96221. * Creates a video texture.
  96222. * If you want to display a video in your scene, this is the special texture for that.
  96223. * This special texture works similar to other textures, with the exception of a few parameters.
  96224. * @see https://doc.babylonjs.com/how_to/video_texture
  96225. * @param name optional name, will detect from video source, if not defined
  96226. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96227. * @param scene is obviously the current scene.
  96228. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96229. * @param invertY is false by default but can be used to invert video on Y axis
  96230. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96231. * @param settings allows finer control over video usage
  96232. */
  96233. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96234. private _getName;
  96235. private _getVideo;
  96236. private _createInternalTexture;
  96237. private reset;
  96238. /**
  96239. * @hidden Internal method to initiate `update`.
  96240. */
  96241. _rebuild(): void;
  96242. /**
  96243. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96244. */
  96245. update(): void;
  96246. /**
  96247. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96248. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96249. */
  96250. updateTexture(isVisible: boolean): void;
  96251. protected _updateInternalTexture: () => void;
  96252. /**
  96253. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96254. * @param url New url.
  96255. */
  96256. updateURL(url: string): void;
  96257. /**
  96258. * Dispose the texture and release its associated resources.
  96259. */
  96260. dispose(): void;
  96261. /**
  96262. * Creates a video texture straight from a stream.
  96263. * @param scene Define the scene the texture should be created in
  96264. * @param stream Define the stream the texture should be created from
  96265. * @returns The created video texture as a promise
  96266. */
  96267. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96268. /**
  96269. * Creates a video texture straight from your WebCam video feed.
  96270. * @param scene Define the scene the texture should be created in
  96271. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96272. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96273. * @returns The created video texture as a promise
  96274. */
  96275. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96276. minWidth: number;
  96277. maxWidth: number;
  96278. minHeight: number;
  96279. maxHeight: number;
  96280. deviceId: string;
  96281. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96282. /**
  96283. * Creates a video texture straight from your WebCam video feed.
  96284. * @param scene Define the scene the texture should be created in
  96285. * @param onReady Define a callback to triggered once the texture will be ready
  96286. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96287. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96288. */
  96289. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96290. minWidth: number;
  96291. maxWidth: number;
  96292. minHeight: number;
  96293. maxHeight: number;
  96294. deviceId: string;
  96295. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. /**
  96300. * Defines the interface used by objects working like Scene
  96301. * @hidden
  96302. */
  96303. interface ISceneLike {
  96304. _addPendingData(data: any): void;
  96305. _removePendingData(data: any): void;
  96306. offlineProvider: IOfflineProvider;
  96307. }
  96308. /** Interface defining initialization parameters for Engine class */
  96309. export interface EngineOptions extends WebGLContextAttributes {
  96310. /**
  96311. * Defines if the engine should no exceed a specified device ratio
  96312. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96313. */
  96314. limitDeviceRatio?: number;
  96315. /**
  96316. * Defines if webvr should be enabled automatically
  96317. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96318. */
  96319. autoEnableWebVR?: boolean;
  96320. /**
  96321. * Defines if webgl2 should be turned off even if supported
  96322. * @see http://doc.babylonjs.com/features/webgl2
  96323. */
  96324. disableWebGL2Support?: boolean;
  96325. /**
  96326. * Defines if webaudio should be initialized as well
  96327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96328. */
  96329. audioEngine?: boolean;
  96330. /**
  96331. * Defines if animations should run using a deterministic lock step
  96332. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96333. */
  96334. deterministicLockstep?: boolean;
  96335. /** Defines the maximum steps to use with deterministic lock step mode */
  96336. lockstepMaxSteps?: number;
  96337. /**
  96338. * Defines that engine should ignore context lost events
  96339. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96340. */
  96341. doNotHandleContextLost?: boolean;
  96342. /**
  96343. * Defines that engine should ignore modifying touch action attribute and style
  96344. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96345. */
  96346. doNotHandleTouchAction?: boolean;
  96347. /**
  96348. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96349. */
  96350. useHighPrecisionFloats?: boolean;
  96351. }
  96352. /**
  96353. * The base engine class (root of all engines)
  96354. */
  96355. export class ThinEngine {
  96356. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96357. static ExceptionList: ({
  96358. key: string;
  96359. capture: string;
  96360. captureConstraint: number;
  96361. targets: string[];
  96362. } | {
  96363. key: string;
  96364. capture: null;
  96365. captureConstraint: null;
  96366. targets: string[];
  96367. })[];
  96368. /** @hidden */
  96369. static _TextureLoaders: IInternalTextureLoader[];
  96370. /**
  96371. * Returns the current npm package of the sdk
  96372. */
  96373. static readonly NpmPackage: string;
  96374. /**
  96375. * Returns the current version of the framework
  96376. */
  96377. static readonly Version: string;
  96378. /**
  96379. * Returns a string describing the current engine
  96380. */
  96381. readonly description: string;
  96382. /**
  96383. * Gets or sets the epsilon value used by collision engine
  96384. */
  96385. static CollisionsEpsilon: number;
  96386. /**
  96387. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96388. */
  96389. static ShadersRepository: string;
  96390. /** @hidden */
  96391. _shaderProcessor: IShaderProcessor;
  96392. /**
  96393. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96394. */
  96395. forcePOTTextures: boolean;
  96396. /**
  96397. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96398. */
  96399. isFullscreen: boolean;
  96400. /**
  96401. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96402. */
  96403. cullBackFaces: boolean;
  96404. /**
  96405. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96406. */
  96407. renderEvenInBackground: boolean;
  96408. /**
  96409. * Gets or sets a boolean indicating that cache can be kept between frames
  96410. */
  96411. preventCacheWipeBetweenFrames: boolean;
  96412. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96413. validateShaderPrograms: boolean;
  96414. /**
  96415. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96416. */
  96417. disableUniformBuffers: boolean;
  96418. /** @hidden */
  96419. _uniformBuffers: UniformBuffer[];
  96420. /**
  96421. * Gets a boolean indicating that the engine supports uniform buffers
  96422. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96423. */
  96424. readonly supportsUniformBuffers: boolean;
  96425. /** @hidden */
  96426. _gl: WebGLRenderingContext;
  96427. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96428. protected _windowIsBackground: boolean;
  96429. protected _webGLVersion: number;
  96430. protected _highPrecisionShadersAllowed: boolean;
  96431. /** @hidden */
  96432. readonly _shouldUseHighPrecisionShader: boolean;
  96433. /**
  96434. * Gets a boolean indicating that only power of 2 textures are supported
  96435. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96436. */
  96437. readonly needPOTTextures: boolean;
  96438. /** @hidden */
  96439. _badOS: boolean;
  96440. /** @hidden */
  96441. _badDesktopOS: boolean;
  96442. private _hardwareScalingLevel;
  96443. /** @hidden */
  96444. _caps: EngineCapabilities;
  96445. private _isStencilEnable;
  96446. protected _colorWrite: boolean;
  96447. private _glVersion;
  96448. private _glRenderer;
  96449. private _glVendor;
  96450. /** @hidden */
  96451. _videoTextureSupported: boolean;
  96452. protected _renderingQueueLaunched: boolean;
  96453. protected _activeRenderLoops: (() => void)[];
  96454. /**
  96455. * Observable signaled when a context lost event is raised
  96456. */
  96457. onContextLostObservable: Observable<ThinEngine>;
  96458. /**
  96459. * Observable signaled when a context restored event is raised
  96460. */
  96461. onContextRestoredObservable: Observable<ThinEngine>;
  96462. private _onContextLost;
  96463. private _onContextRestored;
  96464. protected _contextWasLost: boolean;
  96465. /** @hidden */
  96466. _doNotHandleContextLost: boolean;
  96467. /**
  96468. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96470. */
  96471. doNotHandleContextLost: boolean;
  96472. /**
  96473. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96474. */
  96475. disableVertexArrayObjects: boolean;
  96476. /** @hidden */
  96477. protected _depthCullingState: DepthCullingState;
  96478. /** @hidden */
  96479. protected _stencilState: StencilState;
  96480. /** @hidden */
  96481. protected _alphaState: AlphaState;
  96482. /** @hidden */
  96483. _internalTexturesCache: InternalTexture[];
  96484. /** @hidden */
  96485. protected _activeChannel: number;
  96486. private _currentTextureChannel;
  96487. /** @hidden */
  96488. protected _boundTexturesCache: {
  96489. [key: string]: Nullable<InternalTexture>;
  96490. };
  96491. /** @hidden */
  96492. protected _currentEffect: Nullable<Effect>;
  96493. /** @hidden */
  96494. protected _currentProgram: Nullable<WebGLProgram>;
  96495. private _compiledEffects;
  96496. private _vertexAttribArraysEnabled;
  96497. /** @hidden */
  96498. protected _cachedViewport: Nullable<IViewportLike>;
  96499. private _cachedVertexArrayObject;
  96500. /** @hidden */
  96501. protected _cachedVertexBuffers: any;
  96502. /** @hidden */
  96503. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96504. /** @hidden */
  96505. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96506. /** @hidden */
  96507. _currentRenderTarget: Nullable<InternalTexture>;
  96508. private _uintIndicesCurrentlySet;
  96509. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96510. /** @hidden */
  96511. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96512. private _currentBufferPointers;
  96513. private _currentInstanceLocations;
  96514. private _currentInstanceBuffers;
  96515. private _textureUnits;
  96516. /** @hidden */
  96517. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96518. /** @hidden */
  96519. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96520. /** @hidden */
  96521. _bindedRenderFunction: any;
  96522. private _vaoRecordInProgress;
  96523. private _mustWipeVertexAttributes;
  96524. private _emptyTexture;
  96525. private _emptyCubeTexture;
  96526. private _emptyTexture3D;
  96527. /** @hidden */
  96528. _frameHandler: number;
  96529. private _nextFreeTextureSlots;
  96530. private _maxSimultaneousTextures;
  96531. private _activeRequests;
  96532. protected _texturesSupported: string[];
  96533. /** @hidden */
  96534. _textureFormatInUse: Nullable<string>;
  96535. protected readonly _supportsHardwareTextureRescaling: boolean;
  96536. /**
  96537. * Gets the list of texture formats supported
  96538. */
  96539. readonly texturesSupported: Array<string>;
  96540. /**
  96541. * Gets the list of texture formats in use
  96542. */
  96543. readonly textureFormatInUse: Nullable<string>;
  96544. /**
  96545. * Gets the current viewport
  96546. */
  96547. readonly currentViewport: Nullable<IViewportLike>;
  96548. /**
  96549. * Gets the default empty texture
  96550. */
  96551. readonly emptyTexture: InternalTexture;
  96552. /**
  96553. * Gets the default empty 3D texture
  96554. */
  96555. readonly emptyTexture3D: InternalTexture;
  96556. /**
  96557. * Gets the default empty cube texture
  96558. */
  96559. readonly emptyCubeTexture: InternalTexture;
  96560. /**
  96561. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96562. */
  96563. readonly premultipliedAlpha: boolean;
  96564. /**
  96565. * Observable event triggered before each texture is initialized
  96566. */
  96567. onBeforeTextureInitObservable: Observable<Texture>;
  96568. /**
  96569. * Creates a new engine
  96570. * @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
  96571. * @param antialias defines enable antialiasing (default: false)
  96572. * @param options defines further options to be sent to the getContext() function
  96573. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96574. */
  96575. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96576. private _rebuildInternalTextures;
  96577. private _rebuildEffects;
  96578. /**
  96579. * Gets a boolean indicating if all created effects are ready
  96580. * @returns true if all effects are ready
  96581. */
  96582. areAllEffectsReady(): boolean;
  96583. protected _rebuildBuffers(): void;
  96584. private _initGLContext;
  96585. /**
  96586. * Gets version of the current webGL context
  96587. */
  96588. readonly webGLVersion: number;
  96589. /**
  96590. * Gets a string idenfifying the name of the class
  96591. * @returns "Engine" string
  96592. */
  96593. getClassName(): string;
  96594. /**
  96595. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96596. */
  96597. readonly isStencilEnable: boolean;
  96598. /** @hidden */
  96599. _prepareWorkingCanvas(): void;
  96600. /**
  96601. * Reset the texture cache to empty state
  96602. */
  96603. resetTextureCache(): void;
  96604. /**
  96605. * Gets an object containing information about the current webGL context
  96606. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96607. */
  96608. getGlInfo(): {
  96609. vendor: string;
  96610. renderer: string;
  96611. version: string;
  96612. };
  96613. /**
  96614. * Defines the hardware scaling level.
  96615. * By default the hardware scaling level is computed from the window device ratio.
  96616. * 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.
  96617. * @param level defines the level to use
  96618. */
  96619. setHardwareScalingLevel(level: number): void;
  96620. /**
  96621. * Gets the current hardware scaling level.
  96622. * By default the hardware scaling level is computed from the window device ratio.
  96623. * 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.
  96624. * @returns a number indicating the current hardware scaling level
  96625. */
  96626. getHardwareScalingLevel(): number;
  96627. /**
  96628. * Gets the list of loaded textures
  96629. * @returns an array containing all loaded textures
  96630. */
  96631. getLoadedTexturesCache(): InternalTexture[];
  96632. /**
  96633. * Gets the object containing all engine capabilities
  96634. * @returns the EngineCapabilities object
  96635. */
  96636. getCaps(): EngineCapabilities;
  96637. /**
  96638. * stop executing a render loop function and remove it from the execution array
  96639. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96640. */
  96641. stopRenderLoop(renderFunction?: () => void): void;
  96642. /** @hidden */
  96643. _renderLoop(): void;
  96644. /**
  96645. * Gets the HTML canvas attached with the current webGL context
  96646. * @returns a HTML canvas
  96647. */
  96648. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96649. /**
  96650. * Gets host window
  96651. * @returns the host window object
  96652. */
  96653. getHostWindow(): Nullable<Window>;
  96654. /**
  96655. * Gets the current render width
  96656. * @param useScreen defines if screen size must be used (or the current render target if any)
  96657. * @returns a number defining the current render width
  96658. */
  96659. getRenderWidth(useScreen?: boolean): number;
  96660. /**
  96661. * Gets the current render height
  96662. * @param useScreen defines if screen size must be used (or the current render target if any)
  96663. * @returns a number defining the current render height
  96664. */
  96665. getRenderHeight(useScreen?: boolean): number;
  96666. /**
  96667. * Can be used to override the current requestAnimationFrame requester.
  96668. * @hidden
  96669. */
  96670. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96671. /**
  96672. * Register and execute a render loop. The engine can have more than one render function
  96673. * @param renderFunction defines the function to continuously execute
  96674. */
  96675. runRenderLoop(renderFunction: () => void): void;
  96676. /**
  96677. * Clear the current render buffer or the current render target (if any is set up)
  96678. * @param color defines the color to use
  96679. * @param backBuffer defines if the back buffer must be cleared
  96680. * @param depth defines if the depth buffer must be cleared
  96681. * @param stencil defines if the stencil buffer must be cleared
  96682. */
  96683. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96684. private _viewportCached;
  96685. /** @hidden */
  96686. _viewport(x: number, y: number, width: number, height: number): void;
  96687. /**
  96688. * Set the WebGL's viewport
  96689. * @param viewport defines the viewport element to be used
  96690. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96691. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96692. */
  96693. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96694. /**
  96695. * Begin a new frame
  96696. */
  96697. beginFrame(): void;
  96698. /**
  96699. * Enf the current frame
  96700. */
  96701. endFrame(): void;
  96702. /**
  96703. * Resize the view according to the canvas' size
  96704. */
  96705. resize(): void;
  96706. /**
  96707. * Force a specific size of the canvas
  96708. * @param width defines the new canvas' width
  96709. * @param height defines the new canvas' height
  96710. */
  96711. setSize(width: number, height: number): void;
  96712. /**
  96713. * Binds the frame buffer to the specified texture.
  96714. * @param texture The texture to render to or null for the default canvas
  96715. * @param faceIndex The face of the texture to render to in case of cube texture
  96716. * @param requiredWidth The width of the target to render to
  96717. * @param requiredHeight The height of the target to render to
  96718. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96719. * @param depthStencilTexture The depth stencil texture to use to render
  96720. * @param lodLevel defines le lod level to bind to the frame buffer
  96721. */
  96722. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96723. /** @hidden */
  96724. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96725. /**
  96726. * Unbind the current render target texture from the webGL context
  96727. * @param texture defines the render target texture to unbind
  96728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96730. */
  96731. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96732. /**
  96733. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96734. */
  96735. flushFramebuffer(): void;
  96736. /**
  96737. * Unbind the current render target and bind the default framebuffer
  96738. */
  96739. restoreDefaultFramebuffer(): void;
  96740. private _resetVertexBufferBinding;
  96741. /**
  96742. * Creates a vertex buffer
  96743. * @param data the data for the vertex buffer
  96744. * @returns the new WebGL static buffer
  96745. */
  96746. createVertexBuffer(data: DataArray): DataBuffer;
  96747. private _createVertexBuffer;
  96748. /**
  96749. * Creates a dynamic vertex buffer
  96750. * @param data the data for the dynamic vertex buffer
  96751. * @returns the new WebGL dynamic buffer
  96752. */
  96753. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96754. /**
  96755. * Updates a dynamic vertex buffer.
  96756. * @param vertexBuffer the vertex buffer to update
  96757. * @param data the data used to update the vertex buffer
  96758. * @param byteOffset the byte offset of the data
  96759. * @param byteLength the byte length of the data
  96760. */
  96761. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96762. protected _resetIndexBufferBinding(): void;
  96763. /**
  96764. * Creates a new index buffer
  96765. * @param indices defines the content of the index buffer
  96766. * @param updatable defines if the index buffer must be updatable
  96767. * @returns a new webGL buffer
  96768. */
  96769. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96770. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96771. /**
  96772. * Bind a webGL buffer to the webGL context
  96773. * @param buffer defines the buffer to bind
  96774. */
  96775. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96776. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96777. private bindBuffer;
  96778. /**
  96779. * update the bound buffer with the given data
  96780. * @param data defines the data to update
  96781. */
  96782. updateArrayBuffer(data: Float32Array): void;
  96783. private _vertexAttribPointer;
  96784. private _bindIndexBufferWithCache;
  96785. private _bindVertexBuffersAttributes;
  96786. /**
  96787. * Records a vertex array object
  96788. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96789. * @param vertexBuffers defines the list of vertex buffers to store
  96790. * @param indexBuffer defines the index buffer to store
  96791. * @param effect defines the effect to store
  96792. * @returns the new vertex array object
  96793. */
  96794. recordVertexArrayObject(vertexBuffers: {
  96795. [key: string]: VertexBuffer;
  96796. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96797. /**
  96798. * Bind a specific vertex array object
  96799. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96800. * @param vertexArrayObject defines the vertex array object to bind
  96801. * @param indexBuffer defines the index buffer to bind
  96802. */
  96803. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96804. /**
  96805. * Bind webGl buffers directly to the webGL context
  96806. * @param vertexBuffer defines the vertex buffer to bind
  96807. * @param indexBuffer defines the index buffer to bind
  96808. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96809. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96810. * @param effect defines the effect associated with the vertex buffer
  96811. */
  96812. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96813. private _unbindVertexArrayObject;
  96814. /**
  96815. * Bind a list of vertex buffers to the webGL context
  96816. * @param vertexBuffers defines the list of vertex buffers to bind
  96817. * @param indexBuffer defines the index buffer to bind
  96818. * @param effect defines the effect associated with the vertex buffers
  96819. */
  96820. bindBuffers(vertexBuffers: {
  96821. [key: string]: Nullable<VertexBuffer>;
  96822. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96823. /**
  96824. * Unbind all instance attributes
  96825. */
  96826. unbindInstanceAttributes(): void;
  96827. /**
  96828. * Release and free the memory of a vertex array object
  96829. * @param vao defines the vertex array object to delete
  96830. */
  96831. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96832. /** @hidden */
  96833. _releaseBuffer(buffer: DataBuffer): boolean;
  96834. protected _deleteBuffer(buffer: DataBuffer): void;
  96835. /**
  96836. * Creates a webGL buffer to use with instanciation
  96837. * @param capacity defines the size of the buffer
  96838. * @returns the webGL buffer
  96839. */
  96840. createInstancesBuffer(capacity: number): DataBuffer;
  96841. /**
  96842. * Delete a webGL buffer used with instanciation
  96843. * @param buffer defines the webGL buffer to delete
  96844. */
  96845. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96846. /**
  96847. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96848. * @param instancesBuffer defines the webGL buffer to update and bind
  96849. * @param data defines the data to store in the buffer
  96850. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96851. */
  96852. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96853. /**
  96854. * Apply all cached states (depth, culling, stencil and alpha)
  96855. */
  96856. applyStates(): void;
  96857. /**
  96858. * Send a draw order
  96859. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96860. * @param indexStart defines the starting index
  96861. * @param indexCount defines the number of index to draw
  96862. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96863. */
  96864. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96865. /**
  96866. * Draw a list of points
  96867. * @param verticesStart defines the index of first vertex to draw
  96868. * @param verticesCount defines the count of vertices to draw
  96869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96870. */
  96871. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96872. /**
  96873. * Draw a list of unindexed primitives
  96874. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96875. * @param verticesStart defines the index of first vertex to draw
  96876. * @param verticesCount defines the count of vertices to draw
  96877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96878. */
  96879. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96880. /**
  96881. * Draw a list of indexed primitives
  96882. * @param fillMode defines the primitive to use
  96883. * @param indexStart defines the starting index
  96884. * @param indexCount defines the number of index to draw
  96885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96886. */
  96887. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96888. /**
  96889. * Draw a list of unindexed primitives
  96890. * @param fillMode defines the primitive to use
  96891. * @param verticesStart defines the index of first vertex to draw
  96892. * @param verticesCount defines the count of vertices to draw
  96893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96894. */
  96895. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96896. private _drawMode;
  96897. /** @hidden */
  96898. protected _reportDrawCall(): void;
  96899. /** @hidden */
  96900. _releaseEffect(effect: Effect): void;
  96901. /** @hidden */
  96902. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96903. /**
  96904. * Create a new effect (used to store vertex/fragment shaders)
  96905. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96906. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96907. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96908. * @param samplers defines an array of string used to represent textures
  96909. * @param defines defines the string containing the defines to use to compile the shaders
  96910. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96911. * @param onCompiled defines a function to call when the effect creation is successful
  96912. * @param onError defines a function to call when the effect creation has failed
  96913. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96914. * @returns the new Effect
  96915. */
  96916. 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;
  96917. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96918. private _compileShader;
  96919. private _compileRawShader;
  96920. /**
  96921. * Directly creates a webGL program
  96922. * @param pipelineContext defines the pipeline context to attach to
  96923. * @param vertexCode defines the vertex shader code to use
  96924. * @param fragmentCode defines the fragment shader code to use
  96925. * @param context defines the webGL context to use (if not set, the current one will be used)
  96926. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96927. * @returns the new webGL program
  96928. */
  96929. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96930. /**
  96931. * Creates a webGL program
  96932. * @param pipelineContext defines the pipeline context to attach to
  96933. * @param vertexCode defines the vertex shader code to use
  96934. * @param fragmentCode defines the fragment shader code to use
  96935. * @param defines defines the string containing the defines to use to compile the shaders
  96936. * @param context defines the webGL context to use (if not set, the current one will be used)
  96937. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96938. * @returns the new webGL program
  96939. */
  96940. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96941. /**
  96942. * Creates a new pipeline context
  96943. * @returns the new pipeline
  96944. */
  96945. createPipelineContext(): IPipelineContext;
  96946. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96947. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96948. /** @hidden */
  96949. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96950. /** @hidden */
  96951. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96952. /** @hidden */
  96953. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96954. /**
  96955. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96956. * @param pipelineContext defines the pipeline context to use
  96957. * @param uniformsNames defines the list of uniform names
  96958. * @returns an array of webGL uniform locations
  96959. */
  96960. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96961. /**
  96962. * Gets the lsit of active attributes for a given webGL program
  96963. * @param pipelineContext defines the pipeline context to use
  96964. * @param attributesNames defines the list of attribute names to get
  96965. * @returns an array of indices indicating the offset of each attribute
  96966. */
  96967. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96968. /**
  96969. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96970. * @param effect defines the effect to activate
  96971. */
  96972. enableEffect(effect: Nullable<Effect>): void;
  96973. /**
  96974. * Set the value of an uniform to an array of int32
  96975. * @param uniform defines the webGL uniform location where to store the value
  96976. * @param array defines the array of int32 to store
  96977. */
  96978. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96979. /**
  96980. * Set the value of an uniform to an array of int32 (stored as vec2)
  96981. * @param uniform defines the webGL uniform location where to store the value
  96982. * @param array defines the array of int32 to store
  96983. */
  96984. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96985. /**
  96986. * Set the value of an uniform to an array of int32 (stored as vec3)
  96987. * @param uniform defines the webGL uniform location where to store the value
  96988. * @param array defines the array of int32 to store
  96989. */
  96990. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96991. /**
  96992. * Set the value of an uniform to an array of int32 (stored as vec4)
  96993. * @param uniform defines the webGL uniform location where to store the value
  96994. * @param array defines the array of int32 to store
  96995. */
  96996. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96997. /**
  96998. * Set the value of an uniform to an array of float32
  96999. * @param uniform defines the webGL uniform location where to store the value
  97000. * @param array defines the array of float32 to store
  97001. */
  97002. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97003. /**
  97004. * Set the value of an uniform to an array of float32 (stored as vec2)
  97005. * @param uniform defines the webGL uniform location where to store the value
  97006. * @param array defines the array of float32 to store
  97007. */
  97008. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97009. /**
  97010. * Set the value of an uniform to an array of float32 (stored as vec3)
  97011. * @param uniform defines the webGL uniform location where to store the value
  97012. * @param array defines the array of float32 to store
  97013. */
  97014. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97015. /**
  97016. * Set the value of an uniform to an array of float32 (stored as vec4)
  97017. * @param uniform defines the webGL uniform location where to store the value
  97018. * @param array defines the array of float32 to store
  97019. */
  97020. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97021. /**
  97022. * Set the value of an uniform to an array of number
  97023. * @param uniform defines the webGL uniform location where to store the value
  97024. * @param array defines the array of number to store
  97025. */
  97026. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97027. /**
  97028. * Set the value of an uniform to an array of number (stored as vec2)
  97029. * @param uniform defines the webGL uniform location where to store the value
  97030. * @param array defines the array of number to store
  97031. */
  97032. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97033. /**
  97034. * Set the value of an uniform to an array of number (stored as vec3)
  97035. * @param uniform defines the webGL uniform location where to store the value
  97036. * @param array defines the array of number to store
  97037. */
  97038. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97039. /**
  97040. * Set the value of an uniform to an array of number (stored as vec4)
  97041. * @param uniform defines the webGL uniform location where to store the value
  97042. * @param array defines the array of number to store
  97043. */
  97044. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97045. /**
  97046. * Set the value of an uniform to an array of float32 (stored as matrices)
  97047. * @param uniform defines the webGL uniform location where to store the value
  97048. * @param matrices defines the array of float32 to store
  97049. */
  97050. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97051. /**
  97052. * Set the value of an uniform to a matrix (3x3)
  97053. * @param uniform defines the webGL uniform location where to store the value
  97054. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97055. */
  97056. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97057. /**
  97058. * Set the value of an uniform to a matrix (2x2)
  97059. * @param uniform defines the webGL uniform location where to store the value
  97060. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97061. */
  97062. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97063. /**
  97064. * Set the value of an uniform to a number (int)
  97065. * @param uniform defines the webGL uniform location where to store the value
  97066. * @param value defines the int number to store
  97067. */
  97068. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97069. /**
  97070. * Set the value of an uniform to a number (float)
  97071. * @param uniform defines the webGL uniform location where to store the value
  97072. * @param value defines the float number to store
  97073. */
  97074. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97075. /**
  97076. * Set the value of an uniform to a vec2
  97077. * @param uniform defines the webGL uniform location where to store the value
  97078. * @param x defines the 1st component of the value
  97079. * @param y defines the 2nd component of the value
  97080. */
  97081. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97082. /**
  97083. * Set the value of an uniform to a vec3
  97084. * @param uniform defines the webGL uniform location where to store the value
  97085. * @param x defines the 1st component of the value
  97086. * @param y defines the 2nd component of the value
  97087. * @param z defines the 3rd component of the value
  97088. */
  97089. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97090. /**
  97091. * Set the value of an uniform to a boolean
  97092. * @param uniform defines the webGL uniform location where to store the value
  97093. * @param bool defines the boolean to store
  97094. */
  97095. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97096. /**
  97097. * Set the value of an uniform to a vec4
  97098. * @param uniform defines the webGL uniform location where to store the value
  97099. * @param x defines the 1st component of the value
  97100. * @param y defines the 2nd component of the value
  97101. * @param z defines the 3rd component of the value
  97102. * @param w defines the 4th component of the value
  97103. */
  97104. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97105. /**
  97106. * Sets a Color4 on a uniform variable
  97107. * @param uniform defines the uniform location
  97108. * @param color4 defines the value to be set
  97109. */
  97110. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97111. /**
  97112. * Gets the depth culling state manager
  97113. */
  97114. readonly depthCullingState: DepthCullingState;
  97115. /**
  97116. * Gets the alpha state manager
  97117. */
  97118. readonly alphaState: AlphaState;
  97119. /**
  97120. * Gets the stencil state manager
  97121. */
  97122. readonly stencilState: StencilState;
  97123. /**
  97124. * Clears the list of texture accessible through engine.
  97125. * This can help preventing texture load conflict due to name collision.
  97126. */
  97127. clearInternalTexturesCache(): void;
  97128. /**
  97129. * Force the entire cache to be cleared
  97130. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97131. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97132. */
  97133. wipeCaches(bruteForce?: boolean): void;
  97134. /** @hidden */
  97135. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97136. min: number;
  97137. mag: number;
  97138. };
  97139. /** @hidden */
  97140. _createTexture(): WebGLTexture;
  97141. /**
  97142. * Usually called from Texture.ts.
  97143. * Passed information to create a WebGLTexture
  97144. * @param urlArg defines a value which contains one of the following:
  97145. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97146. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97147. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97149. * @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)
  97150. * @param scene needed for loading to the correct scene
  97151. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97152. * @param onLoad optional callback to be called upon successful completion
  97153. * @param onError optional callback to be called upon failure
  97154. * @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
  97155. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97156. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97157. * @param forcedExtension defines the extension to use to pick the right loader
  97158. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97159. * @param mimeType defines an optional mime type
  97160. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97161. */
  97162. 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;
  97163. /**
  97164. * @hidden
  97165. */
  97166. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97167. /**
  97168. * Creates a raw texture
  97169. * @param data defines the data to store in the texture
  97170. * @param width defines the width of the texture
  97171. * @param height defines the height of the texture
  97172. * @param format defines the format of the data
  97173. * @param generateMipMaps defines if the engine should generate the mip levels
  97174. * @param invertY defines if data must be stored with Y axis inverted
  97175. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97176. * @param compression defines the compression used (null by default)
  97177. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97178. * @returns the raw texture inside an InternalTexture
  97179. */
  97180. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97181. /**
  97182. * Creates a new raw cube texture
  97183. * @param data defines the array of data to use to create each face
  97184. * @param size defines the size of the textures
  97185. * @param format defines the format of the data
  97186. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97187. * @param generateMipMaps defines if the engine should generate the mip levels
  97188. * @param invertY defines if data must be stored with Y axis inverted
  97189. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97190. * @param compression defines the compression used (null by default)
  97191. * @returns the cube texture as an InternalTexture
  97192. */
  97193. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97194. /**
  97195. * Creates a new raw 3D texture
  97196. * @param data defines the data used to create the texture
  97197. * @param width defines the width of the texture
  97198. * @param height defines the height of the texture
  97199. * @param depth defines the depth of the texture
  97200. * @param format defines the format of the texture
  97201. * @param generateMipMaps defines if the engine must generate mip levels
  97202. * @param invertY defines if data must be stored with Y axis inverted
  97203. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97204. * @param compression defines the compressed used (can be null)
  97205. * @param textureType defines the compressed used (can be null)
  97206. * @returns a new raw 3D texture (stored in an InternalTexture)
  97207. */
  97208. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97209. private _unpackFlipYCached;
  97210. /**
  97211. * In case you are sharing the context with other applications, it might
  97212. * be interested to not cache the unpack flip y state to ensure a consistent
  97213. * value would be set.
  97214. */
  97215. enableUnpackFlipYCached: boolean;
  97216. /** @hidden */
  97217. _unpackFlipY(value: boolean): void;
  97218. /** @hidden */
  97219. _getUnpackAlignement(): number;
  97220. /**
  97221. * Update the sampling mode of a given texture
  97222. * @param samplingMode defines the required sampling mode
  97223. * @param texture defines the texture to update
  97224. */
  97225. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97226. /**
  97227. * Updates a depth texture Comparison Mode and Function.
  97228. * If the comparison Function is equal to 0, the mode will be set to none.
  97229. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97230. * @param texture The texture to set the comparison function for
  97231. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97232. */
  97233. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97234. /** @hidden */
  97235. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97236. width: number;
  97237. height: number;
  97238. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97239. /**
  97240. * Creates a depth stencil texture.
  97241. * This is only available in WebGL 2 or with the depth texture extension available.
  97242. * @param size The size of face edge in the texture.
  97243. * @param options The options defining the texture.
  97244. * @returns The texture
  97245. */
  97246. createDepthStencilTexture(size: number | {
  97247. width: number;
  97248. height: number;
  97249. }, options: DepthTextureCreationOptions): InternalTexture;
  97250. /**
  97251. * Creates a depth stencil texture.
  97252. * This is only available in WebGL 2 or with the depth texture extension available.
  97253. * @param size The size of face edge in the texture.
  97254. * @param options The options defining the texture.
  97255. * @returns The texture
  97256. */
  97257. private _createDepthStencilTexture;
  97258. /** @hidden */
  97259. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97260. /** @hidden */
  97261. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97262. /** @hidden */
  97263. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97264. /** @hidden */
  97265. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  97266. /**
  97267. * @hidden
  97268. */
  97269. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97270. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97271. private _prepareWebGLTexture;
  97272. /** @hidden */
  97273. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97274. /** @hidden */
  97275. _releaseFramebufferObjects(texture: InternalTexture): void;
  97276. /** @hidden */
  97277. _releaseTexture(texture: InternalTexture): void;
  97278. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97279. protected _setProgram(program: WebGLProgram): void;
  97280. protected _boundUniforms: {
  97281. [key: number]: WebGLUniformLocation;
  97282. };
  97283. /**
  97284. * Binds an effect to the webGL context
  97285. * @param effect defines the effect to bind
  97286. */
  97287. bindSamplers(effect: Effect): void;
  97288. private _activateCurrentTexture;
  97289. /** @hidden */
  97290. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97291. /** @hidden */
  97292. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97293. /**
  97294. * Unbind all textures from the webGL context
  97295. */
  97296. unbindAllTextures(): void;
  97297. /**
  97298. * Sets a texture to the according uniform.
  97299. * @param channel The texture channel
  97300. * @param uniform The uniform to set
  97301. * @param texture The texture to apply
  97302. */
  97303. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97304. private _bindSamplerUniformToChannel;
  97305. private _getTextureWrapMode;
  97306. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97307. /**
  97308. * Sets an array of texture to the webGL context
  97309. * @param channel defines the channel where the texture array must be set
  97310. * @param uniform defines the associated uniform location
  97311. * @param textures defines the array of textures to bind
  97312. */
  97313. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97314. /** @hidden */
  97315. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97316. private _setTextureParameterFloat;
  97317. private _setTextureParameterInteger;
  97318. /**
  97319. * Unbind all vertex attributes from the webGL context
  97320. */
  97321. unbindAllAttributes(): void;
  97322. /**
  97323. * 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
  97324. */
  97325. releaseEffects(): void;
  97326. /**
  97327. * Dispose and release all associated resources
  97328. */
  97329. dispose(): void;
  97330. /**
  97331. * Attach a new callback raised when context lost event is fired
  97332. * @param callback defines the callback to call
  97333. */
  97334. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97335. /**
  97336. * Attach a new callback raised when context restored event is fired
  97337. * @param callback defines the callback to call
  97338. */
  97339. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97340. /**
  97341. * Get the current error code of the webGL context
  97342. * @returns the error code
  97343. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97344. */
  97345. getError(): number;
  97346. private _canRenderToFloatFramebuffer;
  97347. private _canRenderToHalfFloatFramebuffer;
  97348. private _canRenderToFramebuffer;
  97349. /** @hidden */
  97350. _getWebGLTextureType(type: number): number;
  97351. /** @hidden */
  97352. _getInternalFormat(format: number): number;
  97353. /** @hidden */
  97354. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97355. /** @hidden */
  97356. _getRGBAMultiSampleBufferFormat(type: number): number;
  97357. /** @hidden */
  97358. _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;
  97359. /**
  97360. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97361. * @returns true if the engine can be created
  97362. * @ignorenaming
  97363. */
  97364. static isSupported(): boolean;
  97365. /**
  97366. * Find the next highest power of two.
  97367. * @param x Number to start search from.
  97368. * @return Next highest power of two.
  97369. */
  97370. static CeilingPOT(x: number): number;
  97371. /**
  97372. * Find the next lowest power of two.
  97373. * @param x Number to start search from.
  97374. * @return Next lowest power of two.
  97375. */
  97376. static FloorPOT(x: number): number;
  97377. /**
  97378. * Find the nearest power of two.
  97379. * @param x Number to start search from.
  97380. * @return Next nearest power of two.
  97381. */
  97382. static NearestPOT(x: number): number;
  97383. /**
  97384. * Get the closest exponent of two
  97385. * @param value defines the value to approximate
  97386. * @param max defines the maximum value to return
  97387. * @param mode defines how to define the closest value
  97388. * @returns closest exponent of two of the given value
  97389. */
  97390. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97391. /**
  97392. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97393. * @param func - the function to be called
  97394. * @param requester - the object that will request the next frame. Falls back to window.
  97395. * @returns frame number
  97396. */
  97397. static QueueNewFrame(func: () => void, requester?: any): number;
  97398. }
  97399. }
  97400. declare module BABYLON {
  97401. /**
  97402. * Class representing spherical harmonics coefficients to the 3rd degree
  97403. */
  97404. export class SphericalHarmonics {
  97405. /**
  97406. * Defines whether or not the harmonics have been prescaled for rendering.
  97407. */
  97408. preScaled: boolean;
  97409. /**
  97410. * The l0,0 coefficients of the spherical harmonics
  97411. */
  97412. l00: Vector3;
  97413. /**
  97414. * The l1,-1 coefficients of the spherical harmonics
  97415. */
  97416. l1_1: Vector3;
  97417. /**
  97418. * The l1,0 coefficients of the spherical harmonics
  97419. */
  97420. l10: Vector3;
  97421. /**
  97422. * The l1,1 coefficients of the spherical harmonics
  97423. */
  97424. l11: Vector3;
  97425. /**
  97426. * The l2,-2 coefficients of the spherical harmonics
  97427. */
  97428. l2_2: Vector3;
  97429. /**
  97430. * The l2,-1 coefficients of the spherical harmonics
  97431. */
  97432. l2_1: Vector3;
  97433. /**
  97434. * The l2,0 coefficients of the spherical harmonics
  97435. */
  97436. l20: Vector3;
  97437. /**
  97438. * The l2,1 coefficients of the spherical harmonics
  97439. */
  97440. l21: Vector3;
  97441. /**
  97442. * The l2,2 coefficients of the spherical harmonics
  97443. */
  97444. l22: Vector3;
  97445. /**
  97446. * Adds a light to the spherical harmonics
  97447. * @param direction the direction of the light
  97448. * @param color the color of the light
  97449. * @param deltaSolidAngle the delta solid angle of the light
  97450. */
  97451. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97452. /**
  97453. * Scales the spherical harmonics by the given amount
  97454. * @param scale the amount to scale
  97455. */
  97456. scaleInPlace(scale: number): void;
  97457. /**
  97458. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97459. *
  97460. * ```
  97461. * E_lm = A_l * L_lm
  97462. * ```
  97463. *
  97464. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97465. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97466. * the scaling factors are given in equation 9.
  97467. */
  97468. convertIncidentRadianceToIrradiance(): void;
  97469. /**
  97470. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97471. *
  97472. * ```
  97473. * L = (1/pi) * E * rho
  97474. * ```
  97475. *
  97476. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97477. */
  97478. convertIrradianceToLambertianRadiance(): void;
  97479. /**
  97480. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97481. * required operations at run time.
  97482. *
  97483. * This is simply done by scaling back the SH with Ylm constants parameter.
  97484. * The trigonometric part being applied by the shader at run time.
  97485. */
  97486. preScaleForRendering(): void;
  97487. /**
  97488. * Constructs a spherical harmonics from an array.
  97489. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97490. * @returns the spherical harmonics
  97491. */
  97492. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97493. /**
  97494. * Gets the spherical harmonics from polynomial
  97495. * @param polynomial the spherical polynomial
  97496. * @returns the spherical harmonics
  97497. */
  97498. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97499. }
  97500. /**
  97501. * Class representing spherical polynomial coefficients to the 3rd degree
  97502. */
  97503. export class SphericalPolynomial {
  97504. private _harmonics;
  97505. /**
  97506. * The spherical harmonics used to create the polynomials.
  97507. */
  97508. readonly preScaledHarmonics: SphericalHarmonics;
  97509. /**
  97510. * The x coefficients of the spherical polynomial
  97511. */
  97512. x: Vector3;
  97513. /**
  97514. * The y coefficients of the spherical polynomial
  97515. */
  97516. y: Vector3;
  97517. /**
  97518. * The z coefficients of the spherical polynomial
  97519. */
  97520. z: Vector3;
  97521. /**
  97522. * The xx coefficients of the spherical polynomial
  97523. */
  97524. xx: Vector3;
  97525. /**
  97526. * The yy coefficients of the spherical polynomial
  97527. */
  97528. yy: Vector3;
  97529. /**
  97530. * The zz coefficients of the spherical polynomial
  97531. */
  97532. zz: Vector3;
  97533. /**
  97534. * The xy coefficients of the spherical polynomial
  97535. */
  97536. xy: Vector3;
  97537. /**
  97538. * The yz coefficients of the spherical polynomial
  97539. */
  97540. yz: Vector3;
  97541. /**
  97542. * The zx coefficients of the spherical polynomial
  97543. */
  97544. zx: Vector3;
  97545. /**
  97546. * Adds an ambient color to the spherical polynomial
  97547. * @param color the color to add
  97548. */
  97549. addAmbient(color: Color3): void;
  97550. /**
  97551. * Scales the spherical polynomial by the given amount
  97552. * @param scale the amount to scale
  97553. */
  97554. scaleInPlace(scale: number): void;
  97555. /**
  97556. * Gets the spherical polynomial from harmonics
  97557. * @param harmonics the spherical harmonics
  97558. * @returns the spherical polynomial
  97559. */
  97560. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97561. /**
  97562. * Constructs a spherical polynomial from an array.
  97563. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97564. * @returns the spherical polynomial
  97565. */
  97566. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97567. }
  97568. }
  97569. declare module BABYLON {
  97570. /**
  97571. * Defines the source of the internal texture
  97572. */
  97573. export enum InternalTextureSource {
  97574. /**
  97575. * The source of the texture data is unknown
  97576. */
  97577. Unknown = 0,
  97578. /**
  97579. * Texture data comes from an URL
  97580. */
  97581. Url = 1,
  97582. /**
  97583. * Texture data is only used for temporary storage
  97584. */
  97585. Temp = 2,
  97586. /**
  97587. * Texture data comes from raw data (ArrayBuffer)
  97588. */
  97589. Raw = 3,
  97590. /**
  97591. * Texture content is dynamic (video or dynamic texture)
  97592. */
  97593. Dynamic = 4,
  97594. /**
  97595. * Texture content is generated by rendering to it
  97596. */
  97597. RenderTarget = 5,
  97598. /**
  97599. * Texture content is part of a multi render target process
  97600. */
  97601. MultiRenderTarget = 6,
  97602. /**
  97603. * Texture data comes from a cube data file
  97604. */
  97605. Cube = 7,
  97606. /**
  97607. * Texture data comes from a raw cube data
  97608. */
  97609. CubeRaw = 8,
  97610. /**
  97611. * Texture data come from a prefiltered cube data file
  97612. */
  97613. CubePrefiltered = 9,
  97614. /**
  97615. * Texture content is raw 3D data
  97616. */
  97617. Raw3D = 10,
  97618. /**
  97619. * Texture content is a depth texture
  97620. */
  97621. Depth = 11,
  97622. /**
  97623. * Texture data comes from a raw cube data encoded with RGBD
  97624. */
  97625. CubeRawRGBD = 12
  97626. }
  97627. /**
  97628. * Class used to store data associated with WebGL texture data for the engine
  97629. * This class should not be used directly
  97630. */
  97631. export class InternalTexture {
  97632. /** @hidden */
  97633. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97634. /**
  97635. * Defines if the texture is ready
  97636. */
  97637. isReady: boolean;
  97638. /**
  97639. * Defines if the texture is a cube texture
  97640. */
  97641. isCube: boolean;
  97642. /**
  97643. * Defines if the texture contains 3D data
  97644. */
  97645. is3D: boolean;
  97646. /**
  97647. * Defines if the texture contains multiview data
  97648. */
  97649. isMultiview: boolean;
  97650. /**
  97651. * Gets the URL used to load this texture
  97652. */
  97653. url: string;
  97654. /**
  97655. * Gets the sampling mode of the texture
  97656. */
  97657. samplingMode: number;
  97658. /**
  97659. * Gets a boolean indicating if the texture needs mipmaps generation
  97660. */
  97661. generateMipMaps: boolean;
  97662. /**
  97663. * Gets the number of samples used by the texture (WebGL2+ only)
  97664. */
  97665. samples: number;
  97666. /**
  97667. * Gets the type of the texture (int, float...)
  97668. */
  97669. type: number;
  97670. /**
  97671. * Gets the format of the texture (RGB, RGBA...)
  97672. */
  97673. format: number;
  97674. /**
  97675. * Observable called when the texture is loaded
  97676. */
  97677. onLoadedObservable: Observable<InternalTexture>;
  97678. /**
  97679. * Gets the width of the texture
  97680. */
  97681. width: number;
  97682. /**
  97683. * Gets the height of the texture
  97684. */
  97685. height: number;
  97686. /**
  97687. * Gets the depth of the texture
  97688. */
  97689. depth: number;
  97690. /**
  97691. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97692. */
  97693. baseWidth: number;
  97694. /**
  97695. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97696. */
  97697. baseHeight: number;
  97698. /**
  97699. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97700. */
  97701. baseDepth: number;
  97702. /**
  97703. * Gets a boolean indicating if the texture is inverted on Y axis
  97704. */
  97705. invertY: boolean;
  97706. /** @hidden */
  97707. _invertVScale: boolean;
  97708. /** @hidden */
  97709. _associatedChannel: number;
  97710. /** @hidden */
  97711. _source: InternalTextureSource;
  97712. /** @hidden */
  97713. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97714. /** @hidden */
  97715. _bufferView: Nullable<ArrayBufferView>;
  97716. /** @hidden */
  97717. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97718. /** @hidden */
  97719. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97720. /** @hidden */
  97721. _size: number;
  97722. /** @hidden */
  97723. _extension: string;
  97724. /** @hidden */
  97725. _files: Nullable<string[]>;
  97726. /** @hidden */
  97727. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97728. /** @hidden */
  97729. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97730. /** @hidden */
  97731. _framebuffer: Nullable<WebGLFramebuffer>;
  97732. /** @hidden */
  97733. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97734. /** @hidden */
  97735. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97736. /** @hidden */
  97737. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97738. /** @hidden */
  97739. _attachments: Nullable<number[]>;
  97740. /** @hidden */
  97741. _cachedCoordinatesMode: Nullable<number>;
  97742. /** @hidden */
  97743. _cachedWrapU: Nullable<number>;
  97744. /** @hidden */
  97745. _cachedWrapV: Nullable<number>;
  97746. /** @hidden */
  97747. _cachedWrapR: Nullable<number>;
  97748. /** @hidden */
  97749. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97750. /** @hidden */
  97751. _isDisabled: boolean;
  97752. /** @hidden */
  97753. _compression: Nullable<string>;
  97754. /** @hidden */
  97755. _generateStencilBuffer: boolean;
  97756. /** @hidden */
  97757. _generateDepthBuffer: boolean;
  97758. /** @hidden */
  97759. _comparisonFunction: number;
  97760. /** @hidden */
  97761. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97762. /** @hidden */
  97763. _lodGenerationScale: number;
  97764. /** @hidden */
  97765. _lodGenerationOffset: number;
  97766. /** @hidden */
  97767. _colorTextureArray: Nullable<WebGLTexture>;
  97768. /** @hidden */
  97769. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97770. /** @hidden */
  97771. _lodTextureHigh: Nullable<BaseTexture>;
  97772. /** @hidden */
  97773. _lodTextureMid: Nullable<BaseTexture>;
  97774. /** @hidden */
  97775. _lodTextureLow: Nullable<BaseTexture>;
  97776. /** @hidden */
  97777. _isRGBD: boolean;
  97778. /** @hidden */
  97779. _linearSpecularLOD: boolean;
  97780. /** @hidden */
  97781. _irradianceTexture: Nullable<BaseTexture>;
  97782. /** @hidden */
  97783. _webGLTexture: Nullable<WebGLTexture>;
  97784. /** @hidden */
  97785. _references: number;
  97786. private _engine;
  97787. /**
  97788. * Gets the Engine the texture belongs to.
  97789. * @returns The babylon engine
  97790. */
  97791. getEngine(): ThinEngine;
  97792. /**
  97793. * Gets the data source type of the texture
  97794. */
  97795. readonly source: InternalTextureSource;
  97796. /**
  97797. * Creates a new InternalTexture
  97798. * @param engine defines the engine to use
  97799. * @param source defines the type of data that will be used
  97800. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97801. */
  97802. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97803. /**
  97804. * Increments the number of references (ie. the number of Texture that point to it)
  97805. */
  97806. incrementReferences(): void;
  97807. /**
  97808. * Change the size of the texture (not the size of the content)
  97809. * @param width defines the new width
  97810. * @param height defines the new height
  97811. * @param depth defines the new depth (1 by default)
  97812. */
  97813. updateSize(width: int, height: int, depth?: int): void;
  97814. /** @hidden */
  97815. _rebuild(): void;
  97816. /** @hidden */
  97817. _swapAndDie(target: InternalTexture): void;
  97818. /**
  97819. * Dispose the current allocated resources
  97820. */
  97821. dispose(): void;
  97822. }
  97823. }
  97824. declare module BABYLON {
  97825. /**
  97826. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97828. */
  97829. export class Analyser {
  97830. /**
  97831. * Gets or sets the smoothing
  97832. * @ignorenaming
  97833. */
  97834. SMOOTHING: number;
  97835. /**
  97836. * Gets or sets the FFT table size
  97837. * @ignorenaming
  97838. */
  97839. FFT_SIZE: number;
  97840. /**
  97841. * Gets or sets the bar graph amplitude
  97842. * @ignorenaming
  97843. */
  97844. BARGRAPHAMPLITUDE: number;
  97845. /**
  97846. * Gets or sets the position of the debug canvas
  97847. * @ignorenaming
  97848. */
  97849. DEBUGCANVASPOS: {
  97850. x: number;
  97851. y: number;
  97852. };
  97853. /**
  97854. * Gets or sets the debug canvas size
  97855. * @ignorenaming
  97856. */
  97857. DEBUGCANVASSIZE: {
  97858. width: number;
  97859. height: number;
  97860. };
  97861. private _byteFreqs;
  97862. private _byteTime;
  97863. private _floatFreqs;
  97864. private _webAudioAnalyser;
  97865. private _debugCanvas;
  97866. private _debugCanvasContext;
  97867. private _scene;
  97868. private _registerFunc;
  97869. private _audioEngine;
  97870. /**
  97871. * Creates a new analyser
  97872. * @param scene defines hosting scene
  97873. */
  97874. constructor(scene: Scene);
  97875. /**
  97876. * Get the number of data values you will have to play with for the visualization
  97877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97878. * @returns a number
  97879. */
  97880. getFrequencyBinCount(): number;
  97881. /**
  97882. * Gets the current frequency data as a byte array
  97883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97884. * @returns a Uint8Array
  97885. */
  97886. getByteFrequencyData(): Uint8Array;
  97887. /**
  97888. * Gets the current waveform as a byte array
  97889. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97890. * @returns a Uint8Array
  97891. */
  97892. getByteTimeDomainData(): Uint8Array;
  97893. /**
  97894. * Gets the current frequency data as a float array
  97895. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97896. * @returns a Float32Array
  97897. */
  97898. getFloatFrequencyData(): Float32Array;
  97899. /**
  97900. * Renders the debug canvas
  97901. */
  97902. drawDebugCanvas(): void;
  97903. /**
  97904. * Stops rendering the debug canvas and removes it
  97905. */
  97906. stopDebugCanvas(): void;
  97907. /**
  97908. * Connects two audio nodes
  97909. * @param inputAudioNode defines first node to connect
  97910. * @param outputAudioNode defines second node to connect
  97911. */
  97912. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97913. /**
  97914. * Releases all associated resources
  97915. */
  97916. dispose(): void;
  97917. }
  97918. }
  97919. declare module BABYLON {
  97920. /**
  97921. * This represents an audio engine and it is responsible
  97922. * to play, synchronize and analyse sounds throughout the application.
  97923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97924. */
  97925. export interface IAudioEngine extends IDisposable {
  97926. /**
  97927. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97928. */
  97929. readonly canUseWebAudio: boolean;
  97930. /**
  97931. * Gets the current AudioContext if available.
  97932. */
  97933. readonly audioContext: Nullable<AudioContext>;
  97934. /**
  97935. * The master gain node defines the global audio volume of your audio engine.
  97936. */
  97937. readonly masterGain: GainNode;
  97938. /**
  97939. * Gets whether or not mp3 are supported by your browser.
  97940. */
  97941. readonly isMP3supported: boolean;
  97942. /**
  97943. * Gets whether or not ogg are supported by your browser.
  97944. */
  97945. readonly isOGGsupported: boolean;
  97946. /**
  97947. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97948. * @ignoreNaming
  97949. */
  97950. WarnedWebAudioUnsupported: boolean;
  97951. /**
  97952. * Defines if the audio engine relies on a custom unlocked button.
  97953. * In this case, the embedded button will not be displayed.
  97954. */
  97955. useCustomUnlockedButton: boolean;
  97956. /**
  97957. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97958. */
  97959. readonly unlocked: boolean;
  97960. /**
  97961. * Event raised when audio has been unlocked on the browser.
  97962. */
  97963. onAudioUnlockedObservable: Observable<AudioEngine>;
  97964. /**
  97965. * Event raised when audio has been locked on the browser.
  97966. */
  97967. onAudioLockedObservable: Observable<AudioEngine>;
  97968. /**
  97969. * Flags the audio engine in Locked state.
  97970. * This happens due to new browser policies preventing audio to autoplay.
  97971. */
  97972. lock(): void;
  97973. /**
  97974. * Unlocks the audio engine once a user action has been done on the dom.
  97975. * This is helpful to resume play once browser policies have been satisfied.
  97976. */
  97977. unlock(): void;
  97978. }
  97979. /**
  97980. * This represents the default audio engine used in babylon.
  97981. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97983. */
  97984. export class AudioEngine implements IAudioEngine {
  97985. private _audioContext;
  97986. private _audioContextInitialized;
  97987. private _muteButton;
  97988. private _hostElement;
  97989. /**
  97990. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97991. */
  97992. canUseWebAudio: boolean;
  97993. /**
  97994. * The master gain node defines the global audio volume of your audio engine.
  97995. */
  97996. masterGain: GainNode;
  97997. /**
  97998. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97999. * @ignoreNaming
  98000. */
  98001. WarnedWebAudioUnsupported: boolean;
  98002. /**
  98003. * Gets whether or not mp3 are supported by your browser.
  98004. */
  98005. isMP3supported: boolean;
  98006. /**
  98007. * Gets whether or not ogg are supported by your browser.
  98008. */
  98009. isOGGsupported: boolean;
  98010. /**
  98011. * Gets whether audio has been unlocked on the device.
  98012. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98013. * a user interaction has happened.
  98014. */
  98015. unlocked: boolean;
  98016. /**
  98017. * Defines if the audio engine relies on a custom unlocked button.
  98018. * In this case, the embedded button will not be displayed.
  98019. */
  98020. useCustomUnlockedButton: boolean;
  98021. /**
  98022. * Event raised when audio has been unlocked on the browser.
  98023. */
  98024. onAudioUnlockedObservable: Observable<AudioEngine>;
  98025. /**
  98026. * Event raised when audio has been locked on the browser.
  98027. */
  98028. onAudioLockedObservable: Observable<AudioEngine>;
  98029. /**
  98030. * Gets the current AudioContext if available.
  98031. */
  98032. readonly audioContext: Nullable<AudioContext>;
  98033. private _connectedAnalyser;
  98034. /**
  98035. * Instantiates a new audio engine.
  98036. *
  98037. * There should be only one per page as some browsers restrict the number
  98038. * of audio contexts you can create.
  98039. * @param hostElement defines the host element where to display the mute icon if necessary
  98040. */
  98041. constructor(hostElement?: Nullable<HTMLElement>);
  98042. /**
  98043. * Flags the audio engine in Locked state.
  98044. * This happens due to new browser policies preventing audio to autoplay.
  98045. */
  98046. lock(): void;
  98047. /**
  98048. * Unlocks the audio engine once a user action has been done on the dom.
  98049. * This is helpful to resume play once browser policies have been satisfied.
  98050. */
  98051. unlock(): void;
  98052. private _resumeAudioContext;
  98053. private _initializeAudioContext;
  98054. private _tryToRun;
  98055. private _triggerRunningState;
  98056. private _triggerSuspendedState;
  98057. private _displayMuteButton;
  98058. private _moveButtonToTopLeft;
  98059. private _onResize;
  98060. private _hideMuteButton;
  98061. /**
  98062. * Destroy and release the resources associated with the audio ccontext.
  98063. */
  98064. dispose(): void;
  98065. /**
  98066. * Gets the global volume sets on the master gain.
  98067. * @returns the global volume if set or -1 otherwise
  98068. */
  98069. getGlobalVolume(): number;
  98070. /**
  98071. * Sets the global volume of your experience (sets on the master gain).
  98072. * @param newVolume Defines the new global volume of the application
  98073. */
  98074. setGlobalVolume(newVolume: number): void;
  98075. /**
  98076. * Connect the audio engine to an audio analyser allowing some amazing
  98077. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98079. * @param analyser The analyser to connect to the engine
  98080. */
  98081. connectToAnalyser(analyser: Analyser): void;
  98082. }
  98083. }
  98084. declare module BABYLON {
  98085. /**
  98086. * Interface used to present a loading screen while loading a scene
  98087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98088. */
  98089. export interface ILoadingScreen {
  98090. /**
  98091. * Function called to display the loading screen
  98092. */
  98093. displayLoadingUI: () => void;
  98094. /**
  98095. * Function called to hide the loading screen
  98096. */
  98097. hideLoadingUI: () => void;
  98098. /**
  98099. * Gets or sets the color to use for the background
  98100. */
  98101. loadingUIBackgroundColor: string;
  98102. /**
  98103. * Gets or sets the text to display while loading
  98104. */
  98105. loadingUIText: string;
  98106. }
  98107. /**
  98108. * Class used for the default loading screen
  98109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98110. */
  98111. export class DefaultLoadingScreen implements ILoadingScreen {
  98112. private _renderingCanvas;
  98113. private _loadingText;
  98114. private _loadingDivBackgroundColor;
  98115. private _loadingDiv;
  98116. private _loadingTextDiv;
  98117. /** Gets or sets the logo url to use for the default loading screen */
  98118. static DefaultLogoUrl: string;
  98119. /** Gets or sets the spinner url to use for the default loading screen */
  98120. static DefaultSpinnerUrl: string;
  98121. /**
  98122. * Creates a new default loading screen
  98123. * @param _renderingCanvas defines the canvas used to render the scene
  98124. * @param _loadingText defines the default text to display
  98125. * @param _loadingDivBackgroundColor defines the default background color
  98126. */
  98127. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98128. /**
  98129. * Function called to display the loading screen
  98130. */
  98131. displayLoadingUI(): void;
  98132. /**
  98133. * Function called to hide the loading screen
  98134. */
  98135. hideLoadingUI(): void;
  98136. /**
  98137. * Gets or sets the text to display while loading
  98138. */
  98139. loadingUIText: string;
  98140. /**
  98141. * Gets or sets the color to use for the background
  98142. */
  98143. loadingUIBackgroundColor: string;
  98144. private _resizeLoadingUI;
  98145. }
  98146. }
  98147. declare module BABYLON {
  98148. /**
  98149. * Interface for any object that can request an animation frame
  98150. */
  98151. export interface ICustomAnimationFrameRequester {
  98152. /**
  98153. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98154. */
  98155. renderFunction?: Function;
  98156. /**
  98157. * Called to request the next frame to render to
  98158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98159. */
  98160. requestAnimationFrame: Function;
  98161. /**
  98162. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98163. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98164. */
  98165. requestID?: number;
  98166. }
  98167. }
  98168. declare module BABYLON {
  98169. /**
  98170. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98171. */
  98172. export class PerformanceMonitor {
  98173. private _enabled;
  98174. private _rollingFrameTime;
  98175. private _lastFrameTimeMs;
  98176. /**
  98177. * constructor
  98178. * @param frameSampleSize The number of samples required to saturate the sliding window
  98179. */
  98180. constructor(frameSampleSize?: number);
  98181. /**
  98182. * Samples current frame
  98183. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98184. */
  98185. sampleFrame(timeMs?: number): void;
  98186. /**
  98187. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98188. */
  98189. readonly averageFrameTime: number;
  98190. /**
  98191. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98192. */
  98193. readonly averageFrameTimeVariance: number;
  98194. /**
  98195. * Returns the frame time of the most recent frame
  98196. */
  98197. readonly instantaneousFrameTime: number;
  98198. /**
  98199. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98200. */
  98201. readonly averageFPS: number;
  98202. /**
  98203. * Returns the average framerate in frames per second using the most recent frame time
  98204. */
  98205. readonly instantaneousFPS: number;
  98206. /**
  98207. * Returns true if enough samples have been taken to completely fill the sliding window
  98208. */
  98209. readonly isSaturated: boolean;
  98210. /**
  98211. * Enables contributions to the sliding window sample set
  98212. */
  98213. enable(): void;
  98214. /**
  98215. * Disables contributions to the sliding window sample set
  98216. * Samples will not be interpolated over the disabled period
  98217. */
  98218. disable(): void;
  98219. /**
  98220. * Returns true if sampling is enabled
  98221. */
  98222. readonly isEnabled: boolean;
  98223. /**
  98224. * Resets performance monitor
  98225. */
  98226. reset(): void;
  98227. }
  98228. /**
  98229. * RollingAverage
  98230. *
  98231. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98232. */
  98233. export class RollingAverage {
  98234. /**
  98235. * Current average
  98236. */
  98237. average: number;
  98238. /**
  98239. * Current variance
  98240. */
  98241. variance: number;
  98242. protected _samples: Array<number>;
  98243. protected _sampleCount: number;
  98244. protected _pos: number;
  98245. protected _m2: number;
  98246. /**
  98247. * constructor
  98248. * @param length The number of samples required to saturate the sliding window
  98249. */
  98250. constructor(length: number);
  98251. /**
  98252. * Adds a sample to the sample set
  98253. * @param v The sample value
  98254. */
  98255. add(v: number): void;
  98256. /**
  98257. * Returns previously added values or null if outside of history or outside the sliding window domain
  98258. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98259. * @return Value previously recorded with add() or null if outside of range
  98260. */
  98261. history(i: number): number;
  98262. /**
  98263. * Returns true if enough samples have been taken to completely fill the sliding window
  98264. * @return true if sample-set saturated
  98265. */
  98266. isSaturated(): boolean;
  98267. /**
  98268. * Resets the rolling average (equivalent to 0 samples taken so far)
  98269. */
  98270. reset(): void;
  98271. /**
  98272. * Wraps a value around the sample range boundaries
  98273. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98274. * @return Wrapped position in sample range
  98275. */
  98276. protected _wrapPosition(i: number): number;
  98277. }
  98278. }
  98279. declare module BABYLON {
  98280. /**
  98281. * This class is used to track a performance counter which is number based.
  98282. * The user has access to many properties which give statistics of different nature.
  98283. *
  98284. * The implementer can track two kinds of Performance Counter: time and count.
  98285. * 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.
  98286. * 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.
  98287. */
  98288. export class PerfCounter {
  98289. /**
  98290. * Gets or sets a global boolean to turn on and off all the counters
  98291. */
  98292. static Enabled: boolean;
  98293. /**
  98294. * Returns the smallest value ever
  98295. */
  98296. readonly min: number;
  98297. /**
  98298. * Returns the biggest value ever
  98299. */
  98300. readonly max: number;
  98301. /**
  98302. * Returns the average value since the performance counter is running
  98303. */
  98304. readonly average: number;
  98305. /**
  98306. * Returns the average value of the last second the counter was monitored
  98307. */
  98308. readonly lastSecAverage: number;
  98309. /**
  98310. * Returns the current value
  98311. */
  98312. readonly current: number;
  98313. /**
  98314. * Gets the accumulated total
  98315. */
  98316. readonly total: number;
  98317. /**
  98318. * Gets the total value count
  98319. */
  98320. readonly count: number;
  98321. /**
  98322. * Creates a new counter
  98323. */
  98324. constructor();
  98325. /**
  98326. * Call this method to start monitoring a new frame.
  98327. * 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.
  98328. */
  98329. fetchNewFrame(): void;
  98330. /**
  98331. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98332. * @param newCount the count value to add to the monitored count
  98333. * @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.
  98334. */
  98335. addCount(newCount: number, fetchResult: boolean): void;
  98336. /**
  98337. * Start monitoring this performance counter
  98338. */
  98339. beginMonitoring(): void;
  98340. /**
  98341. * Compute the time lapsed since the previous beginMonitoring() call.
  98342. * @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
  98343. */
  98344. endMonitoring(newFrame?: boolean): void;
  98345. private _fetchResult;
  98346. private _startMonitoringTime;
  98347. private _min;
  98348. private _max;
  98349. private _average;
  98350. private _current;
  98351. private _totalValueCount;
  98352. private _totalAccumulated;
  98353. private _lastSecAverage;
  98354. private _lastSecAccumulated;
  98355. private _lastSecTime;
  98356. private _lastSecValueCount;
  98357. }
  98358. }
  98359. declare module BABYLON {
  98360. /**
  98361. * Defines the interface used by display changed events
  98362. */
  98363. export interface IDisplayChangedEventArgs {
  98364. /** Gets the vrDisplay object (if any) */
  98365. vrDisplay: Nullable<any>;
  98366. /** Gets a boolean indicating if webVR is supported */
  98367. vrSupported: boolean;
  98368. }
  98369. /**
  98370. * Defines the interface used by objects containing a viewport (like a camera)
  98371. */
  98372. interface IViewportOwnerLike {
  98373. /**
  98374. * Gets or sets the viewport
  98375. */
  98376. viewport: IViewportLike;
  98377. }
  98378. /**
  98379. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98380. */
  98381. export class Engine extends ThinEngine {
  98382. /** Defines that alpha blending is disabled */
  98383. static readonly ALPHA_DISABLE: number;
  98384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98385. static readonly ALPHA_ADD: number;
  98386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98387. static readonly ALPHA_COMBINE: number;
  98388. /** Defines that alpha blending to DEST - SRC * DEST */
  98389. static readonly ALPHA_SUBTRACT: number;
  98390. /** Defines that alpha blending to SRC * DEST */
  98391. static readonly ALPHA_MULTIPLY: number;
  98392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98393. static readonly ALPHA_MAXIMIZED: number;
  98394. /** Defines that alpha blending to SRC + DEST */
  98395. static readonly ALPHA_ONEONE: number;
  98396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98397. static readonly ALPHA_PREMULTIPLIED: number;
  98398. /**
  98399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98401. */
  98402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98404. static readonly ALPHA_INTERPOLATE: number;
  98405. /**
  98406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98408. */
  98409. static readonly ALPHA_SCREENMODE: number;
  98410. /** Defines that the ressource is not delayed*/
  98411. static readonly DELAYLOADSTATE_NONE: number;
  98412. /** Defines that the ressource was successfully delay loaded */
  98413. static readonly DELAYLOADSTATE_LOADED: number;
  98414. /** Defines that the ressource is currently delay loading */
  98415. static readonly DELAYLOADSTATE_LOADING: number;
  98416. /** Defines that the ressource is delayed and has not started loading */
  98417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98419. static readonly NEVER: number;
  98420. /** 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 */
  98421. static readonly ALWAYS: number;
  98422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98423. static readonly LESS: number;
  98424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98425. static readonly EQUAL: number;
  98426. /** 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 */
  98427. static readonly LEQUAL: number;
  98428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98429. static readonly GREATER: number;
  98430. /** 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 */
  98431. static readonly GEQUAL: number;
  98432. /** 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 */
  98433. static readonly NOTEQUAL: number;
  98434. /** Passed to stencilOperation to specify that stencil value must be kept */
  98435. static readonly KEEP: number;
  98436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98437. static readonly REPLACE: number;
  98438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98439. static readonly INCR: number;
  98440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98441. static readonly DECR: number;
  98442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98443. static readonly INVERT: number;
  98444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98445. static readonly INCR_WRAP: number;
  98446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98447. static readonly DECR_WRAP: number;
  98448. /** Texture is not repeating outside of 0..1 UVs */
  98449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98450. /** Texture is repeating outside of 0..1 UVs */
  98451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98452. /** Texture is repeating and mirrored */
  98453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98454. /** ALPHA */
  98455. static readonly TEXTUREFORMAT_ALPHA: number;
  98456. /** LUMINANCE */
  98457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98458. /** LUMINANCE_ALPHA */
  98459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98460. /** RGB */
  98461. static readonly TEXTUREFORMAT_RGB: number;
  98462. /** RGBA */
  98463. static readonly TEXTUREFORMAT_RGBA: number;
  98464. /** RED */
  98465. static readonly TEXTUREFORMAT_RED: number;
  98466. /** RED (2nd reference) */
  98467. static readonly TEXTUREFORMAT_R: number;
  98468. /** RG */
  98469. static readonly TEXTUREFORMAT_RG: number;
  98470. /** RED_INTEGER */
  98471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98472. /** RED_INTEGER (2nd reference) */
  98473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98474. /** RG_INTEGER */
  98475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98476. /** RGB_INTEGER */
  98477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98478. /** RGBA_INTEGER */
  98479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98480. /** UNSIGNED_BYTE */
  98481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98482. /** UNSIGNED_BYTE (2nd reference) */
  98483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98484. /** FLOAT */
  98485. static readonly TEXTURETYPE_FLOAT: number;
  98486. /** HALF_FLOAT */
  98487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98488. /** BYTE */
  98489. static readonly TEXTURETYPE_BYTE: number;
  98490. /** SHORT */
  98491. static readonly TEXTURETYPE_SHORT: number;
  98492. /** UNSIGNED_SHORT */
  98493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98494. /** INT */
  98495. static readonly TEXTURETYPE_INT: number;
  98496. /** UNSIGNED_INT */
  98497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98498. /** UNSIGNED_SHORT_4_4_4_4 */
  98499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98500. /** UNSIGNED_SHORT_5_5_5_1 */
  98501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98502. /** UNSIGNED_SHORT_5_6_5 */
  98503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98504. /** UNSIGNED_INT_2_10_10_10_REV */
  98505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98506. /** UNSIGNED_INT_24_8 */
  98507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98508. /** UNSIGNED_INT_10F_11F_11F_REV */
  98509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98510. /** UNSIGNED_INT_5_9_9_9_REV */
  98511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98514. /** nearest is mag = nearest and min = nearest and mip = linear */
  98515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98518. /** Trilinear is mag = linear and min = linear and mip = linear */
  98519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98520. /** nearest is mag = nearest and min = nearest and mip = linear */
  98521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98524. /** Trilinear is mag = linear and min = linear and mip = linear */
  98525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98526. /** mag = nearest and min = nearest and mip = nearest */
  98527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98528. /** mag = nearest and min = linear and mip = nearest */
  98529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98530. /** mag = nearest and min = linear and mip = linear */
  98531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98532. /** mag = nearest and min = linear and mip = none */
  98533. static readonly TEXTURE_NEAREST_LINEAR: number;
  98534. /** mag = nearest and min = nearest and mip = none */
  98535. static readonly TEXTURE_NEAREST_NEAREST: number;
  98536. /** mag = linear and min = nearest and mip = nearest */
  98537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98538. /** mag = linear and min = nearest and mip = linear */
  98539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98540. /** mag = linear and min = linear and mip = none */
  98541. static readonly TEXTURE_LINEAR_LINEAR: number;
  98542. /** mag = linear and min = nearest and mip = none */
  98543. static readonly TEXTURE_LINEAR_NEAREST: number;
  98544. /** Explicit coordinates mode */
  98545. static readonly TEXTURE_EXPLICIT_MODE: number;
  98546. /** Spherical coordinates mode */
  98547. static readonly TEXTURE_SPHERICAL_MODE: number;
  98548. /** Planar coordinates mode */
  98549. static readonly TEXTURE_PLANAR_MODE: number;
  98550. /** Cubic coordinates mode */
  98551. static readonly TEXTURE_CUBIC_MODE: number;
  98552. /** Projection coordinates mode */
  98553. static readonly TEXTURE_PROJECTION_MODE: number;
  98554. /** Skybox coordinates mode */
  98555. static readonly TEXTURE_SKYBOX_MODE: number;
  98556. /** Inverse Cubic coordinates mode */
  98557. static readonly TEXTURE_INVCUBIC_MODE: number;
  98558. /** Equirectangular coordinates mode */
  98559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98560. /** Equirectangular Fixed coordinates mode */
  98561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98562. /** Equirectangular Fixed Mirrored coordinates mode */
  98563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98565. static readonly SCALEMODE_FLOOR: number;
  98566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98567. static readonly SCALEMODE_NEAREST: number;
  98568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98569. static readonly SCALEMODE_CEILING: number;
  98570. /**
  98571. * Returns the current npm package of the sdk
  98572. */
  98573. static readonly NpmPackage: string;
  98574. /**
  98575. * Returns the current version of the framework
  98576. */
  98577. static readonly Version: string;
  98578. /** Gets the list of created engines */
  98579. static readonly Instances: Engine[];
  98580. /**
  98581. * Gets the latest created engine
  98582. */
  98583. static readonly LastCreatedEngine: Nullable<Engine>;
  98584. /**
  98585. * Gets the latest created scene
  98586. */
  98587. static readonly LastCreatedScene: Nullable<Scene>;
  98588. /**
  98589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98590. * @param flag defines which part of the materials must be marked as dirty
  98591. * @param predicate defines a predicate used to filter which materials should be affected
  98592. */
  98593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98594. /**
  98595. * Method called to create the default loading screen.
  98596. * This can be overriden in your own app.
  98597. * @param canvas The rendering canvas element
  98598. * @returns The loading screen
  98599. */
  98600. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98601. /**
  98602. * Method called to create the default rescale post process on each engine.
  98603. */
  98604. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98605. /**
  98606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98607. **/
  98608. enableOfflineSupport: boolean;
  98609. /**
  98610. * 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)
  98611. **/
  98612. disableManifestCheck: boolean;
  98613. /**
  98614. * Gets the list of created scenes
  98615. */
  98616. scenes: Scene[];
  98617. /**
  98618. * Event raised when a new scene is created
  98619. */
  98620. onNewSceneAddedObservable: Observable<Scene>;
  98621. /**
  98622. * Gets the list of created postprocesses
  98623. */
  98624. postProcesses: PostProcess[];
  98625. /**
  98626. * Gets a boolean indicating if the pointer is currently locked
  98627. */
  98628. isPointerLock: boolean;
  98629. /**
  98630. * Observable event triggered each time the rendering canvas is resized
  98631. */
  98632. onResizeObservable: Observable<Engine>;
  98633. /**
  98634. * Observable event triggered each time the canvas loses focus
  98635. */
  98636. onCanvasBlurObservable: Observable<Engine>;
  98637. /**
  98638. * Observable event triggered each time the canvas gains focus
  98639. */
  98640. onCanvasFocusObservable: Observable<Engine>;
  98641. /**
  98642. * Observable event triggered each time the canvas receives pointerout event
  98643. */
  98644. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98645. /**
  98646. * Observable raised when the engine begins a new frame
  98647. */
  98648. onBeginFrameObservable: Observable<Engine>;
  98649. /**
  98650. * If set, will be used to request the next animation frame for the render loop
  98651. */
  98652. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98653. /**
  98654. * Observable raised when the engine ends the current frame
  98655. */
  98656. onEndFrameObservable: Observable<Engine>;
  98657. /**
  98658. * Observable raised when the engine is about to compile a shader
  98659. */
  98660. onBeforeShaderCompilationObservable: Observable<Engine>;
  98661. /**
  98662. * Observable raised when the engine has jsut compiled a shader
  98663. */
  98664. onAfterShaderCompilationObservable: Observable<Engine>;
  98665. /**
  98666. * Gets the audio engine
  98667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98668. * @ignorenaming
  98669. */
  98670. static audioEngine: IAudioEngine;
  98671. /**
  98672. * Default AudioEngine factory responsible of creating the Audio Engine.
  98673. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98674. */
  98675. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98676. /**
  98677. * Default offline support factory responsible of creating a tool used to store data locally.
  98678. * By default, this will create a Database object if the workload has been embedded.
  98679. */
  98680. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98681. private _loadingScreen;
  98682. private _pointerLockRequested;
  98683. private _dummyFramebuffer;
  98684. private _rescalePostProcess;
  98685. /** @hidden */
  98686. protected _alphaMode: number;
  98687. /** @hidden */
  98688. protected _alphaEquation: number;
  98689. private _deterministicLockstep;
  98690. private _lockstepMaxSteps;
  98691. protected readonly _supportsHardwareTextureRescaling: boolean;
  98692. private _fps;
  98693. private _deltaTime;
  98694. /** @hidden */
  98695. _drawCalls: PerfCounter;
  98696. /**
  98697. * Turn this value on if you want to pause FPS computation when in background
  98698. */
  98699. disablePerformanceMonitorInBackground: boolean;
  98700. private _performanceMonitor;
  98701. /**
  98702. * Gets the performance monitor attached to this engine
  98703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98704. */
  98705. readonly performanceMonitor: PerformanceMonitor;
  98706. private _onFocus;
  98707. private _onBlur;
  98708. private _onCanvasPointerOut;
  98709. private _onCanvasBlur;
  98710. private _onCanvasFocus;
  98711. private _onFullscreenChange;
  98712. private _onPointerLockChange;
  98713. /**
  98714. * Creates a new engine
  98715. * @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
  98716. * @param antialias defines enable antialiasing (default: false)
  98717. * @param options defines further options to be sent to the getContext() function
  98718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98719. */
  98720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98721. /**
  98722. * Gets current aspect ratio
  98723. * @param viewportOwner defines the camera to use to get the aspect ratio
  98724. * @param useScreen defines if screen size must be used (or the current render target if any)
  98725. * @returns a number defining the aspect ratio
  98726. */
  98727. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98728. /**
  98729. * Gets current screen aspect ratio
  98730. * @returns a number defining the aspect ratio
  98731. */
  98732. getScreenAspectRatio(): number;
  98733. /**
  98734. * Gets host document
  98735. * @returns the host document object
  98736. */
  98737. getHostDocument(): Document;
  98738. /**
  98739. * Gets the client rect of the HTML canvas attached with the current webGL context
  98740. * @returns a client rectanglee
  98741. */
  98742. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98743. /**
  98744. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98746. * @returns true if engine is in deterministic lock step mode
  98747. */
  98748. isDeterministicLockStep(): boolean;
  98749. /**
  98750. * Gets the max steps when engine is running in deterministic lock step
  98751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98752. * @returns the max steps
  98753. */
  98754. getLockstepMaxSteps(): number;
  98755. /**
  98756. * Force the mipmap generation for the given render target texture
  98757. * @param texture defines the render target texture to use
  98758. */
  98759. generateMipMapsForCubemap(texture: InternalTexture): void;
  98760. /** States */
  98761. /**
  98762. * Set various states to the webGL context
  98763. * @param culling defines backface culling state
  98764. * @param zOffset defines the value to apply to zOffset (0 by default)
  98765. * @param force defines if states must be applied even if cache is up to date
  98766. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98767. */
  98768. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98769. /**
  98770. * Set the z offset to apply to current rendering
  98771. * @param value defines the offset to apply
  98772. */
  98773. setZOffset(value: number): void;
  98774. /**
  98775. * Gets the current value of the zOffset
  98776. * @returns the current zOffset state
  98777. */
  98778. getZOffset(): number;
  98779. /**
  98780. * Enable or disable depth buffering
  98781. * @param enable defines the state to set
  98782. */
  98783. setDepthBuffer(enable: boolean): void;
  98784. /**
  98785. * Gets a boolean indicating if depth writing is enabled
  98786. * @returns the current depth writing state
  98787. */
  98788. getDepthWrite(): boolean;
  98789. /**
  98790. * Enable or disable depth writing
  98791. * @param enable defines the state to set
  98792. */
  98793. setDepthWrite(enable: boolean): void;
  98794. /**
  98795. * Enable or disable color writing
  98796. * @param enable defines the state to set
  98797. */
  98798. setColorWrite(enable: boolean): void;
  98799. /**
  98800. * Gets a boolean indicating if color writing is enabled
  98801. * @returns the current color writing state
  98802. */
  98803. getColorWrite(): boolean;
  98804. /**
  98805. * Sets alpha constants used by some alpha blending modes
  98806. * @param r defines the red component
  98807. * @param g defines the green component
  98808. * @param b defines the blue component
  98809. * @param a defines the alpha component
  98810. */
  98811. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98812. /**
  98813. * Sets the current alpha mode
  98814. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98815. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98816. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98817. */
  98818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98819. /**
  98820. * Gets the current alpha mode
  98821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98822. * @returns the current alpha mode
  98823. */
  98824. getAlphaMode(): number;
  98825. /**
  98826. * Sets the current alpha equation
  98827. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98828. */
  98829. setAlphaEquation(equation: number): void;
  98830. /**
  98831. * Gets the current alpha equation.
  98832. * @returns the current alpha equation
  98833. */
  98834. getAlphaEquation(): number;
  98835. /**
  98836. * Gets a boolean indicating if stencil buffer is enabled
  98837. * @returns the current stencil buffer state
  98838. */
  98839. getStencilBuffer(): boolean;
  98840. /**
  98841. * Enable or disable the stencil buffer
  98842. * @param enable defines if the stencil buffer must be enabled or disabled
  98843. */
  98844. setStencilBuffer(enable: boolean): void;
  98845. /**
  98846. * Gets the current stencil mask
  98847. * @returns a number defining the new stencil mask to use
  98848. */
  98849. getStencilMask(): number;
  98850. /**
  98851. * Sets the current stencil mask
  98852. * @param mask defines the new stencil mask to use
  98853. */
  98854. setStencilMask(mask: number): void;
  98855. /**
  98856. * Gets the current stencil function
  98857. * @returns a number defining the stencil function to use
  98858. */
  98859. getStencilFunction(): number;
  98860. /**
  98861. * Gets the current stencil reference value
  98862. * @returns a number defining the stencil reference value to use
  98863. */
  98864. getStencilFunctionReference(): number;
  98865. /**
  98866. * Gets the current stencil mask
  98867. * @returns a number defining the stencil mask to use
  98868. */
  98869. getStencilFunctionMask(): number;
  98870. /**
  98871. * Sets the current stencil function
  98872. * @param stencilFunc defines the new stencil function to use
  98873. */
  98874. setStencilFunction(stencilFunc: number): void;
  98875. /**
  98876. * Sets the current stencil reference
  98877. * @param reference defines the new stencil reference to use
  98878. */
  98879. setStencilFunctionReference(reference: number): void;
  98880. /**
  98881. * Sets the current stencil mask
  98882. * @param mask defines the new stencil mask to use
  98883. */
  98884. setStencilFunctionMask(mask: number): void;
  98885. /**
  98886. * Gets the current stencil operation when stencil fails
  98887. * @returns a number defining stencil operation to use when stencil fails
  98888. */
  98889. getStencilOperationFail(): number;
  98890. /**
  98891. * Gets the current stencil operation when depth fails
  98892. * @returns a number defining stencil operation to use when depth fails
  98893. */
  98894. getStencilOperationDepthFail(): number;
  98895. /**
  98896. * Gets the current stencil operation when stencil passes
  98897. * @returns a number defining stencil operation to use when stencil passes
  98898. */
  98899. getStencilOperationPass(): number;
  98900. /**
  98901. * Sets the stencil operation to use when stencil fails
  98902. * @param operation defines the stencil operation to use when stencil fails
  98903. */
  98904. setStencilOperationFail(operation: number): void;
  98905. /**
  98906. * Sets the stencil operation to use when depth fails
  98907. * @param operation defines the stencil operation to use when depth fails
  98908. */
  98909. setStencilOperationDepthFail(operation: number): void;
  98910. /**
  98911. * Sets the stencil operation to use when stencil passes
  98912. * @param operation defines the stencil operation to use when stencil passes
  98913. */
  98914. setStencilOperationPass(operation: number): void;
  98915. /**
  98916. * Sets a boolean indicating if the dithering state is enabled or disabled
  98917. * @param value defines the dithering state
  98918. */
  98919. setDitheringState(value: boolean): void;
  98920. /**
  98921. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98922. * @param value defines the rasterizer state
  98923. */
  98924. setRasterizerState(value: boolean): void;
  98925. /**
  98926. * Gets the current depth function
  98927. * @returns a number defining the depth function
  98928. */
  98929. getDepthFunction(): Nullable<number>;
  98930. /**
  98931. * Sets the current depth function
  98932. * @param depthFunc defines the function to use
  98933. */
  98934. setDepthFunction(depthFunc: number): void;
  98935. /**
  98936. * Sets the current depth function to GREATER
  98937. */
  98938. setDepthFunctionToGreater(): void;
  98939. /**
  98940. * Sets the current depth function to GEQUAL
  98941. */
  98942. setDepthFunctionToGreaterOrEqual(): void;
  98943. /**
  98944. * Sets the current depth function to LESS
  98945. */
  98946. setDepthFunctionToLess(): void;
  98947. /**
  98948. * Sets the current depth function to LEQUAL
  98949. */
  98950. setDepthFunctionToLessOrEqual(): void;
  98951. private _cachedStencilBuffer;
  98952. private _cachedStencilFunction;
  98953. private _cachedStencilMask;
  98954. private _cachedStencilOperationPass;
  98955. private _cachedStencilOperationFail;
  98956. private _cachedStencilOperationDepthFail;
  98957. private _cachedStencilReference;
  98958. /**
  98959. * Caches the the state of the stencil buffer
  98960. */
  98961. cacheStencilState(): void;
  98962. /**
  98963. * Restores the state of the stencil buffer
  98964. */
  98965. restoreStencilState(): void;
  98966. /**
  98967. * Directly set the WebGL Viewport
  98968. * @param x defines the x coordinate of the viewport (in screen space)
  98969. * @param y defines the y coordinate of the viewport (in screen space)
  98970. * @param width defines the width of the viewport (in screen space)
  98971. * @param height defines the height of the viewport (in screen space)
  98972. * @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
  98973. */
  98974. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98975. /**
  98976. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98977. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98978. * @param y defines the y-coordinate of the corner of the clear rectangle
  98979. * @param width defines the width of the clear rectangle
  98980. * @param height defines the height of the clear rectangle
  98981. * @param clearColor defines the clear color
  98982. */
  98983. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98984. /**
  98985. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98986. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98987. * @param y defines the y-coordinate of the corner of the clear rectangle
  98988. * @param width defines the width of the clear rectangle
  98989. * @param height defines the height of the clear rectangle
  98990. */
  98991. enableScissor(x: number, y: number, width: number, height: number): void;
  98992. /**
  98993. * Disable previously set scissor test rectangle
  98994. */
  98995. disableScissor(): void;
  98996. protected _reportDrawCall(): void;
  98997. /**
  98998. * Initializes a webVR display and starts listening to display change events
  98999. * The onVRDisplayChangedObservable will be notified upon these changes
  99000. * @returns The onVRDisplayChangedObservable
  99001. */
  99002. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99003. /** @hidden */
  99004. _prepareVRComponent(): void;
  99005. /** @hidden */
  99006. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99007. /** @hidden */
  99008. _submitVRFrame(): void;
  99009. /**
  99010. * Call this function to leave webVR mode
  99011. * Will do nothing if webVR is not supported or if there is no webVR device
  99012. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99013. */
  99014. disableVR(): void;
  99015. /**
  99016. * Gets a boolean indicating that the system is in VR mode and is presenting
  99017. * @returns true if VR mode is engaged
  99018. */
  99019. isVRPresenting(): boolean;
  99020. /** @hidden */
  99021. _requestVRFrame(): void;
  99022. /** @hidden */
  99023. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99024. /**
  99025. * Gets the source code of the vertex shader associated with a specific webGL program
  99026. * @param program defines the program to use
  99027. * @returns a string containing the source code of the vertex shader associated with the program
  99028. */
  99029. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99030. /**
  99031. * Gets the source code of the fragment shader associated with a specific webGL program
  99032. * @param program defines the program to use
  99033. * @returns a string containing the source code of the fragment shader associated with the program
  99034. */
  99035. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99036. /**
  99037. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99038. * @param x defines the x coordinate of the rectangle where pixels must be read
  99039. * @param y defines the y coordinate of the rectangle where pixels must be read
  99040. * @param width defines the width of the rectangle where pixels must be read
  99041. * @param height defines the height of the rectangle where pixels must be read
  99042. * @returns a Uint8Array containing RGBA colors
  99043. */
  99044. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99045. /**
  99046. * Sets a depth stencil texture from a render target to the according uniform.
  99047. * @param channel The texture channel
  99048. * @param uniform The uniform to set
  99049. * @param texture The render target texture containing the depth stencil texture to apply
  99050. */
  99051. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99052. /**
  99053. * Sets a texture to the webGL context from a postprocess
  99054. * @param channel defines the channel to use
  99055. * @param postProcess defines the source postprocess
  99056. */
  99057. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99058. /**
  99059. * Binds the output of the passed in post process to the texture channel specified
  99060. * @param channel The channel the texture should be bound to
  99061. * @param postProcess The post process which's output should be bound
  99062. */
  99063. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99064. /** @hidden */
  99065. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99066. protected _rebuildBuffers(): void;
  99067. _renderLoop(): void;
  99068. /**
  99069. * Toggle full screen mode
  99070. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99071. */
  99072. switchFullscreen(requestPointerLock: boolean): void;
  99073. /**
  99074. * Enters full screen mode
  99075. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99076. */
  99077. enterFullscreen(requestPointerLock: boolean): void;
  99078. /**
  99079. * Exits full screen mode
  99080. */
  99081. exitFullscreen(): void;
  99082. /**
  99083. * Enters Pointerlock mode
  99084. */
  99085. enterPointerlock(): void;
  99086. /**
  99087. * Exits Pointerlock mode
  99088. */
  99089. exitPointerlock(): void;
  99090. /**
  99091. * Begin a new frame
  99092. */
  99093. beginFrame(): void;
  99094. /**
  99095. * Enf the current frame
  99096. */
  99097. endFrame(): void;
  99098. resize(): void;
  99099. /**
  99100. * Set the compressed texture format to use, based on the formats you have, and the formats
  99101. * supported by the hardware / browser.
  99102. *
  99103. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99104. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99105. * to API arguments needed to compressed textures. This puts the burden on the container
  99106. * generator to house the arcane code for determining these for current & future formats.
  99107. *
  99108. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99109. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99110. *
  99111. * Note: The result of this call is not taken into account when a texture is base64.
  99112. *
  99113. * @param formatsAvailable defines the list of those format families you have created
  99114. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99115. *
  99116. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99117. * @returns The extension selected.
  99118. */
  99119. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99120. /**
  99121. * Force a specific size of the canvas
  99122. * @param width defines the new canvas' width
  99123. * @param height defines the new canvas' height
  99124. */
  99125. setSize(width: number, height: number): void;
  99126. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99127. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99128. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99129. _releaseTexture(texture: InternalTexture): void;
  99130. /**
  99131. * @hidden
  99132. * Rescales a texture
  99133. * @param source input texutre
  99134. * @param destination destination texture
  99135. * @param scene scene to use to render the resize
  99136. * @param internalFormat format to use when resizing
  99137. * @param onComplete callback to be called when resize has completed
  99138. */
  99139. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99140. /**
  99141. * Gets the current framerate
  99142. * @returns a number representing the framerate
  99143. */
  99144. getFps(): number;
  99145. /**
  99146. * Gets the time spent between current and previous frame
  99147. * @returns a number representing the delta time in ms
  99148. */
  99149. getDeltaTime(): number;
  99150. private _measureFps;
  99151. /**
  99152. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99153. * @param renderTarget The render target to set the frame buffer for
  99154. */
  99155. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99156. /**
  99157. * Update a dynamic index buffer
  99158. * @param indexBuffer defines the target index buffer
  99159. * @param indices defines the data to update
  99160. * @param offset defines the offset in the target index buffer where update should start
  99161. */
  99162. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99163. /**
  99164. * Updates the sample count of a render target texture
  99165. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99166. * @param texture defines the texture to update
  99167. * @param samples defines the sample count to set
  99168. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99169. */
  99170. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99171. /** @hidden */
  99172. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99173. dispose(): void;
  99174. private _disableTouchAction;
  99175. /**
  99176. * Display the loading screen
  99177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99178. */
  99179. displayLoadingUI(): void;
  99180. /**
  99181. * Hide the loading screen
  99182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99183. */
  99184. hideLoadingUI(): void;
  99185. /**
  99186. * Gets the current loading screen object
  99187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99188. */
  99189. /**
  99190. * Sets the current loading screen object
  99191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99192. */
  99193. loadingScreen: ILoadingScreen;
  99194. /**
  99195. * Sets the current loading screen text
  99196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99197. */
  99198. loadingUIText: string;
  99199. /**
  99200. * Sets the current loading screen background color
  99201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99202. */
  99203. loadingUIBackgroundColor: string;
  99204. /** Pointerlock and fullscreen */
  99205. /**
  99206. * Ask the browser to promote the current element to pointerlock mode
  99207. * @param element defines the DOM element to promote
  99208. */
  99209. static _RequestPointerlock(element: HTMLElement): void;
  99210. /**
  99211. * Asks the browser to exit pointerlock mode
  99212. */
  99213. static _ExitPointerlock(): void;
  99214. /**
  99215. * Ask the browser to promote the current element to fullscreen rendering mode
  99216. * @param element defines the DOM element to promote
  99217. */
  99218. static _RequestFullscreen(element: HTMLElement): void;
  99219. /**
  99220. * Asks the browser to exit fullscreen mode
  99221. */
  99222. static _ExitFullscreen(): void;
  99223. }
  99224. }
  99225. declare module BABYLON {
  99226. /**
  99227. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99228. * during the life time of the application.
  99229. */
  99230. export class EngineStore {
  99231. /** Gets the list of created engines */
  99232. static Instances: Engine[];
  99233. /** @hidden */
  99234. static _LastCreatedScene: Nullable<Scene>;
  99235. /**
  99236. * Gets the latest created engine
  99237. */
  99238. static readonly LastCreatedEngine: Nullable<Engine>;
  99239. /**
  99240. * Gets the latest created scene
  99241. */
  99242. static readonly LastCreatedScene: Nullable<Scene>;
  99243. /**
  99244. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99245. * @ignorenaming
  99246. */
  99247. static UseFallbackTexture: boolean;
  99248. /**
  99249. * Texture content used if a texture cannot loaded
  99250. * @ignorenaming
  99251. */
  99252. static FallbackTexture: string;
  99253. }
  99254. }
  99255. declare module BABYLON {
  99256. /**
  99257. * Helper class that provides a small promise polyfill
  99258. */
  99259. export class PromisePolyfill {
  99260. /**
  99261. * Static function used to check if the polyfill is required
  99262. * If this is the case then the function will inject the polyfill to window.Promise
  99263. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99264. */
  99265. static Apply(force?: boolean): void;
  99266. }
  99267. }
  99268. declare module BABYLON {
  99269. /**
  99270. * Interface for screenshot methods with describe argument called `size` as object with options
  99271. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99272. */
  99273. export interface IScreenshotSize {
  99274. /**
  99275. * number in pixels for canvas height
  99276. */
  99277. height?: number;
  99278. /**
  99279. * multiplier allowing render at a higher or lower resolution
  99280. * If value is defined then height and width will be ignored and taken from camera
  99281. */
  99282. precision?: number;
  99283. /**
  99284. * number in pixels for canvas width
  99285. */
  99286. width?: number;
  99287. }
  99288. }
  99289. declare module BABYLON {
  99290. interface IColor4Like {
  99291. r: float;
  99292. g: float;
  99293. b: float;
  99294. a: float;
  99295. }
  99296. /**
  99297. * Class containing a set of static utilities functions
  99298. */
  99299. export class Tools {
  99300. /**
  99301. * Gets or sets the base URL to use to load assets
  99302. */
  99303. static BaseUrl: string;
  99304. /**
  99305. * Enable/Disable Custom HTTP Request Headers globally.
  99306. * default = false
  99307. * @see CustomRequestHeaders
  99308. */
  99309. static UseCustomRequestHeaders: boolean;
  99310. /**
  99311. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99312. * i.e. when loading files, where the server/service expects an Authorization header
  99313. */
  99314. static CustomRequestHeaders: {
  99315. [key: string]: string;
  99316. };
  99317. /**
  99318. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99319. */
  99320. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99321. /**
  99322. * Default behaviour for cors in the application.
  99323. * It can be a string if the expected behavior is identical in the entire app.
  99324. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99325. */
  99326. static CorsBehavior: string | ((url: string | string[]) => string);
  99327. /**
  99328. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99329. * @ignorenaming
  99330. */
  99331. static UseFallbackTexture: boolean;
  99332. /**
  99333. * Use this object to register external classes like custom textures or material
  99334. * to allow the laoders to instantiate them
  99335. */
  99336. static RegisteredExternalClasses: {
  99337. [key: string]: Object;
  99338. };
  99339. /**
  99340. * Texture content used if a texture cannot loaded
  99341. * @ignorenaming
  99342. */
  99343. static fallbackTexture: string;
  99344. /**
  99345. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99346. * @param u defines the coordinate on X axis
  99347. * @param v defines the coordinate on Y axis
  99348. * @param width defines the width of the source data
  99349. * @param height defines the height of the source data
  99350. * @param pixels defines the source byte array
  99351. * @param color defines the output color
  99352. */
  99353. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99354. /**
  99355. * Interpolates between a and b via alpha
  99356. * @param a The lower value (returned when alpha = 0)
  99357. * @param b The upper value (returned when alpha = 1)
  99358. * @param alpha The interpolation-factor
  99359. * @return The mixed value
  99360. */
  99361. static Mix(a: number, b: number, alpha: number): number;
  99362. /**
  99363. * Tries to instantiate a new object from a given class name
  99364. * @param className defines the class name to instantiate
  99365. * @returns the new object or null if the system was not able to do the instantiation
  99366. */
  99367. static Instantiate(className: string): any;
  99368. /**
  99369. * Provides a slice function that will work even on IE
  99370. * @param data defines the array to slice
  99371. * @param start defines the start of the data (optional)
  99372. * @param end defines the end of the data (optional)
  99373. * @returns the new sliced array
  99374. */
  99375. static Slice<T>(data: T, start?: number, end?: number): T;
  99376. /**
  99377. * Polyfill for setImmediate
  99378. * @param action defines the action to execute after the current execution block
  99379. */
  99380. static SetImmediate(action: () => void): void;
  99381. /**
  99382. * Function indicating if a number is an exponent of 2
  99383. * @param value defines the value to test
  99384. * @returns true if the value is an exponent of 2
  99385. */
  99386. static IsExponentOfTwo(value: number): boolean;
  99387. private static _tmpFloatArray;
  99388. /**
  99389. * Returns the nearest 32-bit single precision float representation of a Number
  99390. * @param value A Number. If the parameter is of a different type, it will get converted
  99391. * to a number or to NaN if it cannot be converted
  99392. * @returns number
  99393. */
  99394. static FloatRound(value: number): number;
  99395. /**
  99396. * Extracts the filename from a path
  99397. * @param path defines the path to use
  99398. * @returns the filename
  99399. */
  99400. static GetFilename(path: string): string;
  99401. /**
  99402. * Extracts the "folder" part of a path (everything before the filename).
  99403. * @param uri The URI to extract the info from
  99404. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99405. * @returns The "folder" part of the path
  99406. */
  99407. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99408. /**
  99409. * Extracts text content from a DOM element hierarchy
  99410. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99411. */
  99412. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99413. /**
  99414. * Convert an angle in radians to degrees
  99415. * @param angle defines the angle to convert
  99416. * @returns the angle in degrees
  99417. */
  99418. static ToDegrees(angle: number): number;
  99419. /**
  99420. * Convert an angle in degrees to radians
  99421. * @param angle defines the angle to convert
  99422. * @returns the angle in radians
  99423. */
  99424. static ToRadians(angle: number): number;
  99425. /**
  99426. * Encode a buffer to a base64 string
  99427. * @param buffer defines the buffer to encode
  99428. * @returns the encoded string
  99429. */
  99430. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  99431. /**
  99432. * Returns an array if obj is not an array
  99433. * @param obj defines the object to evaluate as an array
  99434. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99435. * @returns either obj directly if obj is an array or a new array containing obj
  99436. */
  99437. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99438. /**
  99439. * Gets the pointer prefix to use
  99440. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99441. */
  99442. static GetPointerPrefix(): string;
  99443. /**
  99444. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99445. * @param url define the url we are trying
  99446. * @param element define the dom element where to configure the cors policy
  99447. */
  99448. static SetCorsBehavior(url: string | string[], element: {
  99449. crossOrigin: string | null;
  99450. }): void;
  99451. /**
  99452. * Removes unwanted characters from an url
  99453. * @param url defines the url to clean
  99454. * @returns the cleaned url
  99455. */
  99456. static CleanUrl(url: string): string;
  99457. /**
  99458. * Gets or sets a function used to pre-process url before using them to load assets
  99459. */
  99460. static PreprocessUrl: (url: string) => string;
  99461. /**
  99462. * Loads an image as an HTMLImageElement.
  99463. * @param input url string, ArrayBuffer, or Blob to load
  99464. * @param onLoad callback called when the image successfully loads
  99465. * @param onError callback called when the image fails to load
  99466. * @param offlineProvider offline provider for caching
  99467. * @param mimeType optional mime type
  99468. * @returns the HTMLImageElement of the loaded image
  99469. */
  99470. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99471. /**
  99472. * Loads a file
  99473. * @param url url string, ArrayBuffer, or Blob to load
  99474. * @param onSuccess callback called when the file successfully loads
  99475. * @param onProgress callback called while file is loading (if the server supports this mode)
  99476. * @param offlineProvider defines the offline provider for caching
  99477. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99478. * @param onError callback called when the file fails to load
  99479. * @returns a file request object
  99480. */
  99481. 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;
  99482. /**
  99483. * Loads a file from a url
  99484. * @param url the file url to load
  99485. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99486. */
  99487. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99488. /**
  99489. * Load a script (identified by an url). When the url returns, the
  99490. * content of this file is added into a new script element, attached to the DOM (body element)
  99491. * @param scriptUrl defines the url of the script to laod
  99492. * @param onSuccess defines the callback called when the script is loaded
  99493. * @param onError defines the callback to call if an error occurs
  99494. * @param scriptId defines the id of the script element
  99495. */
  99496. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99497. /**
  99498. * Load an asynchronous script (identified by an url). When the url returns, the
  99499. * content of this file is added into a new script element, attached to the DOM (body element)
  99500. * @param scriptUrl defines the url of the script to laod
  99501. * @param scriptId defines the id of the script element
  99502. * @returns a promise request object
  99503. */
  99504. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99505. /**
  99506. * Loads a file from a blob
  99507. * @param fileToLoad defines the blob to use
  99508. * @param callback defines the callback to call when data is loaded
  99509. * @param progressCallback defines the callback to call during loading process
  99510. * @returns a file request object
  99511. */
  99512. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99513. /**
  99514. * Loads a file
  99515. * @param fileToLoad defines the file to load
  99516. * @param callback defines the callback to call when data is loaded
  99517. * @param progressCallBack defines the callback to call during loading process
  99518. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99519. * @returns a file request object
  99520. */
  99521. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  99522. /**
  99523. * Creates a data url from a given string content
  99524. * @param content defines the content to convert
  99525. * @returns the new data url link
  99526. */
  99527. static FileAsURL(content: string): string;
  99528. /**
  99529. * Format the given number to a specific decimal format
  99530. * @param value defines the number to format
  99531. * @param decimals defines the number of decimals to use
  99532. * @returns the formatted string
  99533. */
  99534. static Format(value: number, decimals?: number): string;
  99535. /**
  99536. * Tries to copy an object by duplicating every property
  99537. * @param source defines the source object
  99538. * @param destination defines the target object
  99539. * @param doNotCopyList defines a list of properties to avoid
  99540. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99541. */
  99542. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99543. /**
  99544. * Gets a boolean indicating if the given object has no own property
  99545. * @param obj defines the object to test
  99546. * @returns true if object has no own property
  99547. */
  99548. static IsEmpty(obj: any): boolean;
  99549. /**
  99550. * Function used to register events at window level
  99551. * @param windowElement defines the Window object to use
  99552. * @param events defines the events to register
  99553. */
  99554. static RegisterTopRootEvents(windowElement: Window, events: {
  99555. name: string;
  99556. handler: Nullable<(e: FocusEvent) => any>;
  99557. }[]): void;
  99558. /**
  99559. * Function used to unregister events from window level
  99560. * @param windowElement defines the Window object to use
  99561. * @param events defines the events to unregister
  99562. */
  99563. static UnregisterTopRootEvents(windowElement: Window, events: {
  99564. name: string;
  99565. handler: Nullable<(e: FocusEvent) => any>;
  99566. }[]): void;
  99567. /**
  99568. * @ignore
  99569. */
  99570. static _ScreenshotCanvas: HTMLCanvasElement;
  99571. /**
  99572. * Dumps the current bound framebuffer
  99573. * @param width defines the rendering width
  99574. * @param height defines the rendering height
  99575. * @param engine defines the hosting engine
  99576. * @param successCallback defines the callback triggered once the data are available
  99577. * @param mimeType defines the mime type of the result
  99578. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99579. */
  99580. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99581. /**
  99582. * Converts the canvas data to blob.
  99583. * This acts as a polyfill for browsers not supporting the to blob function.
  99584. * @param canvas Defines the canvas to extract the data from
  99585. * @param successCallback Defines the callback triggered once the data are available
  99586. * @param mimeType Defines the mime type of the result
  99587. */
  99588. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99589. /**
  99590. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99591. * @param successCallback defines the callback triggered once the data are available
  99592. * @param mimeType defines the mime type of the result
  99593. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99594. */
  99595. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99596. /**
  99597. * Downloads a blob in the browser
  99598. * @param blob defines the blob to download
  99599. * @param fileName defines the name of the downloaded file
  99600. */
  99601. static Download(blob: Blob, fileName: string): void;
  99602. /**
  99603. * Captures a screenshot of the current rendering
  99604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99605. * @param engine defines the rendering engine
  99606. * @param camera defines the source camera
  99607. * @param size This parameter can be set to a single number or to an object with the
  99608. * following (optional) properties: precision, width, height. If a single number is passed,
  99609. * it will be used for both width and height. If an object is passed, the screenshot size
  99610. * will be derived from the parameters. The precision property is a multiplier allowing
  99611. * rendering at a higher or lower resolution
  99612. * @param successCallback defines the callback receives a single parameter which contains the
  99613. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99614. * src parameter of an <img> to display it
  99615. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99616. * Check your browser for supported MIME types
  99617. */
  99618. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99619. /**
  99620. * Captures a screenshot of the current rendering
  99621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99622. * @param engine defines the rendering engine
  99623. * @param camera defines the source camera
  99624. * @param size This parameter can be set to a single number or to an object with the
  99625. * following (optional) properties: precision, width, height. If a single number is passed,
  99626. * it will be used for both width and height. If an object is passed, the screenshot size
  99627. * will be derived from the parameters. The precision property is a multiplier allowing
  99628. * rendering at a higher or lower resolution
  99629. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99630. * Check your browser for supported MIME types
  99631. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99632. * to the src parameter of an <img> to display it
  99633. */
  99634. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99635. /**
  99636. * Generates an image screenshot from the specified camera.
  99637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99638. * @param engine The engine to use for rendering
  99639. * @param camera The camera to use for rendering
  99640. * @param size This parameter can be set to a single number or to an object with the
  99641. * following (optional) properties: precision, width, height. If a single number is passed,
  99642. * it will be used for both width and height. If an object is passed, the screenshot size
  99643. * will be derived from the parameters. The precision property is a multiplier allowing
  99644. * rendering at a higher or lower resolution
  99645. * @param successCallback The callback receives a single parameter which contains the
  99646. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99647. * src parameter of an <img> to display it
  99648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99649. * Check your browser for supported MIME types
  99650. * @param samples Texture samples (default: 1)
  99651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99652. * @param fileName A name for for the downloaded file.
  99653. */
  99654. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99655. /**
  99656. * Generates an image screenshot from the specified camera.
  99657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99658. * @param engine The engine to use for rendering
  99659. * @param camera The camera to use for rendering
  99660. * @param size This parameter can be set to a single number or to an object with the
  99661. * following (optional) properties: precision, width, height. If a single number is passed,
  99662. * it will be used for both width and height. If an object is passed, the screenshot size
  99663. * will be derived from the parameters. The precision property is a multiplier allowing
  99664. * rendering at a higher or lower resolution
  99665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99666. * Check your browser for supported MIME types
  99667. * @param samples Texture samples (default: 1)
  99668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99669. * @param fileName A name for for the downloaded file.
  99670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99671. * to the src parameter of an <img> to display it
  99672. */
  99673. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99674. /**
  99675. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99676. * Be aware Math.random() could cause collisions, but:
  99677. * "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"
  99678. * @returns a pseudo random id
  99679. */
  99680. static RandomId(): string;
  99681. /**
  99682. * Test if the given uri is a base64 string
  99683. * @param uri The uri to test
  99684. * @return True if the uri is a base64 string or false otherwise
  99685. */
  99686. static IsBase64(uri: string): boolean;
  99687. /**
  99688. * Decode the given base64 uri.
  99689. * @param uri The uri to decode
  99690. * @return The decoded base64 data.
  99691. */
  99692. static DecodeBase64(uri: string): ArrayBuffer;
  99693. /**
  99694. * Gets the absolute url.
  99695. * @param url the input url
  99696. * @return the absolute url
  99697. */
  99698. static GetAbsoluteUrl(url: string): string;
  99699. /**
  99700. * No log
  99701. */
  99702. static readonly NoneLogLevel: number;
  99703. /**
  99704. * Only message logs
  99705. */
  99706. static readonly MessageLogLevel: number;
  99707. /**
  99708. * Only warning logs
  99709. */
  99710. static readonly WarningLogLevel: number;
  99711. /**
  99712. * Only error logs
  99713. */
  99714. static readonly ErrorLogLevel: number;
  99715. /**
  99716. * All logs
  99717. */
  99718. static readonly AllLogLevel: number;
  99719. /**
  99720. * Gets a value indicating the number of loading errors
  99721. * @ignorenaming
  99722. */
  99723. static readonly errorsCount: number;
  99724. /**
  99725. * Callback called when a new log is added
  99726. */
  99727. static OnNewCacheEntry: (entry: string) => void;
  99728. /**
  99729. * Log a message to the console
  99730. * @param message defines the message to log
  99731. */
  99732. static Log(message: string): void;
  99733. /**
  99734. * Write a warning message to the console
  99735. * @param message defines the message to log
  99736. */
  99737. static Warn(message: string): void;
  99738. /**
  99739. * Write an error message to the console
  99740. * @param message defines the message to log
  99741. */
  99742. static Error(message: string): void;
  99743. /**
  99744. * Gets current log cache (list of logs)
  99745. */
  99746. static readonly LogCache: string;
  99747. /**
  99748. * Clears the log cache
  99749. */
  99750. static ClearLogCache(): void;
  99751. /**
  99752. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99753. */
  99754. static LogLevels: number;
  99755. /**
  99756. * Checks if the window object exists
  99757. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99758. */
  99759. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99760. /**
  99761. * No performance log
  99762. */
  99763. static readonly PerformanceNoneLogLevel: number;
  99764. /**
  99765. * Use user marks to log performance
  99766. */
  99767. static readonly PerformanceUserMarkLogLevel: number;
  99768. /**
  99769. * Log performance to the console
  99770. */
  99771. static readonly PerformanceConsoleLogLevel: number;
  99772. private static _performance;
  99773. /**
  99774. * Sets the current performance log level
  99775. */
  99776. static PerformanceLogLevel: number;
  99777. private static _StartPerformanceCounterDisabled;
  99778. private static _EndPerformanceCounterDisabled;
  99779. private static _StartUserMark;
  99780. private static _EndUserMark;
  99781. private static _StartPerformanceConsole;
  99782. private static _EndPerformanceConsole;
  99783. /**
  99784. * Starts a performance counter
  99785. */
  99786. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99787. /**
  99788. * Ends a specific performance coutner
  99789. */
  99790. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99791. /**
  99792. * Gets either window.performance.now() if supported or Date.now() else
  99793. */
  99794. static readonly Now: number;
  99795. /**
  99796. * This method will return the name of the class used to create the instance of the given object.
  99797. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99798. * @param object the object to get the class name from
  99799. * @param isType defines if the object is actually a type
  99800. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99801. */
  99802. static GetClassName(object: any, isType?: boolean): string;
  99803. /**
  99804. * Gets the first element of an array satisfying a given predicate
  99805. * @param array defines the array to browse
  99806. * @param predicate defines the predicate to use
  99807. * @returns null if not found or the element
  99808. */
  99809. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99810. /**
  99811. * This method will return the name of the full name of the class, including its owning module (if any).
  99812. * 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).
  99813. * @param object the object to get the class name from
  99814. * @param isType defines if the object is actually a type
  99815. * @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.
  99816. * @ignorenaming
  99817. */
  99818. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99819. /**
  99820. * Returns a promise that resolves after the given amount of time.
  99821. * @param delay Number of milliseconds to delay
  99822. * @returns Promise that resolves after the given amount of time
  99823. */
  99824. static DelayAsync(delay: number): Promise<void>;
  99825. }
  99826. /**
  99827. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99828. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99829. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99830. * @param name The name of the class, case should be preserved
  99831. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99832. */
  99833. export function className(name: string, module?: string): (target: Object) => void;
  99834. /**
  99835. * An implementation of a loop for asynchronous functions.
  99836. */
  99837. export class AsyncLoop {
  99838. /**
  99839. * Defines the number of iterations for the loop
  99840. */
  99841. iterations: number;
  99842. /**
  99843. * Defines the current index of the loop.
  99844. */
  99845. index: number;
  99846. private _done;
  99847. private _fn;
  99848. private _successCallback;
  99849. /**
  99850. * Constructor.
  99851. * @param iterations the number of iterations.
  99852. * @param func the function to run each iteration
  99853. * @param successCallback the callback that will be called upon succesful execution
  99854. * @param offset starting offset.
  99855. */
  99856. constructor(
  99857. /**
  99858. * Defines the number of iterations for the loop
  99859. */
  99860. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99861. /**
  99862. * Execute the next iteration. Must be called after the last iteration was finished.
  99863. */
  99864. executeNext(): void;
  99865. /**
  99866. * Break the loop and run the success callback.
  99867. */
  99868. breakLoop(): void;
  99869. /**
  99870. * Create and run an async loop.
  99871. * @param iterations the number of iterations.
  99872. * @param fn the function to run each iteration
  99873. * @param successCallback the callback that will be called upon succesful execution
  99874. * @param offset starting offset.
  99875. * @returns the created async loop object
  99876. */
  99877. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99878. /**
  99879. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99880. * @param iterations total number of iterations
  99881. * @param syncedIterations number of synchronous iterations in each async iteration.
  99882. * @param fn the function to call each iteration.
  99883. * @param callback a success call back that will be called when iterating stops.
  99884. * @param breakFunction a break condition (optional)
  99885. * @param timeout timeout settings for the setTimeout function. default - 0.
  99886. * @returns the created async loop object
  99887. */
  99888. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99889. }
  99890. }
  99891. declare module BABYLON {
  99892. /**
  99893. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99894. * The underlying implementation relies on an associative array to ensure the best performances.
  99895. * The value can be anything including 'null' but except 'undefined'
  99896. */
  99897. export class StringDictionary<T> {
  99898. /**
  99899. * This will clear this dictionary and copy the content from the 'source' one.
  99900. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99901. * @param source the dictionary to take the content from and copy to this dictionary
  99902. */
  99903. copyFrom(source: StringDictionary<T>): void;
  99904. /**
  99905. * Get a value based from its key
  99906. * @param key the given key to get the matching value from
  99907. * @return the value if found, otherwise undefined is returned
  99908. */
  99909. get(key: string): T | undefined;
  99910. /**
  99911. * Get a value from its key or add it if it doesn't exist.
  99912. * This method will ensure you that a given key/data will be present in the dictionary.
  99913. * @param key the given key to get the matching value from
  99914. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99915. * The factory will only be invoked if there's no data for the given key.
  99916. * @return the value corresponding to the key.
  99917. */
  99918. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99919. /**
  99920. * Get a value from its key if present in the dictionary otherwise add it
  99921. * @param key the key to get the value from
  99922. * @param val if there's no such key/value pair in the dictionary add it with this value
  99923. * @return the value corresponding to the key
  99924. */
  99925. getOrAdd(key: string, val: T): T;
  99926. /**
  99927. * Check if there's a given key in the dictionary
  99928. * @param key the key to check for
  99929. * @return true if the key is present, false otherwise
  99930. */
  99931. contains(key: string): boolean;
  99932. /**
  99933. * Add a new key and its corresponding value
  99934. * @param key the key to add
  99935. * @param value the value corresponding to the key
  99936. * @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
  99937. */
  99938. add(key: string, value: T): boolean;
  99939. /**
  99940. * Update a specific value associated to a key
  99941. * @param key defines the key to use
  99942. * @param value defines the value to store
  99943. * @returns true if the value was updated (or false if the key was not found)
  99944. */
  99945. set(key: string, value: T): boolean;
  99946. /**
  99947. * Get the element of the given key and remove it from the dictionary
  99948. * @param key defines the key to search
  99949. * @returns the value associated with the key or null if not found
  99950. */
  99951. getAndRemove(key: string): Nullable<T>;
  99952. /**
  99953. * Remove a key/value from the dictionary.
  99954. * @param key the key to remove
  99955. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99956. */
  99957. remove(key: string): boolean;
  99958. /**
  99959. * Clear the whole content of the dictionary
  99960. */
  99961. clear(): void;
  99962. /**
  99963. * Gets the current count
  99964. */
  99965. readonly count: number;
  99966. /**
  99967. * Execute a callback on each key/val of the dictionary.
  99968. * Note that you can remove any element in this dictionary in the callback implementation
  99969. * @param callback the callback to execute on a given key/value pair
  99970. */
  99971. forEach(callback: (key: string, val: T) => void): void;
  99972. /**
  99973. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99974. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99975. * Note that you can remove any element in this dictionary in the callback implementation
  99976. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99977. * @returns the first item
  99978. */
  99979. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99980. private _count;
  99981. private _data;
  99982. }
  99983. }
  99984. declare module BABYLON {
  99985. /** @hidden */
  99986. export interface ICollisionCoordinator {
  99987. createCollider(): Collider;
  99988. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99989. init(scene: Scene): void;
  99990. }
  99991. /** @hidden */
  99992. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99993. private _scene;
  99994. private _scaledPosition;
  99995. private _scaledVelocity;
  99996. private _finalPosition;
  99997. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99998. createCollider(): Collider;
  99999. init(scene: Scene): void;
  100000. private _collideWithWorld;
  100001. }
  100002. }
  100003. declare module BABYLON {
  100004. /**
  100005. * Class used to manage all inputs for the scene.
  100006. */
  100007. export class InputManager {
  100008. /** The distance in pixel that you have to move to prevent some events */
  100009. static DragMovementThreshold: number;
  100010. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100011. static LongPressDelay: number;
  100012. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100013. static DoubleClickDelay: number;
  100014. /** If you need to check double click without raising a single click at first click, enable this flag */
  100015. static ExclusiveDoubleClickMode: boolean;
  100016. private _wheelEventName;
  100017. private _onPointerMove;
  100018. private _onPointerDown;
  100019. private _onPointerUp;
  100020. private _initClickEvent;
  100021. private _initActionManager;
  100022. private _delayedSimpleClick;
  100023. private _delayedSimpleClickTimeout;
  100024. private _previousDelayedSimpleClickTimeout;
  100025. private _meshPickProceed;
  100026. private _previousButtonPressed;
  100027. private _currentPickResult;
  100028. private _previousPickResult;
  100029. private _totalPointersPressed;
  100030. private _doubleClickOccured;
  100031. private _pointerOverMesh;
  100032. private _pickedDownMesh;
  100033. private _pickedUpMesh;
  100034. private _pointerX;
  100035. private _pointerY;
  100036. private _unTranslatedPointerX;
  100037. private _unTranslatedPointerY;
  100038. private _startingPointerPosition;
  100039. private _previousStartingPointerPosition;
  100040. private _startingPointerTime;
  100041. private _previousStartingPointerTime;
  100042. private _pointerCaptures;
  100043. private _onKeyDown;
  100044. private _onKeyUp;
  100045. private _onCanvasFocusObserver;
  100046. private _onCanvasBlurObserver;
  100047. private _scene;
  100048. /**
  100049. * Creates a new InputManager
  100050. * @param scene defines the hosting scene
  100051. */
  100052. constructor(scene: Scene);
  100053. /**
  100054. * Gets the mesh that is currently under the pointer
  100055. */
  100056. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100057. /**
  100058. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100059. */
  100060. readonly unTranslatedPointer: Vector2;
  100061. /**
  100062. * Gets or sets the current on-screen X position of the pointer
  100063. */
  100064. pointerX: number;
  100065. /**
  100066. * Gets or sets the current on-screen Y position of the pointer
  100067. */
  100068. pointerY: number;
  100069. private _updatePointerPosition;
  100070. private _processPointerMove;
  100071. private _setRayOnPointerInfo;
  100072. private _checkPrePointerObservable;
  100073. /**
  100074. * Use this method to simulate a pointer move on a mesh
  100075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100078. */
  100079. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100080. /**
  100081. * Use this method to simulate a pointer down on a mesh
  100082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100085. */
  100086. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100087. private _processPointerDown;
  100088. /** @hidden */
  100089. _isPointerSwiping(): boolean;
  100090. /**
  100091. * Use this method to simulate a pointer up on a mesh
  100092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100095. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100096. */
  100097. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100098. private _processPointerUp;
  100099. /**
  100100. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100101. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100102. * @returns true if the pointer was captured
  100103. */
  100104. isPointerCaptured(pointerId?: number): boolean;
  100105. /**
  100106. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100107. * @param attachUp defines if you want to attach events to pointerup
  100108. * @param attachDown defines if you want to attach events to pointerdown
  100109. * @param attachMove defines if you want to attach events to pointermove
  100110. */
  100111. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100112. /**
  100113. * Detaches all event handlers
  100114. */
  100115. detachControl(): void;
  100116. /**
  100117. * Force the value of meshUnderPointer
  100118. * @param mesh defines the mesh to use
  100119. */
  100120. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100121. /**
  100122. * Gets the mesh under the pointer
  100123. * @returns a Mesh or null if no mesh is under the pointer
  100124. */
  100125. getPointerOverMesh(): Nullable<AbstractMesh>;
  100126. }
  100127. }
  100128. declare module BABYLON {
  100129. /**
  100130. * Helper class used to generate session unique ID
  100131. */
  100132. export class UniqueIdGenerator {
  100133. private static _UniqueIdCounter;
  100134. /**
  100135. * Gets an unique (relatively to the current scene) Id
  100136. */
  100137. static readonly UniqueId: number;
  100138. }
  100139. }
  100140. declare module BABYLON {
  100141. /**
  100142. * This class defines the direct association between an animation and a target
  100143. */
  100144. export class TargetedAnimation {
  100145. /**
  100146. * Animation to perform
  100147. */
  100148. animation: Animation;
  100149. /**
  100150. * Target to animate
  100151. */
  100152. target: any;
  100153. /**
  100154. * Serialize the object
  100155. * @returns the JSON object representing the current entity
  100156. */
  100157. serialize(): any;
  100158. }
  100159. /**
  100160. * Use this class to create coordinated animations on multiple targets
  100161. */
  100162. export class AnimationGroup implements IDisposable {
  100163. /** The name of the animation group */
  100164. name: string;
  100165. private _scene;
  100166. private _targetedAnimations;
  100167. private _animatables;
  100168. private _from;
  100169. private _to;
  100170. private _isStarted;
  100171. private _isPaused;
  100172. private _speedRatio;
  100173. private _loopAnimation;
  100174. /**
  100175. * Gets or sets the unique id of the node
  100176. */
  100177. uniqueId: number;
  100178. /**
  100179. * This observable will notify when one animation have ended
  100180. */
  100181. onAnimationEndObservable: Observable<TargetedAnimation>;
  100182. /**
  100183. * Observer raised when one animation loops
  100184. */
  100185. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100186. /**
  100187. * This observable will notify when all animations have ended.
  100188. */
  100189. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100190. /**
  100191. * This observable will notify when all animations have paused.
  100192. */
  100193. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100194. /**
  100195. * This observable will notify when all animations are playing.
  100196. */
  100197. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100198. /**
  100199. * Gets the first frame
  100200. */
  100201. readonly from: number;
  100202. /**
  100203. * Gets the last frame
  100204. */
  100205. readonly to: number;
  100206. /**
  100207. * Define if the animations are started
  100208. */
  100209. readonly isStarted: boolean;
  100210. /**
  100211. * Gets a value indicating that the current group is playing
  100212. */
  100213. readonly isPlaying: boolean;
  100214. /**
  100215. * Gets or sets the speed ratio to use for all animations
  100216. */
  100217. /**
  100218. * Gets or sets the speed ratio to use for all animations
  100219. */
  100220. speedRatio: number;
  100221. /**
  100222. * Gets or sets if all animations should loop or not
  100223. */
  100224. loopAnimation: boolean;
  100225. /**
  100226. * Gets the targeted animations for this animation group
  100227. */
  100228. readonly targetedAnimations: Array<TargetedAnimation>;
  100229. /**
  100230. * returning the list of animatables controlled by this animation group.
  100231. */
  100232. readonly animatables: Array<Animatable>;
  100233. /**
  100234. * Instantiates a new Animation Group.
  100235. * This helps managing several animations at once.
  100236. * @see http://doc.babylonjs.com/how_to/group
  100237. * @param name Defines the name of the group
  100238. * @param scene Defines the scene the group belongs to
  100239. */
  100240. constructor(
  100241. /** The name of the animation group */
  100242. name: string, scene?: Nullable<Scene>);
  100243. /**
  100244. * Add an animation (with its target) in the group
  100245. * @param animation defines the animation we want to add
  100246. * @param target defines the target of the animation
  100247. * @returns the TargetedAnimation object
  100248. */
  100249. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100250. /**
  100251. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100252. * It can add constant keys at begin or end
  100253. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100254. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100255. * @returns the animation group
  100256. */
  100257. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100258. /**
  100259. * Start all animations on given targets
  100260. * @param loop defines if animations must loop
  100261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100262. * @param from defines the from key (optional)
  100263. * @param to defines the to key (optional)
  100264. * @returns the current animation group
  100265. */
  100266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100267. /**
  100268. * Pause all animations
  100269. * @returns the animation group
  100270. */
  100271. pause(): AnimationGroup;
  100272. /**
  100273. * Play all animations to initial state
  100274. * This function will start() the animations if they were not started or will restart() them if they were paused
  100275. * @param loop defines if animations must loop
  100276. * @returns the animation group
  100277. */
  100278. play(loop?: boolean): AnimationGroup;
  100279. /**
  100280. * Reset all animations to initial state
  100281. * @returns the animation group
  100282. */
  100283. reset(): AnimationGroup;
  100284. /**
  100285. * Restart animations from key 0
  100286. * @returns the animation group
  100287. */
  100288. restart(): AnimationGroup;
  100289. /**
  100290. * Stop all animations
  100291. * @returns the animation group
  100292. */
  100293. stop(): AnimationGroup;
  100294. /**
  100295. * Set animation weight for all animatables
  100296. * @param weight defines the weight to use
  100297. * @return the animationGroup
  100298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100299. */
  100300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100301. /**
  100302. * Synchronize and normalize all animatables with a source animatable
  100303. * @param root defines the root animatable to synchronize with
  100304. * @return the animationGroup
  100305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100306. */
  100307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100308. /**
  100309. * Goes to a specific frame in this animation group
  100310. * @param frame the frame number to go to
  100311. * @return the animationGroup
  100312. */
  100313. goToFrame(frame: number): AnimationGroup;
  100314. /**
  100315. * Dispose all associated resources
  100316. */
  100317. dispose(): void;
  100318. private _checkAnimationGroupEnded;
  100319. /**
  100320. * Clone the current animation group and returns a copy
  100321. * @param newName defines the name of the new group
  100322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100323. * @returns the new aniamtion group
  100324. */
  100325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100326. /**
  100327. * Serializes the animationGroup to an object
  100328. * @returns Serialized object
  100329. */
  100330. serialize(): any;
  100331. /**
  100332. * Returns a new AnimationGroup object parsed from the source provided.
  100333. * @param parsedAnimationGroup defines the source
  100334. * @param scene defines the scene that will receive the animationGroup
  100335. * @returns a new AnimationGroup
  100336. */
  100337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100338. /**
  100339. * Returns the string "AnimationGroup"
  100340. * @returns "AnimationGroup"
  100341. */
  100342. getClassName(): string;
  100343. /**
  100344. * Creates a detailled string about the object
  100345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100346. * @returns a string representing the object
  100347. */
  100348. toString(fullDetails?: boolean): string;
  100349. }
  100350. }
  100351. declare module BABYLON {
  100352. /**
  100353. * Define an interface for all classes that will hold resources
  100354. */
  100355. export interface IDisposable {
  100356. /**
  100357. * Releases all held resources
  100358. */
  100359. dispose(): void;
  100360. }
  100361. /** Interface defining initialization parameters for Scene class */
  100362. export interface SceneOptions {
  100363. /**
  100364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100365. * It will improve performance when the number of geometries becomes important.
  100366. */
  100367. useGeometryUniqueIdsMap?: boolean;
  100368. /**
  100369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100371. */
  100372. useMaterialMeshMap?: boolean;
  100373. /**
  100374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100376. */
  100377. useClonedMeshhMap?: boolean;
  100378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100379. virtual?: boolean;
  100380. }
  100381. /**
  100382. * Represents a scene to be rendered by the engine.
  100383. * @see http://doc.babylonjs.com/features/scene
  100384. */
  100385. export class Scene extends AbstractScene implements IAnimatable {
  100386. /** The fog is deactivated */
  100387. static readonly FOGMODE_NONE: number;
  100388. /** The fog density is following an exponential function */
  100389. static readonly FOGMODE_EXP: number;
  100390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100391. static readonly FOGMODE_EXP2: number;
  100392. /** The fog density is following a linear function. */
  100393. static readonly FOGMODE_LINEAR: number;
  100394. /**
  100395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100397. */
  100398. static MinDeltaTime: number;
  100399. /**
  100400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100402. */
  100403. static MaxDeltaTime: number;
  100404. /**
  100405. * Factory used to create the default material.
  100406. * @param name The name of the material to create
  100407. * @param scene The scene to create the material for
  100408. * @returns The default material
  100409. */
  100410. static DefaultMaterialFactory(scene: Scene): Material;
  100411. /**
  100412. * Factory used to create the a collision coordinator.
  100413. * @returns The collision coordinator
  100414. */
  100415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100416. /** @hidden */
  100417. _inputManager: InputManager;
  100418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100419. cameraToUseForPointers: Nullable<Camera>;
  100420. /** @hidden */
  100421. readonly _isScene: boolean;
  100422. /**
  100423. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100424. */
  100425. autoClear: boolean;
  100426. /**
  100427. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100428. */
  100429. autoClearDepthAndStencil: boolean;
  100430. /**
  100431. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100432. */
  100433. clearColor: Color4;
  100434. /**
  100435. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100436. */
  100437. ambientColor: Color3;
  100438. /**
  100439. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100440. * It should only be one of the following (if not the default embedded one):
  100441. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100442. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100443. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100444. * The material properties need to be setup according to the type of texture in use.
  100445. */
  100446. environmentBRDFTexture: BaseTexture;
  100447. /** @hidden */
  100448. protected _environmentTexture: Nullable<BaseTexture>;
  100449. /**
  100450. * Texture used in all pbr material as the reflection texture.
  100451. * As in the majority of the scene they are the same (exception for multi room and so on),
  100452. * this is easier to reference from here than from all the materials.
  100453. */
  100454. /**
  100455. * Texture used in all pbr material as the reflection texture.
  100456. * As in the majority of the scene they are the same (exception for multi room and so on),
  100457. * this is easier to set here than in all the materials.
  100458. */
  100459. environmentTexture: Nullable<BaseTexture>;
  100460. /** @hidden */
  100461. protected _environmentIntensity: number;
  100462. /**
  100463. * Intensity of the environment in all pbr material.
  100464. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100465. * As in the majority of the scene they are the same (exception for multi room and so on),
  100466. * this is easier to reference from here than from all the materials.
  100467. */
  100468. /**
  100469. * Intensity of the environment in all pbr material.
  100470. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100471. * As in the majority of the scene they are the same (exception for multi room and so on),
  100472. * this is easier to set here than in all the materials.
  100473. */
  100474. environmentIntensity: number;
  100475. /** @hidden */
  100476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100477. /**
  100478. * Default image processing configuration used either in the rendering
  100479. * Forward main pass or through the imageProcessingPostProcess if present.
  100480. * As in the majority of the scene they are the same (exception for multi camera),
  100481. * this is easier to reference from here than from all the materials and post process.
  100482. *
  100483. * No setter as we it is a shared configuration, you can set the values instead.
  100484. */
  100485. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100486. private _forceWireframe;
  100487. /**
  100488. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100489. */
  100490. forceWireframe: boolean;
  100491. private _forcePointsCloud;
  100492. /**
  100493. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100494. */
  100495. forcePointsCloud: boolean;
  100496. /**
  100497. * Gets or sets the active clipplane 1
  100498. */
  100499. clipPlane: Nullable<Plane>;
  100500. /**
  100501. * Gets or sets the active clipplane 2
  100502. */
  100503. clipPlane2: Nullable<Plane>;
  100504. /**
  100505. * Gets or sets the active clipplane 3
  100506. */
  100507. clipPlane3: Nullable<Plane>;
  100508. /**
  100509. * Gets or sets the active clipplane 4
  100510. */
  100511. clipPlane4: Nullable<Plane>;
  100512. /**
  100513. * Gets or sets a boolean indicating if animations are enabled
  100514. */
  100515. animationsEnabled: boolean;
  100516. private _animationPropertiesOverride;
  100517. /**
  100518. * Gets or sets the animation properties override
  100519. */
  100520. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100521. /**
  100522. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100523. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100524. */
  100525. useConstantAnimationDeltaTime: boolean;
  100526. /**
  100527. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100528. * Please note that it requires to run a ray cast through the scene on every frame
  100529. */
  100530. constantlyUpdateMeshUnderPointer: boolean;
  100531. /**
  100532. * Defines the HTML cursor to use when hovering over interactive elements
  100533. */
  100534. hoverCursor: string;
  100535. /**
  100536. * Defines the HTML default cursor to use (empty by default)
  100537. */
  100538. defaultCursor: string;
  100539. /**
  100540. * Defines wether cursors are handled by the scene.
  100541. */
  100542. doNotHandleCursors: boolean;
  100543. /**
  100544. * This is used to call preventDefault() on pointer down
  100545. * in order to block unwanted artifacts like system double clicks
  100546. */
  100547. preventDefaultOnPointerDown: boolean;
  100548. /**
  100549. * This is used to call preventDefault() on pointer up
  100550. * in order to block unwanted artifacts like system double clicks
  100551. */
  100552. preventDefaultOnPointerUp: boolean;
  100553. /**
  100554. * Gets or sets user defined metadata
  100555. */
  100556. metadata: any;
  100557. /**
  100558. * For internal use only. Please do not use.
  100559. */
  100560. reservedDataStore: any;
  100561. /**
  100562. * Gets the name of the plugin used to load this scene (null by default)
  100563. */
  100564. loadingPluginName: string;
  100565. /**
  100566. * Use this array to add regular expressions used to disable offline support for specific urls
  100567. */
  100568. disableOfflineSupportExceptionRules: RegExp[];
  100569. /**
  100570. * An event triggered when the scene is disposed.
  100571. */
  100572. onDisposeObservable: Observable<Scene>;
  100573. private _onDisposeObserver;
  100574. /** Sets a function to be executed when this scene is disposed. */
  100575. onDispose: () => void;
  100576. /**
  100577. * An event triggered before rendering the scene (right after animations and physics)
  100578. */
  100579. onBeforeRenderObservable: Observable<Scene>;
  100580. private _onBeforeRenderObserver;
  100581. /** Sets a function to be executed before rendering this scene */
  100582. beforeRender: Nullable<() => void>;
  100583. /**
  100584. * An event triggered after rendering the scene
  100585. */
  100586. onAfterRenderObservable: Observable<Scene>;
  100587. /**
  100588. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100589. */
  100590. onAfterRenderCameraObservable: Observable<Camera>;
  100591. private _onAfterRenderObserver;
  100592. /** Sets a function to be executed after rendering this scene */
  100593. afterRender: Nullable<() => void>;
  100594. /**
  100595. * An event triggered before animating the scene
  100596. */
  100597. onBeforeAnimationsObservable: Observable<Scene>;
  100598. /**
  100599. * An event triggered after animations processing
  100600. */
  100601. onAfterAnimationsObservable: Observable<Scene>;
  100602. /**
  100603. * An event triggered before draw calls are ready to be sent
  100604. */
  100605. onBeforeDrawPhaseObservable: Observable<Scene>;
  100606. /**
  100607. * An event triggered after draw calls have been sent
  100608. */
  100609. onAfterDrawPhaseObservable: Observable<Scene>;
  100610. /**
  100611. * An event triggered when the scene is ready
  100612. */
  100613. onReadyObservable: Observable<Scene>;
  100614. /**
  100615. * An event triggered before rendering a camera
  100616. */
  100617. onBeforeCameraRenderObservable: Observable<Camera>;
  100618. private _onBeforeCameraRenderObserver;
  100619. /** Sets a function to be executed before rendering a camera*/
  100620. beforeCameraRender: () => void;
  100621. /**
  100622. * An event triggered after rendering a camera
  100623. */
  100624. onAfterCameraRenderObservable: Observable<Camera>;
  100625. private _onAfterCameraRenderObserver;
  100626. /** Sets a function to be executed after rendering a camera*/
  100627. afterCameraRender: () => void;
  100628. /**
  100629. * An event triggered when active meshes evaluation is about to start
  100630. */
  100631. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100632. /**
  100633. * An event triggered when active meshes evaluation is done
  100634. */
  100635. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100636. /**
  100637. * An event triggered when particles rendering is about to start
  100638. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100639. */
  100640. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100641. /**
  100642. * An event triggered when particles rendering is done
  100643. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100644. */
  100645. onAfterParticlesRenderingObservable: Observable<Scene>;
  100646. /**
  100647. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100648. */
  100649. onDataLoadedObservable: Observable<Scene>;
  100650. /**
  100651. * An event triggered when a camera is created
  100652. */
  100653. onNewCameraAddedObservable: Observable<Camera>;
  100654. /**
  100655. * An event triggered when a camera is removed
  100656. */
  100657. onCameraRemovedObservable: Observable<Camera>;
  100658. /**
  100659. * An event triggered when a light is created
  100660. */
  100661. onNewLightAddedObservable: Observable<Light>;
  100662. /**
  100663. * An event triggered when a light is removed
  100664. */
  100665. onLightRemovedObservable: Observable<Light>;
  100666. /**
  100667. * An event triggered when a geometry is created
  100668. */
  100669. onNewGeometryAddedObservable: Observable<Geometry>;
  100670. /**
  100671. * An event triggered when a geometry is removed
  100672. */
  100673. onGeometryRemovedObservable: Observable<Geometry>;
  100674. /**
  100675. * An event triggered when a transform node is created
  100676. */
  100677. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100678. /**
  100679. * An event triggered when a transform node is removed
  100680. */
  100681. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100682. /**
  100683. * An event triggered when a mesh is created
  100684. */
  100685. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100686. /**
  100687. * An event triggered when a mesh is removed
  100688. */
  100689. onMeshRemovedObservable: Observable<AbstractMesh>;
  100690. /**
  100691. * An event triggered when a skeleton is created
  100692. */
  100693. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100694. /**
  100695. * An event triggered when a skeleton is removed
  100696. */
  100697. onSkeletonRemovedObservable: Observable<Skeleton>;
  100698. /**
  100699. * An event triggered when a material is created
  100700. */
  100701. onNewMaterialAddedObservable: Observable<Material>;
  100702. /**
  100703. * An event triggered when a material is removed
  100704. */
  100705. onMaterialRemovedObservable: Observable<Material>;
  100706. /**
  100707. * An event triggered when a texture is created
  100708. */
  100709. onNewTextureAddedObservable: Observable<BaseTexture>;
  100710. /**
  100711. * An event triggered when a texture is removed
  100712. */
  100713. onTextureRemovedObservable: Observable<BaseTexture>;
  100714. /**
  100715. * An event triggered when render targets are about to be rendered
  100716. * Can happen multiple times per frame.
  100717. */
  100718. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100719. /**
  100720. * An event triggered when render targets were rendered.
  100721. * Can happen multiple times per frame.
  100722. */
  100723. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100724. /**
  100725. * An event triggered before calculating deterministic simulation step
  100726. */
  100727. onBeforeStepObservable: Observable<Scene>;
  100728. /**
  100729. * An event triggered after calculating deterministic simulation step
  100730. */
  100731. onAfterStepObservable: Observable<Scene>;
  100732. /**
  100733. * An event triggered when the activeCamera property is updated
  100734. */
  100735. onActiveCameraChanged: Observable<Scene>;
  100736. /**
  100737. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100738. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100739. * 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)
  100740. */
  100741. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100742. /**
  100743. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100744. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100745. * 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)
  100746. */
  100747. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100748. /**
  100749. * This Observable will when a mesh has been imported into the scene.
  100750. */
  100751. onMeshImportedObservable: Observable<AbstractMesh>;
  100752. /**
  100753. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100754. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100755. */
  100756. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100757. /** @hidden */
  100758. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100759. /**
  100760. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100761. */
  100762. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100763. /**
  100764. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100765. */
  100766. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100767. /**
  100768. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100769. */
  100770. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100771. /** Callback called when a pointer move is detected */
  100772. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100773. /** Callback called when a pointer down is detected */
  100774. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100775. /** Callback called when a pointer up is detected */
  100776. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100777. /** Callback called when a pointer pick is detected */
  100778. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100779. /**
  100780. * 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).
  100781. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100782. */
  100783. onPrePointerObservable: Observable<PointerInfoPre>;
  100784. /**
  100785. * Observable event triggered each time an input event is received from the rendering canvas
  100786. */
  100787. onPointerObservable: Observable<PointerInfo>;
  100788. /**
  100789. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100790. */
  100791. readonly unTranslatedPointer: Vector2;
  100792. /**
  100793. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100794. */
  100795. static DragMovementThreshold: number;
  100796. /**
  100797. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100798. */
  100799. static LongPressDelay: number;
  100800. /**
  100801. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100802. */
  100803. static DoubleClickDelay: number;
  100804. /** If you need to check double click without raising a single click at first click, enable this flag */
  100805. static ExclusiveDoubleClickMode: boolean;
  100806. /** @hidden */
  100807. _mirroredCameraPosition: Nullable<Vector3>;
  100808. /**
  100809. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100810. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100811. */
  100812. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100813. /**
  100814. * Observable event triggered each time an keyboard event is received from the hosting window
  100815. */
  100816. onKeyboardObservable: Observable<KeyboardInfo>;
  100817. private _useRightHandedSystem;
  100818. /**
  100819. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100820. */
  100821. useRightHandedSystem: boolean;
  100822. private _timeAccumulator;
  100823. private _currentStepId;
  100824. private _currentInternalStep;
  100825. /**
  100826. * Sets the step Id used by deterministic lock step
  100827. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100828. * @param newStepId defines the step Id
  100829. */
  100830. setStepId(newStepId: number): void;
  100831. /**
  100832. * Gets the step Id used by deterministic lock step
  100833. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100834. * @returns the step Id
  100835. */
  100836. getStepId(): number;
  100837. /**
  100838. * Gets the internal step used by deterministic lock step
  100839. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100840. * @returns the internal step
  100841. */
  100842. getInternalStep(): number;
  100843. private _fogEnabled;
  100844. /**
  100845. * Gets or sets a boolean indicating if fog is enabled on this scene
  100846. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100847. * (Default is true)
  100848. */
  100849. fogEnabled: boolean;
  100850. private _fogMode;
  100851. /**
  100852. * Gets or sets the fog mode to use
  100853. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100854. * | mode | value |
  100855. * | --- | --- |
  100856. * | FOGMODE_NONE | 0 |
  100857. * | FOGMODE_EXP | 1 |
  100858. * | FOGMODE_EXP2 | 2 |
  100859. * | FOGMODE_LINEAR | 3 |
  100860. */
  100861. fogMode: number;
  100862. /**
  100863. * Gets or sets the fog color to use
  100864. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100865. * (Default is Color3(0.2, 0.2, 0.3))
  100866. */
  100867. fogColor: Color3;
  100868. /**
  100869. * Gets or sets the fog density to use
  100870. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100871. * (Default is 0.1)
  100872. */
  100873. fogDensity: number;
  100874. /**
  100875. * Gets or sets the fog start distance to use
  100876. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100877. * (Default is 0)
  100878. */
  100879. fogStart: number;
  100880. /**
  100881. * Gets or sets the fog end distance to use
  100882. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100883. * (Default is 1000)
  100884. */
  100885. fogEnd: number;
  100886. private _shadowsEnabled;
  100887. /**
  100888. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100889. */
  100890. shadowsEnabled: boolean;
  100891. private _lightsEnabled;
  100892. /**
  100893. * Gets or sets a boolean indicating if lights are enabled on this scene
  100894. */
  100895. lightsEnabled: boolean;
  100896. /** All of the active cameras added to this scene. */
  100897. activeCameras: Camera[];
  100898. /** @hidden */
  100899. _activeCamera: Nullable<Camera>;
  100900. /** Gets or sets the current active camera */
  100901. activeCamera: Nullable<Camera>;
  100902. private _defaultMaterial;
  100903. /** The default material used on meshes when no material is affected */
  100904. /** The default material used on meshes when no material is affected */
  100905. defaultMaterial: Material;
  100906. private _texturesEnabled;
  100907. /**
  100908. * Gets or sets a boolean indicating if textures are enabled on this scene
  100909. */
  100910. texturesEnabled: boolean;
  100911. /**
  100912. * Gets or sets a boolean indicating if particles are enabled on this scene
  100913. */
  100914. particlesEnabled: boolean;
  100915. /**
  100916. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100917. */
  100918. spritesEnabled: boolean;
  100919. private _skeletonsEnabled;
  100920. /**
  100921. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100922. */
  100923. skeletonsEnabled: boolean;
  100924. /**
  100925. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100926. */
  100927. lensFlaresEnabled: boolean;
  100928. /**
  100929. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100931. */
  100932. collisionsEnabled: boolean;
  100933. private _collisionCoordinator;
  100934. /** @hidden */
  100935. readonly collisionCoordinator: ICollisionCoordinator;
  100936. /**
  100937. * Defines the gravity applied to this scene (used only for collisions)
  100938. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100939. */
  100940. gravity: Vector3;
  100941. /**
  100942. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100943. */
  100944. postProcessesEnabled: boolean;
  100945. /**
  100946. * The list of postprocesses added to the scene
  100947. */
  100948. postProcesses: PostProcess[];
  100949. /**
  100950. * Gets the current postprocess manager
  100951. */
  100952. postProcessManager: PostProcessManager;
  100953. /**
  100954. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100955. */
  100956. renderTargetsEnabled: boolean;
  100957. /**
  100958. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100959. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100960. */
  100961. dumpNextRenderTargets: boolean;
  100962. /**
  100963. * The list of user defined render targets added to the scene
  100964. */
  100965. customRenderTargets: RenderTargetTexture[];
  100966. /**
  100967. * Defines if texture loading must be delayed
  100968. * If true, textures will only be loaded when they need to be rendered
  100969. */
  100970. useDelayedTextureLoading: boolean;
  100971. /**
  100972. * Gets the list of meshes imported to the scene through SceneLoader
  100973. */
  100974. importedMeshesFiles: String[];
  100975. /**
  100976. * Gets or sets a boolean indicating if probes are enabled on this scene
  100977. */
  100978. probesEnabled: boolean;
  100979. /**
  100980. * Gets or sets the current offline provider to use to store scene data
  100981. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100982. */
  100983. offlineProvider: IOfflineProvider;
  100984. /**
  100985. * Gets or sets the action manager associated with the scene
  100986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100987. */
  100988. actionManager: AbstractActionManager;
  100989. private _meshesForIntersections;
  100990. /**
  100991. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100992. */
  100993. proceduralTexturesEnabled: boolean;
  100994. private _engine;
  100995. private _totalVertices;
  100996. /** @hidden */
  100997. _activeIndices: PerfCounter;
  100998. /** @hidden */
  100999. _activeParticles: PerfCounter;
  101000. /** @hidden */
  101001. _activeBones: PerfCounter;
  101002. private _animationRatio;
  101003. /** @hidden */
  101004. _animationTimeLast: number;
  101005. /** @hidden */
  101006. _animationTime: number;
  101007. /**
  101008. * Gets or sets a general scale for animation speed
  101009. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101010. */
  101011. animationTimeScale: number;
  101012. /** @hidden */
  101013. _cachedMaterial: Nullable<Material>;
  101014. /** @hidden */
  101015. _cachedEffect: Nullable<Effect>;
  101016. /** @hidden */
  101017. _cachedVisibility: Nullable<number>;
  101018. private _renderId;
  101019. private _frameId;
  101020. private _executeWhenReadyTimeoutId;
  101021. private _intermediateRendering;
  101022. private _viewUpdateFlag;
  101023. private _projectionUpdateFlag;
  101024. /** @hidden */
  101025. _toBeDisposed: Nullable<IDisposable>[];
  101026. private _activeRequests;
  101027. /** @hidden */
  101028. _pendingData: any[];
  101029. private _isDisposed;
  101030. /**
  101031. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101032. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101033. */
  101034. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101035. private _activeMeshes;
  101036. private _processedMaterials;
  101037. private _renderTargets;
  101038. /** @hidden */
  101039. _activeParticleSystems: SmartArray<IParticleSystem>;
  101040. private _activeSkeletons;
  101041. private _softwareSkinnedMeshes;
  101042. private _renderingManager;
  101043. /** @hidden */
  101044. _activeAnimatables: Animatable[];
  101045. private _transformMatrix;
  101046. private _sceneUbo;
  101047. /** @hidden */
  101048. _viewMatrix: Matrix;
  101049. private _projectionMatrix;
  101050. /** @hidden */
  101051. _forcedViewPosition: Nullable<Vector3>;
  101052. /** @hidden */
  101053. _frustumPlanes: Plane[];
  101054. /**
  101055. * Gets the list of frustum planes (built from the active camera)
  101056. */
  101057. readonly frustumPlanes: Plane[];
  101058. /**
  101059. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101060. * This is useful if there are more lights that the maximum simulteanous authorized
  101061. */
  101062. requireLightSorting: boolean;
  101063. /** @hidden */
  101064. readonly useMaterialMeshMap: boolean;
  101065. /** @hidden */
  101066. readonly useClonedMeshhMap: boolean;
  101067. private _externalData;
  101068. private _uid;
  101069. /**
  101070. * @hidden
  101071. * Backing store of defined scene components.
  101072. */
  101073. _components: ISceneComponent[];
  101074. /**
  101075. * @hidden
  101076. * Backing store of defined scene components.
  101077. */
  101078. _serializableComponents: ISceneSerializableComponent[];
  101079. /**
  101080. * List of components to register on the next registration step.
  101081. */
  101082. private _transientComponents;
  101083. /**
  101084. * Registers the transient components if needed.
  101085. */
  101086. private _registerTransientComponents;
  101087. /**
  101088. * @hidden
  101089. * Add a component to the scene.
  101090. * Note that the ccomponent could be registered on th next frame if this is called after
  101091. * the register component stage.
  101092. * @param component Defines the component to add to the scene
  101093. */
  101094. _addComponent(component: ISceneComponent): void;
  101095. /**
  101096. * @hidden
  101097. * Gets a component from the scene.
  101098. * @param name defines the name of the component to retrieve
  101099. * @returns the component or null if not present
  101100. */
  101101. _getComponent(name: string): Nullable<ISceneComponent>;
  101102. /**
  101103. * @hidden
  101104. * Defines the actions happening before camera updates.
  101105. */
  101106. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101107. /**
  101108. * @hidden
  101109. * Defines the actions happening before clear the canvas.
  101110. */
  101111. _beforeClearStage: Stage<SimpleStageAction>;
  101112. /**
  101113. * @hidden
  101114. * Defines the actions when collecting render targets for the frame.
  101115. */
  101116. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101117. /**
  101118. * @hidden
  101119. * Defines the actions happening for one camera in the frame.
  101120. */
  101121. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101122. /**
  101123. * @hidden
  101124. * Defines the actions happening during the per mesh ready checks.
  101125. */
  101126. _isReadyForMeshStage: Stage<MeshStageAction>;
  101127. /**
  101128. * @hidden
  101129. * Defines the actions happening before evaluate active mesh checks.
  101130. */
  101131. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101132. /**
  101133. * @hidden
  101134. * Defines the actions happening during the evaluate sub mesh checks.
  101135. */
  101136. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101137. /**
  101138. * @hidden
  101139. * Defines the actions happening during the active mesh stage.
  101140. */
  101141. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101142. /**
  101143. * @hidden
  101144. * Defines the actions happening during the per camera render target step.
  101145. */
  101146. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101147. /**
  101148. * @hidden
  101149. * Defines the actions happening just before the active camera is drawing.
  101150. */
  101151. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101152. /**
  101153. * @hidden
  101154. * Defines the actions happening just before a render target is drawing.
  101155. */
  101156. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101157. /**
  101158. * @hidden
  101159. * Defines the actions happening just before a rendering group is drawing.
  101160. */
  101161. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101162. /**
  101163. * @hidden
  101164. * Defines the actions happening just before a mesh is drawing.
  101165. */
  101166. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101167. /**
  101168. * @hidden
  101169. * Defines the actions happening just after a mesh has been drawn.
  101170. */
  101171. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101172. /**
  101173. * @hidden
  101174. * Defines the actions happening just after a rendering group has been drawn.
  101175. */
  101176. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101177. /**
  101178. * @hidden
  101179. * Defines the actions happening just after the active camera has been drawn.
  101180. */
  101181. _afterCameraDrawStage: Stage<CameraStageAction>;
  101182. /**
  101183. * @hidden
  101184. * Defines the actions happening just after a render target has been drawn.
  101185. */
  101186. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101187. /**
  101188. * @hidden
  101189. * Defines the actions happening just after rendering all cameras and computing intersections.
  101190. */
  101191. _afterRenderStage: Stage<SimpleStageAction>;
  101192. /**
  101193. * @hidden
  101194. * Defines the actions happening when a pointer move event happens.
  101195. */
  101196. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101197. /**
  101198. * @hidden
  101199. * Defines the actions happening when a pointer down event happens.
  101200. */
  101201. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101202. /**
  101203. * @hidden
  101204. * Defines the actions happening when a pointer up event happens.
  101205. */
  101206. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101207. /**
  101208. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101209. */
  101210. private geometriesByUniqueId;
  101211. /**
  101212. * Creates a new Scene
  101213. * @param engine defines the engine to use to render this scene
  101214. * @param options defines the scene options
  101215. */
  101216. constructor(engine: Engine, options?: SceneOptions);
  101217. /**
  101218. * Gets a string idenfifying the name of the class
  101219. * @returns "Scene" string
  101220. */
  101221. getClassName(): string;
  101222. private _defaultMeshCandidates;
  101223. /**
  101224. * @hidden
  101225. */
  101226. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101227. private _defaultSubMeshCandidates;
  101228. /**
  101229. * @hidden
  101230. */
  101231. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101232. /**
  101233. * Sets the default candidate providers for the scene.
  101234. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101235. * and getCollidingSubMeshCandidates to their default function
  101236. */
  101237. setDefaultCandidateProviders(): void;
  101238. /**
  101239. * Gets the mesh that is currently under the pointer
  101240. */
  101241. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101242. /**
  101243. * Gets or sets the current on-screen X position of the pointer
  101244. */
  101245. pointerX: number;
  101246. /**
  101247. * Gets or sets the current on-screen Y position of the pointer
  101248. */
  101249. pointerY: number;
  101250. /**
  101251. * Gets the cached material (ie. the latest rendered one)
  101252. * @returns the cached material
  101253. */
  101254. getCachedMaterial(): Nullable<Material>;
  101255. /**
  101256. * Gets the cached effect (ie. the latest rendered one)
  101257. * @returns the cached effect
  101258. */
  101259. getCachedEffect(): Nullable<Effect>;
  101260. /**
  101261. * Gets the cached visibility state (ie. the latest rendered one)
  101262. * @returns the cached visibility state
  101263. */
  101264. getCachedVisibility(): Nullable<number>;
  101265. /**
  101266. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101267. * @param material defines the current material
  101268. * @param effect defines the current effect
  101269. * @param visibility defines the current visibility state
  101270. * @returns true if one parameter is not cached
  101271. */
  101272. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101273. /**
  101274. * Gets the engine associated with the scene
  101275. * @returns an Engine
  101276. */
  101277. getEngine(): Engine;
  101278. /**
  101279. * Gets the total number of vertices rendered per frame
  101280. * @returns the total number of vertices rendered per frame
  101281. */
  101282. getTotalVertices(): number;
  101283. /**
  101284. * Gets the performance counter for total vertices
  101285. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101286. */
  101287. readonly totalVerticesPerfCounter: PerfCounter;
  101288. /**
  101289. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101290. * @returns the total number of active indices rendered per frame
  101291. */
  101292. getActiveIndices(): number;
  101293. /**
  101294. * Gets the performance counter for active indices
  101295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101296. */
  101297. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101298. /**
  101299. * Gets the total number of active particles rendered per frame
  101300. * @returns the total number of active particles rendered per frame
  101301. */
  101302. getActiveParticles(): number;
  101303. /**
  101304. * Gets the performance counter for active particles
  101305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101306. */
  101307. readonly activeParticlesPerfCounter: PerfCounter;
  101308. /**
  101309. * Gets the total number of active bones rendered per frame
  101310. * @returns the total number of active bones rendered per frame
  101311. */
  101312. getActiveBones(): number;
  101313. /**
  101314. * Gets the performance counter for active bones
  101315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101316. */
  101317. readonly activeBonesPerfCounter: PerfCounter;
  101318. /**
  101319. * Gets the array of active meshes
  101320. * @returns an array of AbstractMesh
  101321. */
  101322. getActiveMeshes(): SmartArray<AbstractMesh>;
  101323. /**
  101324. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101325. * @returns a number
  101326. */
  101327. getAnimationRatio(): number;
  101328. /**
  101329. * Gets an unique Id for the current render phase
  101330. * @returns a number
  101331. */
  101332. getRenderId(): number;
  101333. /**
  101334. * Gets an unique Id for the current frame
  101335. * @returns a number
  101336. */
  101337. getFrameId(): number;
  101338. /** Call this function if you want to manually increment the render Id*/
  101339. incrementRenderId(): void;
  101340. private _createUbo;
  101341. /**
  101342. * Use this method to simulate a pointer move on a mesh
  101343. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101344. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101345. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101346. * @returns the current scene
  101347. */
  101348. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101349. /**
  101350. * Use this method to simulate a pointer down on a mesh
  101351. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101352. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101353. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101354. * @returns the current scene
  101355. */
  101356. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101357. /**
  101358. * Use this method to simulate a pointer up on a mesh
  101359. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101360. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101361. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101362. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101363. * @returns the current scene
  101364. */
  101365. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101366. /**
  101367. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101368. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101369. * @returns true if the pointer was captured
  101370. */
  101371. isPointerCaptured(pointerId?: number): boolean;
  101372. /**
  101373. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101374. * @param attachUp defines if you want to attach events to pointerup
  101375. * @param attachDown defines if you want to attach events to pointerdown
  101376. * @param attachMove defines if you want to attach events to pointermove
  101377. */
  101378. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101379. /** Detaches all event handlers*/
  101380. detachControl(): void;
  101381. /**
  101382. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101383. * Delay loaded resources are not taking in account
  101384. * @return true if all required resources are ready
  101385. */
  101386. isReady(): boolean;
  101387. /** Resets all cached information relative to material (including effect and visibility) */
  101388. resetCachedMaterial(): void;
  101389. /**
  101390. * Registers a function to be called before every frame render
  101391. * @param func defines the function to register
  101392. */
  101393. registerBeforeRender(func: () => void): void;
  101394. /**
  101395. * Unregisters a function called before every frame render
  101396. * @param func defines the function to unregister
  101397. */
  101398. unregisterBeforeRender(func: () => void): void;
  101399. /**
  101400. * Registers a function to be called after every frame render
  101401. * @param func defines the function to register
  101402. */
  101403. registerAfterRender(func: () => void): void;
  101404. /**
  101405. * Unregisters a function called after every frame render
  101406. * @param func defines the function to unregister
  101407. */
  101408. unregisterAfterRender(func: () => void): void;
  101409. private _executeOnceBeforeRender;
  101410. /**
  101411. * The provided function will run before render once and will be disposed afterwards.
  101412. * A timeout delay can be provided so that the function will be executed in N ms.
  101413. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101414. * @param func The function to be executed.
  101415. * @param timeout optional delay in ms
  101416. */
  101417. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101418. /** @hidden */
  101419. _addPendingData(data: any): void;
  101420. /** @hidden */
  101421. _removePendingData(data: any): void;
  101422. /**
  101423. * Returns the number of items waiting to be loaded
  101424. * @returns the number of items waiting to be loaded
  101425. */
  101426. getWaitingItemsCount(): number;
  101427. /**
  101428. * Returns a boolean indicating if the scene is still loading data
  101429. */
  101430. readonly isLoading: boolean;
  101431. /**
  101432. * Registers a function to be executed when the scene is ready
  101433. * @param {Function} func - the function to be executed
  101434. */
  101435. executeWhenReady(func: () => void): void;
  101436. /**
  101437. * Returns a promise that resolves when the scene is ready
  101438. * @returns A promise that resolves when the scene is ready
  101439. */
  101440. whenReadyAsync(): Promise<void>;
  101441. /** @hidden */
  101442. _checkIsReady(): void;
  101443. /**
  101444. * Gets all animatable attached to the scene
  101445. */
  101446. readonly animatables: Animatable[];
  101447. /**
  101448. * Resets the last animation time frame.
  101449. * Useful to override when animations start running when loading a scene for the first time.
  101450. */
  101451. resetLastAnimationTimeFrame(): void;
  101452. /**
  101453. * Gets the current view matrix
  101454. * @returns a Matrix
  101455. */
  101456. getViewMatrix(): Matrix;
  101457. /**
  101458. * Gets the current projection matrix
  101459. * @returns a Matrix
  101460. */
  101461. getProjectionMatrix(): Matrix;
  101462. /**
  101463. * Gets the current transform matrix
  101464. * @returns a Matrix made of View * Projection
  101465. */
  101466. getTransformMatrix(): Matrix;
  101467. /**
  101468. * Sets the current transform matrix
  101469. * @param viewL defines the View matrix to use
  101470. * @param projectionL defines the Projection matrix to use
  101471. * @param viewR defines the right View matrix to use (if provided)
  101472. * @param projectionR defines the right Projection matrix to use (if provided)
  101473. */
  101474. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101475. /**
  101476. * Gets the uniform buffer used to store scene data
  101477. * @returns a UniformBuffer
  101478. */
  101479. getSceneUniformBuffer(): UniformBuffer;
  101480. /**
  101481. * Gets an unique (relatively to the current scene) Id
  101482. * @returns an unique number for the scene
  101483. */
  101484. getUniqueId(): number;
  101485. /**
  101486. * Add a mesh to the list of scene's meshes
  101487. * @param newMesh defines the mesh to add
  101488. * @param recursive if all child meshes should also be added to the scene
  101489. */
  101490. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101491. /**
  101492. * Remove a mesh for the list of scene's meshes
  101493. * @param toRemove defines the mesh to remove
  101494. * @param recursive if all child meshes should also be removed from the scene
  101495. * @returns the index where the mesh was in the mesh list
  101496. */
  101497. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101498. /**
  101499. * Add a transform node to the list of scene's transform nodes
  101500. * @param newTransformNode defines the transform node to add
  101501. */
  101502. addTransformNode(newTransformNode: TransformNode): void;
  101503. /**
  101504. * Remove a transform node for the list of scene's transform nodes
  101505. * @param toRemove defines the transform node to remove
  101506. * @returns the index where the transform node was in the transform node list
  101507. */
  101508. removeTransformNode(toRemove: TransformNode): number;
  101509. /**
  101510. * Remove a skeleton for the list of scene's skeletons
  101511. * @param toRemove defines the skeleton to remove
  101512. * @returns the index where the skeleton was in the skeleton list
  101513. */
  101514. removeSkeleton(toRemove: Skeleton): number;
  101515. /**
  101516. * Remove a morph target for the list of scene's morph targets
  101517. * @param toRemove defines the morph target to remove
  101518. * @returns the index where the morph target was in the morph target list
  101519. */
  101520. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101521. /**
  101522. * Remove a light for the list of scene's lights
  101523. * @param toRemove defines the light to remove
  101524. * @returns the index where the light was in the light list
  101525. */
  101526. removeLight(toRemove: Light): number;
  101527. /**
  101528. * Remove a camera for the list of scene's cameras
  101529. * @param toRemove defines the camera to remove
  101530. * @returns the index where the camera was in the camera list
  101531. */
  101532. removeCamera(toRemove: Camera): number;
  101533. /**
  101534. * Remove a particle system for the list of scene's particle systems
  101535. * @param toRemove defines the particle system to remove
  101536. * @returns the index where the particle system was in the particle system list
  101537. */
  101538. removeParticleSystem(toRemove: IParticleSystem): number;
  101539. /**
  101540. * Remove a animation for the list of scene's animations
  101541. * @param toRemove defines the animation to remove
  101542. * @returns the index where the animation was in the animation list
  101543. */
  101544. removeAnimation(toRemove: Animation): number;
  101545. /**
  101546. * Will stop the animation of the given target
  101547. * @param target - the target
  101548. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101549. * @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)
  101550. */
  101551. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101552. /**
  101553. * Removes the given animation group from this scene.
  101554. * @param toRemove The animation group to remove
  101555. * @returns The index of the removed animation group
  101556. */
  101557. removeAnimationGroup(toRemove: AnimationGroup): number;
  101558. /**
  101559. * Removes the given multi-material from this scene.
  101560. * @param toRemove The multi-material to remove
  101561. * @returns The index of the removed multi-material
  101562. */
  101563. removeMultiMaterial(toRemove: MultiMaterial): number;
  101564. /**
  101565. * Removes the given material from this scene.
  101566. * @param toRemove The material to remove
  101567. * @returns The index of the removed material
  101568. */
  101569. removeMaterial(toRemove: Material): number;
  101570. /**
  101571. * Removes the given action manager from this scene.
  101572. * @param toRemove The action manager to remove
  101573. * @returns The index of the removed action manager
  101574. */
  101575. removeActionManager(toRemove: AbstractActionManager): number;
  101576. /**
  101577. * Removes the given texture from this scene.
  101578. * @param toRemove The texture to remove
  101579. * @returns The index of the removed texture
  101580. */
  101581. removeTexture(toRemove: BaseTexture): number;
  101582. /**
  101583. * Adds the given light to this scene
  101584. * @param newLight The light to add
  101585. */
  101586. addLight(newLight: Light): void;
  101587. /**
  101588. * Sorts the list list based on light priorities
  101589. */
  101590. sortLightsByPriority(): void;
  101591. /**
  101592. * Adds the given camera to this scene
  101593. * @param newCamera The camera to add
  101594. */
  101595. addCamera(newCamera: Camera): void;
  101596. /**
  101597. * Adds the given skeleton to this scene
  101598. * @param newSkeleton The skeleton to add
  101599. */
  101600. addSkeleton(newSkeleton: Skeleton): void;
  101601. /**
  101602. * Adds the given particle system to this scene
  101603. * @param newParticleSystem The particle system to add
  101604. */
  101605. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101606. /**
  101607. * Adds the given animation to this scene
  101608. * @param newAnimation The animation to add
  101609. */
  101610. addAnimation(newAnimation: Animation): void;
  101611. /**
  101612. * Adds the given animation group to this scene.
  101613. * @param newAnimationGroup The animation group to add
  101614. */
  101615. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101616. /**
  101617. * Adds the given multi-material to this scene
  101618. * @param newMultiMaterial The multi-material to add
  101619. */
  101620. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101621. /**
  101622. * Adds the given material to this scene
  101623. * @param newMaterial The material to add
  101624. */
  101625. addMaterial(newMaterial: Material): void;
  101626. /**
  101627. * Adds the given morph target to this scene
  101628. * @param newMorphTargetManager The morph target to add
  101629. */
  101630. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101631. /**
  101632. * Adds the given geometry to this scene
  101633. * @param newGeometry The geometry to add
  101634. */
  101635. addGeometry(newGeometry: Geometry): void;
  101636. /**
  101637. * Adds the given action manager to this scene
  101638. * @param newActionManager The action manager to add
  101639. */
  101640. addActionManager(newActionManager: AbstractActionManager): void;
  101641. /**
  101642. * Adds the given texture to this scene.
  101643. * @param newTexture The texture to add
  101644. */
  101645. addTexture(newTexture: BaseTexture): void;
  101646. /**
  101647. * Switch active camera
  101648. * @param newCamera defines the new active camera
  101649. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101650. */
  101651. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101652. /**
  101653. * sets the active camera of the scene using its ID
  101654. * @param id defines the camera's ID
  101655. * @return the new active camera or null if none found.
  101656. */
  101657. setActiveCameraByID(id: string): Nullable<Camera>;
  101658. /**
  101659. * sets the active camera of the scene using its name
  101660. * @param name defines the camera's name
  101661. * @returns the new active camera or null if none found.
  101662. */
  101663. setActiveCameraByName(name: string): Nullable<Camera>;
  101664. /**
  101665. * get an animation group using its name
  101666. * @param name defines the material's name
  101667. * @return the animation group or null if none found.
  101668. */
  101669. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101670. /**
  101671. * Get a material using its unique id
  101672. * @param uniqueId defines the material's unique id
  101673. * @return the material or null if none found.
  101674. */
  101675. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101676. /**
  101677. * get a material using its id
  101678. * @param id defines the material's ID
  101679. * @return the material or null if none found.
  101680. */
  101681. getMaterialByID(id: string): Nullable<Material>;
  101682. /**
  101683. * Gets a the last added material using a given id
  101684. * @param id defines the material's ID
  101685. * @return the last material with the given id or null if none found.
  101686. */
  101687. getLastMaterialByID(id: string): Nullable<Material>;
  101688. /**
  101689. * Gets a material using its name
  101690. * @param name defines the material's name
  101691. * @return the material or null if none found.
  101692. */
  101693. getMaterialByName(name: string): Nullable<Material>;
  101694. /**
  101695. * Get a texture using its unique id
  101696. * @param uniqueId defines the texture's unique id
  101697. * @return the texture or null if none found.
  101698. */
  101699. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101700. /**
  101701. * Gets a camera using its id
  101702. * @param id defines the id to look for
  101703. * @returns the camera or null if not found
  101704. */
  101705. getCameraByID(id: string): Nullable<Camera>;
  101706. /**
  101707. * Gets a camera using its unique id
  101708. * @param uniqueId defines the unique id to look for
  101709. * @returns the camera or null if not found
  101710. */
  101711. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101712. /**
  101713. * Gets a camera using its name
  101714. * @param name defines the camera's name
  101715. * @return the camera or null if none found.
  101716. */
  101717. getCameraByName(name: string): Nullable<Camera>;
  101718. /**
  101719. * Gets a bone using its id
  101720. * @param id defines the bone's id
  101721. * @return the bone or null if not found
  101722. */
  101723. getBoneByID(id: string): Nullable<Bone>;
  101724. /**
  101725. * Gets a bone using its id
  101726. * @param name defines the bone's name
  101727. * @return the bone or null if not found
  101728. */
  101729. getBoneByName(name: string): Nullable<Bone>;
  101730. /**
  101731. * Gets a light node using its name
  101732. * @param name defines the the light's name
  101733. * @return the light or null if none found.
  101734. */
  101735. getLightByName(name: string): Nullable<Light>;
  101736. /**
  101737. * Gets a light node using its id
  101738. * @param id defines the light's id
  101739. * @return the light or null if none found.
  101740. */
  101741. getLightByID(id: string): Nullable<Light>;
  101742. /**
  101743. * Gets a light node using its scene-generated unique ID
  101744. * @param uniqueId defines the light's unique id
  101745. * @return the light or null if none found.
  101746. */
  101747. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101748. /**
  101749. * Gets a particle system by id
  101750. * @param id defines the particle system id
  101751. * @return the corresponding system or null if none found
  101752. */
  101753. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101754. /**
  101755. * Gets a geometry using its ID
  101756. * @param id defines the geometry's id
  101757. * @return the geometry or null if none found.
  101758. */
  101759. getGeometryByID(id: string): Nullable<Geometry>;
  101760. private _getGeometryByUniqueID;
  101761. /**
  101762. * Add a new geometry to this scene
  101763. * @param geometry defines the geometry to be added to the scene.
  101764. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101765. * @return a boolean defining if the geometry was added or not
  101766. */
  101767. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101768. /**
  101769. * Removes an existing geometry
  101770. * @param geometry defines the geometry to be removed from the scene
  101771. * @return a boolean defining if the geometry was removed or not
  101772. */
  101773. removeGeometry(geometry: Geometry): boolean;
  101774. /**
  101775. * Gets the list of geometries attached to the scene
  101776. * @returns an array of Geometry
  101777. */
  101778. getGeometries(): Geometry[];
  101779. /**
  101780. * Gets the first added mesh found of a given ID
  101781. * @param id defines the id to search for
  101782. * @return the mesh found or null if not found at all
  101783. */
  101784. getMeshByID(id: string): Nullable<AbstractMesh>;
  101785. /**
  101786. * Gets a list of meshes using their id
  101787. * @param id defines the id to search for
  101788. * @returns a list of meshes
  101789. */
  101790. getMeshesByID(id: string): Array<AbstractMesh>;
  101791. /**
  101792. * Gets the first added transform node found of a given ID
  101793. * @param id defines the id to search for
  101794. * @return the found transform node or null if not found at all.
  101795. */
  101796. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101797. /**
  101798. * Gets a transform node with its auto-generated unique id
  101799. * @param uniqueId efines the unique id to search for
  101800. * @return the found transform node or null if not found at all.
  101801. */
  101802. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101803. /**
  101804. * Gets a list of transform nodes using their id
  101805. * @param id defines the id to search for
  101806. * @returns a list of transform nodes
  101807. */
  101808. getTransformNodesByID(id: string): Array<TransformNode>;
  101809. /**
  101810. * Gets a mesh with its auto-generated unique id
  101811. * @param uniqueId defines the unique id to search for
  101812. * @return the found mesh or null if not found at all.
  101813. */
  101814. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101815. /**
  101816. * Gets a the last added mesh using a given id
  101817. * @param id defines the id to search for
  101818. * @return the found mesh or null if not found at all.
  101819. */
  101820. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101821. /**
  101822. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101823. * @param id defines the id to search for
  101824. * @return the found node or null if not found at all
  101825. */
  101826. getLastEntryByID(id: string): Nullable<Node>;
  101827. /**
  101828. * Gets a node (Mesh, Camera, Light) using a given id
  101829. * @param id defines the id to search for
  101830. * @return the found node or null if not found at all
  101831. */
  101832. getNodeByID(id: string): Nullable<Node>;
  101833. /**
  101834. * Gets a node (Mesh, Camera, Light) using a given name
  101835. * @param name defines the name to search for
  101836. * @return the found node or null if not found at all.
  101837. */
  101838. getNodeByName(name: string): Nullable<Node>;
  101839. /**
  101840. * Gets a mesh using a given name
  101841. * @param name defines the name to search for
  101842. * @return the found mesh or null if not found at all.
  101843. */
  101844. getMeshByName(name: string): Nullable<AbstractMesh>;
  101845. /**
  101846. * Gets a transform node using a given name
  101847. * @param name defines the name to search for
  101848. * @return the found transform node or null if not found at all.
  101849. */
  101850. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101851. /**
  101852. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101853. * @param id defines the id to search for
  101854. * @return the found skeleton or null if not found at all.
  101855. */
  101856. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101857. /**
  101858. * Gets a skeleton using a given auto generated unique id
  101859. * @param uniqueId defines the unique id to search for
  101860. * @return the found skeleton or null if not found at all.
  101861. */
  101862. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101863. /**
  101864. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101865. * @param id defines the id to search for
  101866. * @return the found skeleton or null if not found at all.
  101867. */
  101868. getSkeletonById(id: string): Nullable<Skeleton>;
  101869. /**
  101870. * Gets a skeleton using a given name
  101871. * @param name defines the name to search for
  101872. * @return the found skeleton or null if not found at all.
  101873. */
  101874. getSkeletonByName(name: string): Nullable<Skeleton>;
  101875. /**
  101876. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101877. * @param id defines the id to search for
  101878. * @return the found morph target manager or null if not found at all.
  101879. */
  101880. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101881. /**
  101882. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101883. * @param id defines the id to search for
  101884. * @return the found morph target or null if not found at all.
  101885. */
  101886. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101887. /**
  101888. * Gets a boolean indicating if the given mesh is active
  101889. * @param mesh defines the mesh to look for
  101890. * @returns true if the mesh is in the active list
  101891. */
  101892. isActiveMesh(mesh: AbstractMesh): boolean;
  101893. /**
  101894. * Return a unique id as a string which can serve as an identifier for the scene
  101895. */
  101896. readonly uid: string;
  101897. /**
  101898. * Add an externaly attached data from its key.
  101899. * This method call will fail and return false, if such key already exists.
  101900. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101901. * @param key the unique key that identifies the data
  101902. * @param data the data object to associate to the key for this Engine instance
  101903. * @return true if no such key were already present and the data was added successfully, false otherwise
  101904. */
  101905. addExternalData<T>(key: string, data: T): boolean;
  101906. /**
  101907. * Get an externaly attached data from its key
  101908. * @param key the unique key that identifies the data
  101909. * @return the associated data, if present (can be null), or undefined if not present
  101910. */
  101911. getExternalData<T>(key: string): Nullable<T>;
  101912. /**
  101913. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101914. * @param key the unique key that identifies the data
  101915. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101916. * @return the associated data, can be null if the factory returned null.
  101917. */
  101918. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101919. /**
  101920. * Remove an externaly attached data from the Engine instance
  101921. * @param key the unique key that identifies the data
  101922. * @return true if the data was successfully removed, false if it doesn't exist
  101923. */
  101924. removeExternalData(key: string): boolean;
  101925. private _evaluateSubMesh;
  101926. /**
  101927. * Clear the processed materials smart array preventing retention point in material dispose.
  101928. */
  101929. freeProcessedMaterials(): void;
  101930. private _preventFreeActiveMeshesAndRenderingGroups;
  101931. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101932. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101933. * when disposing several meshes in a row or a hierarchy of meshes.
  101934. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101935. */
  101936. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101937. /**
  101938. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101939. */
  101940. freeActiveMeshes(): void;
  101941. /**
  101942. * Clear the info related to rendering groups preventing retention points during dispose.
  101943. */
  101944. freeRenderingGroups(): void;
  101945. /** @hidden */
  101946. _isInIntermediateRendering(): boolean;
  101947. /**
  101948. * Lambda returning the list of potentially active meshes.
  101949. */
  101950. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101951. /**
  101952. * Lambda returning the list of potentially active sub meshes.
  101953. */
  101954. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101955. /**
  101956. * Lambda returning the list of potentially intersecting sub meshes.
  101957. */
  101958. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101959. /**
  101960. * Lambda returning the list of potentially colliding sub meshes.
  101961. */
  101962. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101963. private _activeMeshesFrozen;
  101964. /**
  101965. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101966. * @returns the current scene
  101967. */
  101968. freezeActiveMeshes(): Scene;
  101969. /**
  101970. * Use this function to restart evaluating active meshes on every frame
  101971. * @returns the current scene
  101972. */
  101973. unfreezeActiveMeshes(): Scene;
  101974. private _evaluateActiveMeshes;
  101975. private _activeMesh;
  101976. /**
  101977. * Update the transform matrix to update from the current active camera
  101978. * @param force defines a boolean used to force the update even if cache is up to date
  101979. */
  101980. updateTransformMatrix(force?: boolean): void;
  101981. private _bindFrameBuffer;
  101982. /** @hidden */
  101983. _allowPostProcessClearColor: boolean;
  101984. /** @hidden */
  101985. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101986. private _processSubCameras;
  101987. private _checkIntersections;
  101988. /** @hidden */
  101989. _advancePhysicsEngineStep(step: number): void;
  101990. /**
  101991. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101992. */
  101993. getDeterministicFrameTime: () => number;
  101994. /** @hidden */
  101995. _animate(): void;
  101996. /** Execute all animations (for a frame) */
  101997. animate(): void;
  101998. /**
  101999. * Render the scene
  102000. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102001. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102002. */
  102003. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102004. /**
  102005. * Freeze all materials
  102006. * A frozen material will not be updatable but should be faster to render
  102007. */
  102008. freezeMaterials(): void;
  102009. /**
  102010. * Unfreeze all materials
  102011. * A frozen material will not be updatable but should be faster to render
  102012. */
  102013. unfreezeMaterials(): void;
  102014. /**
  102015. * Releases all held ressources
  102016. */
  102017. dispose(): void;
  102018. /**
  102019. * Gets if the scene is already disposed
  102020. */
  102021. readonly isDisposed: boolean;
  102022. /**
  102023. * Call this function to reduce memory footprint of the scene.
  102024. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102025. */
  102026. clearCachedVertexData(): void;
  102027. /**
  102028. * This function will remove the local cached buffer data from texture.
  102029. * It will save memory but will prevent the texture from being rebuilt
  102030. */
  102031. cleanCachedTextureBuffer(): void;
  102032. /**
  102033. * Get the world extend vectors with an optional filter
  102034. *
  102035. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102036. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102037. */
  102038. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102039. min: Vector3;
  102040. max: Vector3;
  102041. };
  102042. /**
  102043. * Creates a ray that can be used to pick in the scene
  102044. * @param x defines the x coordinate of the origin (on-screen)
  102045. * @param y defines the y coordinate of the origin (on-screen)
  102046. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102047. * @param camera defines the camera to use for the picking
  102048. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102049. * @returns a Ray
  102050. */
  102051. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102052. /**
  102053. * Creates a ray that can be used to pick in the scene
  102054. * @param x defines the x coordinate of the origin (on-screen)
  102055. * @param y defines the y coordinate of the origin (on-screen)
  102056. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102057. * @param result defines the ray where to store the picking ray
  102058. * @param camera defines the camera to use for the picking
  102059. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102060. * @returns the current scene
  102061. */
  102062. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102063. /**
  102064. * Creates a ray that can be used to pick in the scene
  102065. * @param x defines the x coordinate of the origin (on-screen)
  102066. * @param y defines the y coordinate of the origin (on-screen)
  102067. * @param camera defines the camera to use for the picking
  102068. * @returns a Ray
  102069. */
  102070. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102071. /**
  102072. * Creates a ray that can be used to pick in the scene
  102073. * @param x defines the x coordinate of the origin (on-screen)
  102074. * @param y defines the y coordinate of the origin (on-screen)
  102075. * @param result defines the ray where to store the picking ray
  102076. * @param camera defines the camera to use for the picking
  102077. * @returns the current scene
  102078. */
  102079. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102080. /** Launch a ray to try to pick a mesh in the scene
  102081. * @param x position on screen
  102082. * @param y position on screen
  102083. * @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
  102084. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102085. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102086. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102087. * @returns a PickingInfo
  102088. */
  102089. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102090. /** Use the given ray to pick a mesh in the scene
  102091. * @param ray The ray to use to pick meshes
  102092. * @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
  102093. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102095. * @returns a PickingInfo
  102096. */
  102097. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102098. /**
  102099. * Launch a ray to try to pick a mesh in the scene
  102100. * @param x X position on screen
  102101. * @param y Y position on screen
  102102. * @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
  102103. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102104. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102105. * @returns an array of PickingInfo
  102106. */
  102107. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102108. /**
  102109. * Launch a ray to try to pick a mesh in the scene
  102110. * @param ray Ray to use
  102111. * @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
  102112. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102113. * @returns an array of PickingInfo
  102114. */
  102115. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102116. /**
  102117. * Force the value of meshUnderPointer
  102118. * @param mesh defines the mesh to use
  102119. */
  102120. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102121. /**
  102122. * Gets the mesh under the pointer
  102123. * @returns a Mesh or null if no mesh is under the pointer
  102124. */
  102125. getPointerOverMesh(): Nullable<AbstractMesh>;
  102126. /** @hidden */
  102127. _rebuildGeometries(): void;
  102128. /** @hidden */
  102129. _rebuildTextures(): void;
  102130. private _getByTags;
  102131. /**
  102132. * Get a list of meshes by tags
  102133. * @param tagsQuery defines the tags query to use
  102134. * @param forEach defines a predicate used to filter results
  102135. * @returns an array of Mesh
  102136. */
  102137. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102138. /**
  102139. * Get a list of cameras by tags
  102140. * @param tagsQuery defines the tags query to use
  102141. * @param forEach defines a predicate used to filter results
  102142. * @returns an array of Camera
  102143. */
  102144. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102145. /**
  102146. * Get a list of lights by tags
  102147. * @param tagsQuery defines the tags query to use
  102148. * @param forEach defines a predicate used to filter results
  102149. * @returns an array of Light
  102150. */
  102151. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102152. /**
  102153. * Get a list of materials by tags
  102154. * @param tagsQuery defines the tags query to use
  102155. * @param forEach defines a predicate used to filter results
  102156. * @returns an array of Material
  102157. */
  102158. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102159. /**
  102160. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102161. * This allowed control for front to back rendering or reversly depending of the special needs.
  102162. *
  102163. * @param renderingGroupId The rendering group id corresponding to its index
  102164. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102165. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102166. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102167. */
  102168. 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;
  102169. /**
  102170. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102171. *
  102172. * @param renderingGroupId The rendering group id corresponding to its index
  102173. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102174. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102175. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102176. */
  102177. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102178. /**
  102179. * Gets the current auto clear configuration for one rendering group of the rendering
  102180. * manager.
  102181. * @param index the rendering group index to get the information for
  102182. * @returns The auto clear setup for the requested rendering group
  102183. */
  102184. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102185. private _blockMaterialDirtyMechanism;
  102186. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102187. blockMaterialDirtyMechanism: boolean;
  102188. /**
  102189. * Will flag all materials as dirty to trigger new shader compilation
  102190. * @param flag defines the flag used to specify which material part must be marked as dirty
  102191. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102192. */
  102193. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102194. /** @hidden */
  102195. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  102196. /** @hidden */
  102197. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102198. }
  102199. }
  102200. declare module BABYLON {
  102201. /**
  102202. * Set of assets to keep when moving a scene into an asset container.
  102203. */
  102204. export class KeepAssets extends AbstractScene {
  102205. }
  102206. /**
  102207. * Container with a set of assets that can be added or removed from a scene.
  102208. */
  102209. export class AssetContainer extends AbstractScene {
  102210. /**
  102211. * The scene the AssetContainer belongs to.
  102212. */
  102213. scene: Scene;
  102214. /**
  102215. * Instantiates an AssetContainer.
  102216. * @param scene The scene the AssetContainer belongs to.
  102217. */
  102218. constructor(scene: Scene);
  102219. /**
  102220. * Adds all the assets from the container to the scene.
  102221. */
  102222. addAllToScene(): void;
  102223. /**
  102224. * Removes all the assets in the container from the scene
  102225. */
  102226. removeAllFromScene(): void;
  102227. /**
  102228. * Disposes all the assets in the container
  102229. */
  102230. dispose(): void;
  102231. private _moveAssets;
  102232. /**
  102233. * Removes all the assets contained in the scene and adds them to the container.
  102234. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102235. */
  102236. moveAllFromScene(keepAssets?: KeepAssets): void;
  102237. /**
  102238. * 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.
  102239. * @returns the root mesh
  102240. */
  102241. createRootMesh(): Mesh;
  102242. }
  102243. }
  102244. declare module BABYLON {
  102245. /**
  102246. * Defines how the parser contract is defined.
  102247. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102248. */
  102249. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102250. /**
  102251. * Defines how the individual parser contract is defined.
  102252. * These parser can parse an individual asset
  102253. */
  102254. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102255. /**
  102256. * Base class of the scene acting as a container for the different elements composing a scene.
  102257. * This class is dynamically extended by the different components of the scene increasing
  102258. * flexibility and reducing coupling
  102259. */
  102260. export abstract class AbstractScene {
  102261. /**
  102262. * Stores the list of available parsers in the application.
  102263. */
  102264. private static _BabylonFileParsers;
  102265. /**
  102266. * Stores the list of available individual parsers in the application.
  102267. */
  102268. private static _IndividualBabylonFileParsers;
  102269. /**
  102270. * Adds a parser in the list of available ones
  102271. * @param name Defines the name of the parser
  102272. * @param parser Defines the parser to add
  102273. */
  102274. static AddParser(name: string, parser: BabylonFileParser): void;
  102275. /**
  102276. * Gets a general parser from the list of avaialble ones
  102277. * @param name Defines the name of the parser
  102278. * @returns the requested parser or null
  102279. */
  102280. static GetParser(name: string): Nullable<BabylonFileParser>;
  102281. /**
  102282. * Adds n individual parser in the list of available ones
  102283. * @param name Defines the name of the parser
  102284. * @param parser Defines the parser to add
  102285. */
  102286. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102287. /**
  102288. * Gets an individual parser from the list of avaialble ones
  102289. * @param name Defines the name of the parser
  102290. * @returns the requested parser or null
  102291. */
  102292. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102293. /**
  102294. * Parser json data and populate both a scene and its associated container object
  102295. * @param jsonData Defines the data to parse
  102296. * @param scene Defines the scene to parse the data for
  102297. * @param container Defines the container attached to the parsing sequence
  102298. * @param rootUrl Defines the root url of the data
  102299. */
  102300. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102301. /**
  102302. * Gets the list of root nodes (ie. nodes with no parent)
  102303. */
  102304. rootNodes: Node[];
  102305. /** All of the cameras added to this scene
  102306. * @see http://doc.babylonjs.com/babylon101/cameras
  102307. */
  102308. cameras: Camera[];
  102309. /**
  102310. * All of the lights added to this scene
  102311. * @see http://doc.babylonjs.com/babylon101/lights
  102312. */
  102313. lights: Light[];
  102314. /**
  102315. * All of the (abstract) meshes added to this scene
  102316. */
  102317. meshes: AbstractMesh[];
  102318. /**
  102319. * The list of skeletons added to the scene
  102320. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102321. */
  102322. skeletons: Skeleton[];
  102323. /**
  102324. * All of the particle systems added to this scene
  102325. * @see http://doc.babylonjs.com/babylon101/particles
  102326. */
  102327. particleSystems: IParticleSystem[];
  102328. /**
  102329. * Gets a list of Animations associated with the scene
  102330. */
  102331. animations: Animation[];
  102332. /**
  102333. * All of the animation groups added to this scene
  102334. * @see http://doc.babylonjs.com/how_to/group
  102335. */
  102336. animationGroups: AnimationGroup[];
  102337. /**
  102338. * All of the multi-materials added to this scene
  102339. * @see http://doc.babylonjs.com/how_to/multi_materials
  102340. */
  102341. multiMaterials: MultiMaterial[];
  102342. /**
  102343. * All of the materials added to this scene
  102344. * In the context of a Scene, it is not supposed to be modified manually.
  102345. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102346. * Note also that the order of the Material wihin the array is not significant and might change.
  102347. * @see http://doc.babylonjs.com/babylon101/materials
  102348. */
  102349. materials: Material[];
  102350. /**
  102351. * The list of morph target managers added to the scene
  102352. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102353. */
  102354. morphTargetManagers: MorphTargetManager[];
  102355. /**
  102356. * The list of geometries used in the scene.
  102357. */
  102358. geometries: Geometry[];
  102359. /**
  102360. * All of the tranform nodes added to this scene
  102361. * In the context of a Scene, it is not supposed to be modified manually.
  102362. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102363. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102364. * @see http://doc.babylonjs.com/how_to/transformnode
  102365. */
  102366. transformNodes: TransformNode[];
  102367. /**
  102368. * ActionManagers available on the scene.
  102369. */
  102370. actionManagers: AbstractActionManager[];
  102371. /**
  102372. * Textures to keep.
  102373. */
  102374. textures: BaseTexture[];
  102375. /**
  102376. * Environment texture for the scene
  102377. */
  102378. environmentTexture: Nullable<BaseTexture>;
  102379. }
  102380. }
  102381. declare module BABYLON {
  102382. /**
  102383. * Interface used to define options for Sound class
  102384. */
  102385. export interface ISoundOptions {
  102386. /**
  102387. * Does the sound autoplay once loaded.
  102388. */
  102389. autoplay?: boolean;
  102390. /**
  102391. * Does the sound loop after it finishes playing once.
  102392. */
  102393. loop?: boolean;
  102394. /**
  102395. * Sound's volume
  102396. */
  102397. volume?: number;
  102398. /**
  102399. * Is it a spatial sound?
  102400. */
  102401. spatialSound?: boolean;
  102402. /**
  102403. * Maximum distance to hear that sound
  102404. */
  102405. maxDistance?: number;
  102406. /**
  102407. * Uses user defined attenuation function
  102408. */
  102409. useCustomAttenuation?: boolean;
  102410. /**
  102411. * Define the roll off factor of spatial sounds.
  102412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102413. */
  102414. rolloffFactor?: number;
  102415. /**
  102416. * Define the reference distance the sound should be heard perfectly.
  102417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102418. */
  102419. refDistance?: number;
  102420. /**
  102421. * Define the distance attenuation model the sound will follow.
  102422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102423. */
  102424. distanceModel?: string;
  102425. /**
  102426. * Defines the playback speed (1 by default)
  102427. */
  102428. playbackRate?: number;
  102429. /**
  102430. * Defines if the sound is from a streaming source
  102431. */
  102432. streaming?: boolean;
  102433. /**
  102434. * Defines an optional length (in seconds) inside the sound file
  102435. */
  102436. length?: number;
  102437. /**
  102438. * Defines an optional offset (in seconds) inside the sound file
  102439. */
  102440. offset?: number;
  102441. /**
  102442. * If true, URLs will not be required to state the audio file codec to use.
  102443. */
  102444. skipCodecCheck?: boolean;
  102445. }
  102446. /**
  102447. * Defines a sound that can be played in the application.
  102448. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102450. */
  102451. export class Sound {
  102452. /**
  102453. * The name of the sound in the scene.
  102454. */
  102455. name: string;
  102456. /**
  102457. * Does the sound autoplay once loaded.
  102458. */
  102459. autoplay: boolean;
  102460. /**
  102461. * Does the sound loop after it finishes playing once.
  102462. */
  102463. loop: boolean;
  102464. /**
  102465. * Does the sound use a custom attenuation curve to simulate the falloff
  102466. * happening when the source gets further away from the camera.
  102467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102468. */
  102469. useCustomAttenuation: boolean;
  102470. /**
  102471. * The sound track id this sound belongs to.
  102472. */
  102473. soundTrackId: number;
  102474. /**
  102475. * Is this sound currently played.
  102476. */
  102477. isPlaying: boolean;
  102478. /**
  102479. * Is this sound currently paused.
  102480. */
  102481. isPaused: boolean;
  102482. /**
  102483. * Does this sound enables spatial sound.
  102484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102485. */
  102486. spatialSound: boolean;
  102487. /**
  102488. * Define the reference distance the sound should be heard perfectly.
  102489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102490. */
  102491. refDistance: number;
  102492. /**
  102493. * Define the roll off factor of spatial sounds.
  102494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102495. */
  102496. rolloffFactor: number;
  102497. /**
  102498. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102500. */
  102501. maxDistance: number;
  102502. /**
  102503. * Define the distance attenuation model the sound will follow.
  102504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102505. */
  102506. distanceModel: string;
  102507. /**
  102508. * @hidden
  102509. * Back Compat
  102510. **/
  102511. onended: () => any;
  102512. /**
  102513. * Observable event when the current playing sound finishes.
  102514. */
  102515. onEndedObservable: Observable<Sound>;
  102516. private _panningModel;
  102517. private _playbackRate;
  102518. private _streaming;
  102519. private _startTime;
  102520. private _startOffset;
  102521. private _position;
  102522. /** @hidden */
  102523. _positionInEmitterSpace: boolean;
  102524. private _localDirection;
  102525. private _volume;
  102526. private _isReadyToPlay;
  102527. private _isDirectional;
  102528. private _readyToPlayCallback;
  102529. private _audioBuffer;
  102530. private _soundSource;
  102531. private _streamingSource;
  102532. private _soundPanner;
  102533. private _soundGain;
  102534. private _inputAudioNode;
  102535. private _outputAudioNode;
  102536. private _coneInnerAngle;
  102537. private _coneOuterAngle;
  102538. private _coneOuterGain;
  102539. private _scene;
  102540. private _connectedTransformNode;
  102541. private _customAttenuationFunction;
  102542. private _registerFunc;
  102543. private _isOutputConnected;
  102544. private _htmlAudioElement;
  102545. private _urlType;
  102546. private _length?;
  102547. private _offset?;
  102548. /** @hidden */
  102549. static _SceneComponentInitialization: (scene: Scene) => void;
  102550. /**
  102551. * Create a sound and attach it to a scene
  102552. * @param name Name of your sound
  102553. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102554. * @param scene defines the scene the sound belongs to
  102555. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102556. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102557. */
  102558. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102559. /**
  102560. * Release the sound and its associated resources
  102561. */
  102562. dispose(): void;
  102563. /**
  102564. * Gets if the sounds is ready to be played or not.
  102565. * @returns true if ready, otherwise false
  102566. */
  102567. isReady(): boolean;
  102568. private _soundLoaded;
  102569. /**
  102570. * Sets the data of the sound from an audiobuffer
  102571. * @param audioBuffer The audioBuffer containing the data
  102572. */
  102573. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102574. /**
  102575. * Updates the current sounds options such as maxdistance, loop...
  102576. * @param options A JSON object containing values named as the object properties
  102577. */
  102578. updateOptions(options: ISoundOptions): void;
  102579. private _createSpatialParameters;
  102580. private _updateSpatialParameters;
  102581. /**
  102582. * Switch the panning model to HRTF:
  102583. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102585. */
  102586. switchPanningModelToHRTF(): void;
  102587. /**
  102588. * Switch the panning model to Equal Power:
  102589. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102591. */
  102592. switchPanningModelToEqualPower(): void;
  102593. private _switchPanningModel;
  102594. /**
  102595. * Connect this sound to a sound track audio node like gain...
  102596. * @param soundTrackAudioNode the sound track audio node to connect to
  102597. */
  102598. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102599. /**
  102600. * Transform this sound into a directional source
  102601. * @param coneInnerAngle Size of the inner cone in degree
  102602. * @param coneOuterAngle Size of the outer cone in degree
  102603. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102604. */
  102605. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102606. /**
  102607. * Gets or sets the inner angle for the directional cone.
  102608. */
  102609. /**
  102610. * Gets or sets the inner angle for the directional cone.
  102611. */
  102612. directionalConeInnerAngle: number;
  102613. /**
  102614. * Gets or sets the outer angle for the directional cone.
  102615. */
  102616. /**
  102617. * Gets or sets the outer angle for the directional cone.
  102618. */
  102619. directionalConeOuterAngle: number;
  102620. /**
  102621. * Sets the position of the emitter if spatial sound is enabled
  102622. * @param newPosition Defines the new posisiton
  102623. */
  102624. setPosition(newPosition: Vector3): void;
  102625. /**
  102626. * Sets the local direction of the emitter if spatial sound is enabled
  102627. * @param newLocalDirection Defines the new local direction
  102628. */
  102629. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102630. private _updateDirection;
  102631. /** @hidden */
  102632. updateDistanceFromListener(): void;
  102633. /**
  102634. * Sets a new custom attenuation function for the sound.
  102635. * @param callback Defines the function used for the attenuation
  102636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102637. */
  102638. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102639. /**
  102640. * Play the sound
  102641. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102642. * @param offset (optional) Start the sound at a specific time in seconds
  102643. * @param length (optional) Sound duration (in seconds)
  102644. */
  102645. play(time?: number, offset?: number, length?: number): void;
  102646. private _onended;
  102647. /**
  102648. * Stop the sound
  102649. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102650. */
  102651. stop(time?: number): void;
  102652. /**
  102653. * Put the sound in pause
  102654. */
  102655. pause(): void;
  102656. /**
  102657. * Sets a dedicated volume for this sounds
  102658. * @param newVolume Define the new volume of the sound
  102659. * @param time Define time for gradual change to new volume
  102660. */
  102661. setVolume(newVolume: number, time?: number): void;
  102662. /**
  102663. * Set the sound play back rate
  102664. * @param newPlaybackRate Define the playback rate the sound should be played at
  102665. */
  102666. setPlaybackRate(newPlaybackRate: number): void;
  102667. /**
  102668. * Gets the volume of the sound.
  102669. * @returns the volume of the sound
  102670. */
  102671. getVolume(): number;
  102672. /**
  102673. * Attach the sound to a dedicated mesh
  102674. * @param transformNode The transform node to connect the sound with
  102675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102676. */
  102677. attachToMesh(transformNode: TransformNode): void;
  102678. /**
  102679. * Detach the sound from the previously attached mesh
  102680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102681. */
  102682. detachFromMesh(): void;
  102683. private _onRegisterAfterWorldMatrixUpdate;
  102684. /**
  102685. * Clone the current sound in the scene.
  102686. * @returns the new sound clone
  102687. */
  102688. clone(): Nullable<Sound>;
  102689. /**
  102690. * Gets the current underlying audio buffer containing the data
  102691. * @returns the audio buffer
  102692. */
  102693. getAudioBuffer(): Nullable<AudioBuffer>;
  102694. /**
  102695. * Serializes the Sound in a JSON representation
  102696. * @returns the JSON representation of the sound
  102697. */
  102698. serialize(): any;
  102699. /**
  102700. * Parse a JSON representation of a sound to innstantiate in a given scene
  102701. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102702. * @param scene Define the scene the new parsed sound should be created in
  102703. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102704. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102705. * @returns the newly parsed sound
  102706. */
  102707. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * This defines an action helpful to play a defined sound on a triggered action.
  102713. */
  102714. export class PlaySoundAction extends Action {
  102715. private _sound;
  102716. /**
  102717. * Instantiate the action
  102718. * @param triggerOptions defines the trigger options
  102719. * @param sound defines the sound to play
  102720. * @param condition defines the trigger related conditions
  102721. */
  102722. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102723. /** @hidden */
  102724. _prepare(): void;
  102725. /**
  102726. * Execute the action and play the sound.
  102727. */
  102728. execute(): void;
  102729. /**
  102730. * Serializes the actions and its related information.
  102731. * @param parent defines the object to serialize in
  102732. * @returns the serialized object
  102733. */
  102734. serialize(parent: any): any;
  102735. }
  102736. /**
  102737. * This defines an action helpful to stop a defined sound on a triggered action.
  102738. */
  102739. export class StopSoundAction extends Action {
  102740. private _sound;
  102741. /**
  102742. * Instantiate the action
  102743. * @param triggerOptions defines the trigger options
  102744. * @param sound defines the sound to stop
  102745. * @param condition defines the trigger related conditions
  102746. */
  102747. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102748. /** @hidden */
  102749. _prepare(): void;
  102750. /**
  102751. * Execute the action and stop the sound.
  102752. */
  102753. execute(): void;
  102754. /**
  102755. * Serializes the actions and its related information.
  102756. * @param parent defines the object to serialize in
  102757. * @returns the serialized object
  102758. */
  102759. serialize(parent: any): any;
  102760. }
  102761. }
  102762. declare module BABYLON {
  102763. /**
  102764. * This defines an action responsible to change the value of a property
  102765. * by interpolating between its current value and the newly set one once triggered.
  102766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102767. */
  102768. export class InterpolateValueAction extends Action {
  102769. /**
  102770. * Defines the path of the property where the value should be interpolated
  102771. */
  102772. propertyPath: string;
  102773. /**
  102774. * Defines the target value at the end of the interpolation.
  102775. */
  102776. value: any;
  102777. /**
  102778. * Defines the time it will take for the property to interpolate to the value.
  102779. */
  102780. duration: number;
  102781. /**
  102782. * Defines if the other scene animations should be stopped when the action has been triggered
  102783. */
  102784. stopOtherAnimations?: boolean;
  102785. /**
  102786. * Defines a callback raised once the interpolation animation has been done.
  102787. */
  102788. onInterpolationDone?: () => void;
  102789. /**
  102790. * Observable triggered once the interpolation animation has been done.
  102791. */
  102792. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102793. private _target;
  102794. private _effectiveTarget;
  102795. private _property;
  102796. /**
  102797. * Instantiate the action
  102798. * @param triggerOptions defines the trigger options
  102799. * @param target defines the object containing the value to interpolate
  102800. * @param propertyPath defines the path to the property in the target object
  102801. * @param value defines the target value at the end of the interpolation
  102802. * @param duration deines the time it will take for the property to interpolate to the value.
  102803. * @param condition defines the trigger related conditions
  102804. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102805. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102806. */
  102807. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102808. /** @hidden */
  102809. _prepare(): void;
  102810. /**
  102811. * Execute the action starts the value interpolation.
  102812. */
  102813. execute(): void;
  102814. /**
  102815. * Serializes the actions and its related information.
  102816. * @param parent defines the object to serialize in
  102817. * @returns the serialized object
  102818. */
  102819. serialize(parent: any): any;
  102820. }
  102821. }
  102822. declare module BABYLON {
  102823. /**
  102824. * Options allowed during the creation of a sound track.
  102825. */
  102826. export interface ISoundTrackOptions {
  102827. /**
  102828. * The volume the sound track should take during creation
  102829. */
  102830. volume?: number;
  102831. /**
  102832. * Define if the sound track is the main sound track of the scene
  102833. */
  102834. mainTrack?: boolean;
  102835. }
  102836. /**
  102837. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102838. * It will be also used in a future release to apply effects on a specific track.
  102839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102840. */
  102841. export class SoundTrack {
  102842. /**
  102843. * The unique identifier of the sound track in the scene.
  102844. */
  102845. id: number;
  102846. /**
  102847. * The list of sounds included in the sound track.
  102848. */
  102849. soundCollection: Array<Sound>;
  102850. private _outputAudioNode;
  102851. private _scene;
  102852. private _isMainTrack;
  102853. private _connectedAnalyser;
  102854. private _options;
  102855. private _isInitialized;
  102856. /**
  102857. * Creates a new sound track.
  102858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102859. * @param scene Define the scene the sound track belongs to
  102860. * @param options
  102861. */
  102862. constructor(scene: Scene, options?: ISoundTrackOptions);
  102863. private _initializeSoundTrackAudioGraph;
  102864. /**
  102865. * Release the sound track and its associated resources
  102866. */
  102867. dispose(): void;
  102868. /**
  102869. * Adds a sound to this sound track
  102870. * @param sound define the cound to add
  102871. * @ignoreNaming
  102872. */
  102873. AddSound(sound: Sound): void;
  102874. /**
  102875. * Removes a sound to this sound track
  102876. * @param sound define the cound to remove
  102877. * @ignoreNaming
  102878. */
  102879. RemoveSound(sound: Sound): void;
  102880. /**
  102881. * Set a global volume for the full sound track.
  102882. * @param newVolume Define the new volume of the sound track
  102883. */
  102884. setVolume(newVolume: number): void;
  102885. /**
  102886. * Switch the panning model to HRTF:
  102887. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102889. */
  102890. switchPanningModelToHRTF(): void;
  102891. /**
  102892. * Switch the panning model to Equal Power:
  102893. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102895. */
  102896. switchPanningModelToEqualPower(): void;
  102897. /**
  102898. * Connect the sound track to an audio analyser allowing some amazing
  102899. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102901. * @param analyser The analyser to connect to the engine
  102902. */
  102903. connectToAnalyser(analyser: Analyser): void;
  102904. }
  102905. }
  102906. declare module BABYLON {
  102907. interface AbstractScene {
  102908. /**
  102909. * The list of sounds used in the scene.
  102910. */
  102911. sounds: Nullable<Array<Sound>>;
  102912. }
  102913. interface Scene {
  102914. /**
  102915. * @hidden
  102916. * Backing field
  102917. */
  102918. _mainSoundTrack: SoundTrack;
  102919. /**
  102920. * The main sound track played by the scene.
  102921. * It cotains your primary collection of sounds.
  102922. */
  102923. mainSoundTrack: SoundTrack;
  102924. /**
  102925. * The list of sound tracks added to the scene
  102926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102927. */
  102928. soundTracks: Nullable<Array<SoundTrack>>;
  102929. /**
  102930. * Gets a sound using a given name
  102931. * @param name defines the name to search for
  102932. * @return the found sound or null if not found at all.
  102933. */
  102934. getSoundByName(name: string): Nullable<Sound>;
  102935. /**
  102936. * Gets or sets if audio support is enabled
  102937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102938. */
  102939. audioEnabled: boolean;
  102940. /**
  102941. * Gets or sets if audio will be output to headphones
  102942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102943. */
  102944. headphone: boolean;
  102945. /**
  102946. * Gets or sets custom audio listener position provider
  102947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102948. */
  102949. audioListenerPositionProvider: Nullable<() => Vector3>;
  102950. }
  102951. /**
  102952. * Defines the sound scene component responsible to manage any sounds
  102953. * in a given scene.
  102954. */
  102955. export class AudioSceneComponent implements ISceneSerializableComponent {
  102956. /**
  102957. * The component name helpfull to identify the component in the list of scene components.
  102958. */
  102959. readonly name: string;
  102960. /**
  102961. * The scene the component belongs to.
  102962. */
  102963. scene: Scene;
  102964. private _audioEnabled;
  102965. /**
  102966. * Gets whether audio is enabled or not.
  102967. * Please use related enable/disable method to switch state.
  102968. */
  102969. readonly audioEnabled: boolean;
  102970. private _headphone;
  102971. /**
  102972. * Gets whether audio is outputing to headphone or not.
  102973. * Please use the according Switch methods to change output.
  102974. */
  102975. readonly headphone: boolean;
  102976. private _audioListenerPositionProvider;
  102977. /**
  102978. * Gets the current audio listener position provider
  102979. */
  102980. /**
  102981. * Sets a custom listener position for all sounds in the scene
  102982. * By default, this is the position of the first active camera
  102983. */
  102984. audioListenerPositionProvider: Nullable<() => Vector3>;
  102985. /**
  102986. * Creates a new instance of the component for the given scene
  102987. * @param scene Defines the scene to register the component in
  102988. */
  102989. constructor(scene: Scene);
  102990. /**
  102991. * Registers the component in a given scene
  102992. */
  102993. register(): void;
  102994. /**
  102995. * Rebuilds the elements related to this component in case of
  102996. * context lost for instance.
  102997. */
  102998. rebuild(): void;
  102999. /**
  103000. * Serializes the component data to the specified json object
  103001. * @param serializationObject The object to serialize to
  103002. */
  103003. serialize(serializationObject: any): void;
  103004. /**
  103005. * Adds all the elements from the container to the scene
  103006. * @param container the container holding the elements
  103007. */
  103008. addFromContainer(container: AbstractScene): void;
  103009. /**
  103010. * Removes all the elements in the container from the scene
  103011. * @param container contains the elements to remove
  103012. * @param dispose if the removed element should be disposed (default: false)
  103013. */
  103014. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103015. /**
  103016. * Disposes the component and the associated ressources.
  103017. */
  103018. dispose(): void;
  103019. /**
  103020. * Disables audio in the associated scene.
  103021. */
  103022. disableAudio(): void;
  103023. /**
  103024. * Enables audio in the associated scene.
  103025. */
  103026. enableAudio(): void;
  103027. /**
  103028. * Switch audio to headphone output.
  103029. */
  103030. switchAudioModeForHeadphones(): void;
  103031. /**
  103032. * Switch audio to normal speakers.
  103033. */
  103034. switchAudioModeForNormalSpeakers(): void;
  103035. private _afterRender;
  103036. }
  103037. }
  103038. declare module BABYLON {
  103039. /**
  103040. * Wraps one or more Sound objects and selects one with random weight for playback.
  103041. */
  103042. export class WeightedSound {
  103043. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103044. loop: boolean;
  103045. private _coneInnerAngle;
  103046. private _coneOuterAngle;
  103047. private _volume;
  103048. /** A Sound is currently playing. */
  103049. isPlaying: boolean;
  103050. /** A Sound is currently paused. */
  103051. isPaused: boolean;
  103052. private _sounds;
  103053. private _weights;
  103054. private _currentIndex?;
  103055. /**
  103056. * Creates a new WeightedSound from the list of sounds given.
  103057. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103058. * @param sounds Array of Sounds that will be selected from.
  103059. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103060. */
  103061. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103062. /**
  103063. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103064. */
  103065. /**
  103066. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103067. */
  103068. directionalConeInnerAngle: number;
  103069. /**
  103070. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103071. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103072. */
  103073. /**
  103074. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103075. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103076. */
  103077. directionalConeOuterAngle: number;
  103078. /**
  103079. * Playback volume.
  103080. */
  103081. /**
  103082. * Playback volume.
  103083. */
  103084. volume: number;
  103085. private _onended;
  103086. /**
  103087. * Suspend playback
  103088. */
  103089. pause(): void;
  103090. /**
  103091. * Stop playback
  103092. */
  103093. stop(): void;
  103094. /**
  103095. * Start playback.
  103096. * @param startOffset Position the clip head at a specific time in seconds.
  103097. */
  103098. play(startOffset?: number): void;
  103099. }
  103100. }
  103101. declare module BABYLON {
  103102. /**
  103103. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103105. */
  103106. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103107. /**
  103108. * Gets the name of the behavior.
  103109. */
  103110. readonly name: string;
  103111. /**
  103112. * The easing function used by animations
  103113. */
  103114. static EasingFunction: BackEase;
  103115. /**
  103116. * The easing mode used by animations
  103117. */
  103118. static EasingMode: number;
  103119. /**
  103120. * The duration of the animation, in milliseconds
  103121. */
  103122. transitionDuration: number;
  103123. /**
  103124. * Length of the distance animated by the transition when lower radius is reached
  103125. */
  103126. lowerRadiusTransitionRange: number;
  103127. /**
  103128. * Length of the distance animated by the transition when upper radius is reached
  103129. */
  103130. upperRadiusTransitionRange: number;
  103131. private _autoTransitionRange;
  103132. /**
  103133. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103134. */
  103135. /**
  103136. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103137. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103138. */
  103139. autoTransitionRange: boolean;
  103140. private _attachedCamera;
  103141. private _onAfterCheckInputsObserver;
  103142. private _onMeshTargetChangedObserver;
  103143. /**
  103144. * Initializes the behavior.
  103145. */
  103146. init(): void;
  103147. /**
  103148. * Attaches the behavior to its arc rotate camera.
  103149. * @param camera Defines the camera to attach the behavior to
  103150. */
  103151. attach(camera: ArcRotateCamera): void;
  103152. /**
  103153. * Detaches the behavior from its current arc rotate camera.
  103154. */
  103155. detach(): void;
  103156. private _radiusIsAnimating;
  103157. private _radiusBounceTransition;
  103158. private _animatables;
  103159. private _cachedWheelPrecision;
  103160. /**
  103161. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103162. * @param radiusLimit The limit to check against.
  103163. * @return Bool to indicate if at limit.
  103164. */
  103165. private _isRadiusAtLimit;
  103166. /**
  103167. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103168. * @param radiusDelta The delta by which to animate to. Can be negative.
  103169. */
  103170. private _applyBoundRadiusAnimation;
  103171. /**
  103172. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103173. */
  103174. protected _clearAnimationLocks(): void;
  103175. /**
  103176. * Stops and removes all animations that have been applied to the camera
  103177. */
  103178. stopAllAnimations(): void;
  103179. }
  103180. }
  103181. declare module BABYLON {
  103182. /**
  103183. * 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.
  103184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103185. */
  103186. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103187. /**
  103188. * Gets the name of the behavior.
  103189. */
  103190. readonly name: string;
  103191. private _mode;
  103192. private _radiusScale;
  103193. private _positionScale;
  103194. private _defaultElevation;
  103195. private _elevationReturnTime;
  103196. private _elevationReturnWaitTime;
  103197. private _zoomStopsAnimation;
  103198. private _framingTime;
  103199. /**
  103200. * The easing function used by animations
  103201. */
  103202. static EasingFunction: ExponentialEase;
  103203. /**
  103204. * The easing mode used by animations
  103205. */
  103206. static EasingMode: number;
  103207. /**
  103208. * Sets the current mode used by the behavior
  103209. */
  103210. /**
  103211. * Gets current mode used by the behavior.
  103212. */
  103213. mode: number;
  103214. /**
  103215. * Sets the scale applied to the radius (1 by default)
  103216. */
  103217. /**
  103218. * Gets the scale applied to the radius
  103219. */
  103220. radiusScale: number;
  103221. /**
  103222. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103223. */
  103224. /**
  103225. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103226. */
  103227. positionScale: number;
  103228. /**
  103229. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103230. * behaviour is triggered, in radians.
  103231. */
  103232. /**
  103233. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103234. * behaviour is triggered, in radians.
  103235. */
  103236. defaultElevation: number;
  103237. /**
  103238. * Sets the time (in milliseconds) taken to return to the default beta position.
  103239. * Negative value indicates camera should not return to default.
  103240. */
  103241. /**
  103242. * Gets the time (in milliseconds) taken to return to the default beta position.
  103243. * Negative value indicates camera should not return to default.
  103244. */
  103245. elevationReturnTime: number;
  103246. /**
  103247. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103248. */
  103249. /**
  103250. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103251. */
  103252. elevationReturnWaitTime: number;
  103253. /**
  103254. * Sets the flag that indicates if user zooming should stop animation.
  103255. */
  103256. /**
  103257. * Gets the flag that indicates if user zooming should stop animation.
  103258. */
  103259. zoomStopsAnimation: boolean;
  103260. /**
  103261. * Sets the transition time when framing the mesh, in milliseconds
  103262. */
  103263. /**
  103264. * Gets the transition time when framing the mesh, in milliseconds
  103265. */
  103266. framingTime: number;
  103267. /**
  103268. * Define if the behavior should automatically change the configured
  103269. * camera limits and sensibilities.
  103270. */
  103271. autoCorrectCameraLimitsAndSensibility: boolean;
  103272. private _onPrePointerObservableObserver;
  103273. private _onAfterCheckInputsObserver;
  103274. private _onMeshTargetChangedObserver;
  103275. private _attachedCamera;
  103276. private _isPointerDown;
  103277. private _lastInteractionTime;
  103278. /**
  103279. * Initializes the behavior.
  103280. */
  103281. init(): void;
  103282. /**
  103283. * Attaches the behavior to its arc rotate camera.
  103284. * @param camera Defines the camera to attach the behavior to
  103285. */
  103286. attach(camera: ArcRotateCamera): void;
  103287. /**
  103288. * Detaches the behavior from its current arc rotate camera.
  103289. */
  103290. detach(): void;
  103291. private _animatables;
  103292. private _betaIsAnimating;
  103293. private _betaTransition;
  103294. private _radiusTransition;
  103295. private _vectorTransition;
  103296. /**
  103297. * Targets the given mesh and updates zoom level accordingly.
  103298. * @param mesh The mesh to target.
  103299. * @param radius Optional. If a cached radius position already exists, overrides default.
  103300. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103303. */
  103304. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103305. /**
  103306. * Targets the given mesh with its children and updates zoom level accordingly.
  103307. * @param mesh The mesh to target.
  103308. * @param radius Optional. If a cached radius position already exists, overrides default.
  103309. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103310. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103311. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103312. */
  103313. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103314. /**
  103315. * Targets the given meshes with their children and updates zoom level accordingly.
  103316. * @param meshes The mesh to target.
  103317. * @param radius Optional. If a cached radius position already exists, overrides default.
  103318. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103319. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103320. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103321. */
  103322. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103323. /**
  103324. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103325. * @param minimumWorld Determines the smaller position of the bounding box extend
  103326. * @param maximumWorld Determines the bigger position of the bounding box extend
  103327. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103328. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103329. */
  103330. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103331. /**
  103332. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103333. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103334. * frustum width.
  103335. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103336. * to fully enclose the mesh in the viewing frustum.
  103337. */
  103338. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103339. /**
  103340. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103341. * is automatically returned to its default position (expected to be above ground plane).
  103342. */
  103343. private _maintainCameraAboveGround;
  103344. /**
  103345. * Returns the frustum slope based on the canvas ratio and camera FOV
  103346. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103347. */
  103348. private _getFrustumSlope;
  103349. /**
  103350. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103351. */
  103352. private _clearAnimationLocks;
  103353. /**
  103354. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103355. */
  103356. private _applyUserInteraction;
  103357. /**
  103358. * Stops and removes all animations that have been applied to the camera
  103359. */
  103360. stopAllAnimations(): void;
  103361. /**
  103362. * Gets a value indicating if the user is moving the camera
  103363. */
  103364. readonly isUserIsMoving: boolean;
  103365. /**
  103366. * The camera can move all the way towards the mesh.
  103367. */
  103368. static IgnoreBoundsSizeMode: number;
  103369. /**
  103370. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103371. */
  103372. static FitFrustumSidesMode: number;
  103373. }
  103374. }
  103375. declare module BABYLON {
  103376. /**
  103377. * Base class for Camera Pointer Inputs.
  103378. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103379. * for example usage.
  103380. */
  103381. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103382. /**
  103383. * Defines the camera the input is attached to.
  103384. */
  103385. abstract camera: Camera;
  103386. /**
  103387. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103388. */
  103389. protected _altKey: boolean;
  103390. protected _ctrlKey: boolean;
  103391. protected _metaKey: boolean;
  103392. protected _shiftKey: boolean;
  103393. /**
  103394. * Which mouse buttons were pressed at time of last mouse event.
  103395. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103396. */
  103397. protected _buttonsPressed: number;
  103398. /**
  103399. * Defines the buttons associated with the input to handle camera move.
  103400. */
  103401. buttons: number[];
  103402. /**
  103403. * Attach the input controls to a specific dom element to get the input from.
  103404. * @param element Defines the element the controls should be listened from
  103405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103406. */
  103407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103408. /**
  103409. * Detach the current controls from the specified dom element.
  103410. * @param element Defines the element to stop listening the inputs from
  103411. */
  103412. detachControl(element: Nullable<HTMLElement>): void;
  103413. /**
  103414. * Gets the class name of the current input.
  103415. * @returns the class name
  103416. */
  103417. getClassName(): string;
  103418. /**
  103419. * Get the friendly name associated with the input class.
  103420. * @returns the input friendly name
  103421. */
  103422. getSimpleName(): string;
  103423. /**
  103424. * Called on pointer POINTERDOUBLETAP event.
  103425. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103426. */
  103427. protected onDoubleTap(type: string): void;
  103428. /**
  103429. * Called on pointer POINTERMOVE event if only a single touch is active.
  103430. * Override this method to provide functionality.
  103431. */
  103432. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103433. /**
  103434. * Called on pointer POINTERMOVE event if multiple touches are active.
  103435. * Override this method to provide functionality.
  103436. */
  103437. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103438. /**
  103439. * Called on JS contextmenu event.
  103440. * Override this method to provide functionality.
  103441. */
  103442. protected onContextMenu(evt: PointerEvent): void;
  103443. /**
  103444. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103445. * press.
  103446. * Override this method to provide functionality.
  103447. */
  103448. protected onButtonDown(evt: PointerEvent): void;
  103449. /**
  103450. * Called each time a new POINTERUP event occurs. Ie, for each button
  103451. * release.
  103452. * Override this method to provide functionality.
  103453. */
  103454. protected onButtonUp(evt: PointerEvent): void;
  103455. /**
  103456. * Called when window becomes inactive.
  103457. * Override this method to provide functionality.
  103458. */
  103459. protected onLostFocus(): void;
  103460. private _pointerInput;
  103461. private _observer;
  103462. private _onLostFocus;
  103463. private pointA;
  103464. private pointB;
  103465. }
  103466. }
  103467. declare module BABYLON {
  103468. /**
  103469. * Manage the pointers inputs to control an arc rotate camera.
  103470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103471. */
  103472. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103473. /**
  103474. * Defines the camera the input is attached to.
  103475. */
  103476. camera: ArcRotateCamera;
  103477. /**
  103478. * Gets the class name of the current input.
  103479. * @returns the class name
  103480. */
  103481. getClassName(): string;
  103482. /**
  103483. * Defines the buttons associated with the input to handle camera move.
  103484. */
  103485. buttons: number[];
  103486. /**
  103487. * Defines the pointer angular sensibility along the X axis or how fast is
  103488. * the camera rotating.
  103489. */
  103490. angularSensibilityX: number;
  103491. /**
  103492. * Defines the pointer angular sensibility along the Y axis or how fast is
  103493. * the camera rotating.
  103494. */
  103495. angularSensibilityY: number;
  103496. /**
  103497. * Defines the pointer pinch precision or how fast is the camera zooming.
  103498. */
  103499. pinchPrecision: number;
  103500. /**
  103501. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103502. * from 0.
  103503. * It defines the percentage of current camera.radius to use as delta when
  103504. * pinch zoom is used.
  103505. */
  103506. pinchDeltaPercentage: number;
  103507. /**
  103508. * Defines the pointer panning sensibility or how fast is the camera moving.
  103509. */
  103510. panningSensibility: number;
  103511. /**
  103512. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103513. */
  103514. multiTouchPanning: boolean;
  103515. /**
  103516. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103517. * zoom (pinch) through multitouch.
  103518. */
  103519. multiTouchPanAndZoom: boolean;
  103520. /**
  103521. * Revers pinch action direction.
  103522. */
  103523. pinchInwards: boolean;
  103524. private _isPanClick;
  103525. private _twoFingerActivityCount;
  103526. private _isPinching;
  103527. /**
  103528. * Called on pointer POINTERMOVE event if only a single touch is active.
  103529. */
  103530. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103531. /**
  103532. * Called on pointer POINTERDOUBLETAP event.
  103533. */
  103534. protected onDoubleTap(type: string): void;
  103535. /**
  103536. * Called on pointer POINTERMOVE event if multiple touches are active.
  103537. */
  103538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103539. /**
  103540. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103541. * press.
  103542. */
  103543. protected onButtonDown(evt: PointerEvent): void;
  103544. /**
  103545. * Called each time a new POINTERUP event occurs. Ie, for each button
  103546. * release.
  103547. */
  103548. protected onButtonUp(evt: PointerEvent): void;
  103549. /**
  103550. * Called when window becomes inactive.
  103551. */
  103552. protected onLostFocus(): void;
  103553. }
  103554. }
  103555. declare module BABYLON {
  103556. /**
  103557. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103559. */
  103560. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103561. /**
  103562. * Defines the camera the input is attached to.
  103563. */
  103564. camera: ArcRotateCamera;
  103565. /**
  103566. * Defines the list of key codes associated with the up action (increase alpha)
  103567. */
  103568. keysUp: number[];
  103569. /**
  103570. * Defines the list of key codes associated with the down action (decrease alpha)
  103571. */
  103572. keysDown: number[];
  103573. /**
  103574. * Defines the list of key codes associated with the left action (increase beta)
  103575. */
  103576. keysLeft: number[];
  103577. /**
  103578. * Defines the list of key codes associated with the right action (decrease beta)
  103579. */
  103580. keysRight: number[];
  103581. /**
  103582. * Defines the list of key codes associated with the reset action.
  103583. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103584. */
  103585. keysReset: number[];
  103586. /**
  103587. * Defines the panning sensibility of the inputs.
  103588. * (How fast is the camera paning)
  103589. */
  103590. panningSensibility: number;
  103591. /**
  103592. * Defines the zooming sensibility of the inputs.
  103593. * (How fast is the camera zooming)
  103594. */
  103595. zoomingSensibility: number;
  103596. /**
  103597. * Defines wether maintaining the alt key down switch the movement mode from
  103598. * orientation to zoom.
  103599. */
  103600. useAltToZoom: boolean;
  103601. /**
  103602. * Rotation speed of the camera
  103603. */
  103604. angularSpeed: number;
  103605. private _keys;
  103606. private _ctrlPressed;
  103607. private _altPressed;
  103608. private _onCanvasBlurObserver;
  103609. private _onKeyboardObserver;
  103610. private _engine;
  103611. private _scene;
  103612. /**
  103613. * Attach the input controls to a specific dom element to get the input from.
  103614. * @param element Defines the element the controls should be listened from
  103615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103616. */
  103617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103618. /**
  103619. * Detach the current controls from the specified dom element.
  103620. * @param element Defines the element to stop listening the inputs from
  103621. */
  103622. detachControl(element: Nullable<HTMLElement>): void;
  103623. /**
  103624. * Update the current camera state depending on the inputs that have been used this frame.
  103625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103626. */
  103627. checkInputs(): void;
  103628. /**
  103629. * Gets the class name of the current intput.
  103630. * @returns the class name
  103631. */
  103632. getClassName(): string;
  103633. /**
  103634. * Get the friendly name associated with the input class.
  103635. * @returns the input friendly name
  103636. */
  103637. getSimpleName(): string;
  103638. }
  103639. }
  103640. declare module BABYLON {
  103641. /**
  103642. * Manage the mouse wheel inputs to control an arc rotate camera.
  103643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103644. */
  103645. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103646. /**
  103647. * Defines the camera the input is attached to.
  103648. */
  103649. camera: ArcRotateCamera;
  103650. /**
  103651. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103652. */
  103653. wheelPrecision: number;
  103654. /**
  103655. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103656. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103657. */
  103658. wheelDeltaPercentage: number;
  103659. private _wheel;
  103660. private _observer;
  103661. private computeDeltaFromMouseWheelLegacyEvent;
  103662. /**
  103663. * Attach the input controls to a specific dom element to get the input from.
  103664. * @param element Defines the element the controls should be listened from
  103665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103666. */
  103667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103668. /**
  103669. * Detach the current controls from the specified dom element.
  103670. * @param element Defines the element to stop listening the inputs from
  103671. */
  103672. detachControl(element: Nullable<HTMLElement>): void;
  103673. /**
  103674. * Gets the class name of the current intput.
  103675. * @returns the class name
  103676. */
  103677. getClassName(): string;
  103678. /**
  103679. * Get the friendly name associated with the input class.
  103680. * @returns the input friendly name
  103681. */
  103682. getSimpleName(): string;
  103683. }
  103684. }
  103685. declare module BABYLON {
  103686. /**
  103687. * Default Inputs manager for the ArcRotateCamera.
  103688. * It groups all the default supported inputs for ease of use.
  103689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103690. */
  103691. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103692. /**
  103693. * Instantiates a new ArcRotateCameraInputsManager.
  103694. * @param camera Defines the camera the inputs belong to
  103695. */
  103696. constructor(camera: ArcRotateCamera);
  103697. /**
  103698. * Add mouse wheel input support to the input manager.
  103699. * @returns the current input manager
  103700. */
  103701. addMouseWheel(): ArcRotateCameraInputsManager;
  103702. /**
  103703. * Add pointers input support to the input manager.
  103704. * @returns the current input manager
  103705. */
  103706. addPointers(): ArcRotateCameraInputsManager;
  103707. /**
  103708. * Add keyboard input support to the input manager.
  103709. * @returns the current input manager
  103710. */
  103711. addKeyboard(): ArcRotateCameraInputsManager;
  103712. }
  103713. }
  103714. declare module BABYLON {
  103715. /**
  103716. * This represents an orbital type of camera.
  103717. *
  103718. * 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.
  103719. * 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.
  103720. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103721. */
  103722. export class ArcRotateCamera extends TargetCamera {
  103723. /**
  103724. * Defines the rotation angle of the camera along the longitudinal axis.
  103725. */
  103726. alpha: number;
  103727. /**
  103728. * Defines the rotation angle of the camera along the latitudinal axis.
  103729. */
  103730. beta: number;
  103731. /**
  103732. * Defines the radius of the camera from it s target point.
  103733. */
  103734. radius: number;
  103735. protected _target: Vector3;
  103736. protected _targetHost: Nullable<AbstractMesh>;
  103737. /**
  103738. * Defines the target point of the camera.
  103739. * The camera looks towards it form the radius distance.
  103740. */
  103741. target: Vector3;
  103742. /**
  103743. * Define the current local position of the camera in the scene
  103744. */
  103745. position: Vector3;
  103746. protected _upVector: Vector3;
  103747. protected _upToYMatrix: Matrix;
  103748. protected _YToUpMatrix: Matrix;
  103749. /**
  103750. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103751. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103752. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103753. */
  103754. upVector: Vector3;
  103755. /**
  103756. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103757. */
  103758. setMatUp(): void;
  103759. /**
  103760. * Current inertia value on the longitudinal axis.
  103761. * The bigger this number the longer it will take for the camera to stop.
  103762. */
  103763. inertialAlphaOffset: number;
  103764. /**
  103765. * Current inertia value on the latitudinal axis.
  103766. * The bigger this number the longer it will take for the camera to stop.
  103767. */
  103768. inertialBetaOffset: number;
  103769. /**
  103770. * Current inertia value on the radius axis.
  103771. * The bigger this number the longer it will take for the camera to stop.
  103772. */
  103773. inertialRadiusOffset: number;
  103774. /**
  103775. * Minimum allowed angle on the longitudinal axis.
  103776. * This can help limiting how the Camera is able to move in the scene.
  103777. */
  103778. lowerAlphaLimit: Nullable<number>;
  103779. /**
  103780. * Maximum allowed angle on the longitudinal axis.
  103781. * This can help limiting how the Camera is able to move in the scene.
  103782. */
  103783. upperAlphaLimit: Nullable<number>;
  103784. /**
  103785. * Minimum allowed angle on the latitudinal axis.
  103786. * This can help limiting how the Camera is able to move in the scene.
  103787. */
  103788. lowerBetaLimit: number;
  103789. /**
  103790. * Maximum allowed angle on the latitudinal axis.
  103791. * This can help limiting how the Camera is able to move in the scene.
  103792. */
  103793. upperBetaLimit: number;
  103794. /**
  103795. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103796. * This can help limiting how the Camera is able to move in the scene.
  103797. */
  103798. lowerRadiusLimit: Nullable<number>;
  103799. /**
  103800. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103801. * This can help limiting how the Camera is able to move in the scene.
  103802. */
  103803. upperRadiusLimit: Nullable<number>;
  103804. /**
  103805. * Defines the current inertia value used during panning of the camera along the X axis.
  103806. */
  103807. inertialPanningX: number;
  103808. /**
  103809. * Defines the current inertia value used during panning of the camera along the Y axis.
  103810. */
  103811. inertialPanningY: number;
  103812. /**
  103813. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103814. * Basically if your fingers moves away from more than this distance you will be considered
  103815. * in pinch mode.
  103816. */
  103817. pinchToPanMaxDistance: number;
  103818. /**
  103819. * Defines the maximum distance the camera can pan.
  103820. * This could help keeping the cammera always in your scene.
  103821. */
  103822. panningDistanceLimit: Nullable<number>;
  103823. /**
  103824. * Defines the target of the camera before paning.
  103825. */
  103826. panningOriginTarget: Vector3;
  103827. /**
  103828. * Defines the value of the inertia used during panning.
  103829. * 0 would mean stop inertia and one would mean no decelleration at all.
  103830. */
  103831. panningInertia: number;
  103832. /**
  103833. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103834. */
  103835. angularSensibilityX: number;
  103836. /**
  103837. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103838. */
  103839. angularSensibilityY: number;
  103840. /**
  103841. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103842. */
  103843. pinchPrecision: number;
  103844. /**
  103845. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103846. * It will be used instead of pinchDeltaPrecision if different from 0.
  103847. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103848. */
  103849. pinchDeltaPercentage: number;
  103850. /**
  103851. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103852. */
  103853. panningSensibility: number;
  103854. /**
  103855. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103856. */
  103857. keysUp: number[];
  103858. /**
  103859. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103860. */
  103861. keysDown: number[];
  103862. /**
  103863. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103864. */
  103865. keysLeft: number[];
  103866. /**
  103867. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103868. */
  103869. keysRight: number[];
  103870. /**
  103871. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103872. */
  103873. wheelPrecision: number;
  103874. /**
  103875. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103876. * It will be used instead of pinchDeltaPrecision if different from 0.
  103877. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103878. */
  103879. wheelDeltaPercentage: number;
  103880. /**
  103881. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103882. */
  103883. zoomOnFactor: number;
  103884. /**
  103885. * Defines a screen offset for the camera position.
  103886. */
  103887. targetScreenOffset: Vector2;
  103888. /**
  103889. * Allows the camera to be completely reversed.
  103890. * If false the camera can not arrive upside down.
  103891. */
  103892. allowUpsideDown: boolean;
  103893. /**
  103894. * Define if double tap/click is used to restore the previously saved state of the camera.
  103895. */
  103896. useInputToRestoreState: boolean;
  103897. /** @hidden */
  103898. _viewMatrix: Matrix;
  103899. /** @hidden */
  103900. _useCtrlForPanning: boolean;
  103901. /** @hidden */
  103902. _panningMouseButton: number;
  103903. /**
  103904. * Defines the input associated to the camera.
  103905. */
  103906. inputs: ArcRotateCameraInputsManager;
  103907. /** @hidden */
  103908. _reset: () => void;
  103909. /**
  103910. * Defines the allowed panning axis.
  103911. */
  103912. panningAxis: Vector3;
  103913. protected _localDirection: Vector3;
  103914. protected _transformedDirection: Vector3;
  103915. private _bouncingBehavior;
  103916. /**
  103917. * Gets the bouncing behavior of the camera if it has been enabled.
  103918. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103919. */
  103920. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103921. /**
  103922. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103923. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103924. */
  103925. useBouncingBehavior: boolean;
  103926. private _framingBehavior;
  103927. /**
  103928. * Gets the framing behavior of the camera if it has been enabled.
  103929. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103930. */
  103931. readonly framingBehavior: Nullable<FramingBehavior>;
  103932. /**
  103933. * Defines if the framing behavior of the camera is enabled on the camera.
  103934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103935. */
  103936. useFramingBehavior: boolean;
  103937. private _autoRotationBehavior;
  103938. /**
  103939. * Gets the auto rotation behavior of the camera if it has been enabled.
  103940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103941. */
  103942. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103943. /**
  103944. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103946. */
  103947. useAutoRotationBehavior: boolean;
  103948. /**
  103949. * Observable triggered when the mesh target has been changed on the camera.
  103950. */
  103951. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103952. /**
  103953. * Event raised when the camera is colliding with a mesh.
  103954. */
  103955. onCollide: (collidedMesh: AbstractMesh) => void;
  103956. /**
  103957. * Defines whether the camera should check collision with the objects oh the scene.
  103958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103959. */
  103960. checkCollisions: boolean;
  103961. /**
  103962. * Defines the collision radius of the camera.
  103963. * This simulates a sphere around the camera.
  103964. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103965. */
  103966. collisionRadius: Vector3;
  103967. protected _collider: Collider;
  103968. protected _previousPosition: Vector3;
  103969. protected _collisionVelocity: Vector3;
  103970. protected _newPosition: Vector3;
  103971. protected _previousAlpha: number;
  103972. protected _previousBeta: number;
  103973. protected _previousRadius: number;
  103974. protected _collisionTriggered: boolean;
  103975. protected _targetBoundingCenter: Nullable<Vector3>;
  103976. private _computationVector;
  103977. /**
  103978. * Instantiates a new ArcRotateCamera in a given scene
  103979. * @param name Defines the name of the camera
  103980. * @param alpha Defines the camera rotation along the logitudinal axis
  103981. * @param beta Defines the camera rotation along the latitudinal axis
  103982. * @param radius Defines the camera distance from its target
  103983. * @param target Defines the camera target
  103984. * @param scene Defines the scene the camera belongs to
  103985. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103986. */
  103987. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103988. /** @hidden */
  103989. _initCache(): void;
  103990. /** @hidden */
  103991. _updateCache(ignoreParentClass?: boolean): void;
  103992. protected _getTargetPosition(): Vector3;
  103993. private _storedAlpha;
  103994. private _storedBeta;
  103995. private _storedRadius;
  103996. private _storedTarget;
  103997. private _storedTargetScreenOffset;
  103998. /**
  103999. * Stores the current state of the camera (alpha, beta, radius and target)
  104000. * @returns the camera itself
  104001. */
  104002. storeState(): Camera;
  104003. /**
  104004. * @hidden
  104005. * Restored camera state. You must call storeState() first
  104006. */
  104007. _restoreStateValues(): boolean;
  104008. /** @hidden */
  104009. _isSynchronizedViewMatrix(): boolean;
  104010. /**
  104011. * Attached controls to the current camera.
  104012. * @param element Defines the element the controls should be listened from
  104013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104014. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104015. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104016. */
  104017. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104018. /**
  104019. * Detach the current controls from the camera.
  104020. * The camera will stop reacting to inputs.
  104021. * @param element Defines the element to stop listening the inputs from
  104022. */
  104023. detachControl(element: HTMLElement): void;
  104024. /** @hidden */
  104025. _checkInputs(): void;
  104026. protected _checkLimits(): void;
  104027. /**
  104028. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104029. */
  104030. rebuildAnglesAndRadius(): void;
  104031. /**
  104032. * Use a position to define the current camera related information like alpha, beta and radius
  104033. * @param position Defines the position to set the camera at
  104034. */
  104035. setPosition(position: Vector3): void;
  104036. /**
  104037. * Defines the target the camera should look at.
  104038. * This will automatically adapt alpha beta and radius to fit within the new target.
  104039. * @param target Defines the new target as a Vector or a mesh
  104040. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104041. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104042. */
  104043. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104044. /** @hidden */
  104045. _getViewMatrix(): Matrix;
  104046. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104047. /**
  104048. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104049. * @param meshes Defines the mesh to zoom on
  104050. * @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)
  104051. */
  104052. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104053. /**
  104054. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104055. * The target will be changed but the radius
  104056. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104057. * @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)
  104058. */
  104059. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104060. min: Vector3;
  104061. max: Vector3;
  104062. distance: number;
  104063. }, doNotUpdateMaxZ?: boolean): void;
  104064. /**
  104065. * @override
  104066. * Override Camera.createRigCamera
  104067. */
  104068. createRigCamera(name: string, cameraIndex: number): Camera;
  104069. /**
  104070. * @hidden
  104071. * @override
  104072. * Override Camera._updateRigCameras
  104073. */
  104074. _updateRigCameras(): void;
  104075. /**
  104076. * Destroy the camera and release the current resources hold by it.
  104077. */
  104078. dispose(): void;
  104079. /**
  104080. * Gets the current object class name.
  104081. * @return the class name
  104082. */
  104083. getClassName(): string;
  104084. }
  104085. }
  104086. declare module BABYLON {
  104087. /**
  104088. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104090. */
  104091. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104092. /**
  104093. * Gets the name of the behavior.
  104094. */
  104095. readonly name: string;
  104096. private _zoomStopsAnimation;
  104097. private _idleRotationSpeed;
  104098. private _idleRotationWaitTime;
  104099. private _idleRotationSpinupTime;
  104100. /**
  104101. * Sets the flag that indicates if user zooming should stop animation.
  104102. */
  104103. /**
  104104. * Gets the flag that indicates if user zooming should stop animation.
  104105. */
  104106. zoomStopsAnimation: boolean;
  104107. /**
  104108. * Sets the default speed at which the camera rotates around the model.
  104109. */
  104110. /**
  104111. * Gets the default speed at which the camera rotates around the model.
  104112. */
  104113. idleRotationSpeed: number;
  104114. /**
  104115. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104116. */
  104117. /**
  104118. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104119. */
  104120. idleRotationWaitTime: number;
  104121. /**
  104122. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104123. */
  104124. /**
  104125. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104126. */
  104127. idleRotationSpinupTime: number;
  104128. /**
  104129. * Gets a value indicating if the camera is currently rotating because of this behavior
  104130. */
  104131. readonly rotationInProgress: boolean;
  104132. private _onPrePointerObservableObserver;
  104133. private _onAfterCheckInputsObserver;
  104134. private _attachedCamera;
  104135. private _isPointerDown;
  104136. private _lastFrameTime;
  104137. private _lastInteractionTime;
  104138. private _cameraRotationSpeed;
  104139. /**
  104140. * Initializes the behavior.
  104141. */
  104142. init(): void;
  104143. /**
  104144. * Attaches the behavior to its arc rotate camera.
  104145. * @param camera Defines the camera to attach the behavior to
  104146. */
  104147. attach(camera: ArcRotateCamera): void;
  104148. /**
  104149. * Detaches the behavior from its current arc rotate camera.
  104150. */
  104151. detach(): void;
  104152. /**
  104153. * Returns true if user is scrolling.
  104154. * @return true if user is scrolling.
  104155. */
  104156. private _userIsZooming;
  104157. private _lastFrameRadius;
  104158. private _shouldAnimationStopForInteraction;
  104159. /**
  104160. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104161. */
  104162. private _applyUserInteraction;
  104163. private _userIsMoving;
  104164. }
  104165. }
  104166. declare module BABYLON {
  104167. /**
  104168. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104169. */
  104170. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104171. private ui;
  104172. /**
  104173. * The name of the behavior
  104174. */
  104175. name: string;
  104176. /**
  104177. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104178. */
  104179. distanceAwayFromFace: number;
  104180. /**
  104181. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104182. */
  104183. distanceAwayFromBottomOfFace: number;
  104184. private _faceVectors;
  104185. private _target;
  104186. private _scene;
  104187. private _onRenderObserver;
  104188. private _tmpMatrix;
  104189. private _tmpVector;
  104190. /**
  104191. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104192. * @param ui The transform node that should be attched to the mesh
  104193. */
  104194. constructor(ui: TransformNode);
  104195. /**
  104196. * Initializes the behavior
  104197. */
  104198. init(): void;
  104199. private _closestFace;
  104200. private _zeroVector;
  104201. private _lookAtTmpMatrix;
  104202. private _lookAtToRef;
  104203. /**
  104204. * Attaches the AttachToBoxBehavior to the passed in mesh
  104205. * @param target The mesh that the specified node will be attached to
  104206. */
  104207. attach(target: Mesh): void;
  104208. /**
  104209. * Detaches the behavior from the mesh
  104210. */
  104211. detach(): void;
  104212. }
  104213. }
  104214. declare module BABYLON {
  104215. /**
  104216. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104217. */
  104218. export class FadeInOutBehavior implements Behavior<Mesh> {
  104219. /**
  104220. * Time in milliseconds to delay before fading in (Default: 0)
  104221. */
  104222. delay: number;
  104223. /**
  104224. * Time in milliseconds for the mesh to fade in (Default: 300)
  104225. */
  104226. fadeInTime: number;
  104227. private _millisecondsPerFrame;
  104228. private _hovered;
  104229. private _hoverValue;
  104230. private _ownerNode;
  104231. /**
  104232. * Instatiates the FadeInOutBehavior
  104233. */
  104234. constructor();
  104235. /**
  104236. * The name of the behavior
  104237. */
  104238. readonly name: string;
  104239. /**
  104240. * Initializes the behavior
  104241. */
  104242. init(): void;
  104243. /**
  104244. * Attaches the fade behavior on the passed in mesh
  104245. * @param ownerNode The mesh that will be faded in/out once attached
  104246. */
  104247. attach(ownerNode: Mesh): void;
  104248. /**
  104249. * Detaches the behavior from the mesh
  104250. */
  104251. detach(): void;
  104252. /**
  104253. * Triggers the mesh to begin fading in or out
  104254. * @param value if the object should fade in or out (true to fade in)
  104255. */
  104256. fadeIn(value: boolean): void;
  104257. private _update;
  104258. private _setAllVisibility;
  104259. }
  104260. }
  104261. declare module BABYLON {
  104262. /**
  104263. * Class containing a set of static utilities functions for managing Pivots
  104264. * @hidden
  104265. */
  104266. export class PivotTools {
  104267. private static _PivotCached;
  104268. private static _OldPivotPoint;
  104269. private static _PivotTranslation;
  104270. private static _PivotTmpVector;
  104271. /** @hidden */
  104272. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104273. /** @hidden */
  104274. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104275. }
  104276. }
  104277. declare module BABYLON {
  104278. /**
  104279. * Class containing static functions to help procedurally build meshes
  104280. */
  104281. export class PlaneBuilder {
  104282. /**
  104283. * Creates a plane mesh
  104284. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104285. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104286. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104290. * @param name defines the name of the mesh
  104291. * @param options defines the options used to create the mesh
  104292. * @param scene defines the hosting scene
  104293. * @returns the plane mesh
  104294. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104295. */
  104296. static CreatePlane(name: string, options: {
  104297. size?: number;
  104298. width?: number;
  104299. height?: number;
  104300. sideOrientation?: number;
  104301. frontUVs?: Vector4;
  104302. backUVs?: Vector4;
  104303. updatable?: boolean;
  104304. sourcePlane?: Plane;
  104305. }, scene?: Nullable<Scene>): Mesh;
  104306. }
  104307. }
  104308. declare module BABYLON {
  104309. /**
  104310. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104311. */
  104312. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104313. private static _AnyMouseID;
  104314. /**
  104315. * Abstract mesh the behavior is set on
  104316. */
  104317. attachedNode: AbstractMesh;
  104318. private _dragPlane;
  104319. private _scene;
  104320. private _pointerObserver;
  104321. private _beforeRenderObserver;
  104322. private static _planeScene;
  104323. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104324. /**
  104325. * 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)
  104326. */
  104327. maxDragAngle: number;
  104328. /**
  104329. * @hidden
  104330. */
  104331. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104332. /**
  104333. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104334. */
  104335. currentDraggingPointerID: number;
  104336. /**
  104337. * The last position where the pointer hit the drag plane in world space
  104338. */
  104339. lastDragPosition: Vector3;
  104340. /**
  104341. * If the behavior is currently in a dragging state
  104342. */
  104343. dragging: boolean;
  104344. /**
  104345. * 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)
  104346. */
  104347. dragDeltaRatio: number;
  104348. /**
  104349. * If the drag plane orientation should be updated during the dragging (Default: true)
  104350. */
  104351. updateDragPlane: boolean;
  104352. private _debugMode;
  104353. private _moving;
  104354. /**
  104355. * Fires each time the attached mesh is dragged with the pointer
  104356. * * delta between last drag position and current drag position in world space
  104357. * * dragDistance along the drag axis
  104358. * * dragPlaneNormal normal of the current drag plane used during the drag
  104359. * * dragPlanePoint in world space where the drag intersects the drag plane
  104360. */
  104361. onDragObservable: Observable<{
  104362. delta: Vector3;
  104363. dragPlanePoint: Vector3;
  104364. dragPlaneNormal: Vector3;
  104365. dragDistance: number;
  104366. pointerId: number;
  104367. }>;
  104368. /**
  104369. * Fires each time a drag begins (eg. mouse down on mesh)
  104370. */
  104371. onDragStartObservable: Observable<{
  104372. dragPlanePoint: Vector3;
  104373. pointerId: number;
  104374. }>;
  104375. /**
  104376. * Fires each time a drag ends (eg. mouse release after drag)
  104377. */
  104378. onDragEndObservable: Observable<{
  104379. dragPlanePoint: Vector3;
  104380. pointerId: number;
  104381. }>;
  104382. /**
  104383. * If the attached mesh should be moved when dragged
  104384. */
  104385. moveAttached: boolean;
  104386. /**
  104387. * If the drag behavior will react to drag events (Default: true)
  104388. */
  104389. enabled: boolean;
  104390. /**
  104391. * If pointer events should start and release the drag (Default: true)
  104392. */
  104393. startAndReleaseDragOnPointerEvents: boolean;
  104394. /**
  104395. * If camera controls should be detached during the drag
  104396. */
  104397. detachCameraControls: boolean;
  104398. /**
  104399. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104400. */
  104401. useObjectOrienationForDragging: boolean;
  104402. private _options;
  104403. /**
  104404. * Creates a pointer drag behavior that can be attached to a mesh
  104405. * @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)
  104406. */
  104407. constructor(options?: {
  104408. dragAxis?: Vector3;
  104409. dragPlaneNormal?: Vector3;
  104410. });
  104411. /**
  104412. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104413. */
  104414. validateDrag: (targetPosition: Vector3) => boolean;
  104415. /**
  104416. * The name of the behavior
  104417. */
  104418. readonly name: string;
  104419. /**
  104420. * Initializes the behavior
  104421. */
  104422. init(): void;
  104423. private _tmpVector;
  104424. private _alternatePickedPoint;
  104425. private _worldDragAxis;
  104426. private _targetPosition;
  104427. private _attachedElement;
  104428. /**
  104429. * Attaches the drag behavior the passed in mesh
  104430. * @param ownerNode The mesh that will be dragged around once attached
  104431. * @param predicate Predicate to use for pick filtering
  104432. */
  104433. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104434. /**
  104435. * Force relase the drag action by code.
  104436. */
  104437. releaseDrag(): void;
  104438. private _startDragRay;
  104439. private _lastPointerRay;
  104440. /**
  104441. * Simulates the start of a pointer drag event on the behavior
  104442. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104443. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104444. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104445. */
  104446. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104447. private _startDrag;
  104448. private _dragDelta;
  104449. private _moveDrag;
  104450. private _pickWithRayOnDragPlane;
  104451. private _pointA;
  104452. private _pointB;
  104453. private _pointC;
  104454. private _lineA;
  104455. private _lineB;
  104456. private _localAxis;
  104457. private _lookAt;
  104458. private _updateDragPlanePosition;
  104459. /**
  104460. * Detaches the behavior from the mesh
  104461. */
  104462. detach(): void;
  104463. }
  104464. }
  104465. declare module BABYLON {
  104466. /**
  104467. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104468. */
  104469. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104470. private _dragBehaviorA;
  104471. private _dragBehaviorB;
  104472. private _startDistance;
  104473. private _initialScale;
  104474. private _targetScale;
  104475. private _ownerNode;
  104476. private _sceneRenderObserver;
  104477. /**
  104478. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104479. */
  104480. constructor();
  104481. /**
  104482. * The name of the behavior
  104483. */
  104484. readonly name: string;
  104485. /**
  104486. * Initializes the behavior
  104487. */
  104488. init(): void;
  104489. private _getCurrentDistance;
  104490. /**
  104491. * Attaches the scale behavior the passed in mesh
  104492. * @param ownerNode The mesh that will be scaled around once attached
  104493. */
  104494. attach(ownerNode: Mesh): void;
  104495. /**
  104496. * Detaches the behavior from the mesh
  104497. */
  104498. detach(): void;
  104499. }
  104500. }
  104501. declare module BABYLON {
  104502. /**
  104503. * 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
  104504. */
  104505. export class SixDofDragBehavior implements Behavior<Mesh> {
  104506. private static _virtualScene;
  104507. private _ownerNode;
  104508. private _sceneRenderObserver;
  104509. private _scene;
  104510. private _targetPosition;
  104511. private _virtualOriginMesh;
  104512. private _virtualDragMesh;
  104513. private _pointerObserver;
  104514. private _moving;
  104515. private _startingOrientation;
  104516. /**
  104517. * 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)
  104518. */
  104519. private zDragFactor;
  104520. /**
  104521. * If the object should rotate to face the drag origin
  104522. */
  104523. rotateDraggedObject: boolean;
  104524. /**
  104525. * If the behavior is currently in a dragging state
  104526. */
  104527. dragging: boolean;
  104528. /**
  104529. * 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)
  104530. */
  104531. dragDeltaRatio: number;
  104532. /**
  104533. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104534. */
  104535. currentDraggingPointerID: number;
  104536. /**
  104537. * If camera controls should be detached during the drag
  104538. */
  104539. detachCameraControls: boolean;
  104540. /**
  104541. * Fires each time a drag starts
  104542. */
  104543. onDragStartObservable: Observable<{}>;
  104544. /**
  104545. * Fires each time a drag ends (eg. mouse release after drag)
  104546. */
  104547. onDragEndObservable: Observable<{}>;
  104548. /**
  104549. * 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
  104550. */
  104551. constructor();
  104552. /**
  104553. * The name of the behavior
  104554. */
  104555. readonly name: string;
  104556. /**
  104557. * Initializes the behavior
  104558. */
  104559. init(): void;
  104560. /**
  104561. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104562. */
  104563. private readonly _pointerCamera;
  104564. /**
  104565. * Attaches the scale behavior the passed in mesh
  104566. * @param ownerNode The mesh that will be scaled around once attached
  104567. */
  104568. attach(ownerNode: Mesh): void;
  104569. /**
  104570. * Detaches the behavior from the mesh
  104571. */
  104572. detach(): void;
  104573. }
  104574. }
  104575. declare module BABYLON {
  104576. /**
  104577. * Class used to apply inverse kinematics to bones
  104578. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104579. */
  104580. export class BoneIKController {
  104581. private static _tmpVecs;
  104582. private static _tmpQuat;
  104583. private static _tmpMats;
  104584. /**
  104585. * Gets or sets the target mesh
  104586. */
  104587. targetMesh: AbstractMesh;
  104588. /** Gets or sets the mesh used as pole */
  104589. poleTargetMesh: AbstractMesh;
  104590. /**
  104591. * Gets or sets the bone used as pole
  104592. */
  104593. poleTargetBone: Nullable<Bone>;
  104594. /**
  104595. * Gets or sets the target position
  104596. */
  104597. targetPosition: Vector3;
  104598. /**
  104599. * Gets or sets the pole target position
  104600. */
  104601. poleTargetPosition: Vector3;
  104602. /**
  104603. * Gets or sets the pole target local offset
  104604. */
  104605. poleTargetLocalOffset: Vector3;
  104606. /**
  104607. * Gets or sets the pole angle
  104608. */
  104609. poleAngle: number;
  104610. /**
  104611. * Gets or sets the mesh associated with the controller
  104612. */
  104613. mesh: AbstractMesh;
  104614. /**
  104615. * 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)
  104616. */
  104617. slerpAmount: number;
  104618. private _bone1Quat;
  104619. private _bone1Mat;
  104620. private _bone2Ang;
  104621. private _bone1;
  104622. private _bone2;
  104623. private _bone1Length;
  104624. private _bone2Length;
  104625. private _maxAngle;
  104626. private _maxReach;
  104627. private _rightHandedSystem;
  104628. private _bendAxis;
  104629. private _slerping;
  104630. private _adjustRoll;
  104631. /**
  104632. * Gets or sets maximum allowed angle
  104633. */
  104634. maxAngle: number;
  104635. /**
  104636. * Creates a new BoneIKController
  104637. * @param mesh defines the mesh to control
  104638. * @param bone defines the bone to control
  104639. * @param options defines options to set up the controller
  104640. */
  104641. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104642. targetMesh?: AbstractMesh;
  104643. poleTargetMesh?: AbstractMesh;
  104644. poleTargetBone?: Bone;
  104645. poleTargetLocalOffset?: Vector3;
  104646. poleAngle?: number;
  104647. bendAxis?: Vector3;
  104648. maxAngle?: number;
  104649. slerpAmount?: number;
  104650. });
  104651. private _setMaxAngle;
  104652. /**
  104653. * Force the controller to update the bones
  104654. */
  104655. update(): void;
  104656. }
  104657. }
  104658. declare module BABYLON {
  104659. /**
  104660. * Class used to make a bone look toward a point in space
  104661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104662. */
  104663. export class BoneLookController {
  104664. private static _tmpVecs;
  104665. private static _tmpQuat;
  104666. private static _tmpMats;
  104667. /**
  104668. * The target Vector3 that the bone will look at
  104669. */
  104670. target: Vector3;
  104671. /**
  104672. * The mesh that the bone is attached to
  104673. */
  104674. mesh: AbstractMesh;
  104675. /**
  104676. * The bone that will be looking to the target
  104677. */
  104678. bone: Bone;
  104679. /**
  104680. * The up axis of the coordinate system that is used when the bone is rotated
  104681. */
  104682. upAxis: Vector3;
  104683. /**
  104684. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104685. */
  104686. upAxisSpace: Space;
  104687. /**
  104688. * Used to make an adjustment to the yaw of the bone
  104689. */
  104690. adjustYaw: number;
  104691. /**
  104692. * Used to make an adjustment to the pitch of the bone
  104693. */
  104694. adjustPitch: number;
  104695. /**
  104696. * Used to make an adjustment to the roll of the bone
  104697. */
  104698. adjustRoll: number;
  104699. /**
  104700. * 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)
  104701. */
  104702. slerpAmount: number;
  104703. private _minYaw;
  104704. private _maxYaw;
  104705. private _minPitch;
  104706. private _maxPitch;
  104707. private _minYawSin;
  104708. private _minYawCos;
  104709. private _maxYawSin;
  104710. private _maxYawCos;
  104711. private _midYawConstraint;
  104712. private _minPitchTan;
  104713. private _maxPitchTan;
  104714. private _boneQuat;
  104715. private _slerping;
  104716. private _transformYawPitch;
  104717. private _transformYawPitchInv;
  104718. private _firstFrameSkipped;
  104719. private _yawRange;
  104720. private _fowardAxis;
  104721. /**
  104722. * Gets or sets the minimum yaw angle that the bone can look to
  104723. */
  104724. minYaw: number;
  104725. /**
  104726. * Gets or sets the maximum yaw angle that the bone can look to
  104727. */
  104728. maxYaw: number;
  104729. /**
  104730. * Gets or sets the minimum pitch angle that the bone can look to
  104731. */
  104732. minPitch: number;
  104733. /**
  104734. * Gets or sets the maximum pitch angle that the bone can look to
  104735. */
  104736. maxPitch: number;
  104737. /**
  104738. * Create a BoneLookController
  104739. * @param mesh the mesh that the bone belongs to
  104740. * @param bone the bone that will be looking to the target
  104741. * @param target the target Vector3 to look at
  104742. * @param options optional settings:
  104743. * * maxYaw: the maximum angle the bone will yaw to
  104744. * * minYaw: the minimum angle the bone will yaw to
  104745. * * maxPitch: the maximum angle the bone will pitch to
  104746. * * minPitch: the minimum angle the bone will yaw to
  104747. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104748. * * upAxis: the up axis of the coordinate system
  104749. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104750. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104751. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104752. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104753. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104754. * * adjustRoll: used to make an adjustment to the roll of the bone
  104755. **/
  104756. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104757. maxYaw?: number;
  104758. minYaw?: number;
  104759. maxPitch?: number;
  104760. minPitch?: number;
  104761. slerpAmount?: number;
  104762. upAxis?: Vector3;
  104763. upAxisSpace?: Space;
  104764. yawAxis?: Vector3;
  104765. pitchAxis?: Vector3;
  104766. adjustYaw?: number;
  104767. adjustPitch?: number;
  104768. adjustRoll?: number;
  104769. });
  104770. /**
  104771. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104772. */
  104773. update(): void;
  104774. private _getAngleDiff;
  104775. private _getAngleBetween;
  104776. private _isAngleBetween;
  104777. }
  104778. }
  104779. declare module BABYLON {
  104780. /**
  104781. * Manage the gamepad inputs to control an arc rotate camera.
  104782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104783. */
  104784. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104785. /**
  104786. * Defines the camera the input is attached to.
  104787. */
  104788. camera: ArcRotateCamera;
  104789. /**
  104790. * Defines the gamepad the input is gathering event from.
  104791. */
  104792. gamepad: Nullable<Gamepad>;
  104793. /**
  104794. * Defines the gamepad rotation sensiblity.
  104795. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104796. */
  104797. gamepadRotationSensibility: number;
  104798. /**
  104799. * Defines the gamepad move sensiblity.
  104800. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104801. */
  104802. gamepadMoveSensibility: number;
  104803. private _yAxisScale;
  104804. /**
  104805. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104806. */
  104807. invertYAxis: boolean;
  104808. private _onGamepadConnectedObserver;
  104809. private _onGamepadDisconnectedObserver;
  104810. /**
  104811. * Attach the input controls to a specific dom element to get the input from.
  104812. * @param element Defines the element the controls should be listened from
  104813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104814. */
  104815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104816. /**
  104817. * Detach the current controls from the specified dom element.
  104818. * @param element Defines the element to stop listening the inputs from
  104819. */
  104820. detachControl(element: Nullable<HTMLElement>): void;
  104821. /**
  104822. * Update the current camera state depending on the inputs that have been used this frame.
  104823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104824. */
  104825. checkInputs(): void;
  104826. /**
  104827. * Gets the class name of the current intput.
  104828. * @returns the class name
  104829. */
  104830. getClassName(): string;
  104831. /**
  104832. * Get the friendly name associated with the input class.
  104833. * @returns the input friendly name
  104834. */
  104835. getSimpleName(): string;
  104836. }
  104837. }
  104838. declare module BABYLON {
  104839. interface ArcRotateCameraInputsManager {
  104840. /**
  104841. * Add orientation input support to the input manager.
  104842. * @returns the current input manager
  104843. */
  104844. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104845. }
  104846. /**
  104847. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104849. */
  104850. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104851. /**
  104852. * Defines the camera the input is attached to.
  104853. */
  104854. camera: ArcRotateCamera;
  104855. /**
  104856. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104857. */
  104858. alphaCorrection: number;
  104859. /**
  104860. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104861. */
  104862. gammaCorrection: number;
  104863. private _alpha;
  104864. private _gamma;
  104865. private _dirty;
  104866. private _deviceOrientationHandler;
  104867. /**
  104868. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104869. */
  104870. constructor();
  104871. /**
  104872. * Attach the input controls to a specific dom element to get the input from.
  104873. * @param element Defines the element the controls should be listened from
  104874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104875. */
  104876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104877. /** @hidden */
  104878. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104879. /**
  104880. * Update the current camera state depending on the inputs that have been used this frame.
  104881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104882. */
  104883. checkInputs(): void;
  104884. /**
  104885. * Detach the current controls from the specified dom element.
  104886. * @param element Defines the element to stop listening the inputs from
  104887. */
  104888. detachControl(element: Nullable<HTMLElement>): void;
  104889. /**
  104890. * Gets the class name of the current intput.
  104891. * @returns the class name
  104892. */
  104893. getClassName(): string;
  104894. /**
  104895. * Get the friendly name associated with the input class.
  104896. * @returns the input friendly name
  104897. */
  104898. getSimpleName(): string;
  104899. }
  104900. }
  104901. declare module BABYLON {
  104902. /**
  104903. * Listen to mouse events to control the camera.
  104904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104905. */
  104906. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104907. /**
  104908. * Defines the camera the input is attached to.
  104909. */
  104910. camera: FlyCamera;
  104911. /**
  104912. * Defines if touch is enabled. (Default is true.)
  104913. */
  104914. touchEnabled: boolean;
  104915. /**
  104916. * Defines the buttons associated with the input to handle camera rotation.
  104917. */
  104918. buttons: number[];
  104919. /**
  104920. * Assign buttons for Yaw control.
  104921. */
  104922. buttonsYaw: number[];
  104923. /**
  104924. * Assign buttons for Pitch control.
  104925. */
  104926. buttonsPitch: number[];
  104927. /**
  104928. * Assign buttons for Roll control.
  104929. */
  104930. buttonsRoll: number[];
  104931. /**
  104932. * Detect if any button is being pressed while mouse is moved.
  104933. * -1 = Mouse locked.
  104934. * 0 = Left button.
  104935. * 1 = Middle Button.
  104936. * 2 = Right Button.
  104937. */
  104938. activeButton: number;
  104939. /**
  104940. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104941. * Higher values reduce its sensitivity.
  104942. */
  104943. angularSensibility: number;
  104944. private _mousemoveCallback;
  104945. private _observer;
  104946. private _rollObserver;
  104947. private previousPosition;
  104948. private noPreventDefault;
  104949. private element;
  104950. /**
  104951. * Listen to mouse events to control the camera.
  104952. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104954. */
  104955. constructor(touchEnabled?: boolean);
  104956. /**
  104957. * Attach the mouse control to the HTML DOM element.
  104958. * @param element Defines the element that listens to the input events.
  104959. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104960. */
  104961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104962. /**
  104963. * Detach the current controls from the specified dom element.
  104964. * @param element Defines the element to stop listening the inputs from
  104965. */
  104966. detachControl(element: Nullable<HTMLElement>): void;
  104967. /**
  104968. * Gets the class name of the current input.
  104969. * @returns the class name.
  104970. */
  104971. getClassName(): string;
  104972. /**
  104973. * Get the friendly name associated with the input class.
  104974. * @returns the input's friendly name.
  104975. */
  104976. getSimpleName(): string;
  104977. private _pointerInput;
  104978. private _onMouseMove;
  104979. /**
  104980. * Rotate camera by mouse offset.
  104981. */
  104982. private rotateCamera;
  104983. }
  104984. }
  104985. declare module BABYLON {
  104986. /**
  104987. * Default Inputs manager for the FlyCamera.
  104988. * It groups all the default supported inputs for ease of use.
  104989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104990. */
  104991. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104992. /**
  104993. * Instantiates a new FlyCameraInputsManager.
  104994. * @param camera Defines the camera the inputs belong to.
  104995. */
  104996. constructor(camera: FlyCamera);
  104997. /**
  104998. * Add keyboard input support to the input manager.
  104999. * @returns the new FlyCameraKeyboardMoveInput().
  105000. */
  105001. addKeyboard(): FlyCameraInputsManager;
  105002. /**
  105003. * Add mouse input support to the input manager.
  105004. * @param touchEnabled Enable touch screen support.
  105005. * @returns the new FlyCameraMouseInput().
  105006. */
  105007. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105008. }
  105009. }
  105010. declare module BABYLON {
  105011. /**
  105012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105013. * such as in a 3D Space Shooter or a Flight Simulator.
  105014. */
  105015. export class FlyCamera extends TargetCamera {
  105016. /**
  105017. * Define the collision ellipsoid of the camera.
  105018. * This is helpful for simulating a camera body, like a player's body.
  105019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105020. */
  105021. ellipsoid: Vector3;
  105022. /**
  105023. * Define an offset for the position of the ellipsoid around the camera.
  105024. * This can be helpful if the camera is attached away from the player's body center,
  105025. * such as at its head.
  105026. */
  105027. ellipsoidOffset: Vector3;
  105028. /**
  105029. * Enable or disable collisions of the camera with the rest of the scene objects.
  105030. */
  105031. checkCollisions: boolean;
  105032. /**
  105033. * Enable or disable gravity on the camera.
  105034. */
  105035. applyGravity: boolean;
  105036. /**
  105037. * Define the current direction the camera is moving to.
  105038. */
  105039. cameraDirection: Vector3;
  105040. /**
  105041. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105042. * This overrides and empties cameraRotation.
  105043. */
  105044. rotationQuaternion: Quaternion;
  105045. /**
  105046. * Track Roll to maintain the wanted Rolling when looking around.
  105047. */
  105048. _trackRoll: number;
  105049. /**
  105050. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105051. */
  105052. rollCorrect: number;
  105053. /**
  105054. * Mimic a banked turn, Rolling the camera when Yawing.
  105055. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105056. */
  105057. bankedTurn: boolean;
  105058. /**
  105059. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105060. */
  105061. bankedTurnLimit: number;
  105062. /**
  105063. * Value of 0 disables the banked Roll.
  105064. * Value of 1 is equal to the Yaw angle in radians.
  105065. */
  105066. bankedTurnMultiplier: number;
  105067. /**
  105068. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105069. */
  105070. inputs: FlyCameraInputsManager;
  105071. /**
  105072. * Gets the input sensibility for mouse input.
  105073. * Higher values reduce sensitivity.
  105074. */
  105075. /**
  105076. * Sets the input sensibility for a mouse input.
  105077. * Higher values reduce sensitivity.
  105078. */
  105079. angularSensibility: number;
  105080. /**
  105081. * Get the keys for camera movement forward.
  105082. */
  105083. /**
  105084. * Set the keys for camera movement forward.
  105085. */
  105086. keysForward: number[];
  105087. /**
  105088. * Get the keys for camera movement backward.
  105089. */
  105090. keysBackward: number[];
  105091. /**
  105092. * Get the keys for camera movement up.
  105093. */
  105094. /**
  105095. * Set the keys for camera movement up.
  105096. */
  105097. keysUp: number[];
  105098. /**
  105099. * Get the keys for camera movement down.
  105100. */
  105101. /**
  105102. * Set the keys for camera movement down.
  105103. */
  105104. keysDown: number[];
  105105. /**
  105106. * Get the keys for camera movement left.
  105107. */
  105108. /**
  105109. * Set the keys for camera movement left.
  105110. */
  105111. keysLeft: number[];
  105112. /**
  105113. * Set the keys for camera movement right.
  105114. */
  105115. /**
  105116. * Set the keys for camera movement right.
  105117. */
  105118. keysRight: number[];
  105119. /**
  105120. * Event raised when the camera collides with a mesh in the scene.
  105121. */
  105122. onCollide: (collidedMesh: AbstractMesh) => void;
  105123. private _collider;
  105124. private _needMoveForGravity;
  105125. private _oldPosition;
  105126. private _diffPosition;
  105127. private _newPosition;
  105128. /** @hidden */
  105129. _localDirection: Vector3;
  105130. /** @hidden */
  105131. _transformedDirection: Vector3;
  105132. /**
  105133. * Instantiates a FlyCamera.
  105134. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105135. * such as in a 3D Space Shooter or a Flight Simulator.
  105136. * @param name Define the name of the camera in the scene.
  105137. * @param position Define the starting position of the camera in the scene.
  105138. * @param scene Define the scene the camera belongs to.
  105139. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105140. */
  105141. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105142. /**
  105143. * Attach a control to the HTML DOM element.
  105144. * @param element Defines the element that listens to the input events.
  105145. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105146. */
  105147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105148. /**
  105149. * Detach a control from the HTML DOM element.
  105150. * The camera will stop reacting to that input.
  105151. * @param element Defines the element that listens to the input events.
  105152. */
  105153. detachControl(element: HTMLElement): void;
  105154. private _collisionMask;
  105155. /**
  105156. * Get the mask that the camera ignores in collision events.
  105157. */
  105158. /**
  105159. * Set the mask that the camera ignores in collision events.
  105160. */
  105161. collisionMask: number;
  105162. /** @hidden */
  105163. _collideWithWorld(displacement: Vector3): void;
  105164. /** @hidden */
  105165. private _onCollisionPositionChange;
  105166. /** @hidden */
  105167. _checkInputs(): void;
  105168. /** @hidden */
  105169. _decideIfNeedsToMove(): boolean;
  105170. /** @hidden */
  105171. _updatePosition(): void;
  105172. /**
  105173. * Restore the Roll to its target value at the rate specified.
  105174. * @param rate - Higher means slower restoring.
  105175. * @hidden
  105176. */
  105177. restoreRoll(rate: number): void;
  105178. /**
  105179. * Destroy the camera and release the current resources held by it.
  105180. */
  105181. dispose(): void;
  105182. /**
  105183. * Get the current object class name.
  105184. * @returns the class name.
  105185. */
  105186. getClassName(): string;
  105187. }
  105188. }
  105189. declare module BABYLON {
  105190. /**
  105191. * Listen to keyboard events to control the camera.
  105192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105193. */
  105194. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105195. /**
  105196. * Defines the camera the input is attached to.
  105197. */
  105198. camera: FlyCamera;
  105199. /**
  105200. * The list of keyboard keys used to control the forward move of the camera.
  105201. */
  105202. keysForward: number[];
  105203. /**
  105204. * The list of keyboard keys used to control the backward move of the camera.
  105205. */
  105206. keysBackward: number[];
  105207. /**
  105208. * The list of keyboard keys used to control the forward move of the camera.
  105209. */
  105210. keysUp: number[];
  105211. /**
  105212. * The list of keyboard keys used to control the backward move of the camera.
  105213. */
  105214. keysDown: number[];
  105215. /**
  105216. * The list of keyboard keys used to control the right strafe move of the camera.
  105217. */
  105218. keysRight: number[];
  105219. /**
  105220. * The list of keyboard keys used to control the left strafe move of the camera.
  105221. */
  105222. keysLeft: number[];
  105223. private _keys;
  105224. private _onCanvasBlurObserver;
  105225. private _onKeyboardObserver;
  105226. private _engine;
  105227. private _scene;
  105228. /**
  105229. * Attach the input controls to a specific dom element to get the input from.
  105230. * @param element Defines the element the controls should be listened from
  105231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105232. */
  105233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105234. /**
  105235. * Detach the current controls from the specified dom element.
  105236. * @param element Defines the element to stop listening the inputs from
  105237. */
  105238. detachControl(element: Nullable<HTMLElement>): void;
  105239. /**
  105240. * Gets the class name of the current intput.
  105241. * @returns the class name
  105242. */
  105243. getClassName(): string;
  105244. /** @hidden */
  105245. _onLostFocus(e: FocusEvent): void;
  105246. /**
  105247. * Get the friendly name associated with the input class.
  105248. * @returns the input friendly name
  105249. */
  105250. getSimpleName(): string;
  105251. /**
  105252. * Update the current camera state depending on the inputs that have been used this frame.
  105253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105254. */
  105255. checkInputs(): void;
  105256. }
  105257. }
  105258. declare module BABYLON {
  105259. /**
  105260. * Manage the mouse wheel inputs to control a follow camera.
  105261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105262. */
  105263. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105264. /**
  105265. * Defines the camera the input is attached to.
  105266. */
  105267. camera: FollowCamera;
  105268. /**
  105269. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105270. */
  105271. axisControlRadius: boolean;
  105272. /**
  105273. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105274. */
  105275. axisControlHeight: boolean;
  105276. /**
  105277. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105278. */
  105279. axisControlRotation: boolean;
  105280. /**
  105281. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105282. * relation to mouseWheel events.
  105283. */
  105284. wheelPrecision: number;
  105285. /**
  105286. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105287. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105288. */
  105289. wheelDeltaPercentage: number;
  105290. private _wheel;
  105291. private _observer;
  105292. /**
  105293. * Attach the input controls to a specific dom element to get the input from.
  105294. * @param element Defines the element the controls should be listened from
  105295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105296. */
  105297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105298. /**
  105299. * Detach the current controls from the specified dom element.
  105300. * @param element Defines the element to stop listening the inputs from
  105301. */
  105302. detachControl(element: Nullable<HTMLElement>): void;
  105303. /**
  105304. * Gets the class name of the current intput.
  105305. * @returns the class name
  105306. */
  105307. getClassName(): string;
  105308. /**
  105309. * Get the friendly name associated with the input class.
  105310. * @returns the input friendly name
  105311. */
  105312. getSimpleName(): string;
  105313. }
  105314. }
  105315. declare module BABYLON {
  105316. /**
  105317. * Manage the pointers inputs to control an follow camera.
  105318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105319. */
  105320. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105321. /**
  105322. * Defines the camera the input is attached to.
  105323. */
  105324. camera: FollowCamera;
  105325. /**
  105326. * Gets the class name of the current input.
  105327. * @returns the class name
  105328. */
  105329. getClassName(): string;
  105330. /**
  105331. * Defines the pointer angular sensibility along the X axis or how fast is
  105332. * the camera rotating.
  105333. * A negative number will reverse the axis direction.
  105334. */
  105335. angularSensibilityX: number;
  105336. /**
  105337. * Defines the pointer angular sensibility along the Y axis or how fast is
  105338. * the camera rotating.
  105339. * A negative number will reverse the axis direction.
  105340. */
  105341. angularSensibilityY: number;
  105342. /**
  105343. * Defines the pointer pinch precision or how fast is the camera zooming.
  105344. * A negative number will reverse the axis direction.
  105345. */
  105346. pinchPrecision: number;
  105347. /**
  105348. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105349. * from 0.
  105350. * It defines the percentage of current camera.radius to use as delta when
  105351. * pinch zoom is used.
  105352. */
  105353. pinchDeltaPercentage: number;
  105354. /**
  105355. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105356. */
  105357. axisXControlRadius: boolean;
  105358. /**
  105359. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105360. */
  105361. axisXControlHeight: boolean;
  105362. /**
  105363. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105364. */
  105365. axisXControlRotation: boolean;
  105366. /**
  105367. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105368. */
  105369. axisYControlRadius: boolean;
  105370. /**
  105371. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105372. */
  105373. axisYControlHeight: boolean;
  105374. /**
  105375. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105376. */
  105377. axisYControlRotation: boolean;
  105378. /**
  105379. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105380. */
  105381. axisPinchControlRadius: boolean;
  105382. /**
  105383. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105384. */
  105385. axisPinchControlHeight: boolean;
  105386. /**
  105387. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105388. */
  105389. axisPinchControlRotation: boolean;
  105390. /**
  105391. * Log error messages if basic misconfiguration has occurred.
  105392. */
  105393. warningEnable: boolean;
  105394. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105396. private _warningCounter;
  105397. private _warning;
  105398. }
  105399. }
  105400. declare module BABYLON {
  105401. /**
  105402. * Default Inputs manager for the FollowCamera.
  105403. * It groups all the default supported inputs for ease of use.
  105404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105405. */
  105406. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105407. /**
  105408. * Instantiates a new FollowCameraInputsManager.
  105409. * @param camera Defines the camera the inputs belong to
  105410. */
  105411. constructor(camera: FollowCamera);
  105412. /**
  105413. * Add keyboard input support to the input manager.
  105414. * @returns the current input manager
  105415. */
  105416. addKeyboard(): FollowCameraInputsManager;
  105417. /**
  105418. * Add mouse wheel input support to the input manager.
  105419. * @returns the current input manager
  105420. */
  105421. addMouseWheel(): FollowCameraInputsManager;
  105422. /**
  105423. * Add pointers input support to the input manager.
  105424. * @returns the current input manager
  105425. */
  105426. addPointers(): FollowCameraInputsManager;
  105427. /**
  105428. * Add orientation input support to the input manager.
  105429. * @returns the current input manager
  105430. */
  105431. addVRDeviceOrientation(): FollowCameraInputsManager;
  105432. }
  105433. }
  105434. declare module BABYLON {
  105435. /**
  105436. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105437. * an arc rotate version arcFollowCamera are available.
  105438. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105439. */
  105440. export class FollowCamera extends TargetCamera {
  105441. /**
  105442. * Distance the follow camera should follow an object at
  105443. */
  105444. radius: number;
  105445. /**
  105446. * Minimum allowed distance of the camera to the axis of rotation
  105447. * (The camera can not get closer).
  105448. * This can help limiting how the Camera is able to move in the scene.
  105449. */
  105450. lowerRadiusLimit: Nullable<number>;
  105451. /**
  105452. * Maximum allowed distance of the camera to the axis of rotation
  105453. * (The camera can not get further).
  105454. * This can help limiting how the Camera is able to move in the scene.
  105455. */
  105456. upperRadiusLimit: Nullable<number>;
  105457. /**
  105458. * Define a rotation offset between the camera and the object it follows
  105459. */
  105460. rotationOffset: number;
  105461. /**
  105462. * Minimum allowed angle to camera position relative to target object.
  105463. * This can help limiting how the Camera is able to move in the scene.
  105464. */
  105465. lowerRotationOffsetLimit: Nullable<number>;
  105466. /**
  105467. * Maximum allowed angle to camera position relative to target object.
  105468. * This can help limiting how the Camera is able to move in the scene.
  105469. */
  105470. upperRotationOffsetLimit: Nullable<number>;
  105471. /**
  105472. * Define a height offset between the camera and the object it follows.
  105473. * It can help following an object from the top (like a car chaing a plane)
  105474. */
  105475. heightOffset: number;
  105476. /**
  105477. * Minimum allowed height of camera position relative to target object.
  105478. * This can help limiting how the Camera is able to move in the scene.
  105479. */
  105480. lowerHeightOffsetLimit: Nullable<number>;
  105481. /**
  105482. * Maximum allowed height of camera position relative to target object.
  105483. * This can help limiting how the Camera is able to move in the scene.
  105484. */
  105485. upperHeightOffsetLimit: Nullable<number>;
  105486. /**
  105487. * Define how fast the camera can accelerate to follow it s target.
  105488. */
  105489. cameraAcceleration: number;
  105490. /**
  105491. * Define the speed limit of the camera following an object.
  105492. */
  105493. maxCameraSpeed: number;
  105494. /**
  105495. * Define the target of the camera.
  105496. */
  105497. lockedTarget: Nullable<AbstractMesh>;
  105498. /**
  105499. * Defines the input associated with the camera.
  105500. */
  105501. inputs: FollowCameraInputsManager;
  105502. /**
  105503. * Instantiates the follow camera.
  105504. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105505. * @param name Define the name of the camera in the scene
  105506. * @param position Define the position of the camera
  105507. * @param scene Define the scene the camera belong to
  105508. * @param lockedTarget Define the target of the camera
  105509. */
  105510. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105511. private _follow;
  105512. /**
  105513. * Attached controls to the current camera.
  105514. * @param element Defines the element the controls should be listened from
  105515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105516. */
  105517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105518. /**
  105519. * Detach the current controls from the camera.
  105520. * The camera will stop reacting to inputs.
  105521. * @param element Defines the element to stop listening the inputs from
  105522. */
  105523. detachControl(element: HTMLElement): void;
  105524. /** @hidden */
  105525. _checkInputs(): void;
  105526. private _checkLimits;
  105527. /**
  105528. * Gets the camera class name.
  105529. * @returns the class name
  105530. */
  105531. getClassName(): string;
  105532. }
  105533. /**
  105534. * Arc Rotate version of the follow camera.
  105535. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105536. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105537. */
  105538. export class ArcFollowCamera extends TargetCamera {
  105539. /** The longitudinal angle of the camera */
  105540. alpha: number;
  105541. /** The latitudinal angle of the camera */
  105542. beta: number;
  105543. /** The radius of the camera from its target */
  105544. radius: number;
  105545. /** Define the camera target (the messh it should follow) */
  105546. target: Nullable<AbstractMesh>;
  105547. private _cartesianCoordinates;
  105548. /**
  105549. * Instantiates a new ArcFollowCamera
  105550. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105551. * @param name Define the name of the camera
  105552. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105553. * @param beta Define the rotation angle of the camera around the elevation axis
  105554. * @param radius Define the radius of the camera from its target point
  105555. * @param target Define the target of the camera
  105556. * @param scene Define the scene the camera belongs to
  105557. */
  105558. constructor(name: string,
  105559. /** The longitudinal angle of the camera */
  105560. alpha: number,
  105561. /** The latitudinal angle of the camera */
  105562. beta: number,
  105563. /** The radius of the camera from its target */
  105564. radius: number,
  105565. /** Define the camera target (the messh it should follow) */
  105566. target: Nullable<AbstractMesh>, scene: Scene);
  105567. private _follow;
  105568. /** @hidden */
  105569. _checkInputs(): void;
  105570. /**
  105571. * Returns the class name of the object.
  105572. * It is mostly used internally for serialization purposes.
  105573. */
  105574. getClassName(): string;
  105575. }
  105576. }
  105577. declare module BABYLON {
  105578. /**
  105579. * Manage the keyboard inputs to control the movement of a follow camera.
  105580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105581. */
  105582. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105583. /**
  105584. * Defines the camera the input is attached to.
  105585. */
  105586. camera: FollowCamera;
  105587. /**
  105588. * Defines the list of key codes associated with the up action (increase heightOffset)
  105589. */
  105590. keysHeightOffsetIncr: number[];
  105591. /**
  105592. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105593. */
  105594. keysHeightOffsetDecr: number[];
  105595. /**
  105596. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105597. */
  105598. keysHeightOffsetModifierAlt: boolean;
  105599. /**
  105600. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105601. */
  105602. keysHeightOffsetModifierCtrl: boolean;
  105603. /**
  105604. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105605. */
  105606. keysHeightOffsetModifierShift: boolean;
  105607. /**
  105608. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105609. */
  105610. keysRotationOffsetIncr: number[];
  105611. /**
  105612. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105613. */
  105614. keysRotationOffsetDecr: number[];
  105615. /**
  105616. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105617. */
  105618. keysRotationOffsetModifierAlt: boolean;
  105619. /**
  105620. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105621. */
  105622. keysRotationOffsetModifierCtrl: boolean;
  105623. /**
  105624. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105625. */
  105626. keysRotationOffsetModifierShift: boolean;
  105627. /**
  105628. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105629. */
  105630. keysRadiusIncr: number[];
  105631. /**
  105632. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105633. */
  105634. keysRadiusDecr: number[];
  105635. /**
  105636. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105637. */
  105638. keysRadiusModifierAlt: boolean;
  105639. /**
  105640. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105641. */
  105642. keysRadiusModifierCtrl: boolean;
  105643. /**
  105644. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105645. */
  105646. keysRadiusModifierShift: boolean;
  105647. /**
  105648. * Defines the rate of change of heightOffset.
  105649. */
  105650. heightSensibility: number;
  105651. /**
  105652. * Defines the rate of change of rotationOffset.
  105653. */
  105654. rotationSensibility: number;
  105655. /**
  105656. * Defines the rate of change of radius.
  105657. */
  105658. radiusSensibility: number;
  105659. private _keys;
  105660. private _ctrlPressed;
  105661. private _altPressed;
  105662. private _shiftPressed;
  105663. private _onCanvasBlurObserver;
  105664. private _onKeyboardObserver;
  105665. private _engine;
  105666. private _scene;
  105667. /**
  105668. * Attach the input controls to a specific dom element to get the input from.
  105669. * @param element Defines the element the controls should be listened from
  105670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105671. */
  105672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105673. /**
  105674. * Detach the current controls from the specified dom element.
  105675. * @param element Defines the element to stop listening the inputs from
  105676. */
  105677. detachControl(element: Nullable<HTMLElement>): void;
  105678. /**
  105679. * Update the current camera state depending on the inputs that have been used this frame.
  105680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105681. */
  105682. checkInputs(): void;
  105683. /**
  105684. * Gets the class name of the current input.
  105685. * @returns the class name
  105686. */
  105687. getClassName(): string;
  105688. /**
  105689. * Get the friendly name associated with the input class.
  105690. * @returns the input friendly name
  105691. */
  105692. getSimpleName(): string;
  105693. /**
  105694. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105695. * allow modification of the heightOffset value.
  105696. */
  105697. private _modifierHeightOffset;
  105698. /**
  105699. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105700. * allow modification of the rotationOffset value.
  105701. */
  105702. private _modifierRotationOffset;
  105703. /**
  105704. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105705. * allow modification of the radius value.
  105706. */
  105707. private _modifierRadius;
  105708. }
  105709. }
  105710. declare module BABYLON {
  105711. interface FreeCameraInputsManager {
  105712. /**
  105713. * @hidden
  105714. */
  105715. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105716. /**
  105717. * Add orientation input support to the input manager.
  105718. * @returns the current input manager
  105719. */
  105720. addDeviceOrientation(): FreeCameraInputsManager;
  105721. }
  105722. /**
  105723. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105724. * Screen rotation is taken into account.
  105725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105726. */
  105727. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105728. private _camera;
  105729. private _screenOrientationAngle;
  105730. private _constantTranform;
  105731. private _screenQuaternion;
  105732. private _alpha;
  105733. private _beta;
  105734. private _gamma;
  105735. /**
  105736. * Can be used to detect if a device orientation sensor is availible on a device
  105737. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105738. * @returns a promise that will resolve on orientation change
  105739. */
  105740. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105741. /**
  105742. * @hidden
  105743. */
  105744. _onDeviceOrientationChangedObservable: Observable<void>;
  105745. /**
  105746. * Instantiates a new input
  105747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105748. */
  105749. constructor();
  105750. /**
  105751. * Define the camera controlled by the input.
  105752. */
  105753. camera: FreeCamera;
  105754. /**
  105755. * Attach the input controls to a specific dom element to get the input from.
  105756. * @param element Defines the element the controls should be listened from
  105757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105758. */
  105759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105760. private _orientationChanged;
  105761. private _deviceOrientation;
  105762. /**
  105763. * Detach the current controls from the specified dom element.
  105764. * @param element Defines the element to stop listening the inputs from
  105765. */
  105766. detachControl(element: Nullable<HTMLElement>): void;
  105767. /**
  105768. * Update the current camera state depending on the inputs that have been used this frame.
  105769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105770. */
  105771. checkInputs(): void;
  105772. /**
  105773. * Gets the class name of the current intput.
  105774. * @returns the class name
  105775. */
  105776. getClassName(): string;
  105777. /**
  105778. * Get the friendly name associated with the input class.
  105779. * @returns the input friendly name
  105780. */
  105781. getSimpleName(): string;
  105782. }
  105783. }
  105784. declare module BABYLON {
  105785. /**
  105786. * Manage the gamepad inputs to control a free camera.
  105787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105788. */
  105789. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105790. /**
  105791. * Define the camera the input is attached to.
  105792. */
  105793. camera: FreeCamera;
  105794. /**
  105795. * Define the Gamepad controlling the input
  105796. */
  105797. gamepad: Nullable<Gamepad>;
  105798. /**
  105799. * Defines the gamepad rotation sensiblity.
  105800. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105801. */
  105802. gamepadAngularSensibility: number;
  105803. /**
  105804. * Defines the gamepad move sensiblity.
  105805. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105806. */
  105807. gamepadMoveSensibility: number;
  105808. private _yAxisScale;
  105809. /**
  105810. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105811. */
  105812. invertYAxis: boolean;
  105813. private _onGamepadConnectedObserver;
  105814. private _onGamepadDisconnectedObserver;
  105815. private _cameraTransform;
  105816. private _deltaTransform;
  105817. private _vector3;
  105818. private _vector2;
  105819. /**
  105820. * Attach the input controls to a specific dom element to get the input from.
  105821. * @param element Defines the element the controls should be listened from
  105822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105823. */
  105824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105825. /**
  105826. * Detach the current controls from the specified dom element.
  105827. * @param element Defines the element to stop listening the inputs from
  105828. */
  105829. detachControl(element: Nullable<HTMLElement>): void;
  105830. /**
  105831. * Update the current camera state depending on the inputs that have been used this frame.
  105832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105833. */
  105834. checkInputs(): void;
  105835. /**
  105836. * Gets the class name of the current intput.
  105837. * @returns the class name
  105838. */
  105839. getClassName(): string;
  105840. /**
  105841. * Get the friendly name associated with the input class.
  105842. * @returns the input friendly name
  105843. */
  105844. getSimpleName(): string;
  105845. }
  105846. }
  105847. declare module BABYLON {
  105848. /**
  105849. * Defines the potential axis of a Joystick
  105850. */
  105851. export enum JoystickAxis {
  105852. /** X axis */
  105853. X = 0,
  105854. /** Y axis */
  105855. Y = 1,
  105856. /** Z axis */
  105857. Z = 2
  105858. }
  105859. /**
  105860. * Class used to define virtual joystick (used in touch mode)
  105861. */
  105862. export class VirtualJoystick {
  105863. /**
  105864. * Gets or sets a boolean indicating that left and right values must be inverted
  105865. */
  105866. reverseLeftRight: boolean;
  105867. /**
  105868. * Gets or sets a boolean indicating that up and down values must be inverted
  105869. */
  105870. reverseUpDown: boolean;
  105871. /**
  105872. * Gets the offset value for the position (ie. the change of the position value)
  105873. */
  105874. deltaPosition: Vector3;
  105875. /**
  105876. * Gets a boolean indicating if the virtual joystick was pressed
  105877. */
  105878. pressed: boolean;
  105879. /**
  105880. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105881. */
  105882. static Canvas: Nullable<HTMLCanvasElement>;
  105883. private static _globalJoystickIndex;
  105884. private static vjCanvasContext;
  105885. private static vjCanvasWidth;
  105886. private static vjCanvasHeight;
  105887. private static halfWidth;
  105888. private _action;
  105889. private _axisTargetedByLeftAndRight;
  105890. private _axisTargetedByUpAndDown;
  105891. private _joystickSensibility;
  105892. private _inversedSensibility;
  105893. private _joystickPointerID;
  105894. private _joystickColor;
  105895. private _joystickPointerPos;
  105896. private _joystickPreviousPointerPos;
  105897. private _joystickPointerStartPos;
  105898. private _deltaJoystickVector;
  105899. private _leftJoystick;
  105900. private _touches;
  105901. private _onPointerDownHandlerRef;
  105902. private _onPointerMoveHandlerRef;
  105903. private _onPointerUpHandlerRef;
  105904. private _onResize;
  105905. /**
  105906. * Creates a new virtual joystick
  105907. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105908. */
  105909. constructor(leftJoystick?: boolean);
  105910. /**
  105911. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105912. * @param newJoystickSensibility defines the new sensibility
  105913. */
  105914. setJoystickSensibility(newJoystickSensibility: number): void;
  105915. private _onPointerDown;
  105916. private _onPointerMove;
  105917. private _onPointerUp;
  105918. /**
  105919. * Change the color of the virtual joystick
  105920. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105921. */
  105922. setJoystickColor(newColor: string): void;
  105923. /**
  105924. * Defines a callback to call when the joystick is touched
  105925. * @param action defines the callback
  105926. */
  105927. setActionOnTouch(action: () => any): void;
  105928. /**
  105929. * Defines which axis you'd like to control for left & right
  105930. * @param axis defines the axis to use
  105931. */
  105932. setAxisForLeftRight(axis: JoystickAxis): void;
  105933. /**
  105934. * Defines which axis you'd like to control for up & down
  105935. * @param axis defines the axis to use
  105936. */
  105937. setAxisForUpDown(axis: JoystickAxis): void;
  105938. private _drawVirtualJoystick;
  105939. /**
  105940. * Release internal HTML canvas
  105941. */
  105942. releaseCanvas(): void;
  105943. }
  105944. }
  105945. declare module BABYLON {
  105946. interface FreeCameraInputsManager {
  105947. /**
  105948. * Add virtual joystick input support to the input manager.
  105949. * @returns the current input manager
  105950. */
  105951. addVirtualJoystick(): FreeCameraInputsManager;
  105952. }
  105953. /**
  105954. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105956. */
  105957. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105958. /**
  105959. * Defines the camera the input is attached to.
  105960. */
  105961. camera: FreeCamera;
  105962. private _leftjoystick;
  105963. private _rightjoystick;
  105964. /**
  105965. * Gets the left stick of the virtual joystick.
  105966. * @returns The virtual Joystick
  105967. */
  105968. getLeftJoystick(): VirtualJoystick;
  105969. /**
  105970. * Gets the right stick of the virtual joystick.
  105971. * @returns The virtual Joystick
  105972. */
  105973. getRightJoystick(): VirtualJoystick;
  105974. /**
  105975. * Update the current camera state depending on the inputs that have been used this frame.
  105976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105977. */
  105978. checkInputs(): void;
  105979. /**
  105980. * Attach the input controls to a specific dom element to get the input from.
  105981. * @param element Defines the element the controls should be listened from
  105982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105983. */
  105984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105985. /**
  105986. * Detach the current controls from the specified dom element.
  105987. * @param element Defines the element to stop listening the inputs from
  105988. */
  105989. detachControl(element: Nullable<HTMLElement>): void;
  105990. /**
  105991. * Gets the class name of the current intput.
  105992. * @returns the class name
  105993. */
  105994. getClassName(): string;
  105995. /**
  105996. * Get the friendly name associated with the input class.
  105997. * @returns the input friendly name
  105998. */
  105999. getSimpleName(): string;
  106000. }
  106001. }
  106002. declare module BABYLON {
  106003. /**
  106004. * This represents a FPS type of camera controlled by touch.
  106005. * This is like a universal camera minus the Gamepad controls.
  106006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106007. */
  106008. export class TouchCamera extends FreeCamera {
  106009. /**
  106010. * Defines the touch sensibility for rotation.
  106011. * The higher the faster.
  106012. */
  106013. touchAngularSensibility: number;
  106014. /**
  106015. * Defines the touch sensibility for move.
  106016. * The higher the faster.
  106017. */
  106018. touchMoveSensibility: number;
  106019. /**
  106020. * Instantiates a new touch camera.
  106021. * This represents a FPS type of camera controlled by touch.
  106022. * This is like a universal camera minus the Gamepad controls.
  106023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106024. * @param name Define the name of the camera in the scene
  106025. * @param position Define the start position of the camera in the scene
  106026. * @param scene Define the scene the camera belongs to
  106027. */
  106028. constructor(name: string, position: Vector3, scene: Scene);
  106029. /**
  106030. * Gets the current object class name.
  106031. * @return the class name
  106032. */
  106033. getClassName(): string;
  106034. /** @hidden */
  106035. _setupInputs(): void;
  106036. }
  106037. }
  106038. declare module BABYLON {
  106039. /**
  106040. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106041. * being tilted forward or back and left or right.
  106042. */
  106043. export class DeviceOrientationCamera extends FreeCamera {
  106044. private _initialQuaternion;
  106045. private _quaternionCache;
  106046. private _tmpDragQuaternion;
  106047. private _disablePointerInputWhenUsingDeviceOrientation;
  106048. /**
  106049. * Creates a new device orientation camera
  106050. * @param name The name of the camera
  106051. * @param position The start position camera
  106052. * @param scene The scene the camera belongs to
  106053. */
  106054. constructor(name: string, position: Vector3, scene: Scene);
  106055. /**
  106056. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106057. */
  106058. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106059. private _dragFactor;
  106060. /**
  106061. * Enabled turning on the y axis when the orientation sensor is active
  106062. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106063. */
  106064. enableHorizontalDragging(dragFactor?: number): void;
  106065. /**
  106066. * Gets the current instance class name ("DeviceOrientationCamera").
  106067. * This helps avoiding instanceof at run time.
  106068. * @returns the class name
  106069. */
  106070. getClassName(): string;
  106071. /**
  106072. * @hidden
  106073. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106074. */
  106075. _checkInputs(): void;
  106076. /**
  106077. * Reset the camera to its default orientation on the specified axis only.
  106078. * @param axis The axis to reset
  106079. */
  106080. resetToCurrentRotation(axis?: Axis): void;
  106081. }
  106082. }
  106083. declare module BABYLON {
  106084. /**
  106085. * Defines supported buttons for XBox360 compatible gamepads
  106086. */
  106087. export enum Xbox360Button {
  106088. /** A */
  106089. A = 0,
  106090. /** B */
  106091. B = 1,
  106092. /** X */
  106093. X = 2,
  106094. /** Y */
  106095. Y = 3,
  106096. /** Start */
  106097. Start = 4,
  106098. /** Back */
  106099. Back = 5,
  106100. /** Left button */
  106101. LB = 6,
  106102. /** Right button */
  106103. RB = 7,
  106104. /** Left stick */
  106105. LeftStick = 8,
  106106. /** Right stick */
  106107. RightStick = 9
  106108. }
  106109. /** Defines values for XBox360 DPad */
  106110. export enum Xbox360Dpad {
  106111. /** Up */
  106112. Up = 0,
  106113. /** Down */
  106114. Down = 1,
  106115. /** Left */
  106116. Left = 2,
  106117. /** Right */
  106118. Right = 3
  106119. }
  106120. /**
  106121. * Defines a XBox360 gamepad
  106122. */
  106123. export class Xbox360Pad extends Gamepad {
  106124. private _leftTrigger;
  106125. private _rightTrigger;
  106126. private _onlefttriggerchanged;
  106127. private _onrighttriggerchanged;
  106128. private _onbuttondown;
  106129. private _onbuttonup;
  106130. private _ondpaddown;
  106131. private _ondpadup;
  106132. /** Observable raised when a button is pressed */
  106133. onButtonDownObservable: Observable<Xbox360Button>;
  106134. /** Observable raised when a button is released */
  106135. onButtonUpObservable: Observable<Xbox360Button>;
  106136. /** Observable raised when a pad is pressed */
  106137. onPadDownObservable: Observable<Xbox360Dpad>;
  106138. /** Observable raised when a pad is released */
  106139. onPadUpObservable: Observable<Xbox360Dpad>;
  106140. private _buttonA;
  106141. private _buttonB;
  106142. private _buttonX;
  106143. private _buttonY;
  106144. private _buttonBack;
  106145. private _buttonStart;
  106146. private _buttonLB;
  106147. private _buttonRB;
  106148. private _buttonLeftStick;
  106149. private _buttonRightStick;
  106150. private _dPadUp;
  106151. private _dPadDown;
  106152. private _dPadLeft;
  106153. private _dPadRight;
  106154. private _isXboxOnePad;
  106155. /**
  106156. * Creates a new XBox360 gamepad object
  106157. * @param id defines the id of this gamepad
  106158. * @param index defines its index
  106159. * @param gamepad defines the internal HTML gamepad object
  106160. * @param xboxOne defines if it is a XBox One gamepad
  106161. */
  106162. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106163. /**
  106164. * Defines the callback to call when left trigger is pressed
  106165. * @param callback defines the callback to use
  106166. */
  106167. onlefttriggerchanged(callback: (value: number) => void): void;
  106168. /**
  106169. * Defines the callback to call when right trigger is pressed
  106170. * @param callback defines the callback to use
  106171. */
  106172. onrighttriggerchanged(callback: (value: number) => void): void;
  106173. /**
  106174. * Gets the left trigger value
  106175. */
  106176. /**
  106177. * Sets the left trigger value
  106178. */
  106179. leftTrigger: number;
  106180. /**
  106181. * Gets the right trigger value
  106182. */
  106183. /**
  106184. * Sets the right trigger value
  106185. */
  106186. rightTrigger: number;
  106187. /**
  106188. * Defines the callback to call when a button is pressed
  106189. * @param callback defines the callback to use
  106190. */
  106191. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106192. /**
  106193. * Defines the callback to call when a button is released
  106194. * @param callback defines the callback to use
  106195. */
  106196. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106197. /**
  106198. * Defines the callback to call when a pad is pressed
  106199. * @param callback defines the callback to use
  106200. */
  106201. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106202. /**
  106203. * Defines the callback to call when a pad is released
  106204. * @param callback defines the callback to use
  106205. */
  106206. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106207. private _setButtonValue;
  106208. private _setDPadValue;
  106209. /**
  106210. * Gets the value of the `A` button
  106211. */
  106212. /**
  106213. * Sets the value of the `A` button
  106214. */
  106215. buttonA: number;
  106216. /**
  106217. * Gets the value of the `B` button
  106218. */
  106219. /**
  106220. * Sets the value of the `B` button
  106221. */
  106222. buttonB: number;
  106223. /**
  106224. * Gets the value of the `X` button
  106225. */
  106226. /**
  106227. * Sets the value of the `X` button
  106228. */
  106229. buttonX: number;
  106230. /**
  106231. * Gets the value of the `Y` button
  106232. */
  106233. /**
  106234. * Sets the value of the `Y` button
  106235. */
  106236. buttonY: number;
  106237. /**
  106238. * Gets the value of the `Start` button
  106239. */
  106240. /**
  106241. * Sets the value of the `Start` button
  106242. */
  106243. buttonStart: number;
  106244. /**
  106245. * Gets the value of the `Back` button
  106246. */
  106247. /**
  106248. * Sets the value of the `Back` button
  106249. */
  106250. buttonBack: number;
  106251. /**
  106252. * Gets the value of the `Left` button
  106253. */
  106254. /**
  106255. * Sets the value of the `Left` button
  106256. */
  106257. buttonLB: number;
  106258. /**
  106259. * Gets the value of the `Right` button
  106260. */
  106261. /**
  106262. * Sets the value of the `Right` button
  106263. */
  106264. buttonRB: number;
  106265. /**
  106266. * Gets the value of the Left joystick
  106267. */
  106268. /**
  106269. * Sets the value of the Left joystick
  106270. */
  106271. buttonLeftStick: number;
  106272. /**
  106273. * Gets the value of the Right joystick
  106274. */
  106275. /**
  106276. * Sets the value of the Right joystick
  106277. */
  106278. buttonRightStick: number;
  106279. /**
  106280. * Gets the value of D-pad up
  106281. */
  106282. /**
  106283. * Sets the value of D-pad up
  106284. */
  106285. dPadUp: number;
  106286. /**
  106287. * Gets the value of D-pad down
  106288. */
  106289. /**
  106290. * Sets the value of D-pad down
  106291. */
  106292. dPadDown: number;
  106293. /**
  106294. * Gets the value of D-pad left
  106295. */
  106296. /**
  106297. * Sets the value of D-pad left
  106298. */
  106299. dPadLeft: number;
  106300. /**
  106301. * Gets the value of D-pad right
  106302. */
  106303. /**
  106304. * Sets the value of D-pad right
  106305. */
  106306. dPadRight: number;
  106307. /**
  106308. * Force the gamepad to synchronize with device values
  106309. */
  106310. update(): void;
  106311. /**
  106312. * Disposes the gamepad
  106313. */
  106314. dispose(): void;
  106315. }
  106316. }
  106317. declare module BABYLON {
  106318. /**
  106319. * Defines supported buttons for DualShock compatible gamepads
  106320. */
  106321. export enum DualShockButton {
  106322. /** Cross */
  106323. Cross = 0,
  106324. /** Circle */
  106325. Circle = 1,
  106326. /** Square */
  106327. Square = 2,
  106328. /** Triangle */
  106329. Triangle = 3,
  106330. /** Options */
  106331. Options = 4,
  106332. /** Share */
  106333. Share = 5,
  106334. /** L1 */
  106335. L1 = 6,
  106336. /** R1 */
  106337. R1 = 7,
  106338. /** Left stick */
  106339. LeftStick = 8,
  106340. /** Right stick */
  106341. RightStick = 9
  106342. }
  106343. /** Defines values for DualShock DPad */
  106344. export enum DualShockDpad {
  106345. /** Up */
  106346. Up = 0,
  106347. /** Down */
  106348. Down = 1,
  106349. /** Left */
  106350. Left = 2,
  106351. /** Right */
  106352. Right = 3
  106353. }
  106354. /**
  106355. * Defines a DualShock gamepad
  106356. */
  106357. export class DualShockPad extends Gamepad {
  106358. private _leftTrigger;
  106359. private _rightTrigger;
  106360. private _onlefttriggerchanged;
  106361. private _onrighttriggerchanged;
  106362. private _onbuttondown;
  106363. private _onbuttonup;
  106364. private _ondpaddown;
  106365. private _ondpadup;
  106366. /** Observable raised when a button is pressed */
  106367. onButtonDownObservable: Observable<DualShockButton>;
  106368. /** Observable raised when a button is released */
  106369. onButtonUpObservable: Observable<DualShockButton>;
  106370. /** Observable raised when a pad is pressed */
  106371. onPadDownObservable: Observable<DualShockDpad>;
  106372. /** Observable raised when a pad is released */
  106373. onPadUpObservable: Observable<DualShockDpad>;
  106374. private _buttonCross;
  106375. private _buttonCircle;
  106376. private _buttonSquare;
  106377. private _buttonTriangle;
  106378. private _buttonShare;
  106379. private _buttonOptions;
  106380. private _buttonL1;
  106381. private _buttonR1;
  106382. private _buttonLeftStick;
  106383. private _buttonRightStick;
  106384. private _dPadUp;
  106385. private _dPadDown;
  106386. private _dPadLeft;
  106387. private _dPadRight;
  106388. /**
  106389. * Creates a new DualShock gamepad object
  106390. * @param id defines the id of this gamepad
  106391. * @param index defines its index
  106392. * @param gamepad defines the internal HTML gamepad object
  106393. */
  106394. constructor(id: string, index: number, gamepad: any);
  106395. /**
  106396. * Defines the callback to call when left trigger is pressed
  106397. * @param callback defines the callback to use
  106398. */
  106399. onlefttriggerchanged(callback: (value: number) => void): void;
  106400. /**
  106401. * Defines the callback to call when right trigger is pressed
  106402. * @param callback defines the callback to use
  106403. */
  106404. onrighttriggerchanged(callback: (value: number) => void): void;
  106405. /**
  106406. * Gets the left trigger value
  106407. */
  106408. /**
  106409. * Sets the left trigger value
  106410. */
  106411. leftTrigger: number;
  106412. /**
  106413. * Gets the right trigger value
  106414. */
  106415. /**
  106416. * Sets the right trigger value
  106417. */
  106418. rightTrigger: number;
  106419. /**
  106420. * Defines the callback to call when a button is pressed
  106421. * @param callback defines the callback to use
  106422. */
  106423. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106424. /**
  106425. * Defines the callback to call when a button is released
  106426. * @param callback defines the callback to use
  106427. */
  106428. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106429. /**
  106430. * Defines the callback to call when a pad is pressed
  106431. * @param callback defines the callback to use
  106432. */
  106433. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106434. /**
  106435. * Defines the callback to call when a pad is released
  106436. * @param callback defines the callback to use
  106437. */
  106438. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106439. private _setButtonValue;
  106440. private _setDPadValue;
  106441. /**
  106442. * Gets the value of the `Cross` button
  106443. */
  106444. /**
  106445. * Sets the value of the `Cross` button
  106446. */
  106447. buttonCross: number;
  106448. /**
  106449. * Gets the value of the `Circle` button
  106450. */
  106451. /**
  106452. * Sets the value of the `Circle` button
  106453. */
  106454. buttonCircle: number;
  106455. /**
  106456. * Gets the value of the `Square` button
  106457. */
  106458. /**
  106459. * Sets the value of the `Square` button
  106460. */
  106461. buttonSquare: number;
  106462. /**
  106463. * Gets the value of the `Triangle` button
  106464. */
  106465. /**
  106466. * Sets the value of the `Triangle` button
  106467. */
  106468. buttonTriangle: number;
  106469. /**
  106470. * Gets the value of the `Options` button
  106471. */
  106472. /**
  106473. * Sets the value of the `Options` button
  106474. */
  106475. buttonOptions: number;
  106476. /**
  106477. * Gets the value of the `Share` button
  106478. */
  106479. /**
  106480. * Sets the value of the `Share` button
  106481. */
  106482. buttonShare: number;
  106483. /**
  106484. * Gets the value of the `L1` button
  106485. */
  106486. /**
  106487. * Sets the value of the `L1` button
  106488. */
  106489. buttonL1: number;
  106490. /**
  106491. * Gets the value of the `R1` button
  106492. */
  106493. /**
  106494. * Sets the value of the `R1` button
  106495. */
  106496. buttonR1: number;
  106497. /**
  106498. * Gets the value of the Left joystick
  106499. */
  106500. /**
  106501. * Sets the value of the Left joystick
  106502. */
  106503. buttonLeftStick: number;
  106504. /**
  106505. * Gets the value of the Right joystick
  106506. */
  106507. /**
  106508. * Sets the value of the Right joystick
  106509. */
  106510. buttonRightStick: number;
  106511. /**
  106512. * Gets the value of D-pad up
  106513. */
  106514. /**
  106515. * Sets the value of D-pad up
  106516. */
  106517. dPadUp: number;
  106518. /**
  106519. * Gets the value of D-pad down
  106520. */
  106521. /**
  106522. * Sets the value of D-pad down
  106523. */
  106524. dPadDown: number;
  106525. /**
  106526. * Gets the value of D-pad left
  106527. */
  106528. /**
  106529. * Sets the value of D-pad left
  106530. */
  106531. dPadLeft: number;
  106532. /**
  106533. * Gets the value of D-pad right
  106534. */
  106535. /**
  106536. * Sets the value of D-pad right
  106537. */
  106538. dPadRight: number;
  106539. /**
  106540. * Force the gamepad to synchronize with device values
  106541. */
  106542. update(): void;
  106543. /**
  106544. * Disposes the gamepad
  106545. */
  106546. dispose(): void;
  106547. }
  106548. }
  106549. declare module BABYLON {
  106550. /**
  106551. * Manager for handling gamepads
  106552. */
  106553. export class GamepadManager {
  106554. private _scene?;
  106555. private _babylonGamepads;
  106556. private _oneGamepadConnected;
  106557. /** @hidden */
  106558. _isMonitoring: boolean;
  106559. private _gamepadEventSupported;
  106560. private _gamepadSupport;
  106561. /**
  106562. * observable to be triggered when the gamepad controller has been connected
  106563. */
  106564. onGamepadConnectedObservable: Observable<Gamepad>;
  106565. /**
  106566. * observable to be triggered when the gamepad controller has been disconnected
  106567. */
  106568. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106569. private _onGamepadConnectedEvent;
  106570. private _onGamepadDisconnectedEvent;
  106571. /**
  106572. * Initializes the gamepad manager
  106573. * @param _scene BabylonJS scene
  106574. */
  106575. constructor(_scene?: Scene | undefined);
  106576. /**
  106577. * The gamepads in the game pad manager
  106578. */
  106579. readonly gamepads: Gamepad[];
  106580. /**
  106581. * Get the gamepad controllers based on type
  106582. * @param type The type of gamepad controller
  106583. * @returns Nullable gamepad
  106584. */
  106585. getGamepadByType(type?: number): Nullable<Gamepad>;
  106586. /**
  106587. * Disposes the gamepad manager
  106588. */
  106589. dispose(): void;
  106590. private _addNewGamepad;
  106591. private _startMonitoringGamepads;
  106592. private _stopMonitoringGamepads;
  106593. /** @hidden */
  106594. _checkGamepadsStatus(): void;
  106595. private _updateGamepadObjects;
  106596. }
  106597. }
  106598. declare module BABYLON {
  106599. interface Scene {
  106600. /** @hidden */
  106601. _gamepadManager: Nullable<GamepadManager>;
  106602. /**
  106603. * Gets the gamepad manager associated with the scene
  106604. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106605. */
  106606. gamepadManager: GamepadManager;
  106607. }
  106608. /**
  106609. * Interface representing a free camera inputs manager
  106610. */
  106611. interface FreeCameraInputsManager {
  106612. /**
  106613. * Adds gamepad input support to the FreeCameraInputsManager.
  106614. * @returns the FreeCameraInputsManager
  106615. */
  106616. addGamepad(): FreeCameraInputsManager;
  106617. }
  106618. /**
  106619. * Interface representing an arc rotate camera inputs manager
  106620. */
  106621. interface ArcRotateCameraInputsManager {
  106622. /**
  106623. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106624. * @returns the camera inputs manager
  106625. */
  106626. addGamepad(): ArcRotateCameraInputsManager;
  106627. }
  106628. /**
  106629. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106630. */
  106631. export class GamepadSystemSceneComponent implements ISceneComponent {
  106632. /**
  106633. * The component name helpfull to identify the component in the list of scene components.
  106634. */
  106635. readonly name: string;
  106636. /**
  106637. * The scene the component belongs to.
  106638. */
  106639. scene: Scene;
  106640. /**
  106641. * Creates a new instance of the component for the given scene
  106642. * @param scene Defines the scene to register the component in
  106643. */
  106644. constructor(scene: Scene);
  106645. /**
  106646. * Registers the component in a given scene
  106647. */
  106648. register(): void;
  106649. /**
  106650. * Rebuilds the elements related to this component in case of
  106651. * context lost for instance.
  106652. */
  106653. rebuild(): void;
  106654. /**
  106655. * Disposes the component and the associated ressources
  106656. */
  106657. dispose(): void;
  106658. private _beforeCameraUpdate;
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * 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,
  106664. * which still works and will still be found in many Playgrounds.
  106665. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106666. */
  106667. export class UniversalCamera extends TouchCamera {
  106668. /**
  106669. * Defines the gamepad rotation sensiblity.
  106670. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106671. */
  106672. gamepadAngularSensibility: number;
  106673. /**
  106674. * Defines the gamepad move sensiblity.
  106675. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106676. */
  106677. gamepadMoveSensibility: number;
  106678. /**
  106679. * 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,
  106680. * which still works and will still be found in many Playgrounds.
  106681. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106682. * @param name Define the name of the camera in the scene
  106683. * @param position Define the start position of the camera in the scene
  106684. * @param scene Define the scene the camera belongs to
  106685. */
  106686. constructor(name: string, position: Vector3, scene: Scene);
  106687. /**
  106688. * Gets the current object class name.
  106689. * @return the class name
  106690. */
  106691. getClassName(): string;
  106692. }
  106693. }
  106694. declare module BABYLON {
  106695. /**
  106696. * This represents a FPS type of camera. This is only here for back compat purpose.
  106697. * Please use the UniversalCamera instead as both are identical.
  106698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106699. */
  106700. export class GamepadCamera extends UniversalCamera {
  106701. /**
  106702. * Instantiates a new Gamepad Camera
  106703. * This represents a FPS type of camera. This is only here for back compat purpose.
  106704. * Please use the UniversalCamera instead as both are identical.
  106705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106706. * @param name Define the name of the camera in the scene
  106707. * @param position Define the start position of the camera in the scene
  106708. * @param scene Define the scene the camera belongs to
  106709. */
  106710. constructor(name: string, position: Vector3, scene: Scene);
  106711. /**
  106712. * Gets the current object class name.
  106713. * @return the class name
  106714. */
  106715. getClassName(): string;
  106716. }
  106717. }
  106718. declare module BABYLON {
  106719. /** @hidden */
  106720. export var passPixelShader: {
  106721. name: string;
  106722. shader: string;
  106723. };
  106724. }
  106725. declare module BABYLON {
  106726. /** @hidden */
  106727. export var passCubePixelShader: {
  106728. name: string;
  106729. shader: string;
  106730. };
  106731. }
  106732. declare module BABYLON {
  106733. /**
  106734. * PassPostProcess which produces an output the same as it's input
  106735. */
  106736. export class PassPostProcess extends PostProcess {
  106737. /**
  106738. * Creates the PassPostProcess
  106739. * @param name The name of the effect.
  106740. * @param options The required width/height ratio to downsize to before computing the render pass.
  106741. * @param camera The camera to apply the render pass to.
  106742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106743. * @param engine The engine which the post process will be applied. (default: current engine)
  106744. * @param reusable If the post process can be reused on the same frame. (default: false)
  106745. * @param textureType The type of texture to be used when performing the post processing.
  106746. * @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)
  106747. */
  106748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106749. }
  106750. /**
  106751. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106752. */
  106753. export class PassCubePostProcess extends PostProcess {
  106754. private _face;
  106755. /**
  106756. * Gets or sets the cube face to display.
  106757. * * 0 is +X
  106758. * * 1 is -X
  106759. * * 2 is +Y
  106760. * * 3 is -Y
  106761. * * 4 is +Z
  106762. * * 5 is -Z
  106763. */
  106764. face: number;
  106765. /**
  106766. * Creates the PassCubePostProcess
  106767. * @param name The name of the effect.
  106768. * @param options The required width/height ratio to downsize to before computing the render pass.
  106769. * @param camera The camera to apply the render pass to.
  106770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106771. * @param engine The engine which the post process will be applied. (default: current engine)
  106772. * @param reusable If the post process can be reused on the same frame. (default: false)
  106773. * @param textureType The type of texture to be used when performing the post processing.
  106774. * @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)
  106775. */
  106776. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106777. }
  106778. }
  106779. declare module BABYLON {
  106780. /** @hidden */
  106781. export var anaglyphPixelShader: {
  106782. name: string;
  106783. shader: string;
  106784. };
  106785. }
  106786. declare module BABYLON {
  106787. /**
  106788. * Postprocess used to generate anaglyphic rendering
  106789. */
  106790. export class AnaglyphPostProcess extends PostProcess {
  106791. private _passedProcess;
  106792. /**
  106793. * Creates a new AnaglyphPostProcess
  106794. * @param name defines postprocess name
  106795. * @param options defines creation options or target ratio scale
  106796. * @param rigCameras defines cameras using this postprocess
  106797. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106798. * @param engine defines hosting engine
  106799. * @param reusable defines if the postprocess will be reused multiple times per frame
  106800. */
  106801. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106802. }
  106803. }
  106804. declare module BABYLON {
  106805. /**
  106806. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106807. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106808. */
  106809. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106810. /**
  106811. * Creates a new AnaglyphArcRotateCamera
  106812. * @param name defines camera name
  106813. * @param alpha defines alpha angle (in radians)
  106814. * @param beta defines beta angle (in radians)
  106815. * @param radius defines radius
  106816. * @param target defines camera target
  106817. * @param interaxialDistance defines distance between each color axis
  106818. * @param scene defines the hosting scene
  106819. */
  106820. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106821. /**
  106822. * Gets camera class name
  106823. * @returns AnaglyphArcRotateCamera
  106824. */
  106825. getClassName(): string;
  106826. }
  106827. }
  106828. declare module BABYLON {
  106829. /**
  106830. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106831. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106832. */
  106833. export class AnaglyphFreeCamera extends FreeCamera {
  106834. /**
  106835. * Creates a new AnaglyphFreeCamera
  106836. * @param name defines camera name
  106837. * @param position defines initial position
  106838. * @param interaxialDistance defines distance between each color axis
  106839. * @param scene defines the hosting scene
  106840. */
  106841. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106842. /**
  106843. * Gets camera class name
  106844. * @returns AnaglyphFreeCamera
  106845. */
  106846. getClassName(): string;
  106847. }
  106848. }
  106849. declare module BABYLON {
  106850. /**
  106851. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106852. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106853. */
  106854. export class AnaglyphGamepadCamera extends GamepadCamera {
  106855. /**
  106856. * Creates a new AnaglyphGamepadCamera
  106857. * @param name defines camera name
  106858. * @param position defines initial position
  106859. * @param interaxialDistance defines distance between each color axis
  106860. * @param scene defines the hosting scene
  106861. */
  106862. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106863. /**
  106864. * Gets camera class name
  106865. * @returns AnaglyphGamepadCamera
  106866. */
  106867. getClassName(): string;
  106868. }
  106869. }
  106870. declare module BABYLON {
  106871. /**
  106872. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106874. */
  106875. export class AnaglyphUniversalCamera extends UniversalCamera {
  106876. /**
  106877. * Creates a new AnaglyphUniversalCamera
  106878. * @param name defines camera name
  106879. * @param position defines initial position
  106880. * @param interaxialDistance defines distance between each color axis
  106881. * @param scene defines the hosting scene
  106882. */
  106883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106884. /**
  106885. * Gets camera class name
  106886. * @returns AnaglyphUniversalCamera
  106887. */
  106888. getClassName(): string;
  106889. }
  106890. }
  106891. declare module BABYLON {
  106892. /** @hidden */
  106893. export var stereoscopicInterlacePixelShader: {
  106894. name: string;
  106895. shader: string;
  106896. };
  106897. }
  106898. declare module BABYLON {
  106899. /**
  106900. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106901. */
  106902. export class StereoscopicInterlacePostProcess extends PostProcess {
  106903. private _stepSize;
  106904. private _passedProcess;
  106905. /**
  106906. * Initializes a StereoscopicInterlacePostProcess
  106907. * @param name The name of the effect.
  106908. * @param rigCameras The rig cameras to be appled to the post process
  106909. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106911. * @param engine The engine which the post process will be applied. (default: current engine)
  106912. * @param reusable If the post process can be reused on the same frame. (default: false)
  106913. */
  106914. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106915. }
  106916. }
  106917. declare module BABYLON {
  106918. /**
  106919. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106920. * @see http://doc.babylonjs.com/features/cameras
  106921. */
  106922. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106923. /**
  106924. * Creates a new StereoscopicArcRotateCamera
  106925. * @param name defines camera name
  106926. * @param alpha defines alpha angle (in radians)
  106927. * @param beta defines beta angle (in radians)
  106928. * @param radius defines radius
  106929. * @param target defines camera target
  106930. * @param interaxialDistance defines distance between each color axis
  106931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106932. * @param scene defines the hosting scene
  106933. */
  106934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106935. /**
  106936. * Gets camera class name
  106937. * @returns StereoscopicArcRotateCamera
  106938. */
  106939. getClassName(): string;
  106940. }
  106941. }
  106942. declare module BABYLON {
  106943. /**
  106944. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106945. * @see http://doc.babylonjs.com/features/cameras
  106946. */
  106947. export class StereoscopicFreeCamera extends FreeCamera {
  106948. /**
  106949. * Creates a new StereoscopicFreeCamera
  106950. * @param name defines camera name
  106951. * @param position defines initial position
  106952. * @param interaxialDistance defines distance between each color axis
  106953. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106954. * @param scene defines the hosting scene
  106955. */
  106956. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106957. /**
  106958. * Gets camera class name
  106959. * @returns StereoscopicFreeCamera
  106960. */
  106961. getClassName(): string;
  106962. }
  106963. }
  106964. declare module BABYLON {
  106965. /**
  106966. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106967. * @see http://doc.babylonjs.com/features/cameras
  106968. */
  106969. export class StereoscopicGamepadCamera extends GamepadCamera {
  106970. /**
  106971. * Creates a new StereoscopicGamepadCamera
  106972. * @param name defines camera name
  106973. * @param position defines initial position
  106974. * @param interaxialDistance defines distance between each color axis
  106975. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106976. * @param scene defines the hosting scene
  106977. */
  106978. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106979. /**
  106980. * Gets camera class name
  106981. * @returns StereoscopicGamepadCamera
  106982. */
  106983. getClassName(): string;
  106984. }
  106985. }
  106986. declare module BABYLON {
  106987. /**
  106988. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106989. * @see http://doc.babylonjs.com/features/cameras
  106990. */
  106991. export class StereoscopicUniversalCamera extends UniversalCamera {
  106992. /**
  106993. * Creates a new StereoscopicUniversalCamera
  106994. * @param name defines camera name
  106995. * @param position defines initial position
  106996. * @param interaxialDistance defines distance between each color axis
  106997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106998. * @param scene defines the hosting scene
  106999. */
  107000. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107001. /**
  107002. * Gets camera class name
  107003. * @returns StereoscopicUniversalCamera
  107004. */
  107005. getClassName(): string;
  107006. }
  107007. }
  107008. declare module BABYLON {
  107009. /**
  107010. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107011. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107012. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107013. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107014. */
  107015. export class VirtualJoysticksCamera extends FreeCamera {
  107016. /**
  107017. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107018. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107019. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107020. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107021. * @param name Define the name of the camera in the scene
  107022. * @param position Define the start position of the camera in the scene
  107023. * @param scene Define the scene the camera belongs to
  107024. */
  107025. constructor(name: string, position: Vector3, scene: Scene);
  107026. /**
  107027. * Gets the current object class name.
  107028. * @return the class name
  107029. */
  107030. getClassName(): string;
  107031. }
  107032. }
  107033. declare module BABYLON {
  107034. /**
  107035. * This represents all the required metrics to create a VR camera.
  107036. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107037. */
  107038. export class VRCameraMetrics {
  107039. /**
  107040. * Define the horizontal resolution off the screen.
  107041. */
  107042. hResolution: number;
  107043. /**
  107044. * Define the vertical resolution off the screen.
  107045. */
  107046. vResolution: number;
  107047. /**
  107048. * Define the horizontal screen size.
  107049. */
  107050. hScreenSize: number;
  107051. /**
  107052. * Define the vertical screen size.
  107053. */
  107054. vScreenSize: number;
  107055. /**
  107056. * Define the vertical screen center position.
  107057. */
  107058. vScreenCenter: number;
  107059. /**
  107060. * Define the distance of the eyes to the screen.
  107061. */
  107062. eyeToScreenDistance: number;
  107063. /**
  107064. * Define the distance between both lenses
  107065. */
  107066. lensSeparationDistance: number;
  107067. /**
  107068. * Define the distance between both viewer's eyes.
  107069. */
  107070. interpupillaryDistance: number;
  107071. /**
  107072. * Define the distortion factor of the VR postprocess.
  107073. * Please, touch with care.
  107074. */
  107075. distortionK: number[];
  107076. /**
  107077. * Define the chromatic aberration correction factors for the VR post process.
  107078. */
  107079. chromaAbCorrection: number[];
  107080. /**
  107081. * Define the scale factor of the post process.
  107082. * The smaller the better but the slower.
  107083. */
  107084. postProcessScaleFactor: number;
  107085. /**
  107086. * Define an offset for the lens center.
  107087. */
  107088. lensCenterOffset: number;
  107089. /**
  107090. * Define if the current vr camera should compensate the distortion of the lense or not.
  107091. */
  107092. compensateDistortion: boolean;
  107093. /**
  107094. * Defines if multiview should be enabled when rendering (Default: false)
  107095. */
  107096. multiviewEnabled: boolean;
  107097. /**
  107098. * Gets the rendering aspect ratio based on the provided resolutions.
  107099. */
  107100. readonly aspectRatio: number;
  107101. /**
  107102. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107103. */
  107104. readonly aspectRatioFov: number;
  107105. /**
  107106. * @hidden
  107107. */
  107108. readonly leftHMatrix: Matrix;
  107109. /**
  107110. * @hidden
  107111. */
  107112. readonly rightHMatrix: Matrix;
  107113. /**
  107114. * @hidden
  107115. */
  107116. readonly leftPreViewMatrix: Matrix;
  107117. /**
  107118. * @hidden
  107119. */
  107120. readonly rightPreViewMatrix: Matrix;
  107121. /**
  107122. * Get the default VRMetrics based on the most generic setup.
  107123. * @returns the default vr metrics
  107124. */
  107125. static GetDefault(): VRCameraMetrics;
  107126. }
  107127. }
  107128. declare module BABYLON {
  107129. /** @hidden */
  107130. export var vrDistortionCorrectionPixelShader: {
  107131. name: string;
  107132. shader: string;
  107133. };
  107134. }
  107135. declare module BABYLON {
  107136. /**
  107137. * VRDistortionCorrectionPostProcess used for mobile VR
  107138. */
  107139. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107140. private _isRightEye;
  107141. private _distortionFactors;
  107142. private _postProcessScaleFactor;
  107143. private _lensCenterOffset;
  107144. private _scaleIn;
  107145. private _scaleFactor;
  107146. private _lensCenter;
  107147. /**
  107148. * Initializes the VRDistortionCorrectionPostProcess
  107149. * @param name The name of the effect.
  107150. * @param camera The camera to apply the render pass to.
  107151. * @param isRightEye If this is for the right eye distortion
  107152. * @param vrMetrics All the required metrics for the VR camera
  107153. */
  107154. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107155. }
  107156. }
  107157. declare module BABYLON {
  107158. /**
  107159. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107160. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107161. */
  107162. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107163. /**
  107164. * Creates a new VRDeviceOrientationArcRotateCamera
  107165. * @param name defines camera name
  107166. * @param alpha defines the camera rotation along the logitudinal axis
  107167. * @param beta defines the camera rotation along the latitudinal axis
  107168. * @param radius defines the camera distance from its target
  107169. * @param target defines the camera target
  107170. * @param scene defines the scene the camera belongs to
  107171. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107172. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107173. */
  107174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107175. /**
  107176. * Gets camera class name
  107177. * @returns VRDeviceOrientationArcRotateCamera
  107178. */
  107179. getClassName(): string;
  107180. }
  107181. }
  107182. declare module BABYLON {
  107183. /**
  107184. * Camera used to simulate VR rendering (based on FreeCamera)
  107185. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107186. */
  107187. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107188. /**
  107189. * Creates a new VRDeviceOrientationFreeCamera
  107190. * @param name defines camera name
  107191. * @param position defines the start position of the camera
  107192. * @param scene defines the scene the camera belongs to
  107193. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107194. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107195. */
  107196. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107197. /**
  107198. * Gets camera class name
  107199. * @returns VRDeviceOrientationFreeCamera
  107200. */
  107201. getClassName(): string;
  107202. }
  107203. }
  107204. declare module BABYLON {
  107205. /**
  107206. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107207. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107208. */
  107209. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107210. /**
  107211. * Creates a new VRDeviceOrientationGamepadCamera
  107212. * @param name defines camera name
  107213. * @param position defines the start position of the camera
  107214. * @param scene defines the scene the camera belongs to
  107215. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107216. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107217. */
  107218. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107219. /**
  107220. * Gets camera class name
  107221. * @returns VRDeviceOrientationGamepadCamera
  107222. */
  107223. getClassName(): string;
  107224. }
  107225. }
  107226. declare module BABYLON {
  107227. /**
  107228. * Base class of materials working in push mode in babylon JS
  107229. * @hidden
  107230. */
  107231. export class PushMaterial extends Material {
  107232. protected _activeEffect: Effect;
  107233. protected _normalMatrix: Matrix;
  107234. /**
  107235. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107236. * This means that the material can keep using a previous shader while a new one is being compiled.
  107237. * This is mostly used when shader parallel compilation is supported (true by default)
  107238. */
  107239. allowShaderHotSwapping: boolean;
  107240. constructor(name: string, scene: Scene);
  107241. getEffect(): Effect;
  107242. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107243. /**
  107244. * Binds the given world matrix to the active effect
  107245. *
  107246. * @param world the matrix to bind
  107247. */
  107248. bindOnlyWorldMatrix(world: Matrix): void;
  107249. /**
  107250. * Binds the given normal matrix to the active effect
  107251. *
  107252. * @param normalMatrix the matrix to bind
  107253. */
  107254. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107255. bind(world: Matrix, mesh?: Mesh): void;
  107256. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107257. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107258. }
  107259. }
  107260. declare module BABYLON {
  107261. /**
  107262. * This groups all the flags used to control the materials channel.
  107263. */
  107264. export class MaterialFlags {
  107265. private static _DiffuseTextureEnabled;
  107266. /**
  107267. * Are diffuse textures enabled in the application.
  107268. */
  107269. static DiffuseTextureEnabled: boolean;
  107270. private static _AmbientTextureEnabled;
  107271. /**
  107272. * Are ambient textures enabled in the application.
  107273. */
  107274. static AmbientTextureEnabled: boolean;
  107275. private static _OpacityTextureEnabled;
  107276. /**
  107277. * Are opacity textures enabled in the application.
  107278. */
  107279. static OpacityTextureEnabled: boolean;
  107280. private static _ReflectionTextureEnabled;
  107281. /**
  107282. * Are reflection textures enabled in the application.
  107283. */
  107284. static ReflectionTextureEnabled: boolean;
  107285. private static _EmissiveTextureEnabled;
  107286. /**
  107287. * Are emissive textures enabled in the application.
  107288. */
  107289. static EmissiveTextureEnabled: boolean;
  107290. private static _SpecularTextureEnabled;
  107291. /**
  107292. * Are specular textures enabled in the application.
  107293. */
  107294. static SpecularTextureEnabled: boolean;
  107295. private static _BumpTextureEnabled;
  107296. /**
  107297. * Are bump textures enabled in the application.
  107298. */
  107299. static BumpTextureEnabled: boolean;
  107300. private static _LightmapTextureEnabled;
  107301. /**
  107302. * Are lightmap textures enabled in the application.
  107303. */
  107304. static LightmapTextureEnabled: boolean;
  107305. private static _RefractionTextureEnabled;
  107306. /**
  107307. * Are refraction textures enabled in the application.
  107308. */
  107309. static RefractionTextureEnabled: boolean;
  107310. private static _ColorGradingTextureEnabled;
  107311. /**
  107312. * Are color grading textures enabled in the application.
  107313. */
  107314. static ColorGradingTextureEnabled: boolean;
  107315. private static _FresnelEnabled;
  107316. /**
  107317. * Are fresnels enabled in the application.
  107318. */
  107319. static FresnelEnabled: boolean;
  107320. private static _ClearCoatTextureEnabled;
  107321. /**
  107322. * Are clear coat textures enabled in the application.
  107323. */
  107324. static ClearCoatTextureEnabled: boolean;
  107325. private static _ClearCoatBumpTextureEnabled;
  107326. /**
  107327. * Are clear coat bump textures enabled in the application.
  107328. */
  107329. static ClearCoatBumpTextureEnabled: boolean;
  107330. private static _ClearCoatTintTextureEnabled;
  107331. /**
  107332. * Are clear coat tint textures enabled in the application.
  107333. */
  107334. static ClearCoatTintTextureEnabled: boolean;
  107335. private static _SheenTextureEnabled;
  107336. /**
  107337. * Are sheen textures enabled in the application.
  107338. */
  107339. static SheenTextureEnabled: boolean;
  107340. private static _AnisotropicTextureEnabled;
  107341. /**
  107342. * Are anisotropic textures enabled in the application.
  107343. */
  107344. static AnisotropicTextureEnabled: boolean;
  107345. private static _ThicknessTextureEnabled;
  107346. /**
  107347. * Are thickness textures enabled in the application.
  107348. */
  107349. static ThicknessTextureEnabled: boolean;
  107350. }
  107351. }
  107352. declare module BABYLON {
  107353. /** @hidden */
  107354. export var defaultFragmentDeclaration: {
  107355. name: string;
  107356. shader: string;
  107357. };
  107358. }
  107359. declare module BABYLON {
  107360. /** @hidden */
  107361. export var defaultUboDeclaration: {
  107362. name: string;
  107363. shader: string;
  107364. };
  107365. }
  107366. declare module BABYLON {
  107367. /** @hidden */
  107368. export var lightFragmentDeclaration: {
  107369. name: string;
  107370. shader: string;
  107371. };
  107372. }
  107373. declare module BABYLON {
  107374. /** @hidden */
  107375. export var lightUboDeclaration: {
  107376. name: string;
  107377. shader: string;
  107378. };
  107379. }
  107380. declare module BABYLON {
  107381. /** @hidden */
  107382. export var lightsFragmentFunctions: {
  107383. name: string;
  107384. shader: string;
  107385. };
  107386. }
  107387. declare module BABYLON {
  107388. /** @hidden */
  107389. export var shadowsFragmentFunctions: {
  107390. name: string;
  107391. shader: string;
  107392. };
  107393. }
  107394. declare module BABYLON {
  107395. /** @hidden */
  107396. export var fresnelFunction: {
  107397. name: string;
  107398. shader: string;
  107399. };
  107400. }
  107401. declare module BABYLON {
  107402. /** @hidden */
  107403. export var reflectionFunction: {
  107404. name: string;
  107405. shader: string;
  107406. };
  107407. }
  107408. declare module BABYLON {
  107409. /** @hidden */
  107410. export var bumpFragmentFunctions: {
  107411. name: string;
  107412. shader: string;
  107413. };
  107414. }
  107415. declare module BABYLON {
  107416. /** @hidden */
  107417. export var logDepthDeclaration: {
  107418. name: string;
  107419. shader: string;
  107420. };
  107421. }
  107422. declare module BABYLON {
  107423. /** @hidden */
  107424. export var bumpFragment: {
  107425. name: string;
  107426. shader: string;
  107427. };
  107428. }
  107429. declare module BABYLON {
  107430. /** @hidden */
  107431. export var depthPrePass: {
  107432. name: string;
  107433. shader: string;
  107434. };
  107435. }
  107436. declare module BABYLON {
  107437. /** @hidden */
  107438. export var lightFragment: {
  107439. name: string;
  107440. shader: string;
  107441. };
  107442. }
  107443. declare module BABYLON {
  107444. /** @hidden */
  107445. export var logDepthFragment: {
  107446. name: string;
  107447. shader: string;
  107448. };
  107449. }
  107450. declare module BABYLON {
  107451. /** @hidden */
  107452. export var defaultPixelShader: {
  107453. name: string;
  107454. shader: string;
  107455. };
  107456. }
  107457. declare module BABYLON {
  107458. /** @hidden */
  107459. export var defaultVertexDeclaration: {
  107460. name: string;
  107461. shader: string;
  107462. };
  107463. }
  107464. declare module BABYLON {
  107465. /** @hidden */
  107466. export var bumpVertexDeclaration: {
  107467. name: string;
  107468. shader: string;
  107469. };
  107470. }
  107471. declare module BABYLON {
  107472. /** @hidden */
  107473. export var bumpVertex: {
  107474. name: string;
  107475. shader: string;
  107476. };
  107477. }
  107478. declare module BABYLON {
  107479. /** @hidden */
  107480. export var fogVertex: {
  107481. name: string;
  107482. shader: string;
  107483. };
  107484. }
  107485. declare module BABYLON {
  107486. /** @hidden */
  107487. export var shadowsVertex: {
  107488. name: string;
  107489. shader: string;
  107490. };
  107491. }
  107492. declare module BABYLON {
  107493. /** @hidden */
  107494. export var pointCloudVertex: {
  107495. name: string;
  107496. shader: string;
  107497. };
  107498. }
  107499. declare module BABYLON {
  107500. /** @hidden */
  107501. export var logDepthVertex: {
  107502. name: string;
  107503. shader: string;
  107504. };
  107505. }
  107506. declare module BABYLON {
  107507. /** @hidden */
  107508. export var defaultVertexShader: {
  107509. name: string;
  107510. shader: string;
  107511. };
  107512. }
  107513. declare module BABYLON {
  107514. /** @hidden */
  107515. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107516. MAINUV1: boolean;
  107517. MAINUV2: boolean;
  107518. DIFFUSE: boolean;
  107519. DIFFUSEDIRECTUV: number;
  107520. AMBIENT: boolean;
  107521. AMBIENTDIRECTUV: number;
  107522. OPACITY: boolean;
  107523. OPACITYDIRECTUV: number;
  107524. OPACITYRGB: boolean;
  107525. REFLECTION: boolean;
  107526. EMISSIVE: boolean;
  107527. EMISSIVEDIRECTUV: number;
  107528. SPECULAR: boolean;
  107529. SPECULARDIRECTUV: number;
  107530. BUMP: boolean;
  107531. BUMPDIRECTUV: number;
  107532. PARALLAX: boolean;
  107533. PARALLAXOCCLUSION: boolean;
  107534. SPECULAROVERALPHA: boolean;
  107535. CLIPPLANE: boolean;
  107536. CLIPPLANE2: boolean;
  107537. CLIPPLANE3: boolean;
  107538. CLIPPLANE4: boolean;
  107539. ALPHATEST: boolean;
  107540. DEPTHPREPASS: boolean;
  107541. ALPHAFROMDIFFUSE: boolean;
  107542. POINTSIZE: boolean;
  107543. FOG: boolean;
  107544. SPECULARTERM: boolean;
  107545. DIFFUSEFRESNEL: boolean;
  107546. OPACITYFRESNEL: boolean;
  107547. REFLECTIONFRESNEL: boolean;
  107548. REFRACTIONFRESNEL: boolean;
  107549. EMISSIVEFRESNEL: boolean;
  107550. FRESNEL: boolean;
  107551. NORMAL: boolean;
  107552. UV1: boolean;
  107553. UV2: boolean;
  107554. VERTEXCOLOR: boolean;
  107555. VERTEXALPHA: boolean;
  107556. NUM_BONE_INFLUENCERS: number;
  107557. BonesPerMesh: number;
  107558. BONETEXTURE: boolean;
  107559. INSTANCES: boolean;
  107560. GLOSSINESS: boolean;
  107561. ROUGHNESS: boolean;
  107562. EMISSIVEASILLUMINATION: boolean;
  107563. LINKEMISSIVEWITHDIFFUSE: boolean;
  107564. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107565. LIGHTMAP: boolean;
  107566. LIGHTMAPDIRECTUV: number;
  107567. OBJECTSPACE_NORMALMAP: boolean;
  107568. USELIGHTMAPASSHADOWMAP: boolean;
  107569. REFLECTIONMAP_3D: boolean;
  107570. REFLECTIONMAP_SPHERICAL: boolean;
  107571. REFLECTIONMAP_PLANAR: boolean;
  107572. REFLECTIONMAP_CUBIC: boolean;
  107573. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107574. REFLECTIONMAP_PROJECTION: boolean;
  107575. REFLECTIONMAP_SKYBOX: boolean;
  107576. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107577. REFLECTIONMAP_EXPLICIT: boolean;
  107578. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107579. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107580. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107581. INVERTCUBICMAP: boolean;
  107582. LOGARITHMICDEPTH: boolean;
  107583. REFRACTION: boolean;
  107584. REFRACTIONMAP_3D: boolean;
  107585. REFLECTIONOVERALPHA: boolean;
  107586. TWOSIDEDLIGHTING: boolean;
  107587. SHADOWFLOAT: boolean;
  107588. MORPHTARGETS: boolean;
  107589. MORPHTARGETS_NORMAL: boolean;
  107590. MORPHTARGETS_TANGENT: boolean;
  107591. MORPHTARGETS_UV: boolean;
  107592. NUM_MORPH_INFLUENCERS: number;
  107593. NONUNIFORMSCALING: boolean;
  107594. PREMULTIPLYALPHA: boolean;
  107595. IMAGEPROCESSING: boolean;
  107596. VIGNETTE: boolean;
  107597. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107598. VIGNETTEBLENDMODEOPAQUE: boolean;
  107599. TONEMAPPING: boolean;
  107600. TONEMAPPING_ACES: boolean;
  107601. CONTRAST: boolean;
  107602. COLORCURVES: boolean;
  107603. COLORGRADING: boolean;
  107604. COLORGRADING3D: boolean;
  107605. SAMPLER3DGREENDEPTH: boolean;
  107606. SAMPLER3DBGRMAP: boolean;
  107607. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107608. MULTIVIEW: boolean;
  107609. /**
  107610. * If the reflection texture on this material is in linear color space
  107611. * @hidden
  107612. */
  107613. IS_REFLECTION_LINEAR: boolean;
  107614. /**
  107615. * If the refraction texture on this material is in linear color space
  107616. * @hidden
  107617. */
  107618. IS_REFRACTION_LINEAR: boolean;
  107619. EXPOSURE: boolean;
  107620. constructor();
  107621. setReflectionMode(modeToEnable: string): void;
  107622. }
  107623. /**
  107624. * This is the default material used in Babylon. It is the best trade off between quality
  107625. * and performances.
  107626. * @see http://doc.babylonjs.com/babylon101/materials
  107627. */
  107628. export class StandardMaterial extends PushMaterial {
  107629. private _diffuseTexture;
  107630. /**
  107631. * The basic texture of the material as viewed under a light.
  107632. */
  107633. diffuseTexture: Nullable<BaseTexture>;
  107634. private _ambientTexture;
  107635. /**
  107636. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107637. */
  107638. ambientTexture: Nullable<BaseTexture>;
  107639. private _opacityTexture;
  107640. /**
  107641. * Define the transparency of the material from a texture.
  107642. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107643. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107644. */
  107645. opacityTexture: Nullable<BaseTexture>;
  107646. private _reflectionTexture;
  107647. /**
  107648. * Define the texture used to display the reflection.
  107649. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107650. */
  107651. reflectionTexture: Nullable<BaseTexture>;
  107652. private _emissiveTexture;
  107653. /**
  107654. * Define texture of the material as if self lit.
  107655. * This will be mixed in the final result even in the absence of light.
  107656. */
  107657. emissiveTexture: Nullable<BaseTexture>;
  107658. private _specularTexture;
  107659. /**
  107660. * Define how the color and intensity of the highlight given by the light in the material.
  107661. */
  107662. specularTexture: Nullable<BaseTexture>;
  107663. private _bumpTexture;
  107664. /**
  107665. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107666. * 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.
  107667. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107668. */
  107669. bumpTexture: Nullable<BaseTexture>;
  107670. private _lightmapTexture;
  107671. /**
  107672. * Complex lighting can be computationally expensive to compute at runtime.
  107673. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107674. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107675. */
  107676. lightmapTexture: Nullable<BaseTexture>;
  107677. private _refractionTexture;
  107678. /**
  107679. * Define the texture used to display the refraction.
  107680. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107681. */
  107682. refractionTexture: Nullable<BaseTexture>;
  107683. /**
  107684. * The color of the material lit by the environmental background lighting.
  107685. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107686. */
  107687. ambientColor: Color3;
  107688. /**
  107689. * The basic color of the material as viewed under a light.
  107690. */
  107691. diffuseColor: Color3;
  107692. /**
  107693. * Define how the color and intensity of the highlight given by the light in the material.
  107694. */
  107695. specularColor: Color3;
  107696. /**
  107697. * Define the color of the material as if self lit.
  107698. * This will be mixed in the final result even in the absence of light.
  107699. */
  107700. emissiveColor: Color3;
  107701. /**
  107702. * Defines how sharp are the highlights in the material.
  107703. * The bigger the value the sharper giving a more glossy feeling to the result.
  107704. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107705. */
  107706. specularPower: number;
  107707. private _useAlphaFromDiffuseTexture;
  107708. /**
  107709. * Does the transparency come from the diffuse texture alpha channel.
  107710. */
  107711. useAlphaFromDiffuseTexture: boolean;
  107712. private _useEmissiveAsIllumination;
  107713. /**
  107714. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107715. */
  107716. useEmissiveAsIllumination: boolean;
  107717. private _linkEmissiveWithDiffuse;
  107718. /**
  107719. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107720. * the emissive level when the final color is close to one.
  107721. */
  107722. linkEmissiveWithDiffuse: boolean;
  107723. private _useSpecularOverAlpha;
  107724. /**
  107725. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107726. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107727. */
  107728. useSpecularOverAlpha: boolean;
  107729. private _useReflectionOverAlpha;
  107730. /**
  107731. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107732. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107733. */
  107734. useReflectionOverAlpha: boolean;
  107735. private _disableLighting;
  107736. /**
  107737. * Does lights from the scene impacts this material.
  107738. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107739. */
  107740. disableLighting: boolean;
  107741. private _useObjectSpaceNormalMap;
  107742. /**
  107743. * Allows using an object space normal map (instead of tangent space).
  107744. */
  107745. useObjectSpaceNormalMap: boolean;
  107746. private _useParallax;
  107747. /**
  107748. * Is parallax enabled or not.
  107749. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107750. */
  107751. useParallax: boolean;
  107752. private _useParallaxOcclusion;
  107753. /**
  107754. * Is parallax occlusion enabled or not.
  107755. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107756. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107757. */
  107758. useParallaxOcclusion: boolean;
  107759. /**
  107760. * 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.
  107761. */
  107762. parallaxScaleBias: number;
  107763. private _roughness;
  107764. /**
  107765. * Helps to define how blurry the reflections should appears in the material.
  107766. */
  107767. roughness: number;
  107768. /**
  107769. * In case of refraction, define the value of the index of refraction.
  107770. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107771. */
  107772. indexOfRefraction: number;
  107773. /**
  107774. * Invert the refraction texture alongside the y axis.
  107775. * It can be useful with procedural textures or probe for instance.
  107776. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107777. */
  107778. invertRefractionY: boolean;
  107779. /**
  107780. * Defines the alpha limits in alpha test mode.
  107781. */
  107782. alphaCutOff: number;
  107783. private _useLightmapAsShadowmap;
  107784. /**
  107785. * In case of light mapping, define whether the map contains light or shadow informations.
  107786. */
  107787. useLightmapAsShadowmap: boolean;
  107788. private _diffuseFresnelParameters;
  107789. /**
  107790. * Define the diffuse fresnel parameters of the material.
  107791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107792. */
  107793. diffuseFresnelParameters: FresnelParameters;
  107794. private _opacityFresnelParameters;
  107795. /**
  107796. * Define the opacity fresnel parameters of the material.
  107797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107798. */
  107799. opacityFresnelParameters: FresnelParameters;
  107800. private _reflectionFresnelParameters;
  107801. /**
  107802. * Define the reflection fresnel parameters of the material.
  107803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107804. */
  107805. reflectionFresnelParameters: FresnelParameters;
  107806. private _refractionFresnelParameters;
  107807. /**
  107808. * Define the refraction fresnel parameters of the material.
  107809. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107810. */
  107811. refractionFresnelParameters: FresnelParameters;
  107812. private _emissiveFresnelParameters;
  107813. /**
  107814. * Define the emissive fresnel parameters of the material.
  107815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107816. */
  107817. emissiveFresnelParameters: FresnelParameters;
  107818. private _useReflectionFresnelFromSpecular;
  107819. /**
  107820. * If true automatically deducts the fresnels values from the material specularity.
  107821. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107822. */
  107823. useReflectionFresnelFromSpecular: boolean;
  107824. private _useGlossinessFromSpecularMapAlpha;
  107825. /**
  107826. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107827. */
  107828. useGlossinessFromSpecularMapAlpha: boolean;
  107829. private _maxSimultaneousLights;
  107830. /**
  107831. * Defines the maximum number of lights that can be used in the material
  107832. */
  107833. maxSimultaneousLights: number;
  107834. private _invertNormalMapX;
  107835. /**
  107836. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107837. */
  107838. invertNormalMapX: boolean;
  107839. private _invertNormalMapY;
  107840. /**
  107841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107842. */
  107843. invertNormalMapY: boolean;
  107844. private _twoSidedLighting;
  107845. /**
  107846. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107847. */
  107848. twoSidedLighting: boolean;
  107849. /**
  107850. * Default configuration related to image processing available in the standard Material.
  107851. */
  107852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107853. /**
  107854. * Gets the image processing configuration used either in this material.
  107855. */
  107856. /**
  107857. * Sets the Default image processing configuration used either in the this material.
  107858. *
  107859. * If sets to null, the scene one is in use.
  107860. */
  107861. imageProcessingConfiguration: ImageProcessingConfiguration;
  107862. /**
  107863. * Keep track of the image processing observer to allow dispose and replace.
  107864. */
  107865. private _imageProcessingObserver;
  107866. /**
  107867. * Attaches a new image processing configuration to the Standard Material.
  107868. * @param configuration
  107869. */
  107870. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107871. /**
  107872. * Gets wether the color curves effect is enabled.
  107873. */
  107874. /**
  107875. * Sets wether the color curves effect is enabled.
  107876. */
  107877. cameraColorCurvesEnabled: boolean;
  107878. /**
  107879. * Gets wether the color grading effect is enabled.
  107880. */
  107881. /**
  107882. * Gets wether the color grading effect is enabled.
  107883. */
  107884. cameraColorGradingEnabled: boolean;
  107885. /**
  107886. * Gets wether tonemapping is enabled or not.
  107887. */
  107888. /**
  107889. * Sets wether tonemapping is enabled or not
  107890. */
  107891. cameraToneMappingEnabled: boolean;
  107892. /**
  107893. * The camera exposure used on this material.
  107894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107895. * This corresponds to a photographic exposure.
  107896. */
  107897. /**
  107898. * The camera exposure used on this material.
  107899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107900. * This corresponds to a photographic exposure.
  107901. */
  107902. cameraExposure: number;
  107903. /**
  107904. * Gets The camera contrast used on this material.
  107905. */
  107906. /**
  107907. * Sets The camera contrast used on this material.
  107908. */
  107909. cameraContrast: number;
  107910. /**
  107911. * Gets the Color Grading 2D Lookup Texture.
  107912. */
  107913. /**
  107914. * Sets the Color Grading 2D Lookup Texture.
  107915. */
  107916. cameraColorGradingTexture: Nullable<BaseTexture>;
  107917. /**
  107918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107920. * 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;
  107921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107922. */
  107923. /**
  107924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107926. * 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;
  107927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107928. */
  107929. cameraColorCurves: Nullable<ColorCurves>;
  107930. /**
  107931. * Custom callback helping to override the default shader used in the material.
  107932. */
  107933. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107934. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107935. protected _worldViewProjectionMatrix: Matrix;
  107936. protected _globalAmbientColor: Color3;
  107937. protected _useLogarithmicDepth: boolean;
  107938. protected _rebuildInParallel: boolean;
  107939. /**
  107940. * Instantiates a new standard material.
  107941. * This is the default material used in Babylon. It is the best trade off between quality
  107942. * and performances.
  107943. * @see http://doc.babylonjs.com/babylon101/materials
  107944. * @param name Define the name of the material in the scene
  107945. * @param scene Define the scene the material belong to
  107946. */
  107947. constructor(name: string, scene: Scene);
  107948. /**
  107949. * Gets a boolean indicating that current material needs to register RTT
  107950. */
  107951. readonly hasRenderTargetTextures: boolean;
  107952. /**
  107953. * Gets the current class name of the material e.g. "StandardMaterial"
  107954. * Mainly use in serialization.
  107955. * @returns the class name
  107956. */
  107957. getClassName(): string;
  107958. /**
  107959. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107960. * You can try switching to logarithmic depth.
  107961. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107962. */
  107963. useLogarithmicDepth: boolean;
  107964. /**
  107965. * Specifies if the material will require alpha blending
  107966. * @returns a boolean specifying if alpha blending is needed
  107967. */
  107968. needAlphaBlending(): boolean;
  107969. /**
  107970. * Specifies if this material should be rendered in alpha test mode
  107971. * @returns a boolean specifying if an alpha test is needed.
  107972. */
  107973. needAlphaTesting(): boolean;
  107974. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107975. /**
  107976. * Get the texture used for alpha test purpose.
  107977. * @returns the diffuse texture in case of the standard material.
  107978. */
  107979. getAlphaTestTexture(): Nullable<BaseTexture>;
  107980. /**
  107981. * Get if the submesh is ready to be used and all its information available.
  107982. * Child classes can use it to update shaders
  107983. * @param mesh defines the mesh to check
  107984. * @param subMesh defines which submesh to check
  107985. * @param useInstances specifies that instances should be used
  107986. * @returns a boolean indicating that the submesh is ready or not
  107987. */
  107988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107989. /**
  107990. * Builds the material UBO layouts.
  107991. * Used internally during the effect preparation.
  107992. */
  107993. buildUniformLayout(): void;
  107994. /**
  107995. * Unbinds the material from the mesh
  107996. */
  107997. unbind(): void;
  107998. /**
  107999. * Binds the submesh to this material by preparing the effect and shader to draw
  108000. * @param world defines the world transformation matrix
  108001. * @param mesh defines the mesh containing the submesh
  108002. * @param subMesh defines the submesh to bind the material to
  108003. */
  108004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108005. /**
  108006. * Get the list of animatables in the material.
  108007. * @returns the list of animatables object used in the material
  108008. */
  108009. getAnimatables(): IAnimatable[];
  108010. /**
  108011. * Gets the active textures from the material
  108012. * @returns an array of textures
  108013. */
  108014. getActiveTextures(): BaseTexture[];
  108015. /**
  108016. * Specifies if the material uses a texture
  108017. * @param texture defines the texture to check against the material
  108018. * @returns a boolean specifying if the material uses the texture
  108019. */
  108020. hasTexture(texture: BaseTexture): boolean;
  108021. /**
  108022. * Disposes the material
  108023. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108024. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108025. */
  108026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108027. /**
  108028. * Makes a duplicate of the material, and gives it a new name
  108029. * @param name defines the new name for the duplicated material
  108030. * @returns the cloned material
  108031. */
  108032. clone(name: string): StandardMaterial;
  108033. /**
  108034. * Serializes this material in a JSON representation
  108035. * @returns the serialized material object
  108036. */
  108037. serialize(): any;
  108038. /**
  108039. * Creates a standard material from parsed material data
  108040. * @param source defines the JSON representation of the material
  108041. * @param scene defines the hosting scene
  108042. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108043. * @returns a new standard material
  108044. */
  108045. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108046. /**
  108047. * Are diffuse textures enabled in the application.
  108048. */
  108049. static DiffuseTextureEnabled: boolean;
  108050. /**
  108051. * Are ambient textures enabled in the application.
  108052. */
  108053. static AmbientTextureEnabled: boolean;
  108054. /**
  108055. * Are opacity textures enabled in the application.
  108056. */
  108057. static OpacityTextureEnabled: boolean;
  108058. /**
  108059. * Are reflection textures enabled in the application.
  108060. */
  108061. static ReflectionTextureEnabled: boolean;
  108062. /**
  108063. * Are emissive textures enabled in the application.
  108064. */
  108065. static EmissiveTextureEnabled: boolean;
  108066. /**
  108067. * Are specular textures enabled in the application.
  108068. */
  108069. static SpecularTextureEnabled: boolean;
  108070. /**
  108071. * Are bump textures enabled in the application.
  108072. */
  108073. static BumpTextureEnabled: boolean;
  108074. /**
  108075. * Are lightmap textures enabled in the application.
  108076. */
  108077. static LightmapTextureEnabled: boolean;
  108078. /**
  108079. * Are refraction textures enabled in the application.
  108080. */
  108081. static RefractionTextureEnabled: boolean;
  108082. /**
  108083. * Are color grading textures enabled in the application.
  108084. */
  108085. static ColorGradingTextureEnabled: boolean;
  108086. /**
  108087. * Are fresnels enabled in the application.
  108088. */
  108089. static FresnelEnabled: boolean;
  108090. }
  108091. }
  108092. declare module BABYLON {
  108093. /** @hidden */
  108094. export var imageProcessingPixelShader: {
  108095. name: string;
  108096. shader: string;
  108097. };
  108098. }
  108099. declare module BABYLON {
  108100. /**
  108101. * ImageProcessingPostProcess
  108102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108103. */
  108104. export class ImageProcessingPostProcess extends PostProcess {
  108105. /**
  108106. * Default configuration related to image processing available in the PBR Material.
  108107. */
  108108. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108109. /**
  108110. * Gets the image processing configuration used either in this material.
  108111. */
  108112. /**
  108113. * Sets the Default image processing configuration used either in the this material.
  108114. *
  108115. * If sets to null, the scene one is in use.
  108116. */
  108117. imageProcessingConfiguration: ImageProcessingConfiguration;
  108118. /**
  108119. * Keep track of the image processing observer to allow dispose and replace.
  108120. */
  108121. private _imageProcessingObserver;
  108122. /**
  108123. * Attaches a new image processing configuration to the PBR Material.
  108124. * @param configuration
  108125. */
  108126. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108127. /**
  108128. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108129. */
  108130. /**
  108131. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108132. */
  108133. colorCurves: Nullable<ColorCurves>;
  108134. /**
  108135. * Gets wether the color curves effect is enabled.
  108136. */
  108137. /**
  108138. * Sets wether the color curves effect is enabled.
  108139. */
  108140. colorCurvesEnabled: boolean;
  108141. /**
  108142. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108143. */
  108144. /**
  108145. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108146. */
  108147. colorGradingTexture: Nullable<BaseTexture>;
  108148. /**
  108149. * Gets wether the color grading effect is enabled.
  108150. */
  108151. /**
  108152. * Gets wether the color grading effect is enabled.
  108153. */
  108154. colorGradingEnabled: boolean;
  108155. /**
  108156. * Gets exposure used in the effect.
  108157. */
  108158. /**
  108159. * Sets exposure used in the effect.
  108160. */
  108161. exposure: number;
  108162. /**
  108163. * Gets wether tonemapping is enabled or not.
  108164. */
  108165. /**
  108166. * Sets wether tonemapping is enabled or not
  108167. */
  108168. toneMappingEnabled: boolean;
  108169. /**
  108170. * Gets the type of tone mapping effect.
  108171. */
  108172. /**
  108173. * Sets the type of tone mapping effect.
  108174. */
  108175. toneMappingType: number;
  108176. /**
  108177. * Gets contrast used in the effect.
  108178. */
  108179. /**
  108180. * Sets contrast used in the effect.
  108181. */
  108182. contrast: number;
  108183. /**
  108184. * Gets Vignette stretch size.
  108185. */
  108186. /**
  108187. * Sets Vignette stretch size.
  108188. */
  108189. vignetteStretch: number;
  108190. /**
  108191. * Gets Vignette centre X Offset.
  108192. */
  108193. /**
  108194. * Sets Vignette centre X Offset.
  108195. */
  108196. vignetteCentreX: number;
  108197. /**
  108198. * Gets Vignette centre Y Offset.
  108199. */
  108200. /**
  108201. * Sets Vignette centre Y Offset.
  108202. */
  108203. vignetteCentreY: number;
  108204. /**
  108205. * Gets Vignette weight or intensity of the vignette effect.
  108206. */
  108207. /**
  108208. * Sets Vignette weight or intensity of the vignette effect.
  108209. */
  108210. vignetteWeight: number;
  108211. /**
  108212. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108213. * if vignetteEnabled is set to true.
  108214. */
  108215. /**
  108216. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108217. * if vignetteEnabled is set to true.
  108218. */
  108219. vignetteColor: Color4;
  108220. /**
  108221. * Gets Camera field of view used by the Vignette effect.
  108222. */
  108223. /**
  108224. * Sets Camera field of view used by the Vignette effect.
  108225. */
  108226. vignetteCameraFov: number;
  108227. /**
  108228. * Gets the vignette blend mode allowing different kind of effect.
  108229. */
  108230. /**
  108231. * Sets the vignette blend mode allowing different kind of effect.
  108232. */
  108233. vignetteBlendMode: number;
  108234. /**
  108235. * Gets wether the vignette effect is enabled.
  108236. */
  108237. /**
  108238. * Sets wether the vignette effect is enabled.
  108239. */
  108240. vignetteEnabled: boolean;
  108241. private _fromLinearSpace;
  108242. /**
  108243. * Gets wether the input of the processing is in Gamma or Linear Space.
  108244. */
  108245. /**
  108246. * Sets wether the input of the processing is in Gamma or Linear Space.
  108247. */
  108248. fromLinearSpace: boolean;
  108249. /**
  108250. * Defines cache preventing GC.
  108251. */
  108252. private _defines;
  108253. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108254. /**
  108255. * "ImageProcessingPostProcess"
  108256. * @returns "ImageProcessingPostProcess"
  108257. */
  108258. getClassName(): string;
  108259. protected _updateParameters(): void;
  108260. dispose(camera?: Camera): void;
  108261. }
  108262. }
  108263. declare module BABYLON {
  108264. /**
  108265. * Class containing static functions to help procedurally build meshes
  108266. */
  108267. export class GroundBuilder {
  108268. /**
  108269. * Creates a ground mesh
  108270. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108271. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108273. * @param name defines the name of the mesh
  108274. * @param options defines the options used to create the mesh
  108275. * @param scene defines the hosting scene
  108276. * @returns the ground mesh
  108277. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108278. */
  108279. static CreateGround(name: string, options: {
  108280. width?: number;
  108281. height?: number;
  108282. subdivisions?: number;
  108283. subdivisionsX?: number;
  108284. subdivisionsY?: number;
  108285. updatable?: boolean;
  108286. }, scene: any): Mesh;
  108287. /**
  108288. * Creates a tiled ground mesh
  108289. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108290. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108291. * * 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
  108292. * * 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
  108293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108294. * @param name defines the name of the mesh
  108295. * @param options defines the options used to create the mesh
  108296. * @param scene defines the hosting scene
  108297. * @returns the tiled ground mesh
  108298. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108299. */
  108300. static CreateTiledGround(name: string, options: {
  108301. xmin: number;
  108302. zmin: number;
  108303. xmax: number;
  108304. zmax: number;
  108305. subdivisions?: {
  108306. w: number;
  108307. h: number;
  108308. };
  108309. precision?: {
  108310. w: number;
  108311. h: number;
  108312. };
  108313. updatable?: boolean;
  108314. }, scene?: Nullable<Scene>): Mesh;
  108315. /**
  108316. * Creates a ground mesh from a height map
  108317. * * The parameter `url` sets the URL of the height map image resource.
  108318. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108319. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108320. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108321. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108322. * * 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.
  108323. * * 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).
  108324. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108326. * @param name defines the name of the mesh
  108327. * @param url defines the url to the height map
  108328. * @param options defines the options used to create the mesh
  108329. * @param scene defines the hosting scene
  108330. * @returns the ground mesh
  108331. * @see https://doc.babylonjs.com/babylon101/height_map
  108332. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108333. */
  108334. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108335. width?: number;
  108336. height?: number;
  108337. subdivisions?: number;
  108338. minHeight?: number;
  108339. maxHeight?: number;
  108340. colorFilter?: Color3;
  108341. alphaFilter?: number;
  108342. updatable?: boolean;
  108343. onReady?: (mesh: GroundMesh) => void;
  108344. }, scene?: Nullable<Scene>): GroundMesh;
  108345. }
  108346. }
  108347. declare module BABYLON {
  108348. /**
  108349. * Class containing static functions to help procedurally build meshes
  108350. */
  108351. export class TorusBuilder {
  108352. /**
  108353. * Creates a torus mesh
  108354. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108355. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108356. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108360. * @param name defines the name of the mesh
  108361. * @param options defines the options used to create the mesh
  108362. * @param scene defines the hosting scene
  108363. * @returns the torus mesh
  108364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108365. */
  108366. static CreateTorus(name: string, options: {
  108367. diameter?: number;
  108368. thickness?: number;
  108369. tessellation?: number;
  108370. updatable?: boolean;
  108371. sideOrientation?: number;
  108372. frontUVs?: Vector4;
  108373. backUVs?: Vector4;
  108374. }, scene: any): Mesh;
  108375. }
  108376. }
  108377. declare module BABYLON {
  108378. /**
  108379. * Class containing static functions to help procedurally build meshes
  108380. */
  108381. export class CylinderBuilder {
  108382. /**
  108383. * Creates a cylinder or a cone mesh
  108384. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108385. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108386. * * 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.
  108387. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108388. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108389. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108390. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108391. * * 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).
  108392. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108393. * * 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).
  108394. * * 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
  108395. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108396. * * 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
  108397. * * 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.
  108398. * * If `enclose` is false, a ring surface is one element.
  108399. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108400. * * 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
  108401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108404. * @param name defines the name of the mesh
  108405. * @param options defines the options used to create the mesh
  108406. * @param scene defines the hosting scene
  108407. * @returns the cylinder mesh
  108408. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108409. */
  108410. static CreateCylinder(name: string, options: {
  108411. height?: number;
  108412. diameterTop?: number;
  108413. diameterBottom?: number;
  108414. diameter?: number;
  108415. tessellation?: number;
  108416. subdivisions?: number;
  108417. arc?: number;
  108418. faceColors?: Color4[];
  108419. faceUV?: Vector4[];
  108420. updatable?: boolean;
  108421. hasRings?: boolean;
  108422. enclose?: boolean;
  108423. cap?: number;
  108424. sideOrientation?: number;
  108425. frontUVs?: Vector4;
  108426. backUVs?: Vector4;
  108427. }, scene: any): Mesh;
  108428. }
  108429. }
  108430. declare module BABYLON {
  108431. /**
  108432. * Options to modify the vr teleportation behavior.
  108433. */
  108434. export interface VRTeleportationOptions {
  108435. /**
  108436. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108437. */
  108438. floorMeshName?: string;
  108439. /**
  108440. * A list of meshes to be used as the teleportation floor. (default: empty)
  108441. */
  108442. floorMeshes?: Mesh[];
  108443. }
  108444. /**
  108445. * Options to modify the vr experience helper's behavior.
  108446. */
  108447. export interface VRExperienceHelperOptions extends WebVROptions {
  108448. /**
  108449. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108450. */
  108451. createDeviceOrientationCamera?: boolean;
  108452. /**
  108453. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108454. */
  108455. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108456. /**
  108457. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108458. */
  108459. laserToggle?: boolean;
  108460. /**
  108461. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108462. */
  108463. floorMeshes?: Mesh[];
  108464. /**
  108465. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108466. */
  108467. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108468. }
  108469. /**
  108470. * Event containing information after VR has been entered
  108471. */
  108472. export class OnAfterEnteringVRObservableEvent {
  108473. /**
  108474. * If entering vr was successful
  108475. */
  108476. success: boolean;
  108477. }
  108478. /**
  108479. * Helps to quickly add VR support to an existing scene.
  108480. * See http://doc.babylonjs.com/how_to/webvr_helper
  108481. */
  108482. export class VRExperienceHelper {
  108483. /** Options to modify the vr experience helper's behavior. */
  108484. webVROptions: VRExperienceHelperOptions;
  108485. private _scene;
  108486. private _position;
  108487. private _btnVR;
  108488. private _btnVRDisplayed;
  108489. private _webVRsupported;
  108490. private _webVRready;
  108491. private _webVRrequesting;
  108492. private _webVRpresenting;
  108493. private _hasEnteredVR;
  108494. private _fullscreenVRpresenting;
  108495. private _canvas;
  108496. private _webVRCamera;
  108497. private _vrDeviceOrientationCamera;
  108498. private _deviceOrientationCamera;
  108499. private _existingCamera;
  108500. private _onKeyDown;
  108501. private _onVrDisplayPresentChange;
  108502. private _onVRDisplayChanged;
  108503. private _onVRRequestPresentStart;
  108504. private _onVRRequestPresentComplete;
  108505. /**
  108506. * 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)
  108507. */
  108508. enableGazeEvenWhenNoPointerLock: boolean;
  108509. /**
  108510. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108511. */
  108512. exitVROnDoubleTap: boolean;
  108513. /**
  108514. * Observable raised right before entering VR.
  108515. */
  108516. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108517. /**
  108518. * Observable raised when entering VR has completed.
  108519. */
  108520. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108521. /**
  108522. * Observable raised when exiting VR.
  108523. */
  108524. onExitingVRObservable: Observable<VRExperienceHelper>;
  108525. /**
  108526. * Observable raised when controller mesh is loaded.
  108527. */
  108528. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108529. /** Return this.onEnteringVRObservable
  108530. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108531. */
  108532. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108533. /** Return this.onExitingVRObservable
  108534. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108535. */
  108536. readonly onExitingVR: Observable<VRExperienceHelper>;
  108537. /** Return this.onControllerMeshLoadedObservable
  108538. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108539. */
  108540. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108541. private _rayLength;
  108542. private _useCustomVRButton;
  108543. private _teleportationRequested;
  108544. private _teleportActive;
  108545. private _floorMeshName;
  108546. private _floorMeshesCollection;
  108547. private _rotationAllowed;
  108548. private _teleportBackwardsVector;
  108549. private _teleportationTarget;
  108550. private _isDefaultTeleportationTarget;
  108551. private _postProcessMove;
  108552. private _teleportationFillColor;
  108553. private _teleportationBorderColor;
  108554. private _rotationAngle;
  108555. private _haloCenter;
  108556. private _cameraGazer;
  108557. private _padSensibilityUp;
  108558. private _padSensibilityDown;
  108559. private _leftController;
  108560. private _rightController;
  108561. /**
  108562. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108563. */
  108564. onNewMeshSelected: Observable<AbstractMesh>;
  108565. /**
  108566. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108567. * This observable will provide the mesh and the controller used to select the mesh
  108568. */
  108569. onMeshSelectedWithController: Observable<{
  108570. mesh: AbstractMesh;
  108571. controller: WebVRController;
  108572. }>;
  108573. /**
  108574. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108575. */
  108576. onNewMeshPicked: Observable<PickingInfo>;
  108577. private _circleEase;
  108578. /**
  108579. * Observable raised before camera teleportation
  108580. */
  108581. onBeforeCameraTeleport: Observable<Vector3>;
  108582. /**
  108583. * Observable raised after camera teleportation
  108584. */
  108585. onAfterCameraTeleport: Observable<Vector3>;
  108586. /**
  108587. * Observable raised when current selected mesh gets unselected
  108588. */
  108589. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108590. private _raySelectionPredicate;
  108591. /**
  108592. * To be optionaly changed by user to define custom ray selection
  108593. */
  108594. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108595. /**
  108596. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108597. */
  108598. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108599. /**
  108600. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108601. */
  108602. teleportationEnabled: boolean;
  108603. private _defaultHeight;
  108604. private _teleportationInitialized;
  108605. private _interactionsEnabled;
  108606. private _interactionsRequested;
  108607. private _displayGaze;
  108608. private _displayLaserPointer;
  108609. /**
  108610. * The mesh used to display where the user is going to teleport.
  108611. */
  108612. /**
  108613. * Sets the mesh to be used to display where the user is going to teleport.
  108614. */
  108615. teleportationTarget: Mesh;
  108616. /**
  108617. * 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
  108618. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108619. * See http://doc.babylonjs.com/resources/baking_transformations
  108620. */
  108621. gazeTrackerMesh: Mesh;
  108622. /**
  108623. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108624. */
  108625. updateGazeTrackerScale: boolean;
  108626. /**
  108627. * If the gaze trackers color should be updated when selecting meshes
  108628. */
  108629. updateGazeTrackerColor: boolean;
  108630. /**
  108631. * If the controller laser color should be updated when selecting meshes
  108632. */
  108633. updateControllerLaserColor: boolean;
  108634. /**
  108635. * The gaze tracking mesh corresponding to the left controller
  108636. */
  108637. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108638. /**
  108639. * The gaze tracking mesh corresponding to the right controller
  108640. */
  108641. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108642. /**
  108643. * If the ray of the gaze should be displayed.
  108644. */
  108645. /**
  108646. * Sets if the ray of the gaze should be displayed.
  108647. */
  108648. displayGaze: boolean;
  108649. /**
  108650. * If the ray of the LaserPointer should be displayed.
  108651. */
  108652. /**
  108653. * Sets if the ray of the LaserPointer should be displayed.
  108654. */
  108655. displayLaserPointer: boolean;
  108656. /**
  108657. * The deviceOrientationCamera used as the camera when not in VR.
  108658. */
  108659. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108660. /**
  108661. * Based on the current WebVR support, returns the current VR camera used.
  108662. */
  108663. readonly currentVRCamera: Nullable<Camera>;
  108664. /**
  108665. * The webVRCamera which is used when in VR.
  108666. */
  108667. readonly webVRCamera: WebVRFreeCamera;
  108668. /**
  108669. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108670. */
  108671. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108672. /**
  108673. * The html button that is used to trigger entering into VR.
  108674. */
  108675. readonly vrButton: Nullable<HTMLButtonElement>;
  108676. private readonly _teleportationRequestInitiated;
  108677. /**
  108678. * Defines wether or not Pointer lock should be requested when switching to
  108679. * full screen.
  108680. */
  108681. requestPointerLockOnFullScreen: boolean;
  108682. /**
  108683. * Instantiates a VRExperienceHelper.
  108684. * Helps to quickly add VR support to an existing scene.
  108685. * @param scene The scene the VRExperienceHelper belongs to.
  108686. * @param webVROptions Options to modify the vr experience helper's behavior.
  108687. */
  108688. constructor(scene: Scene,
  108689. /** Options to modify the vr experience helper's behavior. */
  108690. webVROptions?: VRExperienceHelperOptions);
  108691. private _onDefaultMeshLoaded;
  108692. private _onResize;
  108693. private _onFullscreenChange;
  108694. /**
  108695. * Gets a value indicating if we are currently in VR mode.
  108696. */
  108697. readonly isInVRMode: boolean;
  108698. private onVrDisplayPresentChange;
  108699. private onVRDisplayChanged;
  108700. private moveButtonToBottomRight;
  108701. private displayVRButton;
  108702. private updateButtonVisibility;
  108703. private _cachedAngularSensibility;
  108704. /**
  108705. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108706. * Otherwise, will use the fullscreen API.
  108707. */
  108708. enterVR(): void;
  108709. /**
  108710. * Attempt to exit VR, or fullscreen.
  108711. */
  108712. exitVR(): void;
  108713. /**
  108714. * The position of the vr experience helper.
  108715. */
  108716. /**
  108717. * Sets the position of the vr experience helper.
  108718. */
  108719. position: Vector3;
  108720. /**
  108721. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108722. */
  108723. enableInteractions(): void;
  108724. private readonly _noControllerIsActive;
  108725. private beforeRender;
  108726. private _isTeleportationFloor;
  108727. /**
  108728. * Adds a floor mesh to be used for teleportation.
  108729. * @param floorMesh the mesh to be used for teleportation.
  108730. */
  108731. addFloorMesh(floorMesh: Mesh): void;
  108732. /**
  108733. * Removes a floor mesh from being used for teleportation.
  108734. * @param floorMesh the mesh to be removed.
  108735. */
  108736. removeFloorMesh(floorMesh: Mesh): void;
  108737. /**
  108738. * Enables interactions and teleportation using the VR controllers and gaze.
  108739. * @param vrTeleportationOptions options to modify teleportation behavior.
  108740. */
  108741. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108742. private _onNewGamepadConnected;
  108743. private _tryEnableInteractionOnController;
  108744. private _onNewGamepadDisconnected;
  108745. private _enableInteractionOnController;
  108746. private _checkTeleportWithRay;
  108747. private _checkRotate;
  108748. private _checkTeleportBackwards;
  108749. private _enableTeleportationOnController;
  108750. private _createTeleportationCircles;
  108751. private _displayTeleportationTarget;
  108752. private _hideTeleportationTarget;
  108753. private _rotateCamera;
  108754. private _moveTeleportationSelectorTo;
  108755. private _workingVector;
  108756. private _workingQuaternion;
  108757. private _workingMatrix;
  108758. /**
  108759. * Teleports the users feet to the desired location
  108760. * @param location The location where the user's feet should be placed
  108761. */
  108762. teleportCamera(location: Vector3): void;
  108763. private _convertNormalToDirectionOfRay;
  108764. private _castRayAndSelectObject;
  108765. private _notifySelectedMeshUnselected;
  108766. /**
  108767. * Sets the color of the laser ray from the vr controllers.
  108768. * @param color new color for the ray.
  108769. */
  108770. changeLaserColor(color: Color3): void;
  108771. /**
  108772. * Sets the color of the ray from the vr headsets gaze.
  108773. * @param color new color for the ray.
  108774. */
  108775. changeGazeColor(color: Color3): void;
  108776. /**
  108777. * Exits VR and disposes of the vr experience helper
  108778. */
  108779. dispose(): void;
  108780. /**
  108781. * Gets the name of the VRExperienceHelper class
  108782. * @returns "VRExperienceHelper"
  108783. */
  108784. getClassName(): string;
  108785. }
  108786. }
  108787. declare module BABYLON {
  108788. /**
  108789. * Manages an XRSession to work with Babylon's engine
  108790. * @see https://doc.babylonjs.com/how_to/webxr
  108791. */
  108792. export class WebXRSessionManager implements IDisposable {
  108793. private scene;
  108794. /**
  108795. * Fires every time a new xrFrame arrives which can be used to update the camera
  108796. */
  108797. onXRFrameObservable: Observable<any>;
  108798. /**
  108799. * Fires when the xr session is ended either by the device or manually done
  108800. */
  108801. onXRSessionEnded: Observable<any>;
  108802. /**
  108803. * Underlying xr session
  108804. */
  108805. session: XRSession;
  108806. /**
  108807. * Type of reference space used when creating the session
  108808. */
  108809. referenceSpace: XRReferenceSpace;
  108810. /** @hidden */
  108811. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108812. /**
  108813. * Current XR frame
  108814. */
  108815. currentFrame: Nullable<XRFrame>;
  108816. private _xrNavigator;
  108817. private baseLayer;
  108818. /**
  108819. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108820. * @param scene The scene which the session should be created for
  108821. */
  108822. constructor(scene: Scene);
  108823. /**
  108824. * Initializes the manager
  108825. * After initialization enterXR can be called to start an XR session
  108826. * @returns Promise which resolves after it is initialized
  108827. */
  108828. initializeAsync(): Promise<void>;
  108829. /**
  108830. * Initializes an xr session
  108831. * @param xrSessionMode mode to initialize
  108832. * @returns a promise which will resolve once the session has been initialized
  108833. */
  108834. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108835. /**
  108836. * Sets the reference space on the xr session
  108837. * @param referenceSpace space to set
  108838. * @returns a promise that will resolve once the reference space has been set
  108839. */
  108840. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108841. /**
  108842. * Updates the render state of the session
  108843. * @param state state to set
  108844. * @returns a promise that resolves once the render state has been updated
  108845. */
  108846. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108847. /**
  108848. * Starts rendering to the xr layer
  108849. * @returns a promise that will resolve once rendering has started
  108850. */
  108851. startRenderingToXRAsync(): Promise<void>;
  108852. /**
  108853. * Stops the xrSession and restores the renderloop
  108854. * @returns Promise which resolves after it exits XR
  108855. */
  108856. exitXRAsync(): Promise<unknown>;
  108857. /**
  108858. * Checks if a session would be supported for the creation options specified
  108859. * @param sessionMode session mode to check if supported eg. immersive-vr
  108860. * @returns true if supported
  108861. */
  108862. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108863. /**
  108864. * @hidden
  108865. * Converts the render layer of xrSession to a render target
  108866. * @param session session to create render target for
  108867. * @param scene scene the new render target should be created for
  108868. */
  108869. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108870. /**
  108871. * Disposes of the session manager
  108872. */
  108873. dispose(): void;
  108874. }
  108875. }
  108876. declare module BABYLON {
  108877. /**
  108878. * WebXR Camera which holds the views for the xrSession
  108879. * @see https://doc.babylonjs.com/how_to/webxr
  108880. */
  108881. export class WebXRCamera extends FreeCamera {
  108882. private static _TmpMatrix;
  108883. /**
  108884. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108885. * @param name the name of the camera
  108886. * @param scene the scene to add the camera to
  108887. */
  108888. constructor(name: string, scene: Scene);
  108889. private _updateNumberOfRigCameras;
  108890. /** @hidden */
  108891. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108892. /**
  108893. * Updates the cameras position from the current pose information of the XR session
  108894. * @param xrSessionManager the session containing pose information
  108895. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108896. */
  108897. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108898. }
  108899. }
  108900. declare module BABYLON {
  108901. /**
  108902. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108903. */
  108904. export class WebXRManagedOutputCanvas implements IDisposable {
  108905. private helper;
  108906. private _canvas;
  108907. /**
  108908. * xrpresent context of the canvas which can be used to display/mirror xr content
  108909. */
  108910. canvasContext: WebGLRenderingContext;
  108911. /**
  108912. * xr layer for the canvas
  108913. */
  108914. xrLayer: Nullable<XRWebGLLayer>;
  108915. /**
  108916. * Initializes the xr layer for the session
  108917. * @param xrSession xr session
  108918. * @returns a promise that will resolve once the XR Layer has been created
  108919. */
  108920. initializeXRLayerAsync(xrSession: any): any;
  108921. /**
  108922. * Initializes the canvas to be added/removed upon entering/exiting xr
  108923. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108924. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108925. */
  108926. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108927. /**
  108928. * Disposes of the object
  108929. */
  108930. dispose(): void;
  108931. private _setManagedOutputCanvas;
  108932. private _addCanvas;
  108933. private _removeCanvas;
  108934. }
  108935. }
  108936. declare module BABYLON {
  108937. /**
  108938. * States of the webXR experience
  108939. */
  108940. export enum WebXRState {
  108941. /**
  108942. * Transitioning to being in XR mode
  108943. */
  108944. ENTERING_XR = 0,
  108945. /**
  108946. * Transitioning to non XR mode
  108947. */
  108948. EXITING_XR = 1,
  108949. /**
  108950. * In XR mode and presenting
  108951. */
  108952. IN_XR = 2,
  108953. /**
  108954. * Not entered XR mode
  108955. */
  108956. NOT_IN_XR = 3
  108957. }
  108958. /**
  108959. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108960. * @see https://doc.babylonjs.com/how_to/webxr
  108961. */
  108962. export class WebXRExperienceHelper implements IDisposable {
  108963. private scene;
  108964. /**
  108965. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  108966. */
  108967. container: AbstractMesh;
  108968. /**
  108969. * Camera used to render xr content
  108970. */
  108971. camera: WebXRCamera;
  108972. /**
  108973. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108974. */
  108975. state: WebXRState;
  108976. private _setState;
  108977. private static _TmpVector;
  108978. /**
  108979. * Fires when the state of the experience helper has changed
  108980. */
  108981. onStateChangedObservable: Observable<WebXRState>;
  108982. /** Session manager used to keep track of xr session */
  108983. sessionManager: WebXRSessionManager;
  108984. private _nonVRCamera;
  108985. private _originalSceneAutoClear;
  108986. private _supported;
  108987. /**
  108988. * Creates the experience helper
  108989. * @param scene the scene to attach the experience helper to
  108990. * @returns a promise for the experience helper
  108991. */
  108992. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108993. /**
  108994. * Creates a WebXRExperienceHelper
  108995. * @param scene The scene the helper should be created in
  108996. */
  108997. private constructor();
  108998. /**
  108999. * Exits XR mode and returns the scene to its original state
  109000. * @returns promise that resolves after xr mode has exited
  109001. */
  109002. exitXRAsync(): Promise<unknown>;
  109003. /**
  109004. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109005. * @param sessionCreationOptions options for the XR session
  109006. * @param referenceSpaceType frame of reference of the XR session
  109007. * @param outputCanvas the output canvas that will be used to enter XR mode
  109008. * @returns promise that resolves after xr mode has entered
  109009. */
  109010. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  109011. /**
  109012. * Updates the global position of the camera by moving the camera's container
  109013. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109014. * @param position The desired global position of the camera
  109015. */
  109016. setPositionOfCameraUsingContainer(position: Vector3): void;
  109017. /**
  109018. * Rotates the xr camera by rotating the camera's container around the camera's position
  109019. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109020. * @param rotation the desired quaternion rotation to apply to the camera
  109021. */
  109022. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109023. /**
  109024. * Disposes of the experience helper
  109025. */
  109026. dispose(): void;
  109027. }
  109028. }
  109029. declare module BABYLON {
  109030. /**
  109031. * Button which can be used to enter a different mode of XR
  109032. */
  109033. export class WebXREnterExitUIButton {
  109034. /** button element */
  109035. element: HTMLElement;
  109036. /** XR initialization options for the button */
  109037. sessionMode: XRSessionMode;
  109038. /** Reference space type */
  109039. referenceSpaceType: XRReferenceSpaceType;
  109040. /**
  109041. * Creates a WebXREnterExitUIButton
  109042. * @param element button element
  109043. * @param sessionMode XR initialization session mode
  109044. * @param referenceSpaceType the type of reference space to be used
  109045. */
  109046. constructor(
  109047. /** button element */
  109048. element: HTMLElement,
  109049. /** XR initialization options for the button */
  109050. sessionMode: XRSessionMode,
  109051. /** Reference space type */
  109052. referenceSpaceType: XRReferenceSpaceType);
  109053. /**
  109054. * Overwritable function which can be used to update the button's visuals when the state changes
  109055. * @param activeButton the current active button in the UI
  109056. */
  109057. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109058. }
  109059. /**
  109060. * Options to create the webXR UI
  109061. */
  109062. export class WebXREnterExitUIOptions {
  109063. /**
  109064. * Context to enter xr with
  109065. */
  109066. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  109067. /**
  109068. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109069. */
  109070. customButtons?: Array<WebXREnterExitUIButton>;
  109071. }
  109072. /**
  109073. * UI to allow the user to enter/exit XR mode
  109074. */
  109075. export class WebXREnterExitUI implements IDisposable {
  109076. private scene;
  109077. private _overlay;
  109078. private _buttons;
  109079. private _activeButton;
  109080. /**
  109081. * Fired every time the active button is changed.
  109082. *
  109083. * When xr is entered via a button that launches xr that button will be the callback parameter
  109084. *
  109085. * When exiting xr the callback parameter will be null)
  109086. */
  109087. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109088. /**
  109089. * Creates UI to allow the user to enter/exit XR mode
  109090. * @param scene the scene to add the ui to
  109091. * @param helper the xr experience helper to enter/exit xr with
  109092. * @param options options to configure the UI
  109093. * @returns the created ui
  109094. */
  109095. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109096. private constructor();
  109097. private _updateButtons;
  109098. /**
  109099. * Disposes of the object
  109100. */
  109101. dispose(): void;
  109102. }
  109103. }
  109104. declare module BABYLON {
  109105. /**
  109106. * Represents an XR input
  109107. */
  109108. export class WebXRController {
  109109. private scene;
  109110. /** The underlying input source for the controller */
  109111. inputSource: XRInputSource;
  109112. private parentContainer;
  109113. /**
  109114. * 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
  109115. */
  109116. grip?: AbstractMesh;
  109117. /**
  109118. * Pointer which can be used to select objects or attach a visible laser to
  109119. */
  109120. pointer: AbstractMesh;
  109121. /**
  109122. * Event that fires when the controller is removed/disposed
  109123. */
  109124. onDisposeObservable: Observable<{}>;
  109125. private _tmpMatrix;
  109126. private _tmpQuaternion;
  109127. private _tmpVector;
  109128. /**
  109129. * Creates the controller
  109130. * @see https://doc.babylonjs.com/how_to/webxr
  109131. * @param scene the scene which the controller should be associated to
  109132. * @param inputSource the underlying input source for the controller
  109133. * @param parentContainer parent that the controller meshes should be children of
  109134. */
  109135. constructor(scene: Scene,
  109136. /** The underlying input source for the controller */
  109137. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109138. /**
  109139. * Updates the controller pose based on the given XRFrame
  109140. * @param xrFrame xr frame to update the pose with
  109141. * @param referenceSpace reference space to use
  109142. */
  109143. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109144. /**
  109145. * Gets a world space ray coming from the controller
  109146. * @param result the resulting ray
  109147. */
  109148. getWorldPointerRayToRef(result: Ray): void;
  109149. /**
  109150. * Disposes of the object
  109151. */
  109152. dispose(): void;
  109153. }
  109154. }
  109155. declare module BABYLON {
  109156. /**
  109157. * XR input used to track XR inputs such as controllers/rays
  109158. */
  109159. export class WebXRInput implements IDisposable {
  109160. /**
  109161. * Base experience the input listens to
  109162. */
  109163. baseExperience: WebXRExperienceHelper;
  109164. /**
  109165. * XR controllers being tracked
  109166. */
  109167. controllers: Array<WebXRController>;
  109168. private _frameObserver;
  109169. private _stateObserver;
  109170. /**
  109171. * Event when a controller has been connected/added
  109172. */
  109173. onControllerAddedObservable: Observable<WebXRController>;
  109174. /**
  109175. * Event when a controller has been removed/disconnected
  109176. */
  109177. onControllerRemovedObservable: Observable<WebXRController>;
  109178. /**
  109179. * Initializes the WebXRInput
  109180. * @param baseExperience experience helper which the input should be created for
  109181. */
  109182. constructor(
  109183. /**
  109184. * Base experience the input listens to
  109185. */
  109186. baseExperience: WebXRExperienceHelper);
  109187. private _onInputSourcesChange;
  109188. private _addAndRemoveControllers;
  109189. /**
  109190. * Disposes of the object
  109191. */
  109192. dispose(): void;
  109193. }
  109194. }
  109195. declare module BABYLON {
  109196. /**
  109197. * Enables teleportation
  109198. */
  109199. export class WebXRControllerTeleportation {
  109200. private _teleportationFillColor;
  109201. private _teleportationBorderColor;
  109202. private _tmpRay;
  109203. private _tmpVector;
  109204. /**
  109205. * Creates a WebXRControllerTeleportation
  109206. * @param input input manager to add teleportation to
  109207. * @param floorMeshes floormeshes which can be teleported to
  109208. */
  109209. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109210. }
  109211. }
  109212. declare module BABYLON {
  109213. /**
  109214. * Handles pointer input automatically for the pointer of XR controllers
  109215. */
  109216. export class WebXRControllerPointerSelection {
  109217. private static _idCounter;
  109218. private _tmpRay;
  109219. /**
  109220. * Creates a WebXRControllerPointerSelection
  109221. * @param input input manager to setup pointer selection
  109222. */
  109223. constructor(input: WebXRInput);
  109224. private _convertNormalToDirectionOfRay;
  109225. private _updatePointerDistance;
  109226. }
  109227. }
  109228. declare module BABYLON {
  109229. /**
  109230. * Class used to represent data loading progression
  109231. */
  109232. export class SceneLoaderProgressEvent {
  109233. /** defines if data length to load can be evaluated */
  109234. readonly lengthComputable: boolean;
  109235. /** defines the loaded data length */
  109236. readonly loaded: number;
  109237. /** defines the data length to load */
  109238. readonly total: number;
  109239. /**
  109240. * Create a new progress event
  109241. * @param lengthComputable defines if data length to load can be evaluated
  109242. * @param loaded defines the loaded data length
  109243. * @param total defines the data length to load
  109244. */
  109245. constructor(
  109246. /** defines if data length to load can be evaluated */
  109247. lengthComputable: boolean,
  109248. /** defines the loaded data length */
  109249. loaded: number,
  109250. /** defines the data length to load */
  109251. total: number);
  109252. /**
  109253. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109254. * @param event defines the source event
  109255. * @returns a new SceneLoaderProgressEvent
  109256. */
  109257. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109258. }
  109259. /**
  109260. * Interface used by SceneLoader plugins to define supported file extensions
  109261. */
  109262. export interface ISceneLoaderPluginExtensions {
  109263. /**
  109264. * Defines the list of supported extensions
  109265. */
  109266. [extension: string]: {
  109267. isBinary: boolean;
  109268. };
  109269. }
  109270. /**
  109271. * Interface used by SceneLoader plugin factory
  109272. */
  109273. export interface ISceneLoaderPluginFactory {
  109274. /**
  109275. * Defines the name of the factory
  109276. */
  109277. name: string;
  109278. /**
  109279. * Function called to create a new plugin
  109280. * @return the new plugin
  109281. */
  109282. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109283. /**
  109284. * Boolean indicating if the plugin can direct load specific data
  109285. */
  109286. canDirectLoad?: (data: string) => boolean;
  109287. }
  109288. /**
  109289. * Interface used to define a SceneLoader plugin
  109290. */
  109291. export interface ISceneLoaderPlugin {
  109292. /**
  109293. * The friendly name of this plugin.
  109294. */
  109295. name: string;
  109296. /**
  109297. * The file extensions supported by this plugin.
  109298. */
  109299. extensions: string | ISceneLoaderPluginExtensions;
  109300. /**
  109301. * Import meshes into a scene.
  109302. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109303. * @param scene The scene to import into
  109304. * @param data The data to import
  109305. * @param rootUrl The root url for scene and resources
  109306. * @param meshes The meshes array to import into
  109307. * @param particleSystems The particle systems array to import into
  109308. * @param skeletons The skeletons array to import into
  109309. * @param onError The callback when import fails
  109310. * @returns True if successful or false otherwise
  109311. */
  109312. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109313. /**
  109314. * Load into a scene.
  109315. * @param scene The scene to load into
  109316. * @param data The data to import
  109317. * @param rootUrl The root url for scene and resources
  109318. * @param onError The callback when import fails
  109319. * @returns true if successful or false otherwise
  109320. */
  109321. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109322. /**
  109323. * The callback that returns true if the data can be directly loaded.
  109324. */
  109325. canDirectLoad?: (data: string) => boolean;
  109326. /**
  109327. * The callback that allows custom handling of the root url based on the response url.
  109328. */
  109329. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109330. /**
  109331. * Load into an asset container.
  109332. * @param scene The scene to load into
  109333. * @param data The data to import
  109334. * @param rootUrl The root url for scene and resources
  109335. * @param onError The callback when import fails
  109336. * @returns The loaded asset container
  109337. */
  109338. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109339. }
  109340. /**
  109341. * Interface used to define an async SceneLoader plugin
  109342. */
  109343. export interface ISceneLoaderPluginAsync {
  109344. /**
  109345. * The friendly name of this plugin.
  109346. */
  109347. name: string;
  109348. /**
  109349. * The file extensions supported by this plugin.
  109350. */
  109351. extensions: string | ISceneLoaderPluginExtensions;
  109352. /**
  109353. * Import meshes into a scene.
  109354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109355. * @param scene The scene to import into
  109356. * @param data The data to import
  109357. * @param rootUrl The root url for scene and resources
  109358. * @param onProgress The callback when the load progresses
  109359. * @param fileName Defines the name of the file to load
  109360. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109361. */
  109362. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109363. meshes: AbstractMesh[];
  109364. particleSystems: IParticleSystem[];
  109365. skeletons: Skeleton[];
  109366. animationGroups: AnimationGroup[];
  109367. }>;
  109368. /**
  109369. * Load into a scene.
  109370. * @param scene The scene to load into
  109371. * @param data The data to import
  109372. * @param rootUrl The root url for scene and resources
  109373. * @param onProgress The callback when the load progresses
  109374. * @param fileName Defines the name of the file to load
  109375. * @returns Nothing
  109376. */
  109377. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109378. /**
  109379. * The callback that returns true if the data can be directly loaded.
  109380. */
  109381. canDirectLoad?: (data: string) => boolean;
  109382. /**
  109383. * The callback that allows custom handling of the root url based on the response url.
  109384. */
  109385. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109386. /**
  109387. * Load into an asset container.
  109388. * @param scene The scene to load into
  109389. * @param data The data to import
  109390. * @param rootUrl The root url for scene and resources
  109391. * @param onProgress The callback when the load progresses
  109392. * @param fileName Defines the name of the file to load
  109393. * @returns The loaded asset container
  109394. */
  109395. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109396. }
  109397. /**
  109398. * Class used to load scene from various file formats using registered plugins
  109399. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109400. */
  109401. export class SceneLoader {
  109402. /**
  109403. * No logging while loading
  109404. */
  109405. static readonly NO_LOGGING: number;
  109406. /**
  109407. * Minimal logging while loading
  109408. */
  109409. static readonly MINIMAL_LOGGING: number;
  109410. /**
  109411. * Summary logging while loading
  109412. */
  109413. static readonly SUMMARY_LOGGING: number;
  109414. /**
  109415. * Detailled logging while loading
  109416. */
  109417. static readonly DETAILED_LOGGING: number;
  109418. /**
  109419. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109420. */
  109421. static ForceFullSceneLoadingForIncremental: boolean;
  109422. /**
  109423. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109424. */
  109425. static ShowLoadingScreen: boolean;
  109426. /**
  109427. * Defines the current logging level (while loading the scene)
  109428. * @ignorenaming
  109429. */
  109430. static loggingLevel: number;
  109431. /**
  109432. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109433. */
  109434. static CleanBoneMatrixWeights: boolean;
  109435. /**
  109436. * Event raised when a plugin is used to load a scene
  109437. */
  109438. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109439. private static _registeredPlugins;
  109440. private static _getDefaultPlugin;
  109441. private static _getPluginForExtension;
  109442. private static _getPluginForDirectLoad;
  109443. private static _getPluginForFilename;
  109444. private static _getDirectLoad;
  109445. private static _loadData;
  109446. private static _getFileInfo;
  109447. /**
  109448. * Gets a plugin that can load the given extension
  109449. * @param extension defines the extension to load
  109450. * @returns a plugin or null if none works
  109451. */
  109452. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109453. /**
  109454. * Gets a boolean indicating that the given extension can be loaded
  109455. * @param extension defines the extension to load
  109456. * @returns true if the extension is supported
  109457. */
  109458. static IsPluginForExtensionAvailable(extension: string): boolean;
  109459. /**
  109460. * Adds a new plugin to the list of registered plugins
  109461. * @param plugin defines the plugin to add
  109462. */
  109463. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109464. /**
  109465. * Import meshes into a scene
  109466. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109467. * @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)
  109468. * @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)
  109469. * @param scene the instance of BABYLON.Scene to append to
  109470. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109471. * @param onProgress a callback with a progress event for each file being loaded
  109472. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109473. * @param pluginExtension the extension used to determine the plugin
  109474. * @returns The loaded plugin
  109475. */
  109476. 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>;
  109477. /**
  109478. * Import meshes into a scene
  109479. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109480. * @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)
  109481. * @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)
  109482. * @param scene the instance of BABYLON.Scene to append to
  109483. * @param onProgress a callback with a progress event for each file being loaded
  109484. * @param pluginExtension the extension used to determine the plugin
  109485. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109486. */
  109487. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109488. meshes: AbstractMesh[];
  109489. particleSystems: IParticleSystem[];
  109490. skeletons: Skeleton[];
  109491. animationGroups: AnimationGroup[];
  109492. }>;
  109493. /**
  109494. * Load a scene
  109495. * @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)
  109496. * @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)
  109497. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109498. * @param onSuccess a callback with the scene when import succeeds
  109499. * @param onProgress a callback with a progress event for each file being loaded
  109500. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109501. * @param pluginExtension the extension used to determine the plugin
  109502. * @returns The loaded plugin
  109503. */
  109504. 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>;
  109505. /**
  109506. * Load a scene
  109507. * @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)
  109508. * @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)
  109509. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109510. * @param onProgress a callback with a progress event for each file being loaded
  109511. * @param pluginExtension the extension used to determine the plugin
  109512. * @returns The loaded scene
  109513. */
  109514. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109515. /**
  109516. * Append a scene
  109517. * @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)
  109518. * @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)
  109519. * @param scene is the instance of BABYLON.Scene to append to
  109520. * @param onSuccess a callback with the scene when import succeeds
  109521. * @param onProgress a callback with a progress event for each file being loaded
  109522. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109523. * @param pluginExtension the extension used to determine the plugin
  109524. * @returns The loaded plugin
  109525. */
  109526. 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>;
  109527. /**
  109528. * Append a scene
  109529. * @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)
  109530. * @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)
  109531. * @param scene is the instance of BABYLON.Scene to append to
  109532. * @param onProgress a callback with a progress event for each file being loaded
  109533. * @param pluginExtension the extension used to determine the plugin
  109534. * @returns The given scene
  109535. */
  109536. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109537. /**
  109538. * Load a scene into an asset container
  109539. * @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)
  109540. * @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)
  109541. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109542. * @param onSuccess a callback with the scene when import succeeds
  109543. * @param onProgress a callback with a progress event for each file being loaded
  109544. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109545. * @param pluginExtension the extension used to determine the plugin
  109546. * @returns The loaded plugin
  109547. */
  109548. 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>;
  109549. /**
  109550. * Load a scene into an asset container
  109551. * @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)
  109552. * @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)
  109553. * @param scene is the instance of Scene to append to
  109554. * @param onProgress a callback with a progress event for each file being loaded
  109555. * @param pluginExtension the extension used to determine the plugin
  109556. * @returns The loaded asset container
  109557. */
  109558. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109559. }
  109560. }
  109561. declare module BABYLON {
  109562. /**
  109563. * Generic Controller
  109564. */
  109565. export class GenericController extends WebVRController {
  109566. /**
  109567. * Base Url for the controller model.
  109568. */
  109569. static readonly MODEL_BASE_URL: string;
  109570. /**
  109571. * File name for the controller model.
  109572. */
  109573. static readonly MODEL_FILENAME: string;
  109574. /**
  109575. * Creates a new GenericController from a gamepad
  109576. * @param vrGamepad the gamepad that the controller should be created from
  109577. */
  109578. constructor(vrGamepad: any);
  109579. /**
  109580. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109581. * @param scene scene in which to add meshes
  109582. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109583. */
  109584. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109585. /**
  109586. * Called once for each button that changed state since the last frame
  109587. * @param buttonIdx Which button index changed
  109588. * @param state New state of the button
  109589. * @param changes Which properties on the state changed since last frame
  109590. */
  109591. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109592. }
  109593. }
  109594. declare module BABYLON {
  109595. /**
  109596. * Defines the WindowsMotionController object that the state of the windows motion controller
  109597. */
  109598. export class WindowsMotionController extends WebVRController {
  109599. /**
  109600. * The base url used to load the left and right controller models
  109601. */
  109602. static MODEL_BASE_URL: string;
  109603. /**
  109604. * The name of the left controller model file
  109605. */
  109606. static MODEL_LEFT_FILENAME: string;
  109607. /**
  109608. * The name of the right controller model file
  109609. */
  109610. static MODEL_RIGHT_FILENAME: string;
  109611. /**
  109612. * The controller name prefix for this controller type
  109613. */
  109614. static readonly GAMEPAD_ID_PREFIX: string;
  109615. /**
  109616. * The controller id pattern for this controller type
  109617. */
  109618. private static readonly GAMEPAD_ID_PATTERN;
  109619. private _loadedMeshInfo;
  109620. private readonly _mapping;
  109621. /**
  109622. * Fired when the trackpad on this controller is clicked
  109623. */
  109624. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109625. /**
  109626. * Fired when the trackpad on this controller is modified
  109627. */
  109628. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109629. /**
  109630. * The current x and y values of this controller's trackpad
  109631. */
  109632. trackpad: StickValues;
  109633. /**
  109634. * Creates a new WindowsMotionController from a gamepad
  109635. * @param vrGamepad the gamepad that the controller should be created from
  109636. */
  109637. constructor(vrGamepad: any);
  109638. /**
  109639. * Fired when the trigger on this controller is modified
  109640. */
  109641. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109642. /**
  109643. * Fired when the menu button on this controller is modified
  109644. */
  109645. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109646. /**
  109647. * Fired when the grip button on this controller is modified
  109648. */
  109649. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109650. /**
  109651. * Fired when the thumbstick button on this controller is modified
  109652. */
  109653. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109654. /**
  109655. * Fired when the touchpad button on this controller is modified
  109656. */
  109657. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109658. /**
  109659. * Fired when the touchpad values on this controller are modified
  109660. */
  109661. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109662. private _updateTrackpad;
  109663. /**
  109664. * Called once per frame by the engine.
  109665. */
  109666. update(): void;
  109667. /**
  109668. * Called once for each button that changed state since the last frame
  109669. * @param buttonIdx Which button index changed
  109670. * @param state New state of the button
  109671. * @param changes Which properties on the state changed since last frame
  109672. */
  109673. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109674. /**
  109675. * Moves the buttons on the controller mesh based on their current state
  109676. * @param buttonName the name of the button to move
  109677. * @param buttonValue the value of the button which determines the buttons new position
  109678. */
  109679. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109680. /**
  109681. * Moves the axis on the controller mesh based on its current state
  109682. * @param axis the index of the axis
  109683. * @param axisValue the value of the axis which determines the meshes new position
  109684. * @hidden
  109685. */
  109686. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109687. /**
  109688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109689. * @param scene scene in which to add meshes
  109690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109691. */
  109692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109693. /**
  109694. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109695. * can be transformed by button presses and axes values, based on this._mapping.
  109696. *
  109697. * @param scene scene in which the meshes exist
  109698. * @param meshes list of meshes that make up the controller model to process
  109699. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109700. */
  109701. private processModel;
  109702. private createMeshInfo;
  109703. /**
  109704. * Gets the ray of the controller in the direction the controller is pointing
  109705. * @param length the length the resulting ray should be
  109706. * @returns a ray in the direction the controller is pointing
  109707. */
  109708. getForwardRay(length?: number): Ray;
  109709. /**
  109710. * Disposes of the controller
  109711. */
  109712. dispose(): void;
  109713. }
  109714. }
  109715. declare module BABYLON {
  109716. /**
  109717. * Oculus Touch Controller
  109718. */
  109719. export class OculusTouchController extends WebVRController {
  109720. /**
  109721. * Base Url for the controller model.
  109722. */
  109723. static MODEL_BASE_URL: string;
  109724. /**
  109725. * File name for the left controller model.
  109726. */
  109727. static MODEL_LEFT_FILENAME: string;
  109728. /**
  109729. * File name for the right controller model.
  109730. */
  109731. static MODEL_RIGHT_FILENAME: string;
  109732. /**
  109733. * Base Url for the Quest controller model.
  109734. */
  109735. static QUEST_MODEL_BASE_URL: string;
  109736. /**
  109737. * @hidden
  109738. * If the controllers are running on a device that needs the updated Quest controller models
  109739. */
  109740. static _IsQuest: boolean;
  109741. /**
  109742. * Fired when the secondary trigger on this controller is modified
  109743. */
  109744. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109745. /**
  109746. * Fired when the thumb rest on this controller is modified
  109747. */
  109748. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109749. /**
  109750. * Creates a new OculusTouchController from a gamepad
  109751. * @param vrGamepad the gamepad that the controller should be created from
  109752. */
  109753. constructor(vrGamepad: any);
  109754. /**
  109755. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109756. * @param scene scene in which to add meshes
  109757. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109758. */
  109759. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109760. /**
  109761. * Fired when the A button on this controller is modified
  109762. */
  109763. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109764. /**
  109765. * Fired when the B button on this controller is modified
  109766. */
  109767. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109768. /**
  109769. * Fired when the X button on this controller is modified
  109770. */
  109771. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109772. /**
  109773. * Fired when the Y button on this controller is modified
  109774. */
  109775. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109776. /**
  109777. * Called once for each button that changed state since the last frame
  109778. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109779. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109780. * 2) secondary trigger (same)
  109781. * 3) A (right) X (left), touch, pressed = value
  109782. * 4) B / Y
  109783. * 5) thumb rest
  109784. * @param buttonIdx Which button index changed
  109785. * @param state New state of the button
  109786. * @param changes Which properties on the state changed since last frame
  109787. */
  109788. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109789. }
  109790. }
  109791. declare module BABYLON {
  109792. /**
  109793. * Vive Controller
  109794. */
  109795. export class ViveController extends WebVRController {
  109796. /**
  109797. * Base Url for the controller model.
  109798. */
  109799. static MODEL_BASE_URL: string;
  109800. /**
  109801. * File name for the controller model.
  109802. */
  109803. static MODEL_FILENAME: string;
  109804. /**
  109805. * Creates a new ViveController from a gamepad
  109806. * @param vrGamepad the gamepad that the controller should be created from
  109807. */
  109808. constructor(vrGamepad: any);
  109809. /**
  109810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109811. * @param scene scene in which to add meshes
  109812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109813. */
  109814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109815. /**
  109816. * Fired when the left button on this controller is modified
  109817. */
  109818. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109819. /**
  109820. * Fired when the right button on this controller is modified
  109821. */
  109822. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109823. /**
  109824. * Fired when the menu button on this controller is modified
  109825. */
  109826. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109827. /**
  109828. * Called once for each button that changed state since the last frame
  109829. * Vive mapping:
  109830. * 0: touchpad
  109831. * 1: trigger
  109832. * 2: left AND right buttons
  109833. * 3: menu button
  109834. * @param buttonIdx Which button index changed
  109835. * @param state New state of the button
  109836. * @param changes Which properties on the state changed since last frame
  109837. */
  109838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109839. }
  109840. }
  109841. declare module BABYLON {
  109842. /**
  109843. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109844. */
  109845. export class WebXRControllerModelLoader {
  109846. /**
  109847. * Creates the WebXRControllerModelLoader
  109848. * @param input xr input that creates the controllers
  109849. */
  109850. constructor(input: WebXRInput);
  109851. }
  109852. }
  109853. declare module BABYLON {
  109854. /**
  109855. * Contains an array of blocks representing the octree
  109856. */
  109857. export interface IOctreeContainer<T> {
  109858. /**
  109859. * Blocks within the octree
  109860. */
  109861. blocks: Array<OctreeBlock<T>>;
  109862. }
  109863. /**
  109864. * Class used to store a cell in an octree
  109865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109866. */
  109867. export class OctreeBlock<T> {
  109868. /**
  109869. * Gets the content of the current block
  109870. */
  109871. entries: T[];
  109872. /**
  109873. * Gets the list of block children
  109874. */
  109875. blocks: Array<OctreeBlock<T>>;
  109876. private _depth;
  109877. private _maxDepth;
  109878. private _capacity;
  109879. private _minPoint;
  109880. private _maxPoint;
  109881. private _boundingVectors;
  109882. private _creationFunc;
  109883. /**
  109884. * Creates a new block
  109885. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109886. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109887. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109888. * @param depth defines the current depth of this block in the octree
  109889. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109890. * @param creationFunc defines a callback to call when an element is added to the block
  109891. */
  109892. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109893. /**
  109894. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109895. */
  109896. readonly capacity: number;
  109897. /**
  109898. * Gets the minimum vector (in world space) of the block's bounding box
  109899. */
  109900. readonly minPoint: Vector3;
  109901. /**
  109902. * Gets the maximum vector (in world space) of the block's bounding box
  109903. */
  109904. readonly maxPoint: Vector3;
  109905. /**
  109906. * Add a new element to this block
  109907. * @param entry defines the element to add
  109908. */
  109909. addEntry(entry: T): void;
  109910. /**
  109911. * Remove an element from this block
  109912. * @param entry defines the element to remove
  109913. */
  109914. removeEntry(entry: T): void;
  109915. /**
  109916. * Add an array of elements to this block
  109917. * @param entries defines the array of elements to add
  109918. */
  109919. addEntries(entries: T[]): void;
  109920. /**
  109921. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109922. * @param frustumPlanes defines the frustum planes to test
  109923. * @param selection defines the array to store current content if selection is positive
  109924. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109925. */
  109926. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109927. /**
  109928. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109929. * @param sphereCenter defines the bounding sphere center
  109930. * @param sphereRadius defines the bounding sphere radius
  109931. * @param selection defines the array to store current content if selection is positive
  109932. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109933. */
  109934. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109935. /**
  109936. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109937. * @param ray defines the ray to test with
  109938. * @param selection defines the array to store current content if selection is positive
  109939. */
  109940. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109941. /**
  109942. * Subdivide the content into child blocks (this block will then be empty)
  109943. */
  109944. createInnerBlocks(): void;
  109945. /**
  109946. * @hidden
  109947. */
  109948. 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;
  109949. }
  109950. }
  109951. declare module BABYLON {
  109952. /**
  109953. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109954. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109955. */
  109956. export class Octree<T> {
  109957. /** 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.) */
  109958. maxDepth: number;
  109959. /**
  109960. * Blocks within the octree containing objects
  109961. */
  109962. blocks: Array<OctreeBlock<T>>;
  109963. /**
  109964. * Content stored in the octree
  109965. */
  109966. dynamicContent: T[];
  109967. private _maxBlockCapacity;
  109968. private _selectionContent;
  109969. private _creationFunc;
  109970. /**
  109971. * Creates a octree
  109972. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109973. * @param creationFunc function to be used to instatiate the octree
  109974. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109975. * @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.)
  109976. */
  109977. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109978. /** 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.) */
  109979. maxDepth?: number);
  109980. /**
  109981. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109982. * @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);
  109983. * @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);
  109984. * @param entries meshes to be added to the octree blocks
  109985. */
  109986. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109987. /**
  109988. * Adds a mesh to the octree
  109989. * @param entry Mesh to add to the octree
  109990. */
  109991. addMesh(entry: T): void;
  109992. /**
  109993. * Remove an element from the octree
  109994. * @param entry defines the element to remove
  109995. */
  109996. removeMesh(entry: T): void;
  109997. /**
  109998. * Selects an array of meshes within the frustum
  109999. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110000. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110001. * @returns array of meshes within the frustum
  110002. */
  110003. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110004. /**
  110005. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110006. * @param sphereCenter defines the bounding sphere center
  110007. * @param sphereRadius defines the bounding sphere radius
  110008. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110009. * @returns an array of objects that intersect the sphere
  110010. */
  110011. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110012. /**
  110013. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110014. * @param ray defines the ray to test with
  110015. * @returns array of intersected objects
  110016. */
  110017. intersectsRay(ray: Ray): SmartArray<T>;
  110018. /**
  110019. * Adds a mesh into the octree block if it intersects the block
  110020. */
  110021. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110022. /**
  110023. * Adds a submesh into the octree block if it intersects the block
  110024. */
  110025. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110026. }
  110027. }
  110028. declare module BABYLON {
  110029. interface Scene {
  110030. /**
  110031. * @hidden
  110032. * Backing Filed
  110033. */
  110034. _selectionOctree: Octree<AbstractMesh>;
  110035. /**
  110036. * Gets the octree used to boost mesh selection (picking)
  110037. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110038. */
  110039. selectionOctree: Octree<AbstractMesh>;
  110040. /**
  110041. * Creates or updates the octree used to boost selection (picking)
  110042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110043. * @param maxCapacity defines the maximum capacity per leaf
  110044. * @param maxDepth defines the maximum depth of the octree
  110045. * @returns an octree of AbstractMesh
  110046. */
  110047. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110048. }
  110049. interface AbstractMesh {
  110050. /**
  110051. * @hidden
  110052. * Backing Field
  110053. */
  110054. _submeshesOctree: Octree<SubMesh>;
  110055. /**
  110056. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110057. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110058. * @param maxCapacity defines the maximum size of each block (64 by default)
  110059. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110060. * @returns the new octree
  110061. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110063. */
  110064. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110065. }
  110066. /**
  110067. * Defines the octree scene component responsible to manage any octrees
  110068. * in a given scene.
  110069. */
  110070. export class OctreeSceneComponent {
  110071. /**
  110072. * The component name help to identify the component in the list of scene components.
  110073. */
  110074. readonly name: string;
  110075. /**
  110076. * The scene the component belongs to.
  110077. */
  110078. scene: Scene;
  110079. /**
  110080. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110081. */
  110082. readonly checksIsEnabled: boolean;
  110083. /**
  110084. * Creates a new instance of the component for the given scene
  110085. * @param scene Defines the scene to register the component in
  110086. */
  110087. constructor(scene: Scene);
  110088. /**
  110089. * Registers the component in a given scene
  110090. */
  110091. register(): void;
  110092. /**
  110093. * Return the list of active meshes
  110094. * @returns the list of active meshes
  110095. */
  110096. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110097. /**
  110098. * Return the list of active sub meshes
  110099. * @param mesh The mesh to get the candidates sub meshes from
  110100. * @returns the list of active sub meshes
  110101. */
  110102. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110103. private _tempRay;
  110104. /**
  110105. * Return the list of sub meshes intersecting with a given local ray
  110106. * @param mesh defines the mesh to find the submesh for
  110107. * @param localRay defines the ray in local space
  110108. * @returns the list of intersecting sub meshes
  110109. */
  110110. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110111. /**
  110112. * Return the list of sub meshes colliding with a collider
  110113. * @param mesh defines the mesh to find the submesh for
  110114. * @param collider defines the collider to evaluate the collision against
  110115. * @returns the list of colliding sub meshes
  110116. */
  110117. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110118. /**
  110119. * Rebuilds the elements related to this component in case of
  110120. * context lost for instance.
  110121. */
  110122. rebuild(): void;
  110123. /**
  110124. * Disposes the component and the associated ressources.
  110125. */
  110126. dispose(): void;
  110127. }
  110128. }
  110129. declare module BABYLON {
  110130. /**
  110131. * Renders a layer on top of an existing scene
  110132. */
  110133. export class UtilityLayerRenderer implements IDisposable {
  110134. /** the original scene that will be rendered on top of */
  110135. originalScene: Scene;
  110136. private _pointerCaptures;
  110137. private _lastPointerEvents;
  110138. private static _DefaultUtilityLayer;
  110139. private static _DefaultKeepDepthUtilityLayer;
  110140. private _sharedGizmoLight;
  110141. private _renderCamera;
  110142. /**
  110143. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110144. * @returns the camera that is used when rendering the utility layer
  110145. */
  110146. getRenderCamera(): Nullable<Camera>;
  110147. /**
  110148. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110149. * @param cam the camera that should be used when rendering the utility layer
  110150. */
  110151. setRenderCamera(cam: Nullable<Camera>): void;
  110152. /**
  110153. * @hidden
  110154. * Light which used by gizmos to get light shading
  110155. */
  110156. _getSharedGizmoLight(): HemisphericLight;
  110157. /**
  110158. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110159. */
  110160. pickUtilitySceneFirst: boolean;
  110161. /**
  110162. * 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)
  110163. */
  110164. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110165. /**
  110166. * 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)
  110167. */
  110168. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110169. /**
  110170. * The scene that is rendered on top of the original scene
  110171. */
  110172. utilityLayerScene: Scene;
  110173. /**
  110174. * If the utility layer should automatically be rendered on top of existing scene
  110175. */
  110176. shouldRender: boolean;
  110177. /**
  110178. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110179. */
  110180. onlyCheckPointerDownEvents: boolean;
  110181. /**
  110182. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110183. */
  110184. processAllEvents: boolean;
  110185. /**
  110186. * Observable raised when the pointer move from the utility layer scene to the main scene
  110187. */
  110188. onPointerOutObservable: Observable<number>;
  110189. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110190. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110191. private _afterRenderObserver;
  110192. private _sceneDisposeObserver;
  110193. private _originalPointerObserver;
  110194. /**
  110195. * Instantiates a UtilityLayerRenderer
  110196. * @param originalScene the original scene that will be rendered on top of
  110197. * @param handleEvents boolean indicating if the utility layer should handle events
  110198. */
  110199. constructor(
  110200. /** the original scene that will be rendered on top of */
  110201. originalScene: Scene, handleEvents?: boolean);
  110202. private _notifyObservers;
  110203. /**
  110204. * Renders the utility layers scene on top of the original scene
  110205. */
  110206. render(): void;
  110207. /**
  110208. * Disposes of the renderer
  110209. */
  110210. dispose(): void;
  110211. private _updateCamera;
  110212. }
  110213. }
  110214. declare module BABYLON {
  110215. /**
  110216. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110217. */
  110218. export class Gizmo implements IDisposable {
  110219. /** The utility layer the gizmo will be added to */
  110220. gizmoLayer: UtilityLayerRenderer;
  110221. /**
  110222. * The root mesh of the gizmo
  110223. */
  110224. _rootMesh: Mesh;
  110225. private _attachedMesh;
  110226. /**
  110227. * Ratio for the scale of the gizmo (Default: 1)
  110228. */
  110229. scaleRatio: number;
  110230. /**
  110231. * If a custom mesh has been set (Default: false)
  110232. */
  110233. protected _customMeshSet: boolean;
  110234. /**
  110235. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110236. * * When set, interactions will be enabled
  110237. */
  110238. attachedMesh: Nullable<AbstractMesh>;
  110239. /**
  110240. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110241. * @param mesh The mesh to replace the default mesh of the gizmo
  110242. */
  110243. setCustomMesh(mesh: Mesh): void;
  110244. /**
  110245. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110246. */
  110247. updateGizmoRotationToMatchAttachedMesh: boolean;
  110248. /**
  110249. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110250. */
  110251. updateGizmoPositionToMatchAttachedMesh: boolean;
  110252. /**
  110253. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110254. */
  110255. updateScale: boolean;
  110256. protected _interactionsEnabled: boolean;
  110257. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110258. private _beforeRenderObserver;
  110259. private _tempVector;
  110260. /**
  110261. * Creates a gizmo
  110262. * @param gizmoLayer The utility layer the gizmo will be added to
  110263. */
  110264. constructor(
  110265. /** The utility layer the gizmo will be added to */
  110266. gizmoLayer?: UtilityLayerRenderer);
  110267. /**
  110268. * Updates the gizmo to match the attached mesh's position/rotation
  110269. */
  110270. protected _update(): void;
  110271. /**
  110272. * Disposes of the gizmo
  110273. */
  110274. dispose(): void;
  110275. }
  110276. }
  110277. declare module BABYLON {
  110278. /**
  110279. * Single plane drag gizmo
  110280. */
  110281. export class PlaneDragGizmo extends Gizmo {
  110282. /**
  110283. * Drag behavior responsible for the gizmos dragging interactions
  110284. */
  110285. dragBehavior: PointerDragBehavior;
  110286. private _pointerObserver;
  110287. /**
  110288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110289. */
  110290. snapDistance: number;
  110291. /**
  110292. * Event that fires each time the gizmo snaps to a new location.
  110293. * * snapDistance is the the change in distance
  110294. */
  110295. onSnapObservable: Observable<{
  110296. snapDistance: number;
  110297. }>;
  110298. private _plane;
  110299. private _coloredMaterial;
  110300. private _hoverMaterial;
  110301. private _isEnabled;
  110302. private _parent;
  110303. /** @hidden */
  110304. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110305. /** @hidden */
  110306. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110307. /**
  110308. * Creates a PlaneDragGizmo
  110309. * @param gizmoLayer The utility layer the gizmo will be added to
  110310. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110311. * @param color The color of the gizmo
  110312. */
  110313. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110315. /**
  110316. * If the gizmo is enabled
  110317. */
  110318. isEnabled: boolean;
  110319. /**
  110320. * Disposes of the gizmo
  110321. */
  110322. dispose(): void;
  110323. }
  110324. }
  110325. declare module BABYLON {
  110326. /**
  110327. * Gizmo that enables dragging a mesh along 3 axis
  110328. */
  110329. export class PositionGizmo extends Gizmo {
  110330. /**
  110331. * Internal gizmo used for interactions on the x axis
  110332. */
  110333. xGizmo: AxisDragGizmo;
  110334. /**
  110335. * Internal gizmo used for interactions on the y axis
  110336. */
  110337. yGizmo: AxisDragGizmo;
  110338. /**
  110339. * Internal gizmo used for interactions on the z axis
  110340. */
  110341. zGizmo: AxisDragGizmo;
  110342. /**
  110343. * Internal gizmo used for interactions on the yz plane
  110344. */
  110345. xPlaneGizmo: PlaneDragGizmo;
  110346. /**
  110347. * Internal gizmo used for interactions on the xz plane
  110348. */
  110349. yPlaneGizmo: PlaneDragGizmo;
  110350. /**
  110351. * Internal gizmo used for interactions on the xy plane
  110352. */
  110353. zPlaneGizmo: PlaneDragGizmo;
  110354. /**
  110355. * private variables
  110356. */
  110357. private _meshAttached;
  110358. private _updateGizmoRotationToMatchAttachedMesh;
  110359. private _snapDistance;
  110360. private _scaleRatio;
  110361. /** Fires an event when any of it's sub gizmos are dragged */
  110362. onDragStartObservable: Observable<unknown>;
  110363. /** Fires an event when any of it's sub gizmos are released from dragging */
  110364. onDragEndObservable: Observable<unknown>;
  110365. /**
  110366. * If set to true, planar drag is enabled
  110367. */
  110368. private _planarGizmoEnabled;
  110369. attachedMesh: Nullable<AbstractMesh>;
  110370. /**
  110371. * Creates a PositionGizmo
  110372. * @param gizmoLayer The utility layer the gizmo will be added to
  110373. */
  110374. constructor(gizmoLayer?: UtilityLayerRenderer);
  110375. /**
  110376. * If the planar drag gizmo is enabled
  110377. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110378. */
  110379. planarGizmoEnabled: boolean;
  110380. updateGizmoRotationToMatchAttachedMesh: boolean;
  110381. /**
  110382. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110383. */
  110384. snapDistance: number;
  110385. /**
  110386. * Ratio for the scale of the gizmo (Default: 1)
  110387. */
  110388. scaleRatio: number;
  110389. /**
  110390. * Disposes of the gizmo
  110391. */
  110392. dispose(): void;
  110393. /**
  110394. * CustomMeshes are not supported by this gizmo
  110395. * @param mesh The mesh to replace the default mesh of the gizmo
  110396. */
  110397. setCustomMesh(mesh: Mesh): void;
  110398. }
  110399. }
  110400. declare module BABYLON {
  110401. /**
  110402. * Single axis drag gizmo
  110403. */
  110404. export class AxisDragGizmo extends Gizmo {
  110405. /**
  110406. * Drag behavior responsible for the gizmos dragging interactions
  110407. */
  110408. dragBehavior: PointerDragBehavior;
  110409. private _pointerObserver;
  110410. /**
  110411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110412. */
  110413. snapDistance: number;
  110414. /**
  110415. * Event that fires each time the gizmo snaps to a new location.
  110416. * * snapDistance is the the change in distance
  110417. */
  110418. onSnapObservable: Observable<{
  110419. snapDistance: number;
  110420. }>;
  110421. private _isEnabled;
  110422. private _parent;
  110423. private _arrow;
  110424. private _coloredMaterial;
  110425. private _hoverMaterial;
  110426. /** @hidden */
  110427. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110428. /** @hidden */
  110429. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110430. /**
  110431. * Creates an AxisDragGizmo
  110432. * @param gizmoLayer The utility layer the gizmo will be added to
  110433. * @param dragAxis The axis which the gizmo will be able to drag on
  110434. * @param color The color of the gizmo
  110435. */
  110436. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110438. /**
  110439. * If the gizmo is enabled
  110440. */
  110441. isEnabled: boolean;
  110442. /**
  110443. * Disposes of the gizmo
  110444. */
  110445. dispose(): void;
  110446. }
  110447. }
  110448. declare module BABYLON.Debug {
  110449. /**
  110450. * The Axes viewer will show 3 axes in a specific point in space
  110451. */
  110452. export class AxesViewer {
  110453. private _xAxis;
  110454. private _yAxis;
  110455. private _zAxis;
  110456. private _scaleLinesFactor;
  110457. private _instanced;
  110458. /**
  110459. * Gets the hosting scene
  110460. */
  110461. scene: Scene;
  110462. /**
  110463. * Gets or sets a number used to scale line length
  110464. */
  110465. scaleLines: number;
  110466. /** Gets the node hierarchy used to render x-axis */
  110467. readonly xAxis: TransformNode;
  110468. /** Gets the node hierarchy used to render y-axis */
  110469. readonly yAxis: TransformNode;
  110470. /** Gets the node hierarchy used to render z-axis */
  110471. readonly zAxis: TransformNode;
  110472. /**
  110473. * Creates a new AxesViewer
  110474. * @param scene defines the hosting scene
  110475. * @param scaleLines defines a number used to scale line length (1 by default)
  110476. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110477. * @param xAxis defines the node hierarchy used to render the x-axis
  110478. * @param yAxis defines the node hierarchy used to render the y-axis
  110479. * @param zAxis defines the node hierarchy used to render the z-axis
  110480. */
  110481. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110482. /**
  110483. * Force the viewer to update
  110484. * @param position defines the position of the viewer
  110485. * @param xaxis defines the x axis of the viewer
  110486. * @param yaxis defines the y axis of the viewer
  110487. * @param zaxis defines the z axis of the viewer
  110488. */
  110489. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110490. /**
  110491. * Creates an instance of this axes viewer.
  110492. * @returns a new axes viewer with instanced meshes
  110493. */
  110494. createInstance(): AxesViewer;
  110495. /** Releases resources */
  110496. dispose(): void;
  110497. private static _SetRenderingGroupId;
  110498. }
  110499. }
  110500. declare module BABYLON.Debug {
  110501. /**
  110502. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110503. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110504. */
  110505. export class BoneAxesViewer extends AxesViewer {
  110506. /**
  110507. * Gets or sets the target mesh where to display the axes viewer
  110508. */
  110509. mesh: Nullable<Mesh>;
  110510. /**
  110511. * Gets or sets the target bone where to display the axes viewer
  110512. */
  110513. bone: Nullable<Bone>;
  110514. /** Gets current position */
  110515. pos: Vector3;
  110516. /** Gets direction of X axis */
  110517. xaxis: Vector3;
  110518. /** Gets direction of Y axis */
  110519. yaxis: Vector3;
  110520. /** Gets direction of Z axis */
  110521. zaxis: Vector3;
  110522. /**
  110523. * Creates a new BoneAxesViewer
  110524. * @param scene defines the hosting scene
  110525. * @param bone defines the target bone
  110526. * @param mesh defines the target mesh
  110527. * @param scaleLines defines a scaling factor for line length (1 by default)
  110528. */
  110529. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110530. /**
  110531. * Force the viewer to update
  110532. */
  110533. update(): void;
  110534. /** Releases resources */
  110535. dispose(): void;
  110536. }
  110537. }
  110538. declare module BABYLON {
  110539. /**
  110540. * Interface used to define scene explorer extensibility option
  110541. */
  110542. export interface IExplorerExtensibilityOption {
  110543. /**
  110544. * Define the option label
  110545. */
  110546. label: string;
  110547. /**
  110548. * Defines the action to execute on click
  110549. */
  110550. action: (entity: any) => void;
  110551. }
  110552. /**
  110553. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110554. */
  110555. export interface IExplorerExtensibilityGroup {
  110556. /**
  110557. * Defines a predicate to test if a given type mut be extended
  110558. */
  110559. predicate: (entity: any) => boolean;
  110560. /**
  110561. * Gets the list of options added to a type
  110562. */
  110563. entries: IExplorerExtensibilityOption[];
  110564. }
  110565. /**
  110566. * Interface used to define the options to use to create the Inspector
  110567. */
  110568. export interface IInspectorOptions {
  110569. /**
  110570. * Display in overlay mode (default: false)
  110571. */
  110572. overlay?: boolean;
  110573. /**
  110574. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110575. */
  110576. globalRoot?: HTMLElement;
  110577. /**
  110578. * Display the Scene explorer
  110579. */
  110580. showExplorer?: boolean;
  110581. /**
  110582. * Display the property inspector
  110583. */
  110584. showInspector?: boolean;
  110585. /**
  110586. * Display in embed mode (both panes on the right)
  110587. */
  110588. embedMode?: boolean;
  110589. /**
  110590. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110591. */
  110592. handleResize?: boolean;
  110593. /**
  110594. * Allow the panes to popup (default: true)
  110595. */
  110596. enablePopup?: boolean;
  110597. /**
  110598. * Allow the panes to be closed by users (default: true)
  110599. */
  110600. enableClose?: boolean;
  110601. /**
  110602. * Optional list of extensibility entries
  110603. */
  110604. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110605. /**
  110606. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110607. */
  110608. inspectorURL?: string;
  110609. }
  110610. interface Scene {
  110611. /**
  110612. * @hidden
  110613. * Backing field
  110614. */
  110615. _debugLayer: DebugLayer;
  110616. /**
  110617. * Gets the debug layer (aka Inspector) associated with the scene
  110618. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110619. */
  110620. debugLayer: DebugLayer;
  110621. }
  110622. /**
  110623. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110624. * what is happening in your scene
  110625. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110626. */
  110627. export class DebugLayer {
  110628. /**
  110629. * Define the url to get the inspector script from.
  110630. * By default it uses the babylonjs CDN.
  110631. * @ignoreNaming
  110632. */
  110633. static InspectorURL: string;
  110634. private _scene;
  110635. private BJSINSPECTOR;
  110636. private _onPropertyChangedObservable?;
  110637. /**
  110638. * Observable triggered when a property is changed through the inspector.
  110639. */
  110640. readonly onPropertyChangedObservable: any;
  110641. /**
  110642. * Instantiates a new debug layer.
  110643. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110644. * what is happening in your scene
  110645. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110646. * @param scene Defines the scene to inspect
  110647. */
  110648. constructor(scene: Scene);
  110649. /** Creates the inspector window. */
  110650. private _createInspector;
  110651. /**
  110652. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110653. * @param entity defines the entity to select
  110654. * @param lineContainerTitle defines the specific block to highlight
  110655. */
  110656. select(entity: any, lineContainerTitle?: string): void;
  110657. /** Get the inspector from bundle or global */
  110658. private _getGlobalInspector;
  110659. /**
  110660. * Get if the inspector is visible or not.
  110661. * @returns true if visible otherwise, false
  110662. */
  110663. isVisible(): boolean;
  110664. /**
  110665. * Hide the inspector and close its window.
  110666. */
  110667. hide(): void;
  110668. /**
  110669. * Launch the debugLayer.
  110670. * @param config Define the configuration of the inspector
  110671. * @return a promise fulfilled when the debug layer is visible
  110672. */
  110673. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110674. }
  110675. }
  110676. declare module BABYLON {
  110677. /**
  110678. * Class containing static functions to help procedurally build meshes
  110679. */
  110680. export class BoxBuilder {
  110681. /**
  110682. * Creates a box mesh
  110683. * * The parameter `size` sets the size (float) of each box side (default 1)
  110684. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110685. * * 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)
  110686. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110690. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110691. * @param name defines the name of the mesh
  110692. * @param options defines the options used to create the mesh
  110693. * @param scene defines the hosting scene
  110694. * @returns the box mesh
  110695. */
  110696. static CreateBox(name: string, options: {
  110697. size?: number;
  110698. width?: number;
  110699. height?: number;
  110700. depth?: number;
  110701. faceUV?: Vector4[];
  110702. faceColors?: Color4[];
  110703. sideOrientation?: number;
  110704. frontUVs?: Vector4;
  110705. backUVs?: Vector4;
  110706. wrap?: boolean;
  110707. topBaseAt?: number;
  110708. bottomBaseAt?: number;
  110709. updatable?: boolean;
  110710. }, scene?: Nullable<Scene>): Mesh;
  110711. }
  110712. }
  110713. declare module BABYLON {
  110714. /**
  110715. * Class containing static functions to help procedurally build meshes
  110716. */
  110717. export class SphereBuilder {
  110718. /**
  110719. * Creates a sphere mesh
  110720. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110721. * * 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`)
  110722. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110723. * * 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
  110724. * * 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)
  110725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110728. * @param name defines the name of the mesh
  110729. * @param options defines the options used to create the mesh
  110730. * @param scene defines the hosting scene
  110731. * @returns the sphere mesh
  110732. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110733. */
  110734. static CreateSphere(name: string, options: {
  110735. segments?: number;
  110736. diameter?: number;
  110737. diameterX?: number;
  110738. diameterY?: number;
  110739. diameterZ?: number;
  110740. arc?: number;
  110741. slice?: number;
  110742. sideOrientation?: number;
  110743. frontUVs?: Vector4;
  110744. backUVs?: Vector4;
  110745. updatable?: boolean;
  110746. }, scene?: Nullable<Scene>): Mesh;
  110747. }
  110748. }
  110749. declare module BABYLON.Debug {
  110750. /**
  110751. * Used to show the physics impostor around the specific mesh
  110752. */
  110753. export class PhysicsViewer {
  110754. /** @hidden */
  110755. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110756. /** @hidden */
  110757. protected _meshes: Array<Nullable<AbstractMesh>>;
  110758. /** @hidden */
  110759. protected _scene: Nullable<Scene>;
  110760. /** @hidden */
  110761. protected _numMeshes: number;
  110762. /** @hidden */
  110763. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110764. private _renderFunction;
  110765. private _utilityLayer;
  110766. private _debugBoxMesh;
  110767. private _debugSphereMesh;
  110768. private _debugCylinderMesh;
  110769. private _debugMaterial;
  110770. private _debugMeshMeshes;
  110771. /**
  110772. * Creates a new PhysicsViewer
  110773. * @param scene defines the hosting scene
  110774. */
  110775. constructor(scene: Scene);
  110776. /** @hidden */
  110777. protected _updateDebugMeshes(): void;
  110778. /**
  110779. * Renders a specified physic impostor
  110780. * @param impostor defines the impostor to render
  110781. * @param targetMesh defines the mesh represented by the impostor
  110782. * @returns the new debug mesh used to render the impostor
  110783. */
  110784. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110785. /**
  110786. * Hides a specified physic impostor
  110787. * @param impostor defines the impostor to hide
  110788. */
  110789. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110790. private _getDebugMaterial;
  110791. private _getDebugBoxMesh;
  110792. private _getDebugSphereMesh;
  110793. private _getDebugCylinderMesh;
  110794. private _getDebugMeshMesh;
  110795. private _getDebugMesh;
  110796. /** Releases all resources */
  110797. dispose(): void;
  110798. }
  110799. }
  110800. declare module BABYLON {
  110801. /**
  110802. * Class containing static functions to help procedurally build meshes
  110803. */
  110804. export class LinesBuilder {
  110805. /**
  110806. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110807. * * 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
  110808. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110809. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110810. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110811. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110813. * * 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
  110814. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110817. * @param name defines the name of the new line system
  110818. * @param options defines the options used to create the line system
  110819. * @param scene defines the hosting scene
  110820. * @returns a new line system mesh
  110821. */
  110822. static CreateLineSystem(name: string, options: {
  110823. lines: Vector3[][];
  110824. updatable?: boolean;
  110825. instance?: Nullable<LinesMesh>;
  110826. colors?: Nullable<Color4[][]>;
  110827. useVertexAlpha?: boolean;
  110828. }, scene: Nullable<Scene>): LinesMesh;
  110829. /**
  110830. * Creates a line mesh
  110831. * 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
  110832. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110833. * * The parameter `points` is an array successive Vector3
  110834. * * 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
  110835. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110836. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110837. * * When updating an instance, remember that only point positions can change, not the number of points
  110838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110840. * @param name defines the name of the new line system
  110841. * @param options defines the options used to create the line system
  110842. * @param scene defines the hosting scene
  110843. * @returns a new line mesh
  110844. */
  110845. static CreateLines(name: string, options: {
  110846. points: Vector3[];
  110847. updatable?: boolean;
  110848. instance?: Nullable<LinesMesh>;
  110849. colors?: Color4[];
  110850. useVertexAlpha?: boolean;
  110851. }, scene?: Nullable<Scene>): LinesMesh;
  110852. /**
  110853. * Creates a dashed line mesh
  110854. * * 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
  110855. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110856. * * The parameter `points` is an array successive Vector3
  110857. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110858. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110859. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110860. * * 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
  110861. * * When updating an instance, remember that only point positions can change, not the number of points
  110862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110863. * @param name defines the name of the mesh
  110864. * @param options defines the options used to create the mesh
  110865. * @param scene defines the hosting scene
  110866. * @returns the dashed line mesh
  110867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110868. */
  110869. static CreateDashedLines(name: string, options: {
  110870. points: Vector3[];
  110871. dashSize?: number;
  110872. gapSize?: number;
  110873. dashNb?: number;
  110874. updatable?: boolean;
  110875. instance?: LinesMesh;
  110876. }, scene?: Nullable<Scene>): LinesMesh;
  110877. }
  110878. }
  110879. declare module BABYLON {
  110880. /**
  110881. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110882. * in order to better appreciate the issue one might have.
  110883. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110884. */
  110885. export class RayHelper {
  110886. /**
  110887. * Defines the ray we are currently tryin to visualize.
  110888. */
  110889. ray: Nullable<Ray>;
  110890. private _renderPoints;
  110891. private _renderLine;
  110892. private _renderFunction;
  110893. private _scene;
  110894. private _updateToMeshFunction;
  110895. private _attachedToMesh;
  110896. private _meshSpaceDirection;
  110897. private _meshSpaceOrigin;
  110898. /**
  110899. * Helper function to create a colored helper in a scene in one line.
  110900. * @param ray Defines the ray we are currently tryin to visualize
  110901. * @param scene Defines the scene the ray is used in
  110902. * @param color Defines the color we want to see the ray in
  110903. * @returns The newly created ray helper.
  110904. */
  110905. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110906. /**
  110907. * Instantiate a new ray helper.
  110908. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110909. * in order to better appreciate the issue one might have.
  110910. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110911. * @param ray Defines the ray we are currently tryin to visualize
  110912. */
  110913. constructor(ray: Ray);
  110914. /**
  110915. * Shows the ray we are willing to debug.
  110916. * @param scene Defines the scene the ray needs to be rendered in
  110917. * @param color Defines the color the ray needs to be rendered in
  110918. */
  110919. show(scene: Scene, color?: Color3): void;
  110920. /**
  110921. * Hides the ray we are debugging.
  110922. */
  110923. hide(): void;
  110924. private _render;
  110925. /**
  110926. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110927. * @param mesh Defines the mesh we want the helper attached to
  110928. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110929. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110930. * @param length Defines the length of the ray
  110931. */
  110932. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110933. /**
  110934. * Detach the ray helper from the mesh it has previously been attached to.
  110935. */
  110936. detachFromMesh(): void;
  110937. private _updateToMesh;
  110938. /**
  110939. * Dispose the helper and release its associated resources.
  110940. */
  110941. dispose(): void;
  110942. }
  110943. }
  110944. declare module BABYLON.Debug {
  110945. /**
  110946. * Class used to render a debug view of a given skeleton
  110947. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110948. */
  110949. export class SkeletonViewer {
  110950. /** defines the skeleton to render */
  110951. skeleton: Skeleton;
  110952. /** defines the mesh attached to the skeleton */
  110953. mesh: AbstractMesh;
  110954. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110955. autoUpdateBonesMatrices: boolean;
  110956. /** defines the rendering group id to use with the viewer */
  110957. renderingGroupId: number;
  110958. /** Gets or sets the color used to render the skeleton */
  110959. color: Color3;
  110960. private _scene;
  110961. private _debugLines;
  110962. private _debugMesh;
  110963. private _isEnabled;
  110964. private _renderFunction;
  110965. private _utilityLayer;
  110966. /**
  110967. * Returns the mesh used to render the bones
  110968. */
  110969. readonly debugMesh: Nullable<LinesMesh>;
  110970. /**
  110971. * Creates a new SkeletonViewer
  110972. * @param skeleton defines the skeleton to render
  110973. * @param mesh defines the mesh attached to the skeleton
  110974. * @param scene defines the hosting scene
  110975. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110976. * @param renderingGroupId defines the rendering group id to use with the viewer
  110977. */
  110978. constructor(
  110979. /** defines the skeleton to render */
  110980. skeleton: Skeleton,
  110981. /** defines the mesh attached to the skeleton */
  110982. mesh: AbstractMesh, scene: Scene,
  110983. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110984. autoUpdateBonesMatrices?: boolean,
  110985. /** defines the rendering group id to use with the viewer */
  110986. renderingGroupId?: number);
  110987. /** Gets or sets a boolean indicating if the viewer is enabled */
  110988. isEnabled: boolean;
  110989. private _getBonePosition;
  110990. private _getLinesForBonesWithLength;
  110991. private _getLinesForBonesNoLength;
  110992. /** Update the viewer to sync with current skeleton state */
  110993. update(): void;
  110994. /** Release associated resources */
  110995. dispose(): void;
  110996. }
  110997. }
  110998. declare module BABYLON {
  110999. /**
  111000. * Options to create the null engine
  111001. */
  111002. export class NullEngineOptions {
  111003. /**
  111004. * Render width (Default: 512)
  111005. */
  111006. renderWidth: number;
  111007. /**
  111008. * Render height (Default: 256)
  111009. */
  111010. renderHeight: number;
  111011. /**
  111012. * Texture size (Default: 512)
  111013. */
  111014. textureSize: number;
  111015. /**
  111016. * If delta time between frames should be constant
  111017. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111018. */
  111019. deterministicLockstep: boolean;
  111020. /**
  111021. * Maximum about of steps between frames (Default: 4)
  111022. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111023. */
  111024. lockstepMaxSteps: number;
  111025. }
  111026. /**
  111027. * The null engine class provides support for headless version of babylon.js.
  111028. * This can be used in server side scenario or for testing purposes
  111029. */
  111030. export class NullEngine extends Engine {
  111031. private _options;
  111032. /**
  111033. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111035. * @returns true if engine is in deterministic lock step mode
  111036. */
  111037. isDeterministicLockStep(): boolean;
  111038. /**
  111039. * Gets the max steps when engine is running in deterministic lock step
  111040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111041. * @returns the max steps
  111042. */
  111043. getLockstepMaxSteps(): number;
  111044. /**
  111045. * Gets the current hardware scaling level.
  111046. * By default the hardware scaling level is computed from the window device ratio.
  111047. * 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.
  111048. * @returns a number indicating the current hardware scaling level
  111049. */
  111050. getHardwareScalingLevel(): number;
  111051. constructor(options?: NullEngineOptions);
  111052. /**
  111053. * Creates a vertex buffer
  111054. * @param vertices the data for the vertex buffer
  111055. * @returns the new WebGL static buffer
  111056. */
  111057. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111058. /**
  111059. * Creates a new index buffer
  111060. * @param indices defines the content of the index buffer
  111061. * @param updatable defines if the index buffer must be updatable
  111062. * @returns a new webGL buffer
  111063. */
  111064. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111065. /**
  111066. * Clear the current render buffer or the current render target (if any is set up)
  111067. * @param color defines the color to use
  111068. * @param backBuffer defines if the back buffer must be cleared
  111069. * @param depth defines if the depth buffer must be cleared
  111070. * @param stencil defines if the stencil buffer must be cleared
  111071. */
  111072. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111073. /**
  111074. * Gets the current render width
  111075. * @param useScreen defines if screen size must be used (or the current render target if any)
  111076. * @returns a number defining the current render width
  111077. */
  111078. getRenderWidth(useScreen?: boolean): number;
  111079. /**
  111080. * Gets the current render height
  111081. * @param useScreen defines if screen size must be used (or the current render target if any)
  111082. * @returns a number defining the current render height
  111083. */
  111084. getRenderHeight(useScreen?: boolean): number;
  111085. /**
  111086. * Set the WebGL's viewport
  111087. * @param viewport defines the viewport element to be used
  111088. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111089. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111090. */
  111091. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111092. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111093. /**
  111094. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111095. * @param pipelineContext defines the pipeline context to use
  111096. * @param uniformsNames defines the list of uniform names
  111097. * @returns an array of webGL uniform locations
  111098. */
  111099. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111100. /**
  111101. * Gets the lsit of active attributes for a given webGL program
  111102. * @param pipelineContext defines the pipeline context to use
  111103. * @param attributesNames defines the list of attribute names to get
  111104. * @returns an array of indices indicating the offset of each attribute
  111105. */
  111106. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111107. /**
  111108. * Binds an effect to the webGL context
  111109. * @param effect defines the effect to bind
  111110. */
  111111. bindSamplers(effect: Effect): void;
  111112. /**
  111113. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111114. * @param effect defines the effect to activate
  111115. */
  111116. enableEffect(effect: Effect): void;
  111117. /**
  111118. * Set various states to the webGL context
  111119. * @param culling defines backface culling state
  111120. * @param zOffset defines the value to apply to zOffset (0 by default)
  111121. * @param force defines if states must be applied even if cache is up to date
  111122. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111123. */
  111124. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111125. /**
  111126. * Set the value of an uniform to an array of int32
  111127. * @param uniform defines the webGL uniform location where to store the value
  111128. * @param array defines the array of int32 to store
  111129. */
  111130. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111131. /**
  111132. * Set the value of an uniform to an array of int32 (stored as vec2)
  111133. * @param uniform defines the webGL uniform location where to store the value
  111134. * @param array defines the array of int32 to store
  111135. */
  111136. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111137. /**
  111138. * Set the value of an uniform to an array of int32 (stored as vec3)
  111139. * @param uniform defines the webGL uniform location where to store the value
  111140. * @param array defines the array of int32 to store
  111141. */
  111142. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111143. /**
  111144. * Set the value of an uniform to an array of int32 (stored as vec4)
  111145. * @param uniform defines the webGL uniform location where to store the value
  111146. * @param array defines the array of int32 to store
  111147. */
  111148. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111149. /**
  111150. * Set the value of an uniform to an array of float32
  111151. * @param uniform defines the webGL uniform location where to store the value
  111152. * @param array defines the array of float32 to store
  111153. */
  111154. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111155. /**
  111156. * Set the value of an uniform to an array of float32 (stored as vec2)
  111157. * @param uniform defines the webGL uniform location where to store the value
  111158. * @param array defines the array of float32 to store
  111159. */
  111160. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111161. /**
  111162. * Set the value of an uniform to an array of float32 (stored as vec3)
  111163. * @param uniform defines the webGL uniform location where to store the value
  111164. * @param array defines the array of float32 to store
  111165. */
  111166. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111167. /**
  111168. * Set the value of an uniform to an array of float32 (stored as vec4)
  111169. * @param uniform defines the webGL uniform location where to store the value
  111170. * @param array defines the array of float32 to store
  111171. */
  111172. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111173. /**
  111174. * Set the value of an uniform to an array of number
  111175. * @param uniform defines the webGL uniform location where to store the value
  111176. * @param array defines the array of number to store
  111177. */
  111178. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111179. /**
  111180. * Set the value of an uniform to an array of number (stored as vec2)
  111181. * @param uniform defines the webGL uniform location where to store the value
  111182. * @param array defines the array of number to store
  111183. */
  111184. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111185. /**
  111186. * Set the value of an uniform to an array of number (stored as vec3)
  111187. * @param uniform defines the webGL uniform location where to store the value
  111188. * @param array defines the array of number to store
  111189. */
  111190. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111191. /**
  111192. * Set the value of an uniform to an array of number (stored as vec4)
  111193. * @param uniform defines the webGL uniform location where to store the value
  111194. * @param array defines the array of number to store
  111195. */
  111196. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111197. /**
  111198. * Set the value of an uniform to an array of float32 (stored as matrices)
  111199. * @param uniform defines the webGL uniform location where to store the value
  111200. * @param matrices defines the array of float32 to store
  111201. */
  111202. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111203. /**
  111204. * Set the value of an uniform to a matrix (3x3)
  111205. * @param uniform defines the webGL uniform location where to store the value
  111206. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111207. */
  111208. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111209. /**
  111210. * Set the value of an uniform to a matrix (2x2)
  111211. * @param uniform defines the webGL uniform location where to store the value
  111212. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111213. */
  111214. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111215. /**
  111216. * Set the value of an uniform to a number (float)
  111217. * @param uniform defines the webGL uniform location where to store the value
  111218. * @param value defines the float number to store
  111219. */
  111220. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111221. /**
  111222. * Set the value of an uniform to a vec2
  111223. * @param uniform defines the webGL uniform location where to store the value
  111224. * @param x defines the 1st component of the value
  111225. * @param y defines the 2nd component of the value
  111226. */
  111227. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111228. /**
  111229. * Set the value of an uniform to a vec3
  111230. * @param uniform defines the webGL uniform location where to store the value
  111231. * @param x defines the 1st component of the value
  111232. * @param y defines the 2nd component of the value
  111233. * @param z defines the 3rd component of the value
  111234. */
  111235. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111236. /**
  111237. * Set the value of an uniform to a boolean
  111238. * @param uniform defines the webGL uniform location where to store the value
  111239. * @param bool defines the boolean to store
  111240. */
  111241. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111242. /**
  111243. * Set the value of an uniform to a vec4
  111244. * @param uniform defines the webGL uniform location where to store the value
  111245. * @param x defines the 1st component of the value
  111246. * @param y defines the 2nd component of the value
  111247. * @param z defines the 3rd component of the value
  111248. * @param w defines the 4th component of the value
  111249. */
  111250. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111251. /**
  111252. * Sets the current alpha mode
  111253. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111254. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111255. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111256. */
  111257. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111258. /**
  111259. * Bind webGl buffers directly to the webGL context
  111260. * @param vertexBuffers defines the vertex buffer to bind
  111261. * @param indexBuffer defines the index buffer to bind
  111262. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111263. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111264. * @param effect defines the effect associated with the vertex buffer
  111265. */
  111266. bindBuffers(vertexBuffers: {
  111267. [key: string]: VertexBuffer;
  111268. }, indexBuffer: DataBuffer, effect: Effect): void;
  111269. /**
  111270. * Force the entire cache to be cleared
  111271. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111272. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111273. */
  111274. wipeCaches(bruteForce?: boolean): void;
  111275. /**
  111276. * Send a draw order
  111277. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111278. * @param indexStart defines the starting index
  111279. * @param indexCount defines the number of index to draw
  111280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111281. */
  111282. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111283. /**
  111284. * Draw a list of indexed primitives
  111285. * @param fillMode defines the primitive to use
  111286. * @param indexStart defines the starting index
  111287. * @param indexCount defines the number of index to draw
  111288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111289. */
  111290. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111291. /**
  111292. * Draw a list of unindexed primitives
  111293. * @param fillMode defines the primitive to use
  111294. * @param verticesStart defines the index of first vertex to draw
  111295. * @param verticesCount defines the count of vertices to draw
  111296. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111297. */
  111298. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111299. /** @hidden */
  111300. _createTexture(): WebGLTexture;
  111301. /** @hidden */
  111302. _releaseTexture(texture: InternalTexture): void;
  111303. /**
  111304. * Usually called from Texture.ts.
  111305. * Passed information to create a WebGLTexture
  111306. * @param urlArg defines a value which contains one of the following:
  111307. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111308. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111309. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111310. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111311. * @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)
  111312. * @param scene needed for loading to the correct scene
  111313. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111314. * @param onLoad optional callback to be called upon successful completion
  111315. * @param onError optional callback to be called upon failure
  111316. * @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
  111317. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111318. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111319. * @param forcedExtension defines the extension to use to pick the right loader
  111320. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111321. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111322. */
  111323. 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;
  111324. /**
  111325. * Creates a new render target texture
  111326. * @param size defines the size of the texture
  111327. * @param options defines the options used to create the texture
  111328. * @returns a new render target texture stored in an InternalTexture
  111329. */
  111330. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111331. /**
  111332. * Update the sampling mode of a given texture
  111333. * @param samplingMode defines the required sampling mode
  111334. * @param texture defines the texture to update
  111335. */
  111336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111337. /**
  111338. * Binds the frame buffer to the specified texture.
  111339. * @param texture The texture to render to or null for the default canvas
  111340. * @param faceIndex The face of the texture to render to in case of cube texture
  111341. * @param requiredWidth The width of the target to render to
  111342. * @param requiredHeight The height of the target to render to
  111343. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111344. * @param depthStencilTexture The depth stencil texture to use to render
  111345. * @param lodLevel defines le lod level to bind to the frame buffer
  111346. */
  111347. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111348. /**
  111349. * Unbind the current render target texture from the webGL context
  111350. * @param texture defines the render target texture to unbind
  111351. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111352. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111353. */
  111354. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111355. /**
  111356. * Creates a dynamic vertex buffer
  111357. * @param vertices the data for the dynamic vertex buffer
  111358. * @returns the new WebGL dynamic buffer
  111359. */
  111360. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111361. /**
  111362. * Update the content of a dynamic texture
  111363. * @param texture defines the texture to update
  111364. * @param canvas defines the canvas containing the source
  111365. * @param invertY defines if data must be stored with Y axis inverted
  111366. * @param premulAlpha defines if alpha is stored as premultiplied
  111367. * @param format defines the format of the data
  111368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111369. */
  111370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111371. /**
  111372. * Gets a boolean indicating if all created effects are ready
  111373. * @returns true if all effects are ready
  111374. */
  111375. areAllEffectsReady(): boolean;
  111376. /**
  111377. * @hidden
  111378. * Get the current error code of the webGL context
  111379. * @returns the error code
  111380. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111381. */
  111382. getError(): number;
  111383. /** @hidden */
  111384. _getUnpackAlignement(): number;
  111385. /** @hidden */
  111386. _unpackFlipY(value: boolean): void;
  111387. /**
  111388. * Update a dynamic index buffer
  111389. * @param indexBuffer defines the target index buffer
  111390. * @param indices defines the data to update
  111391. * @param offset defines the offset in the target index buffer where update should start
  111392. */
  111393. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111394. /**
  111395. * Updates a dynamic vertex buffer.
  111396. * @param vertexBuffer the vertex buffer to update
  111397. * @param vertices the data used to update the vertex buffer
  111398. * @param byteOffset the byte offset of the data (optional)
  111399. * @param byteLength the byte length of the data (optional)
  111400. */
  111401. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111402. /** @hidden */
  111403. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111404. /** @hidden */
  111405. _bindTexture(channel: number, texture: InternalTexture): void;
  111406. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111407. /**
  111408. * 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
  111409. */
  111410. releaseEffects(): void;
  111411. displayLoadingUI(): void;
  111412. hideLoadingUI(): void;
  111413. /** @hidden */
  111414. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111415. /** @hidden */
  111416. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111417. /** @hidden */
  111418. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111419. /** @hidden */
  111420. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111421. }
  111422. }
  111423. declare module BABYLON {
  111424. /** @hidden */
  111425. export class _OcclusionDataStorage {
  111426. /** @hidden */
  111427. occlusionInternalRetryCounter: number;
  111428. /** @hidden */
  111429. isOcclusionQueryInProgress: boolean;
  111430. /** @hidden */
  111431. isOccluded: boolean;
  111432. /** @hidden */
  111433. occlusionRetryCount: number;
  111434. /** @hidden */
  111435. occlusionType: number;
  111436. /** @hidden */
  111437. occlusionQueryAlgorithmType: number;
  111438. }
  111439. interface Engine {
  111440. /**
  111441. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111442. * @return the new query
  111443. */
  111444. createQuery(): WebGLQuery;
  111445. /**
  111446. * Delete and release a webGL query
  111447. * @param query defines the query to delete
  111448. * @return the current engine
  111449. */
  111450. deleteQuery(query: WebGLQuery): Engine;
  111451. /**
  111452. * Check if a given query has resolved and got its value
  111453. * @param query defines the query to check
  111454. * @returns true if the query got its value
  111455. */
  111456. isQueryResultAvailable(query: WebGLQuery): boolean;
  111457. /**
  111458. * Gets the value of a given query
  111459. * @param query defines the query to check
  111460. * @returns the value of the query
  111461. */
  111462. getQueryResult(query: WebGLQuery): number;
  111463. /**
  111464. * Initiates an occlusion query
  111465. * @param algorithmType defines the algorithm to use
  111466. * @param query defines the query to use
  111467. * @returns the current engine
  111468. * @see http://doc.babylonjs.com/features/occlusionquery
  111469. */
  111470. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111471. /**
  111472. * Ends an occlusion query
  111473. * @see http://doc.babylonjs.com/features/occlusionquery
  111474. * @param algorithmType defines the algorithm to use
  111475. * @returns the current engine
  111476. */
  111477. endOcclusionQuery(algorithmType: number): Engine;
  111478. /**
  111479. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111480. * Please note that only one query can be issued at a time
  111481. * @returns a time token used to track the time span
  111482. */
  111483. startTimeQuery(): Nullable<_TimeToken>;
  111484. /**
  111485. * Ends a time query
  111486. * @param token defines the token used to measure the time span
  111487. * @returns the time spent (in ns)
  111488. */
  111489. endTimeQuery(token: _TimeToken): int;
  111490. /** @hidden */
  111491. _currentNonTimestampToken: Nullable<_TimeToken>;
  111492. /** @hidden */
  111493. _createTimeQuery(): WebGLQuery;
  111494. /** @hidden */
  111495. _deleteTimeQuery(query: WebGLQuery): void;
  111496. /** @hidden */
  111497. _getGlAlgorithmType(algorithmType: number): number;
  111498. /** @hidden */
  111499. _getTimeQueryResult(query: WebGLQuery): any;
  111500. /** @hidden */
  111501. _getTimeQueryAvailability(query: WebGLQuery): any;
  111502. }
  111503. interface AbstractMesh {
  111504. /**
  111505. * Backing filed
  111506. * @hidden
  111507. */
  111508. __occlusionDataStorage: _OcclusionDataStorage;
  111509. /**
  111510. * Access property
  111511. * @hidden
  111512. */
  111513. _occlusionDataStorage: _OcclusionDataStorage;
  111514. /**
  111515. * 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.
  111516. * The default value is -1 which means don't break the query and wait till the result
  111517. * @see http://doc.babylonjs.com/features/occlusionquery
  111518. */
  111519. occlusionRetryCount: number;
  111520. /**
  111521. * 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:
  111522. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111523. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111524. * * 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.
  111525. * @see http://doc.babylonjs.com/features/occlusionquery
  111526. */
  111527. occlusionType: number;
  111528. /**
  111529. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111530. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111531. * * 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.
  111532. * @see http://doc.babylonjs.com/features/occlusionquery
  111533. */
  111534. occlusionQueryAlgorithmType: number;
  111535. /**
  111536. * 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
  111537. * @see http://doc.babylonjs.com/features/occlusionquery
  111538. */
  111539. isOccluded: boolean;
  111540. /**
  111541. * Flag to check the progress status of the query
  111542. * @see http://doc.babylonjs.com/features/occlusionquery
  111543. */
  111544. isOcclusionQueryInProgress: boolean;
  111545. }
  111546. }
  111547. declare module BABYLON {
  111548. /** @hidden */
  111549. export var _forceTransformFeedbackToBundle: boolean;
  111550. interface Engine {
  111551. /**
  111552. * Creates a webGL transform feedback object
  111553. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111554. * @returns the webGL transform feedback object
  111555. */
  111556. createTransformFeedback(): WebGLTransformFeedback;
  111557. /**
  111558. * Delete a webGL transform feedback object
  111559. * @param value defines the webGL transform feedback object to delete
  111560. */
  111561. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111562. /**
  111563. * Bind a webGL transform feedback object to the webgl context
  111564. * @param value defines the webGL transform feedback object to bind
  111565. */
  111566. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111567. /**
  111568. * Begins a transform feedback operation
  111569. * @param usePoints defines if points or triangles must be used
  111570. */
  111571. beginTransformFeedback(usePoints: boolean): void;
  111572. /**
  111573. * Ends a transform feedback operation
  111574. */
  111575. endTransformFeedback(): void;
  111576. /**
  111577. * Specify the varyings to use with transform feedback
  111578. * @param program defines the associated webGL program
  111579. * @param value defines the list of strings representing the varying names
  111580. */
  111581. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111582. /**
  111583. * Bind a webGL buffer for a transform feedback operation
  111584. * @param value defines the webGL buffer to bind
  111585. */
  111586. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111587. }
  111588. }
  111589. declare module BABYLON {
  111590. /**
  111591. * Creation options of the multi render target texture.
  111592. */
  111593. export interface IMultiRenderTargetOptions {
  111594. /**
  111595. * Define if the texture needs to create mip maps after render.
  111596. */
  111597. generateMipMaps?: boolean;
  111598. /**
  111599. * Define the types of all the draw buffers we want to create
  111600. */
  111601. types?: number[];
  111602. /**
  111603. * Define the sampling modes of all the draw buffers we want to create
  111604. */
  111605. samplingModes?: number[];
  111606. /**
  111607. * Define if a depth buffer is required
  111608. */
  111609. generateDepthBuffer?: boolean;
  111610. /**
  111611. * Define if a stencil buffer is required
  111612. */
  111613. generateStencilBuffer?: boolean;
  111614. /**
  111615. * Define if a depth texture is required instead of a depth buffer
  111616. */
  111617. generateDepthTexture?: boolean;
  111618. /**
  111619. * Define the number of desired draw buffers
  111620. */
  111621. textureCount?: number;
  111622. /**
  111623. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111624. */
  111625. doNotChangeAspectRatio?: boolean;
  111626. /**
  111627. * Define the default type of the buffers we are creating
  111628. */
  111629. defaultType?: number;
  111630. }
  111631. /**
  111632. * A multi render target, like a render target provides the ability to render to a texture.
  111633. * Unlike the render target, it can render to several draw buffers in one draw.
  111634. * This is specially interesting in deferred rendering or for any effects requiring more than
  111635. * just one color from a single pass.
  111636. */
  111637. export class MultiRenderTarget extends RenderTargetTexture {
  111638. private _internalTextures;
  111639. private _textures;
  111640. private _multiRenderTargetOptions;
  111641. /**
  111642. * Get if draw buffers are currently supported by the used hardware and browser.
  111643. */
  111644. readonly isSupported: boolean;
  111645. /**
  111646. * Get the list of textures generated by the multi render target.
  111647. */
  111648. readonly textures: Texture[];
  111649. /**
  111650. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111651. */
  111652. readonly depthTexture: Texture;
  111653. /**
  111654. * Set the wrapping mode on U of all the textures we are rendering to.
  111655. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111656. */
  111657. wrapU: number;
  111658. /**
  111659. * Set the wrapping mode on V of all the textures we are rendering to.
  111660. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111661. */
  111662. wrapV: number;
  111663. /**
  111664. * Instantiate a new multi render target texture.
  111665. * A multi render target, like a render target provides the ability to render to a texture.
  111666. * Unlike the render target, it can render to several draw buffers in one draw.
  111667. * This is specially interesting in deferred rendering or for any effects requiring more than
  111668. * just one color from a single pass.
  111669. * @param name Define the name of the texture
  111670. * @param size Define the size of the buffers to render to
  111671. * @param count Define the number of target we are rendering into
  111672. * @param scene Define the scene the texture belongs to
  111673. * @param options Define the options used to create the multi render target
  111674. */
  111675. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111676. /** @hidden */
  111677. _rebuild(): void;
  111678. private _createInternalTextures;
  111679. private _createTextures;
  111680. /**
  111681. * Define the number of samples used if MSAA is enabled.
  111682. */
  111683. samples: number;
  111684. /**
  111685. * Resize all the textures in the multi render target.
  111686. * Be carrefull as it will recreate all the data in the new texture.
  111687. * @param size Define the new size
  111688. */
  111689. resize(size: any): void;
  111690. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111691. /**
  111692. * Dispose the render targets and their associated resources
  111693. */
  111694. dispose(): void;
  111695. /**
  111696. * Release all the underlying texture used as draw buffers.
  111697. */
  111698. releaseInternalTextures(): void;
  111699. }
  111700. }
  111701. declare module BABYLON {
  111702. interface ThinEngine {
  111703. /**
  111704. * Unbind a list of render target textures from the webGL context
  111705. * This is used only when drawBuffer extension or webGL2 are active
  111706. * @param textures defines the render target textures to unbind
  111707. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111708. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111709. */
  111710. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111711. /**
  111712. * Create a multi render target texture
  111713. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111714. * @param size defines the size of the texture
  111715. * @param options defines the creation options
  111716. * @returns the cube texture as an InternalTexture
  111717. */
  111718. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111719. /**
  111720. * Update the sample count for a given multiple render target texture
  111721. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111722. * @param textures defines the textures to update
  111723. * @param samples defines the sample count to set
  111724. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111725. */
  111726. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111727. }
  111728. }
  111729. declare module BABYLON {
  111730. /**
  111731. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111732. */
  111733. export interface CubeMapInfo {
  111734. /**
  111735. * The pixel array for the front face.
  111736. * This is stored in format, left to right, up to down format.
  111737. */
  111738. front: Nullable<ArrayBufferView>;
  111739. /**
  111740. * The pixel array for the back face.
  111741. * This is stored in format, left to right, up to down format.
  111742. */
  111743. back: Nullable<ArrayBufferView>;
  111744. /**
  111745. * The pixel array for the left face.
  111746. * This is stored in format, left to right, up to down format.
  111747. */
  111748. left: Nullable<ArrayBufferView>;
  111749. /**
  111750. * The pixel array for the right face.
  111751. * This is stored in format, left to right, up to down format.
  111752. */
  111753. right: Nullable<ArrayBufferView>;
  111754. /**
  111755. * The pixel array for the up face.
  111756. * This is stored in format, left to right, up to down format.
  111757. */
  111758. up: Nullable<ArrayBufferView>;
  111759. /**
  111760. * The pixel array for the down face.
  111761. * This is stored in format, left to right, up to down format.
  111762. */
  111763. down: Nullable<ArrayBufferView>;
  111764. /**
  111765. * The size of the cubemap stored.
  111766. *
  111767. * Each faces will be size * size pixels.
  111768. */
  111769. size: number;
  111770. /**
  111771. * The format of the texture.
  111772. *
  111773. * RGBA, RGB.
  111774. */
  111775. format: number;
  111776. /**
  111777. * The type of the texture data.
  111778. *
  111779. * UNSIGNED_INT, FLOAT.
  111780. */
  111781. type: number;
  111782. /**
  111783. * Specifies whether the texture is in gamma space.
  111784. */
  111785. gammaSpace: boolean;
  111786. }
  111787. /**
  111788. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111789. */
  111790. export class PanoramaToCubeMapTools {
  111791. private static FACE_FRONT;
  111792. private static FACE_BACK;
  111793. private static FACE_RIGHT;
  111794. private static FACE_LEFT;
  111795. private static FACE_DOWN;
  111796. private static FACE_UP;
  111797. /**
  111798. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111799. *
  111800. * @param float32Array The source data.
  111801. * @param inputWidth The width of the input panorama.
  111802. * @param inputHeight The height of the input panorama.
  111803. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111804. * @return The cubemap data
  111805. */
  111806. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111807. private static CreateCubemapTexture;
  111808. private static CalcProjectionSpherical;
  111809. }
  111810. }
  111811. declare module BABYLON {
  111812. /**
  111813. * Helper class dealing with the extraction of spherical polynomial dataArray
  111814. * from a cube map.
  111815. */
  111816. export class CubeMapToSphericalPolynomialTools {
  111817. private static FileFaces;
  111818. /**
  111819. * Converts a texture to the according Spherical Polynomial data.
  111820. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111821. *
  111822. * @param texture The texture to extract the information from.
  111823. * @return The Spherical Polynomial data.
  111824. */
  111825. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111826. /**
  111827. * Converts a cubemap to the according Spherical Polynomial data.
  111828. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111829. *
  111830. * @param cubeInfo The Cube map to extract the information from.
  111831. * @return The Spherical Polynomial data.
  111832. */
  111833. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111834. }
  111835. }
  111836. declare module BABYLON {
  111837. interface BaseTexture {
  111838. /**
  111839. * Get the polynomial representation of the texture data.
  111840. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111841. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111842. */
  111843. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111844. }
  111845. }
  111846. declare module BABYLON {
  111847. /** @hidden */
  111848. export var rgbdEncodePixelShader: {
  111849. name: string;
  111850. shader: string;
  111851. };
  111852. }
  111853. declare module BABYLON {
  111854. /** @hidden */
  111855. export var rgbdDecodePixelShader: {
  111856. name: string;
  111857. shader: string;
  111858. };
  111859. }
  111860. declare module BABYLON {
  111861. /**
  111862. * Raw texture data and descriptor sufficient for WebGL texture upload
  111863. */
  111864. export interface EnvironmentTextureInfo {
  111865. /**
  111866. * Version of the environment map
  111867. */
  111868. version: number;
  111869. /**
  111870. * Width of image
  111871. */
  111872. width: number;
  111873. /**
  111874. * Irradiance information stored in the file.
  111875. */
  111876. irradiance: any;
  111877. /**
  111878. * Specular information stored in the file.
  111879. */
  111880. specular: any;
  111881. }
  111882. /**
  111883. * Defines One Image in the file. It requires only the position in the file
  111884. * as well as the length.
  111885. */
  111886. interface BufferImageData {
  111887. /**
  111888. * Length of the image data.
  111889. */
  111890. length: number;
  111891. /**
  111892. * Position of the data from the null terminator delimiting the end of the JSON.
  111893. */
  111894. position: number;
  111895. }
  111896. /**
  111897. * Defines the specular data enclosed in the file.
  111898. * This corresponds to the version 1 of the data.
  111899. */
  111900. export interface EnvironmentTextureSpecularInfoV1 {
  111901. /**
  111902. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111903. */
  111904. specularDataPosition?: number;
  111905. /**
  111906. * This contains all the images data needed to reconstruct the cubemap.
  111907. */
  111908. mipmaps: Array<BufferImageData>;
  111909. /**
  111910. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111911. */
  111912. lodGenerationScale: number;
  111913. }
  111914. /**
  111915. * Sets of helpers addressing the serialization and deserialization of environment texture
  111916. * stored in a BabylonJS env file.
  111917. * Those files are usually stored as .env files.
  111918. */
  111919. export class EnvironmentTextureTools {
  111920. /**
  111921. * Magic number identifying the env file.
  111922. */
  111923. private static _MagicBytes;
  111924. /**
  111925. * Gets the environment info from an env file.
  111926. * @param data The array buffer containing the .env bytes.
  111927. * @returns the environment file info (the json header) if successfully parsed.
  111928. */
  111929. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111930. /**
  111931. * Creates an environment texture from a loaded cube texture.
  111932. * @param texture defines the cube texture to convert in env file
  111933. * @return a promise containing the environment data if succesfull.
  111934. */
  111935. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111936. /**
  111937. * Creates a JSON representation of the spherical data.
  111938. * @param texture defines the texture containing the polynomials
  111939. * @return the JSON representation of the spherical info
  111940. */
  111941. private static _CreateEnvTextureIrradiance;
  111942. /**
  111943. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111944. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111945. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111946. * @return the views described by info providing access to the underlying buffer
  111947. */
  111948. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111949. /**
  111950. * Uploads the texture info contained in the env file to the GPU.
  111951. * @param texture defines the internal texture to upload to
  111952. * @param arrayBuffer defines the buffer cotaining the data to load
  111953. * @param info defines the texture info retrieved through the GetEnvInfo method
  111954. * @returns a promise
  111955. */
  111956. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111957. private static _OnImageReadyAsync;
  111958. /**
  111959. * Uploads the levels of image data to the GPU.
  111960. * @param texture defines the internal texture to upload to
  111961. * @param imageData defines the array buffer views of image data [mipmap][face]
  111962. * @returns a promise
  111963. */
  111964. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111965. /**
  111966. * Uploads spherical polynomials information to the texture.
  111967. * @param texture defines the texture we are trying to upload the information to
  111968. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111969. */
  111970. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111971. /** @hidden */
  111972. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111973. }
  111974. }
  111975. declare module BABYLON {
  111976. /**
  111977. * Contains position and normal vectors for a vertex
  111978. */
  111979. export class PositionNormalVertex {
  111980. /** the position of the vertex (defaut: 0,0,0) */
  111981. position: Vector3;
  111982. /** the normal of the vertex (defaut: 0,1,0) */
  111983. normal: Vector3;
  111984. /**
  111985. * Creates a PositionNormalVertex
  111986. * @param position the position of the vertex (defaut: 0,0,0)
  111987. * @param normal the normal of the vertex (defaut: 0,1,0)
  111988. */
  111989. constructor(
  111990. /** the position of the vertex (defaut: 0,0,0) */
  111991. position?: Vector3,
  111992. /** the normal of the vertex (defaut: 0,1,0) */
  111993. normal?: Vector3);
  111994. /**
  111995. * Clones the PositionNormalVertex
  111996. * @returns the cloned PositionNormalVertex
  111997. */
  111998. clone(): PositionNormalVertex;
  111999. }
  112000. /**
  112001. * Contains position, normal and uv vectors for a vertex
  112002. */
  112003. export class PositionNormalTextureVertex {
  112004. /** the position of the vertex (defaut: 0,0,0) */
  112005. position: Vector3;
  112006. /** the normal of the vertex (defaut: 0,1,0) */
  112007. normal: Vector3;
  112008. /** the uv of the vertex (default: 0,0) */
  112009. uv: Vector2;
  112010. /**
  112011. * Creates a PositionNormalTextureVertex
  112012. * @param position the position of the vertex (defaut: 0,0,0)
  112013. * @param normal the normal of the vertex (defaut: 0,1,0)
  112014. * @param uv the uv of the vertex (default: 0,0)
  112015. */
  112016. constructor(
  112017. /** the position of the vertex (defaut: 0,0,0) */
  112018. position?: Vector3,
  112019. /** the normal of the vertex (defaut: 0,1,0) */
  112020. normal?: Vector3,
  112021. /** the uv of the vertex (default: 0,0) */
  112022. uv?: Vector2);
  112023. /**
  112024. * Clones the PositionNormalTextureVertex
  112025. * @returns the cloned PositionNormalTextureVertex
  112026. */
  112027. clone(): PositionNormalTextureVertex;
  112028. }
  112029. }
  112030. declare module BABYLON {
  112031. /** @hidden */
  112032. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112033. private _genericAttributeLocation;
  112034. private _varyingLocationCount;
  112035. private _varyingLocationMap;
  112036. private _replacements;
  112037. private _textureCount;
  112038. private _uniforms;
  112039. lineProcessor(line: string): string;
  112040. attributeProcessor(attribute: string): string;
  112041. varyingProcessor(varying: string, isFragment: boolean): string;
  112042. uniformProcessor(uniform: string): string;
  112043. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112044. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112045. }
  112046. }
  112047. declare module BABYLON {
  112048. /**
  112049. * Container for accessors for natively-stored mesh data buffers.
  112050. */
  112051. class NativeDataBuffer extends DataBuffer {
  112052. /**
  112053. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112054. */
  112055. nativeIndexBuffer?: any;
  112056. /**
  112057. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112058. */
  112059. nativeVertexBuffer?: any;
  112060. }
  112061. /** @hidden */
  112062. export class NativeEngine extends Engine {
  112063. private readonly _native;
  112064. getHardwareScalingLevel(): number;
  112065. constructor();
  112066. /**
  112067. * Can be used to override the current requestAnimationFrame requester.
  112068. * @hidden
  112069. */
  112070. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  112071. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112072. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112073. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112074. recordVertexArrayObject(vertexBuffers: {
  112075. [key: string]: VertexBuffer;
  112076. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112077. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112078. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112079. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112080. /**
  112081. * Draw a list of indexed primitives
  112082. * @param fillMode defines the primitive to use
  112083. * @param indexStart defines the starting index
  112084. * @param indexCount defines the number of index to draw
  112085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112086. */
  112087. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112088. /**
  112089. * Draw a list of unindexed primitives
  112090. * @param fillMode defines the primitive to use
  112091. * @param verticesStart defines the index of first vertex to draw
  112092. * @param verticesCount defines the count of vertices to draw
  112093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112094. */
  112095. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112096. createPipelineContext(): IPipelineContext;
  112097. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112098. /** @hidden */
  112099. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112100. /** @hidden */
  112101. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112102. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112103. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112104. protected _setProgram(program: WebGLProgram): void;
  112105. _releaseEffect(effect: Effect): void;
  112106. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112107. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112108. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112109. bindSamplers(effect: Effect): void;
  112110. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112111. getRenderWidth(useScreen?: boolean): number;
  112112. getRenderHeight(useScreen?: boolean): number;
  112113. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112114. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112115. /**
  112116. * Set the z offset to apply to current rendering
  112117. * @param value defines the offset to apply
  112118. */
  112119. setZOffset(value: number): void;
  112120. /**
  112121. * Gets the current value of the zOffset
  112122. * @returns the current zOffset state
  112123. */
  112124. getZOffset(): number;
  112125. /**
  112126. * Enable or disable depth buffering
  112127. * @param enable defines the state to set
  112128. */
  112129. setDepthBuffer(enable: boolean): void;
  112130. /**
  112131. * Gets a boolean indicating if depth writing is enabled
  112132. * @returns the current depth writing state
  112133. */
  112134. getDepthWrite(): boolean;
  112135. /**
  112136. * Enable or disable depth writing
  112137. * @param enable defines the state to set
  112138. */
  112139. setDepthWrite(enable: boolean): void;
  112140. /**
  112141. * Enable or disable color writing
  112142. * @param enable defines the state to set
  112143. */
  112144. setColorWrite(enable: boolean): void;
  112145. /**
  112146. * Gets a boolean indicating if color writing is enabled
  112147. * @returns the current color writing state
  112148. */
  112149. getColorWrite(): boolean;
  112150. /**
  112151. * Sets alpha constants used by some alpha blending modes
  112152. * @param r defines the red component
  112153. * @param g defines the green component
  112154. * @param b defines the blue component
  112155. * @param a defines the alpha component
  112156. */
  112157. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112158. /**
  112159. * Sets the current alpha mode
  112160. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112161. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112162. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112163. */
  112164. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112165. /**
  112166. * Gets the current alpha mode
  112167. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112168. * @returns the current alpha mode
  112169. */
  112170. getAlphaMode(): number;
  112171. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112172. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112173. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112174. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112175. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112176. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112177. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112178. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112179. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112180. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112181. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112182. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112183. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112184. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112185. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112186. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112187. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112188. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112189. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112190. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112191. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112192. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112193. wipeCaches(bruteForce?: boolean): void;
  112194. _createTexture(): WebGLTexture;
  112195. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112196. /**
  112197. * Usually called from BABYLON.Texture.ts.
  112198. * Passed information to create a WebGLTexture
  112199. * @param urlArg defines a value which contains one of the following:
  112200. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112201. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112202. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112203. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112204. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112205. * @param scene needed for loading to the correct scene
  112206. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112207. * @param onLoad optional callback to be called upon successful completion
  112208. * @param onError optional callback to be called upon failure
  112209. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112210. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112211. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112212. * @param forcedExtension defines the extension to use to pick the right loader
  112213. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112214. */
  112215. 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;
  112216. /**
  112217. * Creates a cube texture
  112218. * @param rootUrl defines the url where the files to load is located
  112219. * @param scene defines the current scene
  112220. * @param files defines the list of files to load (1 per face)
  112221. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112222. * @param onLoad defines an optional callback raised when the texture is loaded
  112223. * @param onError defines an optional callback raised if there is an issue to load the texture
  112224. * @param format defines the format of the data
  112225. * @param forcedExtension defines the extension to use to pick the right loader
  112226. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112227. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112228. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112229. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112230. * @returns the cube texture as an InternalTexture
  112231. */
  112232. 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;
  112233. private _getSamplingFilter;
  112234. private static _GetNativeTextureFormat;
  112235. createRenderTargetTexture(size: number | {
  112236. width: number;
  112237. height: number;
  112238. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112239. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112240. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112241. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112242. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112243. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112244. /**
  112245. * Updates a dynamic vertex buffer.
  112246. * @param vertexBuffer the vertex buffer to update
  112247. * @param data the data used to update the vertex buffer
  112248. * @param byteOffset the byte offset of the data (optional)
  112249. * @param byteLength the byte length of the data (optional)
  112250. */
  112251. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112252. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112253. private _updateAnisotropicLevel;
  112254. private _getAddressMode;
  112255. /** @hidden */
  112256. _bindTexture(channel: number, texture: InternalTexture): void;
  112257. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112258. releaseEffects(): void;
  112259. /** @hidden */
  112260. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112261. /** @hidden */
  112262. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112263. /** @hidden */
  112264. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112265. /** @hidden */
  112266. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112267. }
  112268. }
  112269. declare module BABYLON {
  112270. /**
  112271. * Gather the list of clipboard event types as constants.
  112272. */
  112273. export class ClipboardEventTypes {
  112274. /**
  112275. * The clipboard event is fired when a copy command is active (pressed).
  112276. */
  112277. static readonly COPY: number;
  112278. /**
  112279. * The clipboard event is fired when a cut command is active (pressed).
  112280. */
  112281. static readonly CUT: number;
  112282. /**
  112283. * The clipboard event is fired when a paste command is active (pressed).
  112284. */
  112285. static readonly PASTE: number;
  112286. }
  112287. /**
  112288. * This class is used to store clipboard related info for the onClipboardObservable event.
  112289. */
  112290. export class ClipboardInfo {
  112291. /**
  112292. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112293. */
  112294. type: number;
  112295. /**
  112296. * Defines the related dom event
  112297. */
  112298. event: ClipboardEvent;
  112299. /**
  112300. *Creates an instance of ClipboardInfo.
  112301. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112302. * @param event Defines the related dom event
  112303. */
  112304. constructor(
  112305. /**
  112306. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112307. */
  112308. type: number,
  112309. /**
  112310. * Defines the related dom event
  112311. */
  112312. event: ClipboardEvent);
  112313. /**
  112314. * Get the clipboard event's type from the keycode.
  112315. * @param keyCode Defines the keyCode for the current keyboard event.
  112316. * @return {number}
  112317. */
  112318. static GetTypeFromCharacter(keyCode: number): number;
  112319. }
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * Google Daydream controller
  112324. */
  112325. export class DaydreamController extends WebVRController {
  112326. /**
  112327. * Base Url for the controller model.
  112328. */
  112329. static MODEL_BASE_URL: string;
  112330. /**
  112331. * File name for the controller model.
  112332. */
  112333. static MODEL_FILENAME: string;
  112334. /**
  112335. * Gamepad Id prefix used to identify Daydream Controller.
  112336. */
  112337. static readonly GAMEPAD_ID_PREFIX: string;
  112338. /**
  112339. * Creates a new DaydreamController from a gamepad
  112340. * @param vrGamepad the gamepad that the controller should be created from
  112341. */
  112342. constructor(vrGamepad: any);
  112343. /**
  112344. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112345. * @param scene scene in which to add meshes
  112346. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112347. */
  112348. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112349. /**
  112350. * Called once for each button that changed state since the last frame
  112351. * @param buttonIdx Which button index changed
  112352. * @param state New state of the button
  112353. * @param changes Which properties on the state changed since last frame
  112354. */
  112355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112356. }
  112357. }
  112358. declare module BABYLON {
  112359. /**
  112360. * Gear VR Controller
  112361. */
  112362. export class GearVRController extends WebVRController {
  112363. /**
  112364. * Base Url for the controller model.
  112365. */
  112366. static MODEL_BASE_URL: string;
  112367. /**
  112368. * File name for the controller model.
  112369. */
  112370. static MODEL_FILENAME: string;
  112371. /**
  112372. * Gamepad Id prefix used to identify this controller.
  112373. */
  112374. static readonly GAMEPAD_ID_PREFIX: string;
  112375. private readonly _buttonIndexToObservableNameMap;
  112376. /**
  112377. * Creates a new GearVRController from a gamepad
  112378. * @param vrGamepad the gamepad that the controller should be created from
  112379. */
  112380. constructor(vrGamepad: any);
  112381. /**
  112382. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112383. * @param scene scene in which to add meshes
  112384. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112385. */
  112386. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112387. /**
  112388. * Called once for each button that changed state since the last frame
  112389. * @param buttonIdx Which button index changed
  112390. * @param state New state of the button
  112391. * @param changes Which properties on the state changed since last frame
  112392. */
  112393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112394. }
  112395. }
  112396. declare module BABYLON {
  112397. /**
  112398. * Class containing static functions to help procedurally build meshes
  112399. */
  112400. export class PolyhedronBuilder {
  112401. /**
  112402. * Creates a polyhedron mesh
  112403. * * 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
  112404. * * The parameter `size` (positive float, default 1) sets the polygon size
  112405. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112406. * * 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`
  112407. * * 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
  112408. * * 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)`)
  112409. * * 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
  112410. * * 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
  112411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112414. * @param name defines the name of the mesh
  112415. * @param options defines the options used to create the mesh
  112416. * @param scene defines the hosting scene
  112417. * @returns the polyhedron mesh
  112418. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112419. */
  112420. static CreatePolyhedron(name: string, options: {
  112421. type?: number;
  112422. size?: number;
  112423. sizeX?: number;
  112424. sizeY?: number;
  112425. sizeZ?: number;
  112426. custom?: any;
  112427. faceUV?: Vector4[];
  112428. faceColors?: Color4[];
  112429. flat?: boolean;
  112430. updatable?: boolean;
  112431. sideOrientation?: number;
  112432. frontUVs?: Vector4;
  112433. backUVs?: Vector4;
  112434. }, scene?: Nullable<Scene>): Mesh;
  112435. }
  112436. }
  112437. declare module BABYLON {
  112438. /**
  112439. * Gizmo that enables scaling a mesh along 3 axis
  112440. */
  112441. export class ScaleGizmo extends Gizmo {
  112442. /**
  112443. * Internal gizmo used for interactions on the x axis
  112444. */
  112445. xGizmo: AxisScaleGizmo;
  112446. /**
  112447. * Internal gizmo used for interactions on the y axis
  112448. */
  112449. yGizmo: AxisScaleGizmo;
  112450. /**
  112451. * Internal gizmo used for interactions on the z axis
  112452. */
  112453. zGizmo: AxisScaleGizmo;
  112454. /**
  112455. * Internal gizmo used to scale all axis equally
  112456. */
  112457. uniformScaleGizmo: AxisScaleGizmo;
  112458. private _meshAttached;
  112459. private _updateGizmoRotationToMatchAttachedMesh;
  112460. private _snapDistance;
  112461. private _scaleRatio;
  112462. private _uniformScalingMesh;
  112463. private _octahedron;
  112464. /** Fires an event when any of it's sub gizmos are dragged */
  112465. onDragStartObservable: Observable<unknown>;
  112466. /** Fires an event when any of it's sub gizmos are released from dragging */
  112467. onDragEndObservable: Observable<unknown>;
  112468. attachedMesh: Nullable<AbstractMesh>;
  112469. /**
  112470. * Creates a ScaleGizmo
  112471. * @param gizmoLayer The utility layer the gizmo will be added to
  112472. */
  112473. constructor(gizmoLayer?: UtilityLayerRenderer);
  112474. updateGizmoRotationToMatchAttachedMesh: boolean;
  112475. /**
  112476. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112477. */
  112478. snapDistance: number;
  112479. /**
  112480. * Ratio for the scale of the gizmo (Default: 1)
  112481. */
  112482. scaleRatio: number;
  112483. /**
  112484. * Disposes of the gizmo
  112485. */
  112486. dispose(): void;
  112487. }
  112488. }
  112489. declare module BABYLON {
  112490. /**
  112491. * Single axis scale gizmo
  112492. */
  112493. export class AxisScaleGizmo extends Gizmo {
  112494. /**
  112495. * Drag behavior responsible for the gizmos dragging interactions
  112496. */
  112497. dragBehavior: PointerDragBehavior;
  112498. private _pointerObserver;
  112499. /**
  112500. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112501. */
  112502. snapDistance: number;
  112503. /**
  112504. * Event that fires each time the gizmo snaps to a new location.
  112505. * * snapDistance is the the change in distance
  112506. */
  112507. onSnapObservable: Observable<{
  112508. snapDistance: number;
  112509. }>;
  112510. /**
  112511. * If the scaling operation should be done on all axis (default: false)
  112512. */
  112513. uniformScaling: boolean;
  112514. private _isEnabled;
  112515. private _parent;
  112516. private _arrow;
  112517. private _coloredMaterial;
  112518. private _hoverMaterial;
  112519. /**
  112520. * Creates an AxisScaleGizmo
  112521. * @param gizmoLayer The utility layer the gizmo will be added to
  112522. * @param dragAxis The axis which the gizmo will be able to scale on
  112523. * @param color The color of the gizmo
  112524. */
  112525. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112526. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112527. /**
  112528. * If the gizmo is enabled
  112529. */
  112530. isEnabled: boolean;
  112531. /**
  112532. * Disposes of the gizmo
  112533. */
  112534. dispose(): void;
  112535. /**
  112536. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112537. * @param mesh The mesh to replace the default mesh of the gizmo
  112538. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112539. */
  112540. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112541. }
  112542. }
  112543. declare module BABYLON {
  112544. /**
  112545. * Bounding box gizmo
  112546. */
  112547. export class BoundingBoxGizmo extends Gizmo {
  112548. private _lineBoundingBox;
  112549. private _rotateSpheresParent;
  112550. private _scaleBoxesParent;
  112551. private _boundingDimensions;
  112552. private _renderObserver;
  112553. private _pointerObserver;
  112554. private _scaleDragSpeed;
  112555. private _tmpQuaternion;
  112556. private _tmpVector;
  112557. private _tmpRotationMatrix;
  112558. /**
  112559. * 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)
  112560. */
  112561. ignoreChildren: boolean;
  112562. /**
  112563. * 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)
  112564. */
  112565. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112566. /**
  112567. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112568. */
  112569. rotationSphereSize: number;
  112570. /**
  112571. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112572. */
  112573. scaleBoxSize: number;
  112574. /**
  112575. * 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)
  112576. */
  112577. fixedDragMeshScreenSize: boolean;
  112578. /**
  112579. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112580. */
  112581. fixedDragMeshScreenSizeDistanceFactor: number;
  112582. /**
  112583. * Fired when a rotation sphere or scale box is dragged
  112584. */
  112585. onDragStartObservable: Observable<{}>;
  112586. /**
  112587. * Fired when a scale box is dragged
  112588. */
  112589. onScaleBoxDragObservable: Observable<{}>;
  112590. /**
  112591. * Fired when a scale box drag is ended
  112592. */
  112593. onScaleBoxDragEndObservable: Observable<{}>;
  112594. /**
  112595. * Fired when a rotation sphere is dragged
  112596. */
  112597. onRotationSphereDragObservable: Observable<{}>;
  112598. /**
  112599. * Fired when a rotation sphere drag is ended
  112600. */
  112601. onRotationSphereDragEndObservable: Observable<{}>;
  112602. /**
  112603. * 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)
  112604. */
  112605. scalePivot: Nullable<Vector3>;
  112606. /**
  112607. * Mesh used as a pivot to rotate the attached mesh
  112608. */
  112609. private _anchorMesh;
  112610. private _existingMeshScale;
  112611. private _dragMesh;
  112612. private pointerDragBehavior;
  112613. private coloredMaterial;
  112614. private hoverColoredMaterial;
  112615. /**
  112616. * Sets the color of the bounding box gizmo
  112617. * @param color the color to set
  112618. */
  112619. setColor(color: Color3): void;
  112620. /**
  112621. * Creates an BoundingBoxGizmo
  112622. * @param gizmoLayer The utility layer the gizmo will be added to
  112623. * @param color The color of the gizmo
  112624. */
  112625. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112626. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112627. private _selectNode;
  112628. /**
  112629. * Updates the bounding box information for the Gizmo
  112630. */
  112631. updateBoundingBox(): void;
  112632. private _updateRotationSpheres;
  112633. private _updateScaleBoxes;
  112634. /**
  112635. * Enables rotation on the specified axis and disables rotation on the others
  112636. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112637. */
  112638. setEnabledRotationAxis(axis: string): void;
  112639. /**
  112640. * Enables/disables scaling
  112641. * @param enable if scaling should be enabled
  112642. */
  112643. setEnabledScaling(enable: boolean): void;
  112644. private _updateDummy;
  112645. /**
  112646. * Enables a pointer drag behavior on the bounding box of the gizmo
  112647. */
  112648. enableDragBehavior(): void;
  112649. /**
  112650. * Disposes of the gizmo
  112651. */
  112652. dispose(): void;
  112653. /**
  112654. * 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)
  112655. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112656. * @returns the bounding box mesh with the passed in mesh as a child
  112657. */
  112658. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112659. /**
  112660. * CustomMeshes are not supported by this gizmo
  112661. * @param mesh The mesh to replace the default mesh of the gizmo
  112662. */
  112663. setCustomMesh(mesh: Mesh): void;
  112664. }
  112665. }
  112666. declare module BABYLON {
  112667. /**
  112668. * Single plane rotation gizmo
  112669. */
  112670. export class PlaneRotationGizmo extends Gizmo {
  112671. /**
  112672. * Drag behavior responsible for the gizmos dragging interactions
  112673. */
  112674. dragBehavior: PointerDragBehavior;
  112675. private _pointerObserver;
  112676. /**
  112677. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112678. */
  112679. snapDistance: number;
  112680. /**
  112681. * Event that fires each time the gizmo snaps to a new location.
  112682. * * snapDistance is the the change in distance
  112683. */
  112684. onSnapObservable: Observable<{
  112685. snapDistance: number;
  112686. }>;
  112687. private _isEnabled;
  112688. private _parent;
  112689. /**
  112690. * Creates a PlaneRotationGizmo
  112691. * @param gizmoLayer The utility layer the gizmo will be added to
  112692. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112693. * @param color The color of the gizmo
  112694. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112695. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112696. */
  112697. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112699. /**
  112700. * If the gizmo is enabled
  112701. */
  112702. isEnabled: boolean;
  112703. /**
  112704. * Disposes of the gizmo
  112705. */
  112706. dispose(): void;
  112707. }
  112708. }
  112709. declare module BABYLON {
  112710. /**
  112711. * Gizmo that enables rotating a mesh along 3 axis
  112712. */
  112713. export class RotationGizmo extends Gizmo {
  112714. /**
  112715. * Internal gizmo used for interactions on the x axis
  112716. */
  112717. xGizmo: PlaneRotationGizmo;
  112718. /**
  112719. * Internal gizmo used for interactions on the y axis
  112720. */
  112721. yGizmo: PlaneRotationGizmo;
  112722. /**
  112723. * Internal gizmo used for interactions on the z axis
  112724. */
  112725. zGizmo: PlaneRotationGizmo;
  112726. /** Fires an event when any of it's sub gizmos are dragged */
  112727. onDragStartObservable: Observable<unknown>;
  112728. /** Fires an event when any of it's sub gizmos are released from dragging */
  112729. onDragEndObservable: Observable<unknown>;
  112730. private _meshAttached;
  112731. attachedMesh: Nullable<AbstractMesh>;
  112732. /**
  112733. * Creates a RotationGizmo
  112734. * @param gizmoLayer The utility layer the gizmo will be added to
  112735. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112736. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112737. */
  112738. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112739. updateGizmoRotationToMatchAttachedMesh: boolean;
  112740. /**
  112741. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112742. */
  112743. snapDistance: number;
  112744. /**
  112745. * Ratio for the scale of the gizmo (Default: 1)
  112746. */
  112747. scaleRatio: number;
  112748. /**
  112749. * Disposes of the gizmo
  112750. */
  112751. dispose(): void;
  112752. /**
  112753. * CustomMeshes are not supported by this gizmo
  112754. * @param mesh The mesh to replace the default mesh of the gizmo
  112755. */
  112756. setCustomMesh(mesh: Mesh): void;
  112757. }
  112758. }
  112759. declare module BABYLON {
  112760. /**
  112761. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112762. */
  112763. export class GizmoManager implements IDisposable {
  112764. private scene;
  112765. /**
  112766. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112767. */
  112768. gizmos: {
  112769. positionGizmo: Nullable<PositionGizmo>;
  112770. rotationGizmo: Nullable<RotationGizmo>;
  112771. scaleGizmo: Nullable<ScaleGizmo>;
  112772. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112773. };
  112774. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112775. clearGizmoOnEmptyPointerEvent: boolean;
  112776. /** Fires an event when the manager is attached to a mesh */
  112777. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112778. private _gizmosEnabled;
  112779. private _pointerObserver;
  112780. private _attachedMesh;
  112781. private _boundingBoxColor;
  112782. private _defaultUtilityLayer;
  112783. private _defaultKeepDepthUtilityLayer;
  112784. /**
  112785. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112786. */
  112787. boundingBoxDragBehavior: SixDofDragBehavior;
  112788. /**
  112789. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112790. */
  112791. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112792. /**
  112793. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112794. */
  112795. usePointerToAttachGizmos: boolean;
  112796. /**
  112797. * Utility layer that the bounding box gizmo belongs to
  112798. */
  112799. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112800. /**
  112801. * Utility layer that all gizmos besides bounding box belong to
  112802. */
  112803. readonly utilityLayer: UtilityLayerRenderer;
  112804. /**
  112805. * Instatiates a gizmo manager
  112806. * @param scene the scene to overlay the gizmos on top of
  112807. */
  112808. constructor(scene: Scene);
  112809. /**
  112810. * Attaches a set of gizmos to the specified mesh
  112811. * @param mesh The mesh the gizmo's should be attached to
  112812. */
  112813. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112814. /**
  112815. * If the position gizmo is enabled
  112816. */
  112817. positionGizmoEnabled: boolean;
  112818. /**
  112819. * If the rotation gizmo is enabled
  112820. */
  112821. rotationGizmoEnabled: boolean;
  112822. /**
  112823. * If the scale gizmo is enabled
  112824. */
  112825. scaleGizmoEnabled: boolean;
  112826. /**
  112827. * If the boundingBox gizmo is enabled
  112828. */
  112829. boundingBoxGizmoEnabled: boolean;
  112830. /**
  112831. * Disposes of the gizmo manager
  112832. */
  112833. dispose(): void;
  112834. }
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * A directional light is defined by a direction (what a surprise!).
  112839. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112840. * 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.
  112841. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112842. */
  112843. export class DirectionalLight extends ShadowLight {
  112844. private _shadowFrustumSize;
  112845. /**
  112846. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112847. */
  112848. /**
  112849. * Specifies a fix frustum size for the shadow generation.
  112850. */
  112851. shadowFrustumSize: number;
  112852. private _shadowOrthoScale;
  112853. /**
  112854. * Gets the shadow projection scale against the optimal computed one.
  112855. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112856. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112857. */
  112858. /**
  112859. * Sets the shadow projection scale against the optimal computed one.
  112860. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112861. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112862. */
  112863. shadowOrthoScale: number;
  112864. /**
  112865. * Automatically compute the projection matrix to best fit (including all the casters)
  112866. * on each frame.
  112867. */
  112868. autoUpdateExtends: boolean;
  112869. private _orthoLeft;
  112870. private _orthoRight;
  112871. private _orthoTop;
  112872. private _orthoBottom;
  112873. /**
  112874. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112875. * The directional light is emitted from everywhere in the given direction.
  112876. * It can cast shadows.
  112877. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112878. * @param name The friendly name of the light
  112879. * @param direction The direction of the light
  112880. * @param scene The scene the light belongs to
  112881. */
  112882. constructor(name: string, direction: Vector3, scene: Scene);
  112883. /**
  112884. * Returns the string "DirectionalLight".
  112885. * @return The class name
  112886. */
  112887. getClassName(): string;
  112888. /**
  112889. * Returns the integer 1.
  112890. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112891. */
  112892. getTypeID(): number;
  112893. /**
  112894. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112895. * Returns the DirectionalLight Shadow projection matrix.
  112896. */
  112897. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112898. /**
  112899. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112900. * Returns the DirectionalLight Shadow projection matrix.
  112901. */
  112902. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112903. /**
  112904. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112905. * Returns the DirectionalLight Shadow projection matrix.
  112906. */
  112907. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112908. protected _buildUniformLayout(): void;
  112909. /**
  112910. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112911. * @param effect The effect to update
  112912. * @param lightIndex The index of the light in the effect to update
  112913. * @returns The directional light
  112914. */
  112915. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112916. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112917. /**
  112918. * Gets the minZ used for shadow according to both the scene and the light.
  112919. *
  112920. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112921. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112922. * @param activeCamera The camera we are returning the min for
  112923. * @returns the depth min z
  112924. */
  112925. getDepthMinZ(activeCamera: Camera): number;
  112926. /**
  112927. * Gets the maxZ used for shadow according to both the scene and the light.
  112928. *
  112929. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112930. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112931. * @param activeCamera The camera we are returning the max for
  112932. * @returns the depth max z
  112933. */
  112934. getDepthMaxZ(activeCamera: Camera): number;
  112935. /**
  112936. * Prepares the list of defines specific to the light type.
  112937. * @param defines the list of defines
  112938. * @param lightIndex defines the index of the light for the effect
  112939. */
  112940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112941. }
  112942. }
  112943. declare module BABYLON {
  112944. /**
  112945. * Class containing static functions to help procedurally build meshes
  112946. */
  112947. export class HemisphereBuilder {
  112948. /**
  112949. * Creates a hemisphere mesh
  112950. * @param name defines the name of the mesh
  112951. * @param options defines the options used to create the mesh
  112952. * @param scene defines the hosting scene
  112953. * @returns the hemisphere mesh
  112954. */
  112955. static CreateHemisphere(name: string, options: {
  112956. segments?: number;
  112957. diameter?: number;
  112958. sideOrientation?: number;
  112959. }, scene: any): Mesh;
  112960. }
  112961. }
  112962. declare module BABYLON {
  112963. /**
  112964. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112965. * These values define a cone of light starting from the position, emitting toward the direction.
  112966. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112967. * and the exponent defines the speed of the decay of the light with distance (reach).
  112968. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112969. */
  112970. export class SpotLight extends ShadowLight {
  112971. private _angle;
  112972. private _innerAngle;
  112973. private _cosHalfAngle;
  112974. private _lightAngleScale;
  112975. private _lightAngleOffset;
  112976. /**
  112977. * Gets the cone angle of the spot light in Radians.
  112978. */
  112979. /**
  112980. * Sets the cone angle of the spot light in Radians.
  112981. */
  112982. angle: number;
  112983. /**
  112984. * Only used in gltf falloff mode, this defines the angle where
  112985. * the directional falloff will start before cutting at angle which could be seen
  112986. * as outer angle.
  112987. */
  112988. /**
  112989. * Only used in gltf falloff mode, this defines the angle where
  112990. * the directional falloff will start before cutting at angle which could be seen
  112991. * as outer angle.
  112992. */
  112993. innerAngle: number;
  112994. private _shadowAngleScale;
  112995. /**
  112996. * Allows scaling the angle of the light for shadow generation only.
  112997. */
  112998. /**
  112999. * Allows scaling the angle of the light for shadow generation only.
  113000. */
  113001. shadowAngleScale: number;
  113002. /**
  113003. * The light decay speed with the distance from the emission spot.
  113004. */
  113005. exponent: number;
  113006. private _projectionTextureMatrix;
  113007. /**
  113008. * Allows reading the projecton texture
  113009. */
  113010. readonly projectionTextureMatrix: Matrix;
  113011. protected _projectionTextureLightNear: number;
  113012. /**
  113013. * Gets the near clip of the Spotlight for texture projection.
  113014. */
  113015. /**
  113016. * Sets the near clip of the Spotlight for texture projection.
  113017. */
  113018. projectionTextureLightNear: number;
  113019. protected _projectionTextureLightFar: number;
  113020. /**
  113021. * Gets the far clip of the Spotlight for texture projection.
  113022. */
  113023. /**
  113024. * Sets the far clip of the Spotlight for texture projection.
  113025. */
  113026. projectionTextureLightFar: number;
  113027. protected _projectionTextureUpDirection: Vector3;
  113028. /**
  113029. * Gets the Up vector of the Spotlight for texture projection.
  113030. */
  113031. /**
  113032. * Sets the Up vector of the Spotlight for texture projection.
  113033. */
  113034. projectionTextureUpDirection: Vector3;
  113035. private _projectionTexture;
  113036. /**
  113037. * Gets the projection texture of the light.
  113038. */
  113039. /**
  113040. * Sets the projection texture of the light.
  113041. */
  113042. projectionTexture: Nullable<BaseTexture>;
  113043. private _projectionTextureViewLightDirty;
  113044. private _projectionTextureProjectionLightDirty;
  113045. private _projectionTextureDirty;
  113046. private _projectionTextureViewTargetVector;
  113047. private _projectionTextureViewLightMatrix;
  113048. private _projectionTextureProjectionLightMatrix;
  113049. private _projectionTextureScalingMatrix;
  113050. /**
  113051. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113052. * It can cast shadows.
  113053. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113054. * @param name The light friendly name
  113055. * @param position The position of the spot light in the scene
  113056. * @param direction The direction of the light in the scene
  113057. * @param angle The cone angle of the light in Radians
  113058. * @param exponent The light decay speed with the distance from the emission spot
  113059. * @param scene The scene the lights belongs to
  113060. */
  113061. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113062. /**
  113063. * Returns the string "SpotLight".
  113064. * @returns the class name
  113065. */
  113066. getClassName(): string;
  113067. /**
  113068. * Returns the integer 2.
  113069. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113070. */
  113071. getTypeID(): number;
  113072. /**
  113073. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113074. */
  113075. protected _setDirection(value: Vector3): void;
  113076. /**
  113077. * Overrides the position setter to recompute the projection texture view light Matrix.
  113078. */
  113079. protected _setPosition(value: Vector3): void;
  113080. /**
  113081. * 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.
  113082. * Returns the SpotLight.
  113083. */
  113084. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113085. protected _computeProjectionTextureViewLightMatrix(): void;
  113086. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113087. /**
  113088. * Main function for light texture projection matrix computing.
  113089. */
  113090. protected _computeProjectionTextureMatrix(): void;
  113091. protected _buildUniformLayout(): void;
  113092. private _computeAngleValues;
  113093. /**
  113094. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113095. * @param effect The effect to update
  113096. * @param lightIndex The index of the light in the effect to update
  113097. * @returns The spot light
  113098. */
  113099. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113100. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113101. /**
  113102. * Disposes the light and the associated resources.
  113103. */
  113104. dispose(): void;
  113105. /**
  113106. * Prepares the list of defines specific to the light type.
  113107. * @param defines the list of defines
  113108. * @param lightIndex defines the index of the light for the effect
  113109. */
  113110. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113111. }
  113112. }
  113113. declare module BABYLON {
  113114. /**
  113115. * Gizmo that enables viewing a light
  113116. */
  113117. export class LightGizmo extends Gizmo {
  113118. private _lightMesh;
  113119. private _material;
  113120. private cachedPosition;
  113121. private cachedForward;
  113122. /**
  113123. * Creates a LightGizmo
  113124. * @param gizmoLayer The utility layer the gizmo will be added to
  113125. */
  113126. constructor(gizmoLayer?: UtilityLayerRenderer);
  113127. private _light;
  113128. /**
  113129. * The light that the gizmo is attached to
  113130. */
  113131. light: Nullable<Light>;
  113132. /**
  113133. * Gets the material used to render the light gizmo
  113134. */
  113135. readonly material: StandardMaterial;
  113136. /**
  113137. * @hidden
  113138. * Updates the gizmo to match the attached mesh's position/rotation
  113139. */
  113140. protected _update(): void;
  113141. private static _Scale;
  113142. /**
  113143. * Creates the lines for a light mesh
  113144. */
  113145. private static _createLightLines;
  113146. /**
  113147. * Disposes of the light gizmo
  113148. */
  113149. dispose(): void;
  113150. private static _CreateHemisphericLightMesh;
  113151. private static _CreatePointLightMesh;
  113152. private static _CreateSpotLightMesh;
  113153. private static _CreateDirectionalLightMesh;
  113154. }
  113155. }
  113156. declare module BABYLON {
  113157. /** @hidden */
  113158. export var backgroundFragmentDeclaration: {
  113159. name: string;
  113160. shader: string;
  113161. };
  113162. }
  113163. declare module BABYLON {
  113164. /** @hidden */
  113165. export var backgroundUboDeclaration: {
  113166. name: string;
  113167. shader: string;
  113168. };
  113169. }
  113170. declare module BABYLON {
  113171. /** @hidden */
  113172. export var backgroundPixelShader: {
  113173. name: string;
  113174. shader: string;
  113175. };
  113176. }
  113177. declare module BABYLON {
  113178. /** @hidden */
  113179. export var backgroundVertexDeclaration: {
  113180. name: string;
  113181. shader: string;
  113182. };
  113183. }
  113184. declare module BABYLON {
  113185. /** @hidden */
  113186. export var backgroundVertexShader: {
  113187. name: string;
  113188. shader: string;
  113189. };
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Background material used to create an efficient environement around your scene.
  113194. */
  113195. export class BackgroundMaterial extends PushMaterial {
  113196. /**
  113197. * Standard reflectance value at parallel view angle.
  113198. */
  113199. static StandardReflectance0: number;
  113200. /**
  113201. * Standard reflectance value at grazing angle.
  113202. */
  113203. static StandardReflectance90: number;
  113204. protected _primaryColor: Color3;
  113205. /**
  113206. * Key light Color (multiply against the environement texture)
  113207. */
  113208. primaryColor: Color3;
  113209. protected __perceptualColor: Nullable<Color3>;
  113210. /**
  113211. * Experimental Internal Use Only.
  113212. *
  113213. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113214. * This acts as a helper to set the primary color to a more "human friendly" value.
  113215. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113216. * output color as close as possible from the chosen value.
  113217. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113218. * part of lighting setup.)
  113219. */
  113220. _perceptualColor: Nullable<Color3>;
  113221. protected _primaryColorShadowLevel: float;
  113222. /**
  113223. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113224. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113225. */
  113226. primaryColorShadowLevel: float;
  113227. protected _primaryColorHighlightLevel: float;
  113228. /**
  113229. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113230. * The primary color is used at the level chosen to define what the white area would look.
  113231. */
  113232. primaryColorHighlightLevel: float;
  113233. protected _reflectionTexture: Nullable<BaseTexture>;
  113234. /**
  113235. * Reflection Texture used in the material.
  113236. * Should be author in a specific way for the best result (refer to the documentation).
  113237. */
  113238. reflectionTexture: Nullable<BaseTexture>;
  113239. protected _reflectionBlur: float;
  113240. /**
  113241. * Reflection Texture level of blur.
  113242. *
  113243. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113244. * texture twice.
  113245. */
  113246. reflectionBlur: float;
  113247. protected _diffuseTexture: Nullable<BaseTexture>;
  113248. /**
  113249. * Diffuse Texture used in the material.
  113250. * Should be author in a specific way for the best result (refer to the documentation).
  113251. */
  113252. diffuseTexture: Nullable<BaseTexture>;
  113253. protected _shadowLights: Nullable<IShadowLight[]>;
  113254. /**
  113255. * Specify the list of lights casting shadow on the material.
  113256. * All scene shadow lights will be included if null.
  113257. */
  113258. shadowLights: Nullable<IShadowLight[]>;
  113259. protected _shadowLevel: float;
  113260. /**
  113261. * Helps adjusting the shadow to a softer level if required.
  113262. * 0 means black shadows and 1 means no shadows.
  113263. */
  113264. shadowLevel: float;
  113265. protected _sceneCenter: Vector3;
  113266. /**
  113267. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113268. * It is usually zero but might be interesting to modify according to your setup.
  113269. */
  113270. sceneCenter: Vector3;
  113271. protected _opacityFresnel: boolean;
  113272. /**
  113273. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113274. * This helps ensuring a nice transition when the camera goes under the ground.
  113275. */
  113276. opacityFresnel: boolean;
  113277. protected _reflectionFresnel: boolean;
  113278. /**
  113279. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113280. * This helps adding a mirror texture on the ground.
  113281. */
  113282. reflectionFresnel: boolean;
  113283. protected _reflectionFalloffDistance: number;
  113284. /**
  113285. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113286. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113287. */
  113288. reflectionFalloffDistance: number;
  113289. protected _reflectionAmount: number;
  113290. /**
  113291. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113292. */
  113293. reflectionAmount: number;
  113294. protected _reflectionReflectance0: number;
  113295. /**
  113296. * This specifies the weight of the reflection at grazing angle.
  113297. */
  113298. reflectionReflectance0: number;
  113299. protected _reflectionReflectance90: number;
  113300. /**
  113301. * This specifies the weight of the reflection at a perpendicular point of view.
  113302. */
  113303. reflectionReflectance90: number;
  113304. /**
  113305. * Sets the reflection reflectance fresnel values according to the default standard
  113306. * empirically know to work well :-)
  113307. */
  113308. reflectionStandardFresnelWeight: number;
  113309. protected _useRGBColor: boolean;
  113310. /**
  113311. * Helps to directly use the maps channels instead of their level.
  113312. */
  113313. useRGBColor: boolean;
  113314. protected _enableNoise: boolean;
  113315. /**
  113316. * This helps reducing the banding effect that could occur on the background.
  113317. */
  113318. enableNoise: boolean;
  113319. /**
  113320. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113321. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113322. * Recommended to be keep at 1.0 except for special cases.
  113323. */
  113324. fovMultiplier: number;
  113325. private _fovMultiplier;
  113326. /**
  113327. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113328. */
  113329. useEquirectangularFOV: boolean;
  113330. private _maxSimultaneousLights;
  113331. /**
  113332. * Number of Simultaneous lights allowed on the material.
  113333. */
  113334. maxSimultaneousLights: int;
  113335. /**
  113336. * Default configuration related to image processing available in the Background Material.
  113337. */
  113338. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113339. /**
  113340. * Keep track of the image processing observer to allow dispose and replace.
  113341. */
  113342. private _imageProcessingObserver;
  113343. /**
  113344. * Attaches a new image processing configuration to the PBR Material.
  113345. * @param configuration (if null the scene configuration will be use)
  113346. */
  113347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113348. /**
  113349. * Gets the image processing configuration used either in this material.
  113350. */
  113351. /**
  113352. * Sets the Default image processing configuration used either in the this material.
  113353. *
  113354. * If sets to null, the scene one is in use.
  113355. */
  113356. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113357. /**
  113358. * Gets wether the color curves effect is enabled.
  113359. */
  113360. /**
  113361. * Sets wether the color curves effect is enabled.
  113362. */
  113363. cameraColorCurvesEnabled: boolean;
  113364. /**
  113365. * Gets wether the color grading effect is enabled.
  113366. */
  113367. /**
  113368. * Gets wether the color grading effect is enabled.
  113369. */
  113370. cameraColorGradingEnabled: boolean;
  113371. /**
  113372. * Gets wether tonemapping is enabled or not.
  113373. */
  113374. /**
  113375. * Sets wether tonemapping is enabled or not
  113376. */
  113377. cameraToneMappingEnabled: boolean;
  113378. /**
  113379. * The camera exposure used on this material.
  113380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113381. * This corresponds to a photographic exposure.
  113382. */
  113383. /**
  113384. * The camera exposure used on this material.
  113385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113386. * This corresponds to a photographic exposure.
  113387. */
  113388. cameraExposure: float;
  113389. /**
  113390. * Gets The camera contrast used on this material.
  113391. */
  113392. /**
  113393. * Sets The camera contrast used on this material.
  113394. */
  113395. cameraContrast: float;
  113396. /**
  113397. * Gets the Color Grading 2D Lookup Texture.
  113398. */
  113399. /**
  113400. * Sets the Color Grading 2D Lookup Texture.
  113401. */
  113402. cameraColorGradingTexture: Nullable<BaseTexture>;
  113403. /**
  113404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113406. * 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;
  113407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113408. */
  113409. /**
  113410. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113411. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113412. * 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;
  113413. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113414. */
  113415. cameraColorCurves: Nullable<ColorCurves>;
  113416. /**
  113417. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113418. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113419. */
  113420. switchToBGR: boolean;
  113421. private _renderTargets;
  113422. private _reflectionControls;
  113423. private _white;
  113424. private _primaryShadowColor;
  113425. private _primaryHighlightColor;
  113426. /**
  113427. * Instantiates a Background Material in the given scene
  113428. * @param name The friendly name of the material
  113429. * @param scene The scene to add the material to
  113430. */
  113431. constructor(name: string, scene: Scene);
  113432. /**
  113433. * Gets a boolean indicating that current material needs to register RTT
  113434. */
  113435. readonly hasRenderTargetTextures: boolean;
  113436. /**
  113437. * The entire material has been created in order to prevent overdraw.
  113438. * @returns false
  113439. */
  113440. needAlphaTesting(): boolean;
  113441. /**
  113442. * The entire material has been created in order to prevent overdraw.
  113443. * @returns true if blending is enable
  113444. */
  113445. needAlphaBlending(): boolean;
  113446. /**
  113447. * Checks wether the material is ready to be rendered for a given mesh.
  113448. * @param mesh The mesh to render
  113449. * @param subMesh The submesh to check against
  113450. * @param useInstances Specify wether or not the material is used with instances
  113451. * @returns true if all the dependencies are ready (Textures, Effects...)
  113452. */
  113453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113454. /**
  113455. * Compute the primary color according to the chosen perceptual color.
  113456. */
  113457. private _computePrimaryColorFromPerceptualColor;
  113458. /**
  113459. * Compute the highlights and shadow colors according to their chosen levels.
  113460. */
  113461. private _computePrimaryColors;
  113462. /**
  113463. * Build the uniform buffer used in the material.
  113464. */
  113465. buildUniformLayout(): void;
  113466. /**
  113467. * Unbind the material.
  113468. */
  113469. unbind(): void;
  113470. /**
  113471. * Bind only the world matrix to the material.
  113472. * @param world The world matrix to bind.
  113473. */
  113474. bindOnlyWorldMatrix(world: Matrix): void;
  113475. /**
  113476. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113477. * @param world The world matrix to bind.
  113478. * @param subMesh The submesh to bind for.
  113479. */
  113480. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113481. /**
  113482. * Checks to see if a texture is used in the material.
  113483. * @param texture - Base texture to use.
  113484. * @returns - Boolean specifying if a texture is used in the material.
  113485. */
  113486. hasTexture(texture: BaseTexture): boolean;
  113487. /**
  113488. * Dispose the material.
  113489. * @param forceDisposeEffect Force disposal of the associated effect.
  113490. * @param forceDisposeTextures Force disposal of the associated textures.
  113491. */
  113492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113493. /**
  113494. * Clones the material.
  113495. * @param name The cloned name.
  113496. * @returns The cloned material.
  113497. */
  113498. clone(name: string): BackgroundMaterial;
  113499. /**
  113500. * Serializes the current material to its JSON representation.
  113501. * @returns The JSON representation.
  113502. */
  113503. serialize(): any;
  113504. /**
  113505. * Gets the class name of the material
  113506. * @returns "BackgroundMaterial"
  113507. */
  113508. getClassName(): string;
  113509. /**
  113510. * Parse a JSON input to create back a background material.
  113511. * @param source The JSON data to parse
  113512. * @param scene The scene to create the parsed material in
  113513. * @param rootUrl The root url of the assets the material depends upon
  113514. * @returns the instantiated BackgroundMaterial.
  113515. */
  113516. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113517. }
  113518. }
  113519. declare module BABYLON {
  113520. /**
  113521. * Represents the different options available during the creation of
  113522. * a Environment helper.
  113523. *
  113524. * This can control the default ground, skybox and image processing setup of your scene.
  113525. */
  113526. export interface IEnvironmentHelperOptions {
  113527. /**
  113528. * Specifies wether or not to create a ground.
  113529. * True by default.
  113530. */
  113531. createGround: boolean;
  113532. /**
  113533. * Specifies the ground size.
  113534. * 15 by default.
  113535. */
  113536. groundSize: number;
  113537. /**
  113538. * The texture used on the ground for the main color.
  113539. * Comes from the BabylonJS CDN by default.
  113540. *
  113541. * Remarks: Can be either a texture or a url.
  113542. */
  113543. groundTexture: string | BaseTexture;
  113544. /**
  113545. * The color mixed in the ground texture by default.
  113546. * BabylonJS clearColor by default.
  113547. */
  113548. groundColor: Color3;
  113549. /**
  113550. * Specifies the ground opacity.
  113551. * 1 by default.
  113552. */
  113553. groundOpacity: number;
  113554. /**
  113555. * Enables the ground to receive shadows.
  113556. * True by default.
  113557. */
  113558. enableGroundShadow: boolean;
  113559. /**
  113560. * Helps preventing the shadow to be fully black on the ground.
  113561. * 0.5 by default.
  113562. */
  113563. groundShadowLevel: number;
  113564. /**
  113565. * Creates a mirror texture attach to the ground.
  113566. * false by default.
  113567. */
  113568. enableGroundMirror: boolean;
  113569. /**
  113570. * Specifies the ground mirror size ratio.
  113571. * 0.3 by default as the default kernel is 64.
  113572. */
  113573. groundMirrorSizeRatio: number;
  113574. /**
  113575. * Specifies the ground mirror blur kernel size.
  113576. * 64 by default.
  113577. */
  113578. groundMirrorBlurKernel: number;
  113579. /**
  113580. * Specifies the ground mirror visibility amount.
  113581. * 1 by default
  113582. */
  113583. groundMirrorAmount: number;
  113584. /**
  113585. * Specifies the ground mirror reflectance weight.
  113586. * This uses the standard weight of the background material to setup the fresnel effect
  113587. * of the mirror.
  113588. * 1 by default.
  113589. */
  113590. groundMirrorFresnelWeight: number;
  113591. /**
  113592. * Specifies the ground mirror Falloff distance.
  113593. * This can helps reducing the size of the reflection.
  113594. * 0 by Default.
  113595. */
  113596. groundMirrorFallOffDistance: number;
  113597. /**
  113598. * Specifies the ground mirror texture type.
  113599. * Unsigned Int by Default.
  113600. */
  113601. groundMirrorTextureType: number;
  113602. /**
  113603. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113604. * the shown objects.
  113605. */
  113606. groundYBias: number;
  113607. /**
  113608. * Specifies wether or not to create a skybox.
  113609. * True by default.
  113610. */
  113611. createSkybox: boolean;
  113612. /**
  113613. * Specifies the skybox size.
  113614. * 20 by default.
  113615. */
  113616. skyboxSize: number;
  113617. /**
  113618. * The texture used on the skybox for the main color.
  113619. * Comes from the BabylonJS CDN by default.
  113620. *
  113621. * Remarks: Can be either a texture or a url.
  113622. */
  113623. skyboxTexture: string | BaseTexture;
  113624. /**
  113625. * The color mixed in the skybox texture by default.
  113626. * BabylonJS clearColor by default.
  113627. */
  113628. skyboxColor: Color3;
  113629. /**
  113630. * The background rotation around the Y axis of the scene.
  113631. * This helps aligning the key lights of your scene with the background.
  113632. * 0 by default.
  113633. */
  113634. backgroundYRotation: number;
  113635. /**
  113636. * Compute automatically the size of the elements to best fit with the scene.
  113637. */
  113638. sizeAuto: boolean;
  113639. /**
  113640. * Default position of the rootMesh if autoSize is not true.
  113641. */
  113642. rootPosition: Vector3;
  113643. /**
  113644. * Sets up the image processing in the scene.
  113645. * true by default.
  113646. */
  113647. setupImageProcessing: boolean;
  113648. /**
  113649. * The texture used as your environment texture in the scene.
  113650. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113651. *
  113652. * Remarks: Can be either a texture or a url.
  113653. */
  113654. environmentTexture: string | BaseTexture;
  113655. /**
  113656. * The value of the exposure to apply to the scene.
  113657. * 0.6 by default if setupImageProcessing is true.
  113658. */
  113659. cameraExposure: number;
  113660. /**
  113661. * The value of the contrast to apply to the scene.
  113662. * 1.6 by default if setupImageProcessing is true.
  113663. */
  113664. cameraContrast: number;
  113665. /**
  113666. * Specifies wether or not tonemapping should be enabled in the scene.
  113667. * true by default if setupImageProcessing is true.
  113668. */
  113669. toneMappingEnabled: boolean;
  113670. }
  113671. /**
  113672. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113673. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113674. * It also helps with the default setup of your imageProcessing configuration.
  113675. */
  113676. export class EnvironmentHelper {
  113677. /**
  113678. * Default ground texture URL.
  113679. */
  113680. private static _groundTextureCDNUrl;
  113681. /**
  113682. * Default skybox texture URL.
  113683. */
  113684. private static _skyboxTextureCDNUrl;
  113685. /**
  113686. * Default environment texture URL.
  113687. */
  113688. private static _environmentTextureCDNUrl;
  113689. /**
  113690. * Creates the default options for the helper.
  113691. */
  113692. private static _getDefaultOptions;
  113693. private _rootMesh;
  113694. /**
  113695. * Gets the root mesh created by the helper.
  113696. */
  113697. readonly rootMesh: Mesh;
  113698. private _skybox;
  113699. /**
  113700. * Gets the skybox created by the helper.
  113701. */
  113702. readonly skybox: Nullable<Mesh>;
  113703. private _skyboxTexture;
  113704. /**
  113705. * Gets the skybox texture created by the helper.
  113706. */
  113707. readonly skyboxTexture: Nullable<BaseTexture>;
  113708. private _skyboxMaterial;
  113709. /**
  113710. * Gets the skybox material created by the helper.
  113711. */
  113712. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113713. private _ground;
  113714. /**
  113715. * Gets the ground mesh created by the helper.
  113716. */
  113717. readonly ground: Nullable<Mesh>;
  113718. private _groundTexture;
  113719. /**
  113720. * Gets the ground texture created by the helper.
  113721. */
  113722. readonly groundTexture: Nullable<BaseTexture>;
  113723. private _groundMirror;
  113724. /**
  113725. * Gets the ground mirror created by the helper.
  113726. */
  113727. readonly groundMirror: Nullable<MirrorTexture>;
  113728. /**
  113729. * Gets the ground mirror render list to helps pushing the meshes
  113730. * you wish in the ground reflection.
  113731. */
  113732. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113733. private _groundMaterial;
  113734. /**
  113735. * Gets the ground material created by the helper.
  113736. */
  113737. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113738. /**
  113739. * Stores the creation options.
  113740. */
  113741. private readonly _scene;
  113742. private _options;
  113743. /**
  113744. * This observable will be notified with any error during the creation of the environment,
  113745. * mainly texture creation errors.
  113746. */
  113747. onErrorObservable: Observable<{
  113748. message?: string;
  113749. exception?: any;
  113750. }>;
  113751. /**
  113752. * constructor
  113753. * @param options Defines the options we want to customize the helper
  113754. * @param scene The scene to add the material to
  113755. */
  113756. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113757. /**
  113758. * Updates the background according to the new options
  113759. * @param options
  113760. */
  113761. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113762. /**
  113763. * Sets the primary color of all the available elements.
  113764. * @param color the main color to affect to the ground and the background
  113765. */
  113766. setMainColor(color: Color3): void;
  113767. /**
  113768. * Setup the image processing according to the specified options.
  113769. */
  113770. private _setupImageProcessing;
  113771. /**
  113772. * Setup the environment texture according to the specified options.
  113773. */
  113774. private _setupEnvironmentTexture;
  113775. /**
  113776. * Setup the background according to the specified options.
  113777. */
  113778. private _setupBackground;
  113779. /**
  113780. * Get the scene sizes according to the setup.
  113781. */
  113782. private _getSceneSize;
  113783. /**
  113784. * Setup the ground according to the specified options.
  113785. */
  113786. private _setupGround;
  113787. /**
  113788. * Setup the ground material according to the specified options.
  113789. */
  113790. private _setupGroundMaterial;
  113791. /**
  113792. * Setup the ground diffuse texture according to the specified options.
  113793. */
  113794. private _setupGroundDiffuseTexture;
  113795. /**
  113796. * Setup the ground mirror texture according to the specified options.
  113797. */
  113798. private _setupGroundMirrorTexture;
  113799. /**
  113800. * Setup the ground to receive the mirror texture.
  113801. */
  113802. private _setupMirrorInGroundMaterial;
  113803. /**
  113804. * Setup the skybox according to the specified options.
  113805. */
  113806. private _setupSkybox;
  113807. /**
  113808. * Setup the skybox material according to the specified options.
  113809. */
  113810. private _setupSkyboxMaterial;
  113811. /**
  113812. * Setup the skybox reflection texture according to the specified options.
  113813. */
  113814. private _setupSkyboxReflectionTexture;
  113815. private _errorHandler;
  113816. /**
  113817. * Dispose all the elements created by the Helper.
  113818. */
  113819. dispose(): void;
  113820. }
  113821. }
  113822. declare module BABYLON {
  113823. /**
  113824. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113825. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113826. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113827. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113828. */
  113829. export class PhotoDome extends TransformNode {
  113830. /**
  113831. * Define the image as a Monoscopic panoramic 360 image.
  113832. */
  113833. static readonly MODE_MONOSCOPIC: number;
  113834. /**
  113835. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113836. */
  113837. static readonly MODE_TOPBOTTOM: number;
  113838. /**
  113839. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113840. */
  113841. static readonly MODE_SIDEBYSIDE: number;
  113842. private _useDirectMapping;
  113843. /**
  113844. * The texture being displayed on the sphere
  113845. */
  113846. protected _photoTexture: Texture;
  113847. /**
  113848. * Gets or sets the texture being displayed on the sphere
  113849. */
  113850. photoTexture: Texture;
  113851. /**
  113852. * Observable raised when an error occured while loading the 360 image
  113853. */
  113854. onLoadErrorObservable: Observable<string>;
  113855. /**
  113856. * The skybox material
  113857. */
  113858. protected _material: BackgroundMaterial;
  113859. /**
  113860. * The surface used for the skybox
  113861. */
  113862. protected _mesh: Mesh;
  113863. /**
  113864. * Gets the mesh used for the skybox.
  113865. */
  113866. readonly mesh: Mesh;
  113867. /**
  113868. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113869. * Also see the options.resolution property.
  113870. */
  113871. fovMultiplier: number;
  113872. private _imageMode;
  113873. /**
  113874. * Gets or set the current video mode for the video. It can be:
  113875. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113876. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113877. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113878. */
  113879. imageMode: number;
  113880. /**
  113881. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113882. * @param name Element's name, child elements will append suffixes for their own names.
  113883. * @param urlsOfPhoto defines the url of the photo to display
  113884. * @param options defines an object containing optional or exposed sub element properties
  113885. * @param onError defines a callback called when an error occured while loading the texture
  113886. */
  113887. constructor(name: string, urlOfPhoto: string, options: {
  113888. resolution?: number;
  113889. size?: number;
  113890. useDirectMapping?: boolean;
  113891. faceForward?: boolean;
  113892. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113893. private _onBeforeCameraRenderObserver;
  113894. private _changeImageMode;
  113895. /**
  113896. * Releases resources associated with this node.
  113897. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113898. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113899. */
  113900. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113901. }
  113902. }
  113903. declare module BABYLON {
  113904. /**
  113905. * Class used to host RGBD texture specific utilities
  113906. */
  113907. export class RGBDTextureTools {
  113908. /**
  113909. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113910. * @param texture the texture to expand.
  113911. */
  113912. static ExpandRGBDTexture(texture: Texture): void;
  113913. }
  113914. }
  113915. declare module BABYLON {
  113916. /**
  113917. * Class used to host texture specific utilities
  113918. */
  113919. export class BRDFTextureTools {
  113920. /**
  113921. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113922. * @param scene defines the hosting scene
  113923. * @returns the environment BRDF texture
  113924. */
  113925. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113926. private static _environmentBRDFBase64Texture;
  113927. }
  113928. }
  113929. declare module BABYLON {
  113930. /**
  113931. * @hidden
  113932. */
  113933. export interface IMaterialClearCoatDefines {
  113934. CLEARCOAT: boolean;
  113935. CLEARCOAT_DEFAULTIOR: boolean;
  113936. CLEARCOAT_TEXTURE: boolean;
  113937. CLEARCOAT_TEXTUREDIRECTUV: number;
  113938. CLEARCOAT_BUMP: boolean;
  113939. CLEARCOAT_BUMPDIRECTUV: number;
  113940. CLEARCOAT_TINT: boolean;
  113941. CLEARCOAT_TINT_TEXTURE: boolean;
  113942. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113943. /** @hidden */
  113944. _areTexturesDirty: boolean;
  113945. }
  113946. /**
  113947. * Define the code related to the clear coat parameters of the pbr material.
  113948. */
  113949. export class PBRClearCoatConfiguration {
  113950. /**
  113951. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113952. * The default fits with a polyurethane material.
  113953. */
  113954. private static readonly _DefaultIndexOfRefraction;
  113955. private _isEnabled;
  113956. /**
  113957. * Defines if the clear coat is enabled in the material.
  113958. */
  113959. isEnabled: boolean;
  113960. /**
  113961. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113962. */
  113963. intensity: number;
  113964. /**
  113965. * Defines the clear coat layer roughness.
  113966. */
  113967. roughness: number;
  113968. private _indexOfRefraction;
  113969. /**
  113970. * Defines the index of refraction of the clear coat.
  113971. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113972. * The default fits with a polyurethane material.
  113973. * Changing the default value is more performance intensive.
  113974. */
  113975. indexOfRefraction: number;
  113976. private _texture;
  113977. /**
  113978. * Stores the clear coat values in a texture.
  113979. */
  113980. texture: Nullable<BaseTexture>;
  113981. private _bumpTexture;
  113982. /**
  113983. * Define the clear coat specific bump texture.
  113984. */
  113985. bumpTexture: Nullable<BaseTexture>;
  113986. private _isTintEnabled;
  113987. /**
  113988. * Defines if the clear coat tint is enabled in the material.
  113989. */
  113990. isTintEnabled: boolean;
  113991. /**
  113992. * Defines the clear coat tint of the material.
  113993. * This is only use if tint is enabled
  113994. */
  113995. tintColor: Color3;
  113996. /**
  113997. * Defines the distance at which the tint color should be found in the
  113998. * clear coat media.
  113999. * This is only use if tint is enabled
  114000. */
  114001. tintColorAtDistance: number;
  114002. /**
  114003. * Defines the clear coat layer thickness.
  114004. * This is only use if tint is enabled
  114005. */
  114006. tintThickness: number;
  114007. private _tintTexture;
  114008. /**
  114009. * Stores the clear tint values in a texture.
  114010. * rgb is tint
  114011. * a is a thickness factor
  114012. */
  114013. tintTexture: Nullable<BaseTexture>;
  114014. /** @hidden */
  114015. private _internalMarkAllSubMeshesAsTexturesDirty;
  114016. /** @hidden */
  114017. _markAllSubMeshesAsTexturesDirty(): void;
  114018. /**
  114019. * Instantiate a new istance of clear coat configuration.
  114020. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114021. */
  114022. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114023. /**
  114024. * Gets wehter the submesh is ready to be used or not.
  114025. * @param defines the list of "defines" to update.
  114026. * @param scene defines the scene the material belongs to.
  114027. * @param engine defines the engine the material belongs to.
  114028. * @param disableBumpMap defines wether the material disables bump or not.
  114029. * @returns - boolean indicating that the submesh is ready or not.
  114030. */
  114031. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114032. /**
  114033. * Checks to see if a texture is used in the material.
  114034. * @param defines the list of "defines" to update.
  114035. * @param scene defines the scene to the material belongs to.
  114036. */
  114037. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114038. /**
  114039. * Binds the material data.
  114040. * @param uniformBuffer defines the Uniform buffer to fill in.
  114041. * @param scene defines the scene the material belongs to.
  114042. * @param engine defines the engine the material belongs to.
  114043. * @param disableBumpMap defines wether the material disables bump or not.
  114044. * @param isFrozen defines wether the material is frozen or not.
  114045. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114046. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114047. */
  114048. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114049. /**
  114050. * Checks to see if a texture is used in the material.
  114051. * @param texture - Base texture to use.
  114052. * @returns - Boolean specifying if a texture is used in the material.
  114053. */
  114054. hasTexture(texture: BaseTexture): boolean;
  114055. /**
  114056. * Returns an array of the actively used textures.
  114057. * @param activeTextures Array of BaseTextures
  114058. */
  114059. getActiveTextures(activeTextures: BaseTexture[]): void;
  114060. /**
  114061. * Returns the animatable textures.
  114062. * @param animatables Array of animatable textures.
  114063. */
  114064. getAnimatables(animatables: IAnimatable[]): void;
  114065. /**
  114066. * Disposes the resources of the material.
  114067. * @param forceDisposeTextures - Forces the disposal of all textures.
  114068. */
  114069. dispose(forceDisposeTextures?: boolean): void;
  114070. /**
  114071. * Get the current class name of the texture useful for serialization or dynamic coding.
  114072. * @returns "PBRClearCoatConfiguration"
  114073. */
  114074. getClassName(): string;
  114075. /**
  114076. * Add fallbacks to the effect fallbacks list.
  114077. * @param defines defines the Base texture to use.
  114078. * @param fallbacks defines the current fallback list.
  114079. * @param currentRank defines the current fallback rank.
  114080. * @returns the new fallback rank.
  114081. */
  114082. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114083. /**
  114084. * Add the required uniforms to the current list.
  114085. * @param uniforms defines the current uniform list.
  114086. */
  114087. static AddUniforms(uniforms: string[]): void;
  114088. /**
  114089. * Add the required samplers to the current list.
  114090. * @param samplers defines the current sampler list.
  114091. */
  114092. static AddSamplers(samplers: string[]): void;
  114093. /**
  114094. * Add the required uniforms to the current buffer.
  114095. * @param uniformBuffer defines the current uniform buffer.
  114096. */
  114097. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114098. /**
  114099. * Makes a duplicate of the current configuration into another one.
  114100. * @param clearCoatConfiguration define the config where to copy the info
  114101. */
  114102. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114103. /**
  114104. * Serializes this clear coat configuration.
  114105. * @returns - An object with the serialized config.
  114106. */
  114107. serialize(): any;
  114108. /**
  114109. * Parses a anisotropy Configuration from a serialized object.
  114110. * @param source - Serialized object.
  114111. * @param scene Defines the scene we are parsing for
  114112. * @param rootUrl Defines the rootUrl to load from
  114113. */
  114114. parse(source: any, scene: Scene, rootUrl: string): void;
  114115. }
  114116. }
  114117. declare module BABYLON {
  114118. /**
  114119. * @hidden
  114120. */
  114121. export interface IMaterialAnisotropicDefines {
  114122. ANISOTROPIC: boolean;
  114123. ANISOTROPIC_TEXTURE: boolean;
  114124. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114125. MAINUV1: boolean;
  114126. _areTexturesDirty: boolean;
  114127. _needUVs: boolean;
  114128. }
  114129. /**
  114130. * Define the code related to the anisotropic parameters of the pbr material.
  114131. */
  114132. export class PBRAnisotropicConfiguration {
  114133. private _isEnabled;
  114134. /**
  114135. * Defines if the anisotropy is enabled in the material.
  114136. */
  114137. isEnabled: boolean;
  114138. /**
  114139. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114140. */
  114141. intensity: number;
  114142. /**
  114143. * Defines if the effect is along the tangents, bitangents or in between.
  114144. * By default, the effect is "strectching" the highlights along the tangents.
  114145. */
  114146. direction: Vector2;
  114147. private _texture;
  114148. /**
  114149. * Stores the anisotropy values in a texture.
  114150. * rg is direction (like normal from -1 to 1)
  114151. * b is a intensity
  114152. */
  114153. texture: Nullable<BaseTexture>;
  114154. /** @hidden */
  114155. private _internalMarkAllSubMeshesAsTexturesDirty;
  114156. /** @hidden */
  114157. _markAllSubMeshesAsTexturesDirty(): void;
  114158. /**
  114159. * Instantiate a new istance of anisotropy configuration.
  114160. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114161. */
  114162. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114163. /**
  114164. * Specifies that the submesh is ready to be used.
  114165. * @param defines the list of "defines" to update.
  114166. * @param scene defines the scene the material belongs to.
  114167. * @returns - boolean indicating that the submesh is ready or not.
  114168. */
  114169. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114170. /**
  114171. * Checks to see if a texture is used in the material.
  114172. * @param defines the list of "defines" to update.
  114173. * @param mesh the mesh we are preparing the defines for.
  114174. * @param scene defines the scene the material belongs to.
  114175. */
  114176. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114177. /**
  114178. * Binds the material data.
  114179. * @param uniformBuffer defines the Uniform buffer to fill in.
  114180. * @param scene defines the scene the material belongs to.
  114181. * @param isFrozen defines wether the material is frozen or not.
  114182. */
  114183. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114184. /**
  114185. * Checks to see if a texture is used in the material.
  114186. * @param texture - Base texture to use.
  114187. * @returns - Boolean specifying if a texture is used in the material.
  114188. */
  114189. hasTexture(texture: BaseTexture): boolean;
  114190. /**
  114191. * Returns an array of the actively used textures.
  114192. * @param activeTextures Array of BaseTextures
  114193. */
  114194. getActiveTextures(activeTextures: BaseTexture[]): void;
  114195. /**
  114196. * Returns the animatable textures.
  114197. * @param animatables Array of animatable textures.
  114198. */
  114199. getAnimatables(animatables: IAnimatable[]): void;
  114200. /**
  114201. * Disposes the resources of the material.
  114202. * @param forceDisposeTextures - Forces the disposal of all textures.
  114203. */
  114204. dispose(forceDisposeTextures?: boolean): void;
  114205. /**
  114206. * Get the current class name of the texture useful for serialization or dynamic coding.
  114207. * @returns "PBRAnisotropicConfiguration"
  114208. */
  114209. getClassName(): string;
  114210. /**
  114211. * Add fallbacks to the effect fallbacks list.
  114212. * @param defines defines the Base texture to use.
  114213. * @param fallbacks defines the current fallback list.
  114214. * @param currentRank defines the current fallback rank.
  114215. * @returns the new fallback rank.
  114216. */
  114217. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114218. /**
  114219. * Add the required uniforms to the current list.
  114220. * @param uniforms defines the current uniform list.
  114221. */
  114222. static AddUniforms(uniforms: string[]): void;
  114223. /**
  114224. * Add the required uniforms to the current buffer.
  114225. * @param uniformBuffer defines the current uniform buffer.
  114226. */
  114227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114228. /**
  114229. * Add the required samplers to the current list.
  114230. * @param samplers defines the current sampler list.
  114231. */
  114232. static AddSamplers(samplers: string[]): void;
  114233. /**
  114234. * Makes a duplicate of the current configuration into another one.
  114235. * @param anisotropicConfiguration define the config where to copy the info
  114236. */
  114237. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114238. /**
  114239. * Serializes this anisotropy configuration.
  114240. * @returns - An object with the serialized config.
  114241. */
  114242. serialize(): any;
  114243. /**
  114244. * Parses a anisotropy Configuration from a serialized object.
  114245. * @param source - Serialized object.
  114246. * @param scene Defines the scene we are parsing for
  114247. * @param rootUrl Defines the rootUrl to load from
  114248. */
  114249. parse(source: any, scene: Scene, rootUrl: string): void;
  114250. }
  114251. }
  114252. declare module BABYLON {
  114253. /**
  114254. * @hidden
  114255. */
  114256. export interface IMaterialBRDFDefines {
  114257. BRDF_V_HEIGHT_CORRELATED: boolean;
  114258. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114259. SPHERICAL_HARMONICS: boolean;
  114260. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114261. /** @hidden */
  114262. _areMiscDirty: boolean;
  114263. }
  114264. /**
  114265. * Define the code related to the BRDF parameters of the pbr material.
  114266. */
  114267. export class PBRBRDFConfiguration {
  114268. /**
  114269. * Default value used for the energy conservation.
  114270. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114271. */
  114272. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114273. /**
  114274. * Default value used for the Smith Visibility Height Correlated mode.
  114275. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114276. */
  114277. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114278. /**
  114279. * Default value used for the IBL diffuse part.
  114280. * This can help switching back to the polynomials mode globally which is a tiny bit
  114281. * less GPU intensive at the drawback of a lower quality.
  114282. */
  114283. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114284. /**
  114285. * Default value used for activating energy conservation for the specular workflow.
  114286. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114287. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114288. */
  114289. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114290. private _useEnergyConservation;
  114291. /**
  114292. * Defines if the material uses energy conservation.
  114293. */
  114294. useEnergyConservation: boolean;
  114295. private _useSmithVisibilityHeightCorrelated;
  114296. /**
  114297. * LEGACY Mode set to false
  114298. * Defines if the material uses height smith correlated visibility term.
  114299. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114300. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114301. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114302. * Not relying on height correlated will also disable energy conservation.
  114303. */
  114304. useSmithVisibilityHeightCorrelated: boolean;
  114305. private _useSphericalHarmonics;
  114306. /**
  114307. * LEGACY Mode set to false
  114308. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114309. * diffuse part of the IBL.
  114310. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114311. * to the ground truth.
  114312. */
  114313. useSphericalHarmonics: boolean;
  114314. private _useSpecularGlossinessInputEnergyConservation;
  114315. /**
  114316. * Defines if the material uses energy conservation, when the specular workflow is active.
  114317. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114318. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114319. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114320. */
  114321. useSpecularGlossinessInputEnergyConservation: boolean;
  114322. /** @hidden */
  114323. private _internalMarkAllSubMeshesAsMiscDirty;
  114324. /** @hidden */
  114325. _markAllSubMeshesAsMiscDirty(): void;
  114326. /**
  114327. * Instantiate a new istance of clear coat configuration.
  114328. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114329. */
  114330. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114331. /**
  114332. * Checks to see if a texture is used in the material.
  114333. * @param defines the list of "defines" to update.
  114334. */
  114335. prepareDefines(defines: IMaterialBRDFDefines): void;
  114336. /**
  114337. * Get the current class name of the texture useful for serialization or dynamic coding.
  114338. * @returns "PBRClearCoatConfiguration"
  114339. */
  114340. getClassName(): string;
  114341. /**
  114342. * Makes a duplicate of the current configuration into another one.
  114343. * @param brdfConfiguration define the config where to copy the info
  114344. */
  114345. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114346. /**
  114347. * Serializes this BRDF configuration.
  114348. * @returns - An object with the serialized config.
  114349. */
  114350. serialize(): any;
  114351. /**
  114352. * Parses a anisotropy Configuration from a serialized object.
  114353. * @param source - Serialized object.
  114354. * @param scene Defines the scene we are parsing for
  114355. * @param rootUrl Defines the rootUrl to load from
  114356. */
  114357. parse(source: any, scene: Scene, rootUrl: string): void;
  114358. }
  114359. }
  114360. declare module BABYLON {
  114361. /**
  114362. * @hidden
  114363. */
  114364. export interface IMaterialSheenDefines {
  114365. SHEEN: boolean;
  114366. SHEEN_TEXTURE: boolean;
  114367. SHEEN_TEXTUREDIRECTUV: number;
  114368. SHEEN_LINKWITHALBEDO: boolean;
  114369. /** @hidden */
  114370. _areTexturesDirty: boolean;
  114371. }
  114372. /**
  114373. * Define the code related to the Sheen parameters of the pbr material.
  114374. */
  114375. export class PBRSheenConfiguration {
  114376. private _isEnabled;
  114377. /**
  114378. * Defines if the material uses sheen.
  114379. */
  114380. isEnabled: boolean;
  114381. private _linkSheenWithAlbedo;
  114382. /**
  114383. * Defines if the sheen is linked to the sheen color.
  114384. */
  114385. linkSheenWithAlbedo: boolean;
  114386. /**
  114387. * Defines the sheen intensity.
  114388. */
  114389. intensity: number;
  114390. /**
  114391. * Defines the sheen color.
  114392. */
  114393. color: Color3;
  114394. private _texture;
  114395. /**
  114396. * Stores the sheen tint values in a texture.
  114397. * rgb is tint
  114398. * a is a intensity
  114399. */
  114400. texture: Nullable<BaseTexture>;
  114401. /** @hidden */
  114402. private _internalMarkAllSubMeshesAsTexturesDirty;
  114403. /** @hidden */
  114404. _markAllSubMeshesAsTexturesDirty(): void;
  114405. /**
  114406. * Instantiate a new istance of clear coat configuration.
  114407. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114408. */
  114409. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114410. /**
  114411. * Specifies that the submesh is ready to be used.
  114412. * @param defines the list of "defines" to update.
  114413. * @param scene defines the scene the material belongs to.
  114414. * @returns - boolean indicating that the submesh is ready or not.
  114415. */
  114416. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114417. /**
  114418. * Checks to see if a texture is used in the material.
  114419. * @param defines the list of "defines" to update.
  114420. * @param scene defines the scene the material belongs to.
  114421. */
  114422. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114423. /**
  114424. * Binds the material data.
  114425. * @param uniformBuffer defines the Uniform buffer to fill in.
  114426. * @param scene defines the scene the material belongs to.
  114427. * @param isFrozen defines wether the material is frozen or not.
  114428. */
  114429. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114430. /**
  114431. * Checks to see if a texture is used in the material.
  114432. * @param texture - Base texture to use.
  114433. * @returns - Boolean specifying if a texture is used in the material.
  114434. */
  114435. hasTexture(texture: BaseTexture): boolean;
  114436. /**
  114437. * Returns an array of the actively used textures.
  114438. * @param activeTextures Array of BaseTextures
  114439. */
  114440. getActiveTextures(activeTextures: BaseTexture[]): void;
  114441. /**
  114442. * Returns the animatable textures.
  114443. * @param animatables Array of animatable textures.
  114444. */
  114445. getAnimatables(animatables: IAnimatable[]): void;
  114446. /**
  114447. * Disposes the resources of the material.
  114448. * @param forceDisposeTextures - Forces the disposal of all textures.
  114449. */
  114450. dispose(forceDisposeTextures?: boolean): void;
  114451. /**
  114452. * Get the current class name of the texture useful for serialization or dynamic coding.
  114453. * @returns "PBRSheenConfiguration"
  114454. */
  114455. getClassName(): string;
  114456. /**
  114457. * Add fallbacks to the effect fallbacks list.
  114458. * @param defines defines the Base texture to use.
  114459. * @param fallbacks defines the current fallback list.
  114460. * @param currentRank defines the current fallback rank.
  114461. * @returns the new fallback rank.
  114462. */
  114463. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114464. /**
  114465. * Add the required uniforms to the current list.
  114466. * @param uniforms defines the current uniform list.
  114467. */
  114468. static AddUniforms(uniforms: string[]): void;
  114469. /**
  114470. * Add the required uniforms to the current buffer.
  114471. * @param uniformBuffer defines the current uniform buffer.
  114472. */
  114473. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114474. /**
  114475. * Add the required samplers to the current list.
  114476. * @param samplers defines the current sampler list.
  114477. */
  114478. static AddSamplers(samplers: string[]): void;
  114479. /**
  114480. * Makes a duplicate of the current configuration into another one.
  114481. * @param sheenConfiguration define the config where to copy the info
  114482. */
  114483. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114484. /**
  114485. * Serializes this BRDF configuration.
  114486. * @returns - An object with the serialized config.
  114487. */
  114488. serialize(): any;
  114489. /**
  114490. * Parses a anisotropy Configuration from a serialized object.
  114491. * @param source - Serialized object.
  114492. * @param scene Defines the scene we are parsing for
  114493. * @param rootUrl Defines the rootUrl to load from
  114494. */
  114495. parse(source: any, scene: Scene, rootUrl: string): void;
  114496. }
  114497. }
  114498. declare module BABYLON {
  114499. /**
  114500. * @hidden
  114501. */
  114502. export interface IMaterialSubSurfaceDefines {
  114503. SUBSURFACE: boolean;
  114504. SS_REFRACTION: boolean;
  114505. SS_TRANSLUCENCY: boolean;
  114506. SS_SCATERRING: boolean;
  114507. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114508. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114509. SS_REFRACTIONMAP_3D: boolean;
  114510. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114511. SS_LODINREFRACTIONALPHA: boolean;
  114512. SS_GAMMAREFRACTION: boolean;
  114513. SS_RGBDREFRACTION: boolean;
  114514. SS_LINEARSPECULARREFRACTION: boolean;
  114515. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114516. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114517. /** @hidden */
  114518. _areTexturesDirty: boolean;
  114519. }
  114520. /**
  114521. * Define the code related to the sub surface parameters of the pbr material.
  114522. */
  114523. export class PBRSubSurfaceConfiguration {
  114524. private _isRefractionEnabled;
  114525. /**
  114526. * Defines if the refraction is enabled in the material.
  114527. */
  114528. isRefractionEnabled: boolean;
  114529. private _isTranslucencyEnabled;
  114530. /**
  114531. * Defines if the translucency is enabled in the material.
  114532. */
  114533. isTranslucencyEnabled: boolean;
  114534. private _isScatteringEnabled;
  114535. /**
  114536. * Defines the refraction intensity of the material.
  114537. * The refraction when enabled replaces the Diffuse part of the material.
  114538. * The intensity helps transitionning between diffuse and refraction.
  114539. */
  114540. refractionIntensity: number;
  114541. /**
  114542. * Defines the translucency intensity of the material.
  114543. * When translucency has been enabled, this defines how much of the "translucency"
  114544. * is addded to the diffuse part of the material.
  114545. */
  114546. translucencyIntensity: number;
  114547. /**
  114548. * Defines the scattering intensity of the material.
  114549. * When scattering has been enabled, this defines how much of the "scattered light"
  114550. * is addded to the diffuse part of the material.
  114551. */
  114552. scatteringIntensity: number;
  114553. private _thicknessTexture;
  114554. /**
  114555. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114556. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114557. * 0 would mean minimumThickness
  114558. * 1 would mean maximumThickness
  114559. * The other channels might be use as a mask to vary the different effects intensity.
  114560. */
  114561. thicknessTexture: Nullable<BaseTexture>;
  114562. private _refractionTexture;
  114563. /**
  114564. * Defines the texture to use for refraction.
  114565. */
  114566. refractionTexture: Nullable<BaseTexture>;
  114567. private _indexOfRefraction;
  114568. /**
  114569. * Defines the index of refraction used in the material.
  114570. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114571. */
  114572. indexOfRefraction: number;
  114573. private _invertRefractionY;
  114574. /**
  114575. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114576. */
  114577. invertRefractionY: boolean;
  114578. private _linkRefractionWithTransparency;
  114579. /**
  114580. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114581. * Materials half opaque for instance using refraction could benefit from this control.
  114582. */
  114583. linkRefractionWithTransparency: boolean;
  114584. /**
  114585. * Defines the minimum thickness stored in the thickness map.
  114586. * If no thickness map is defined, this value will be used to simulate thickness.
  114587. */
  114588. minimumThickness: number;
  114589. /**
  114590. * Defines the maximum thickness stored in the thickness map.
  114591. */
  114592. maximumThickness: number;
  114593. /**
  114594. * Defines the volume tint of the material.
  114595. * This is used for both translucency and scattering.
  114596. */
  114597. tintColor: Color3;
  114598. /**
  114599. * Defines the distance at which the tint color should be found in the media.
  114600. * This is used for refraction only.
  114601. */
  114602. tintColorAtDistance: number;
  114603. /**
  114604. * Defines how far each channel transmit through the media.
  114605. * It is defined as a color to simplify it selection.
  114606. */
  114607. diffusionDistance: Color3;
  114608. private _useMaskFromThicknessTexture;
  114609. /**
  114610. * Stores the intensity of the different subsurface effects in the thickness texture.
  114611. * * the green channel is the translucency intensity.
  114612. * * the blue channel is the scattering intensity.
  114613. * * the alpha channel is the refraction intensity.
  114614. */
  114615. useMaskFromThicknessTexture: boolean;
  114616. /** @hidden */
  114617. private _internalMarkAllSubMeshesAsTexturesDirty;
  114618. /** @hidden */
  114619. _markAllSubMeshesAsTexturesDirty(): void;
  114620. /**
  114621. * Instantiate a new istance of sub surface configuration.
  114622. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114623. */
  114624. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114625. /**
  114626. * Gets wehter the submesh is ready to be used or not.
  114627. * @param defines the list of "defines" to update.
  114628. * @param scene defines the scene the material belongs to.
  114629. * @returns - boolean indicating that the submesh is ready or not.
  114630. */
  114631. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114632. /**
  114633. * Checks to see if a texture is used in the material.
  114634. * @param defines the list of "defines" to update.
  114635. * @param scene defines the scene to the material belongs to.
  114636. */
  114637. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114638. /**
  114639. * Binds the material data.
  114640. * @param uniformBuffer defines the Uniform buffer to fill in.
  114641. * @param scene defines the scene the material belongs to.
  114642. * @param engine defines the engine the material belongs to.
  114643. * @param isFrozen defines wether the material is frozen or not.
  114644. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114645. */
  114646. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114647. /**
  114648. * Unbinds the material from the mesh.
  114649. * @param activeEffect defines the effect that should be unbound from.
  114650. * @returns true if unbound, otherwise false
  114651. */
  114652. unbind(activeEffect: Effect): boolean;
  114653. /**
  114654. * Returns the texture used for refraction or null if none is used.
  114655. * @param scene defines the scene the material belongs to.
  114656. * @returns - Refraction texture if present. If no refraction texture and refraction
  114657. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114658. */
  114659. private _getRefractionTexture;
  114660. /**
  114661. * Returns true if alpha blending should be disabled.
  114662. */
  114663. readonly disableAlphaBlending: boolean;
  114664. /**
  114665. * Fills the list of render target textures.
  114666. * @param renderTargets the list of render targets to update
  114667. */
  114668. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114669. /**
  114670. * Checks to see if a texture is used in the material.
  114671. * @param texture - Base texture to use.
  114672. * @returns - Boolean specifying if a texture is used in the material.
  114673. */
  114674. hasTexture(texture: BaseTexture): boolean;
  114675. /**
  114676. * Gets a boolean indicating that current material needs to register RTT
  114677. * @returns true if this uses a render target otherwise false.
  114678. */
  114679. hasRenderTargetTextures(): boolean;
  114680. /**
  114681. * Returns an array of the actively used textures.
  114682. * @param activeTextures Array of BaseTextures
  114683. */
  114684. getActiveTextures(activeTextures: BaseTexture[]): void;
  114685. /**
  114686. * Returns the animatable textures.
  114687. * @param animatables Array of animatable textures.
  114688. */
  114689. getAnimatables(animatables: IAnimatable[]): void;
  114690. /**
  114691. * Disposes the resources of the material.
  114692. * @param forceDisposeTextures - Forces the disposal of all textures.
  114693. */
  114694. dispose(forceDisposeTextures?: boolean): void;
  114695. /**
  114696. * Get the current class name of the texture useful for serialization or dynamic coding.
  114697. * @returns "PBRSubSurfaceConfiguration"
  114698. */
  114699. getClassName(): string;
  114700. /**
  114701. * Add fallbacks to the effect fallbacks list.
  114702. * @param defines defines the Base texture to use.
  114703. * @param fallbacks defines the current fallback list.
  114704. * @param currentRank defines the current fallback rank.
  114705. * @returns the new fallback rank.
  114706. */
  114707. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114708. /**
  114709. * Add the required uniforms to the current list.
  114710. * @param uniforms defines the current uniform list.
  114711. */
  114712. static AddUniforms(uniforms: string[]): void;
  114713. /**
  114714. * Add the required samplers to the current list.
  114715. * @param samplers defines the current sampler list.
  114716. */
  114717. static AddSamplers(samplers: string[]): void;
  114718. /**
  114719. * Add the required uniforms to the current buffer.
  114720. * @param uniformBuffer defines the current uniform buffer.
  114721. */
  114722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114723. /**
  114724. * Makes a duplicate of the current configuration into another one.
  114725. * @param configuration define the config where to copy the info
  114726. */
  114727. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114728. /**
  114729. * Serializes this Sub Surface configuration.
  114730. * @returns - An object with the serialized config.
  114731. */
  114732. serialize(): any;
  114733. /**
  114734. * Parses a anisotropy Configuration from a serialized object.
  114735. * @param source - Serialized object.
  114736. * @param scene Defines the scene we are parsing for
  114737. * @param rootUrl Defines the rootUrl to load from
  114738. */
  114739. parse(source: any, scene: Scene, rootUrl: string): void;
  114740. }
  114741. }
  114742. declare module BABYLON {
  114743. /** @hidden */
  114744. export var pbrFragmentDeclaration: {
  114745. name: string;
  114746. shader: string;
  114747. };
  114748. }
  114749. declare module BABYLON {
  114750. /** @hidden */
  114751. export var pbrUboDeclaration: {
  114752. name: string;
  114753. shader: string;
  114754. };
  114755. }
  114756. declare module BABYLON {
  114757. /** @hidden */
  114758. export var pbrFragmentExtraDeclaration: {
  114759. name: string;
  114760. shader: string;
  114761. };
  114762. }
  114763. declare module BABYLON {
  114764. /** @hidden */
  114765. export var pbrFragmentSamplersDeclaration: {
  114766. name: string;
  114767. shader: string;
  114768. };
  114769. }
  114770. declare module BABYLON {
  114771. /** @hidden */
  114772. export var pbrHelperFunctions: {
  114773. name: string;
  114774. shader: string;
  114775. };
  114776. }
  114777. declare module BABYLON {
  114778. /** @hidden */
  114779. export var harmonicsFunctions: {
  114780. name: string;
  114781. shader: string;
  114782. };
  114783. }
  114784. declare module BABYLON {
  114785. /** @hidden */
  114786. export var pbrDirectLightingSetupFunctions: {
  114787. name: string;
  114788. shader: string;
  114789. };
  114790. }
  114791. declare module BABYLON {
  114792. /** @hidden */
  114793. export var pbrDirectLightingFalloffFunctions: {
  114794. name: string;
  114795. shader: string;
  114796. };
  114797. }
  114798. declare module BABYLON {
  114799. /** @hidden */
  114800. export var pbrBRDFFunctions: {
  114801. name: string;
  114802. shader: string;
  114803. };
  114804. }
  114805. declare module BABYLON {
  114806. /** @hidden */
  114807. export var pbrDirectLightingFunctions: {
  114808. name: string;
  114809. shader: string;
  114810. };
  114811. }
  114812. declare module BABYLON {
  114813. /** @hidden */
  114814. export var pbrIBLFunctions: {
  114815. name: string;
  114816. shader: string;
  114817. };
  114818. }
  114819. declare module BABYLON {
  114820. /** @hidden */
  114821. export var pbrDebug: {
  114822. name: string;
  114823. shader: string;
  114824. };
  114825. }
  114826. declare module BABYLON {
  114827. /** @hidden */
  114828. export var pbrPixelShader: {
  114829. name: string;
  114830. shader: string;
  114831. };
  114832. }
  114833. declare module BABYLON {
  114834. /** @hidden */
  114835. export var pbrVertexDeclaration: {
  114836. name: string;
  114837. shader: string;
  114838. };
  114839. }
  114840. declare module BABYLON {
  114841. /** @hidden */
  114842. export var pbrVertexShader: {
  114843. name: string;
  114844. shader: string;
  114845. };
  114846. }
  114847. declare module BABYLON {
  114848. /**
  114849. * Manages the defines for the PBR Material.
  114850. * @hidden
  114851. */
  114852. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114853. PBR: boolean;
  114854. MAINUV1: boolean;
  114855. MAINUV2: boolean;
  114856. UV1: boolean;
  114857. UV2: boolean;
  114858. ALBEDO: boolean;
  114859. ALBEDODIRECTUV: number;
  114860. VERTEXCOLOR: boolean;
  114861. AMBIENT: boolean;
  114862. AMBIENTDIRECTUV: number;
  114863. AMBIENTINGRAYSCALE: boolean;
  114864. OPACITY: boolean;
  114865. VERTEXALPHA: boolean;
  114866. OPACITYDIRECTUV: number;
  114867. OPACITYRGB: boolean;
  114868. ALPHATEST: boolean;
  114869. DEPTHPREPASS: boolean;
  114870. ALPHABLEND: boolean;
  114871. ALPHAFROMALBEDO: boolean;
  114872. ALPHATESTVALUE: string;
  114873. SPECULAROVERALPHA: boolean;
  114874. RADIANCEOVERALPHA: boolean;
  114875. ALPHAFRESNEL: boolean;
  114876. LINEARALPHAFRESNEL: boolean;
  114877. PREMULTIPLYALPHA: boolean;
  114878. EMISSIVE: boolean;
  114879. EMISSIVEDIRECTUV: number;
  114880. REFLECTIVITY: boolean;
  114881. REFLECTIVITYDIRECTUV: number;
  114882. SPECULARTERM: boolean;
  114883. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114884. MICROSURFACEAUTOMATIC: boolean;
  114885. LODBASEDMICROSFURACE: boolean;
  114886. MICROSURFACEMAP: boolean;
  114887. MICROSURFACEMAPDIRECTUV: number;
  114888. METALLICWORKFLOW: boolean;
  114889. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114890. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114891. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114892. AOSTOREINMETALMAPRED: boolean;
  114893. ENVIRONMENTBRDF: boolean;
  114894. ENVIRONMENTBRDF_RGBD: boolean;
  114895. NORMAL: boolean;
  114896. TANGENT: boolean;
  114897. BUMP: boolean;
  114898. BUMPDIRECTUV: number;
  114899. OBJECTSPACE_NORMALMAP: boolean;
  114900. PARALLAX: boolean;
  114901. PARALLAXOCCLUSION: boolean;
  114902. NORMALXYSCALE: boolean;
  114903. LIGHTMAP: boolean;
  114904. LIGHTMAPDIRECTUV: number;
  114905. USELIGHTMAPASSHADOWMAP: boolean;
  114906. GAMMALIGHTMAP: boolean;
  114907. RGBDLIGHTMAP: boolean;
  114908. REFLECTION: boolean;
  114909. REFLECTIONMAP_3D: boolean;
  114910. REFLECTIONMAP_SPHERICAL: boolean;
  114911. REFLECTIONMAP_PLANAR: boolean;
  114912. REFLECTIONMAP_CUBIC: boolean;
  114913. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114914. REFLECTIONMAP_PROJECTION: boolean;
  114915. REFLECTIONMAP_SKYBOX: boolean;
  114916. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114917. REFLECTIONMAP_EXPLICIT: boolean;
  114918. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114919. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114920. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114921. INVERTCUBICMAP: boolean;
  114922. USESPHERICALFROMREFLECTIONMAP: boolean;
  114923. USEIRRADIANCEMAP: boolean;
  114924. SPHERICAL_HARMONICS: boolean;
  114925. USESPHERICALINVERTEX: boolean;
  114926. REFLECTIONMAP_OPPOSITEZ: boolean;
  114927. LODINREFLECTIONALPHA: boolean;
  114928. GAMMAREFLECTION: boolean;
  114929. RGBDREFLECTION: boolean;
  114930. LINEARSPECULARREFLECTION: boolean;
  114931. RADIANCEOCCLUSION: boolean;
  114932. HORIZONOCCLUSION: boolean;
  114933. INSTANCES: boolean;
  114934. NUM_BONE_INFLUENCERS: number;
  114935. BonesPerMesh: number;
  114936. BONETEXTURE: boolean;
  114937. NONUNIFORMSCALING: boolean;
  114938. MORPHTARGETS: boolean;
  114939. MORPHTARGETS_NORMAL: boolean;
  114940. MORPHTARGETS_TANGENT: boolean;
  114941. MORPHTARGETS_UV: boolean;
  114942. NUM_MORPH_INFLUENCERS: number;
  114943. IMAGEPROCESSING: boolean;
  114944. VIGNETTE: boolean;
  114945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114946. VIGNETTEBLENDMODEOPAQUE: boolean;
  114947. TONEMAPPING: boolean;
  114948. TONEMAPPING_ACES: boolean;
  114949. CONTRAST: boolean;
  114950. COLORCURVES: boolean;
  114951. COLORGRADING: boolean;
  114952. COLORGRADING3D: boolean;
  114953. SAMPLER3DGREENDEPTH: boolean;
  114954. SAMPLER3DBGRMAP: boolean;
  114955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114956. EXPOSURE: boolean;
  114957. MULTIVIEW: boolean;
  114958. USEPHYSICALLIGHTFALLOFF: boolean;
  114959. USEGLTFLIGHTFALLOFF: boolean;
  114960. TWOSIDEDLIGHTING: boolean;
  114961. SHADOWFLOAT: boolean;
  114962. CLIPPLANE: boolean;
  114963. CLIPPLANE2: boolean;
  114964. CLIPPLANE3: boolean;
  114965. CLIPPLANE4: boolean;
  114966. POINTSIZE: boolean;
  114967. FOG: boolean;
  114968. LOGARITHMICDEPTH: boolean;
  114969. FORCENORMALFORWARD: boolean;
  114970. SPECULARAA: boolean;
  114971. CLEARCOAT: boolean;
  114972. CLEARCOAT_DEFAULTIOR: boolean;
  114973. CLEARCOAT_TEXTURE: boolean;
  114974. CLEARCOAT_TEXTUREDIRECTUV: number;
  114975. CLEARCOAT_BUMP: boolean;
  114976. CLEARCOAT_BUMPDIRECTUV: number;
  114977. CLEARCOAT_TINT: boolean;
  114978. CLEARCOAT_TINT_TEXTURE: boolean;
  114979. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114980. ANISOTROPIC: boolean;
  114981. ANISOTROPIC_TEXTURE: boolean;
  114982. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114983. BRDF_V_HEIGHT_CORRELATED: boolean;
  114984. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114985. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114986. SHEEN: boolean;
  114987. SHEEN_TEXTURE: boolean;
  114988. SHEEN_TEXTUREDIRECTUV: number;
  114989. SHEEN_LINKWITHALBEDO: boolean;
  114990. SUBSURFACE: boolean;
  114991. SS_REFRACTION: boolean;
  114992. SS_TRANSLUCENCY: boolean;
  114993. SS_SCATERRING: boolean;
  114994. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114995. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114996. SS_REFRACTIONMAP_3D: boolean;
  114997. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114998. SS_LODINREFRACTIONALPHA: boolean;
  114999. SS_GAMMAREFRACTION: boolean;
  115000. SS_RGBDREFRACTION: boolean;
  115001. SS_LINEARSPECULARREFRACTION: boolean;
  115002. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115003. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115004. UNLIT: boolean;
  115005. DEBUGMODE: number;
  115006. /**
  115007. * Initializes the PBR Material defines.
  115008. */
  115009. constructor();
  115010. /**
  115011. * Resets the PBR Material defines.
  115012. */
  115013. reset(): void;
  115014. }
  115015. /**
  115016. * The Physically based material base class of BJS.
  115017. *
  115018. * This offers the main features of a standard PBR material.
  115019. * For more information, please refer to the documentation :
  115020. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115021. */
  115022. export abstract class PBRBaseMaterial extends PushMaterial {
  115023. /**
  115024. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115025. */
  115026. static readonly PBRMATERIAL_OPAQUE: number;
  115027. /**
  115028. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115029. */
  115030. static readonly PBRMATERIAL_ALPHATEST: number;
  115031. /**
  115032. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115033. */
  115034. static readonly PBRMATERIAL_ALPHABLEND: number;
  115035. /**
  115036. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115037. * They are also discarded below the alpha cutoff threshold to improve performances.
  115038. */
  115039. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115040. /**
  115041. * Defines the default value of how much AO map is occluding the analytical lights
  115042. * (point spot...).
  115043. */
  115044. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115045. /**
  115046. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115047. */
  115048. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115049. /**
  115050. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115051. * to enhance interoperability with other engines.
  115052. */
  115053. static readonly LIGHTFALLOFF_GLTF: number;
  115054. /**
  115055. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115056. * to enhance interoperability with other materials.
  115057. */
  115058. static readonly LIGHTFALLOFF_STANDARD: number;
  115059. /**
  115060. * Intensity of the direct lights e.g. the four lights available in your scene.
  115061. * This impacts both the direct diffuse and specular highlights.
  115062. */
  115063. protected _directIntensity: number;
  115064. /**
  115065. * Intensity of the emissive part of the material.
  115066. * This helps controlling the emissive effect without modifying the emissive color.
  115067. */
  115068. protected _emissiveIntensity: number;
  115069. /**
  115070. * Intensity of the environment e.g. how much the environment will light the object
  115071. * either through harmonics for rough material or through the refelction for shiny ones.
  115072. */
  115073. protected _environmentIntensity: number;
  115074. /**
  115075. * This is a special control allowing the reduction of the specular highlights coming from the
  115076. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115077. */
  115078. protected _specularIntensity: number;
  115079. /**
  115080. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115081. */
  115082. private _lightingInfos;
  115083. /**
  115084. * Debug Control allowing disabling the bump map on this material.
  115085. */
  115086. protected _disableBumpMap: boolean;
  115087. /**
  115088. * AKA Diffuse Texture in standard nomenclature.
  115089. */
  115090. protected _albedoTexture: Nullable<BaseTexture>;
  115091. /**
  115092. * AKA Occlusion Texture in other nomenclature.
  115093. */
  115094. protected _ambientTexture: Nullable<BaseTexture>;
  115095. /**
  115096. * AKA Occlusion Texture Intensity in other nomenclature.
  115097. */
  115098. protected _ambientTextureStrength: number;
  115099. /**
  115100. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115101. * 1 means it completely occludes it
  115102. * 0 mean it has no impact
  115103. */
  115104. protected _ambientTextureImpactOnAnalyticalLights: number;
  115105. /**
  115106. * Stores the alpha values in a texture.
  115107. */
  115108. protected _opacityTexture: Nullable<BaseTexture>;
  115109. /**
  115110. * Stores the reflection values in a texture.
  115111. */
  115112. protected _reflectionTexture: Nullable<BaseTexture>;
  115113. /**
  115114. * Stores the emissive values in a texture.
  115115. */
  115116. protected _emissiveTexture: Nullable<BaseTexture>;
  115117. /**
  115118. * AKA Specular texture in other nomenclature.
  115119. */
  115120. protected _reflectivityTexture: Nullable<BaseTexture>;
  115121. /**
  115122. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115123. */
  115124. protected _metallicTexture: Nullable<BaseTexture>;
  115125. /**
  115126. * Specifies the metallic scalar of the metallic/roughness workflow.
  115127. * Can also be used to scale the metalness values of the metallic texture.
  115128. */
  115129. protected _metallic: Nullable<number>;
  115130. /**
  115131. * Specifies the roughness scalar of the metallic/roughness workflow.
  115132. * Can also be used to scale the roughness values of the metallic texture.
  115133. */
  115134. protected _roughness: Nullable<number>;
  115135. /**
  115136. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115137. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115138. */
  115139. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115140. /**
  115141. * Stores surface normal data used to displace a mesh in a texture.
  115142. */
  115143. protected _bumpTexture: Nullable<BaseTexture>;
  115144. /**
  115145. * Stores the pre-calculated light information of a mesh in a texture.
  115146. */
  115147. protected _lightmapTexture: Nullable<BaseTexture>;
  115148. /**
  115149. * The color of a material in ambient lighting.
  115150. */
  115151. protected _ambientColor: Color3;
  115152. /**
  115153. * AKA Diffuse Color in other nomenclature.
  115154. */
  115155. protected _albedoColor: Color3;
  115156. /**
  115157. * AKA Specular Color in other nomenclature.
  115158. */
  115159. protected _reflectivityColor: Color3;
  115160. /**
  115161. * The color applied when light is reflected from a material.
  115162. */
  115163. protected _reflectionColor: Color3;
  115164. /**
  115165. * The color applied when light is emitted from a material.
  115166. */
  115167. protected _emissiveColor: Color3;
  115168. /**
  115169. * AKA Glossiness in other nomenclature.
  115170. */
  115171. protected _microSurface: number;
  115172. /**
  115173. * Specifies that the material will use the light map as a show map.
  115174. */
  115175. protected _useLightmapAsShadowmap: boolean;
  115176. /**
  115177. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115178. * makes the reflect vector face the model (under horizon).
  115179. */
  115180. protected _useHorizonOcclusion: boolean;
  115181. /**
  115182. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115183. * too much the area relying on ambient texture to define their ambient occlusion.
  115184. */
  115185. protected _useRadianceOcclusion: boolean;
  115186. /**
  115187. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115188. */
  115189. protected _useAlphaFromAlbedoTexture: boolean;
  115190. /**
  115191. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115192. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115193. */
  115194. protected _useSpecularOverAlpha: boolean;
  115195. /**
  115196. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115197. */
  115198. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115199. /**
  115200. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115201. */
  115202. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115203. /**
  115204. * Specifies if the metallic texture contains the roughness information in its green channel.
  115205. */
  115206. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115207. /**
  115208. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115209. */
  115210. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115211. /**
  115212. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115213. */
  115214. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115215. /**
  115216. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115217. */
  115218. protected _useAmbientInGrayScale: boolean;
  115219. /**
  115220. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115221. * The material will try to infer what glossiness each pixel should be.
  115222. */
  115223. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115224. /**
  115225. * Defines the falloff type used in this material.
  115226. * It by default is Physical.
  115227. */
  115228. protected _lightFalloff: number;
  115229. /**
  115230. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115231. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115232. */
  115233. protected _useRadianceOverAlpha: boolean;
  115234. /**
  115235. * Allows using an object space normal map (instead of tangent space).
  115236. */
  115237. protected _useObjectSpaceNormalMap: boolean;
  115238. /**
  115239. * Allows using the bump map in parallax mode.
  115240. */
  115241. protected _useParallax: boolean;
  115242. /**
  115243. * Allows using the bump map in parallax occlusion mode.
  115244. */
  115245. protected _useParallaxOcclusion: boolean;
  115246. /**
  115247. * Controls the scale bias of the parallax mode.
  115248. */
  115249. protected _parallaxScaleBias: number;
  115250. /**
  115251. * If sets to true, disables all the lights affecting the material.
  115252. */
  115253. protected _disableLighting: boolean;
  115254. /**
  115255. * Number of Simultaneous lights allowed on the material.
  115256. */
  115257. protected _maxSimultaneousLights: number;
  115258. /**
  115259. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115260. */
  115261. protected _invertNormalMapX: boolean;
  115262. /**
  115263. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115264. */
  115265. protected _invertNormalMapY: boolean;
  115266. /**
  115267. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115268. */
  115269. protected _twoSidedLighting: boolean;
  115270. /**
  115271. * Defines the alpha limits in alpha test mode.
  115272. */
  115273. protected _alphaCutOff: number;
  115274. /**
  115275. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115276. */
  115277. protected _forceAlphaTest: boolean;
  115278. /**
  115279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115280. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115281. */
  115282. protected _useAlphaFresnel: boolean;
  115283. /**
  115284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115285. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115286. */
  115287. protected _useLinearAlphaFresnel: boolean;
  115288. /**
  115289. * The transparency mode of the material.
  115290. */
  115291. protected _transparencyMode: Nullable<number>;
  115292. /**
  115293. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115294. * from cos thetav and roughness:
  115295. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115296. */
  115297. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115298. /**
  115299. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115300. */
  115301. protected _forceIrradianceInFragment: boolean;
  115302. /**
  115303. * Force normal to face away from face.
  115304. */
  115305. protected _forceNormalForward: boolean;
  115306. /**
  115307. * Enables specular anti aliasing in the PBR shader.
  115308. * It will both interacts on the Geometry for analytical and IBL lighting.
  115309. * It also prefilter the roughness map based on the bump values.
  115310. */
  115311. protected _enableSpecularAntiAliasing: boolean;
  115312. /**
  115313. * Default configuration related to image processing available in the PBR Material.
  115314. */
  115315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115316. /**
  115317. * Keep track of the image processing observer to allow dispose and replace.
  115318. */
  115319. private _imageProcessingObserver;
  115320. /**
  115321. * Attaches a new image processing configuration to the PBR Material.
  115322. * @param configuration
  115323. */
  115324. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115325. /**
  115326. * Stores the available render targets.
  115327. */
  115328. private _renderTargets;
  115329. /**
  115330. * Sets the global ambient color for the material used in lighting calculations.
  115331. */
  115332. private _globalAmbientColor;
  115333. /**
  115334. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115335. */
  115336. private _useLogarithmicDepth;
  115337. /**
  115338. * If set to true, no lighting calculations will be applied.
  115339. */
  115340. private _unlit;
  115341. private _debugMode;
  115342. /**
  115343. * @hidden
  115344. * This is reserved for the inspector.
  115345. * Defines the material debug mode.
  115346. * It helps seeing only some components of the material while troubleshooting.
  115347. */
  115348. debugMode: number;
  115349. /**
  115350. * @hidden
  115351. * This is reserved for the inspector.
  115352. * Specify from where on screen the debug mode should start.
  115353. * The value goes from -1 (full screen) to 1 (not visible)
  115354. * It helps with side by side comparison against the final render
  115355. * This defaults to -1
  115356. */
  115357. private debugLimit;
  115358. /**
  115359. * @hidden
  115360. * This is reserved for the inspector.
  115361. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115362. * You can use the factor to better multiply the final value.
  115363. */
  115364. private debugFactor;
  115365. /**
  115366. * Defines the clear coat layer parameters for the material.
  115367. */
  115368. readonly clearCoat: PBRClearCoatConfiguration;
  115369. /**
  115370. * Defines the anisotropic parameters for the material.
  115371. */
  115372. readonly anisotropy: PBRAnisotropicConfiguration;
  115373. /**
  115374. * Defines the BRDF parameters for the material.
  115375. */
  115376. readonly brdf: PBRBRDFConfiguration;
  115377. /**
  115378. * Defines the Sheen parameters for the material.
  115379. */
  115380. readonly sheen: PBRSheenConfiguration;
  115381. /**
  115382. * Defines the SubSurface parameters for the material.
  115383. */
  115384. readonly subSurface: PBRSubSurfaceConfiguration;
  115385. /**
  115386. * Custom callback helping to override the default shader used in the material.
  115387. */
  115388. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115389. protected _rebuildInParallel: boolean;
  115390. /**
  115391. * Instantiates a new PBRMaterial instance.
  115392. *
  115393. * @param name The material name
  115394. * @param scene The scene the material will be use in.
  115395. */
  115396. constructor(name: string, scene: Scene);
  115397. /**
  115398. * Gets a boolean indicating that current material needs to register RTT
  115399. */
  115400. readonly hasRenderTargetTextures: boolean;
  115401. /**
  115402. * Gets the name of the material class.
  115403. */
  115404. getClassName(): string;
  115405. /**
  115406. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115407. */
  115408. /**
  115409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115410. */
  115411. useLogarithmicDepth: boolean;
  115412. /**
  115413. * Gets the current transparency mode.
  115414. */
  115415. /**
  115416. * Sets the transparency mode of the material.
  115417. *
  115418. * | Value | Type | Description |
  115419. * | ----- | ----------------------------------- | ----------- |
  115420. * | 0 | OPAQUE | |
  115421. * | 1 | ALPHATEST | |
  115422. * | 2 | ALPHABLEND | |
  115423. * | 3 | ALPHATESTANDBLEND | |
  115424. *
  115425. */
  115426. transparencyMode: Nullable<number>;
  115427. /**
  115428. * Returns true if alpha blending should be disabled.
  115429. */
  115430. private readonly _disableAlphaBlending;
  115431. /**
  115432. * Specifies whether or not this material should be rendered in alpha blend mode.
  115433. */
  115434. needAlphaBlending(): boolean;
  115435. /**
  115436. * Specifies if the mesh will require alpha blending.
  115437. * @param mesh - BJS mesh.
  115438. */
  115439. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115440. /**
  115441. * Specifies whether or not this material should be rendered in alpha test mode.
  115442. */
  115443. needAlphaTesting(): boolean;
  115444. /**
  115445. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115446. */
  115447. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115448. /**
  115449. * Gets the texture used for the alpha test.
  115450. */
  115451. getAlphaTestTexture(): Nullable<BaseTexture>;
  115452. /**
  115453. * Specifies that the submesh is ready to be used.
  115454. * @param mesh - BJS mesh.
  115455. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115456. * @param useInstances - Specifies that instances should be used.
  115457. * @returns - boolean indicating that the submesh is ready or not.
  115458. */
  115459. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115460. /**
  115461. * Specifies if the material uses metallic roughness workflow.
  115462. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115463. */
  115464. isMetallicWorkflow(): boolean;
  115465. private _prepareEffect;
  115466. private _prepareDefines;
  115467. /**
  115468. * Force shader compilation
  115469. */
  115470. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  115471. clipPlane: boolean;
  115472. }>): void;
  115473. /**
  115474. * Initializes the uniform buffer layout for the shader.
  115475. */
  115476. buildUniformLayout(): void;
  115477. /**
  115478. * Unbinds the material from the mesh
  115479. */
  115480. unbind(): void;
  115481. /**
  115482. * Binds the submesh data.
  115483. * @param world - The world matrix.
  115484. * @param mesh - The BJS mesh.
  115485. * @param subMesh - A submesh of the BJS mesh.
  115486. */
  115487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115488. /**
  115489. * Returns the animatable textures.
  115490. * @returns - Array of animatable textures.
  115491. */
  115492. getAnimatables(): IAnimatable[];
  115493. /**
  115494. * Returns the texture used for reflections.
  115495. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115496. */
  115497. private _getReflectionTexture;
  115498. /**
  115499. * Returns an array of the actively used textures.
  115500. * @returns - Array of BaseTextures
  115501. */
  115502. getActiveTextures(): BaseTexture[];
  115503. /**
  115504. * Checks to see if a texture is used in the material.
  115505. * @param texture - Base texture to use.
  115506. * @returns - Boolean specifying if a texture is used in the material.
  115507. */
  115508. hasTexture(texture: BaseTexture): boolean;
  115509. /**
  115510. * Disposes the resources of the material.
  115511. * @param forceDisposeEffect - Forces the disposal of effects.
  115512. * @param forceDisposeTextures - Forces the disposal of all textures.
  115513. */
  115514. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115515. }
  115516. }
  115517. declare module BABYLON {
  115518. /**
  115519. * The Physically based material of BJS.
  115520. *
  115521. * This offers the main features of a standard PBR material.
  115522. * For more information, please refer to the documentation :
  115523. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115524. */
  115525. export class PBRMaterial extends PBRBaseMaterial {
  115526. /**
  115527. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115528. */
  115529. static readonly PBRMATERIAL_OPAQUE: number;
  115530. /**
  115531. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115532. */
  115533. static readonly PBRMATERIAL_ALPHATEST: number;
  115534. /**
  115535. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115536. */
  115537. static readonly PBRMATERIAL_ALPHABLEND: number;
  115538. /**
  115539. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115540. * They are also discarded below the alpha cutoff threshold to improve performances.
  115541. */
  115542. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115543. /**
  115544. * Defines the default value of how much AO map is occluding the analytical lights
  115545. * (point spot...).
  115546. */
  115547. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115548. /**
  115549. * Intensity of the direct lights e.g. the four lights available in your scene.
  115550. * This impacts both the direct diffuse and specular highlights.
  115551. */
  115552. directIntensity: number;
  115553. /**
  115554. * Intensity of the emissive part of the material.
  115555. * This helps controlling the emissive effect without modifying the emissive color.
  115556. */
  115557. emissiveIntensity: number;
  115558. /**
  115559. * Intensity of the environment e.g. how much the environment will light the object
  115560. * either through harmonics for rough material or through the refelction for shiny ones.
  115561. */
  115562. environmentIntensity: number;
  115563. /**
  115564. * This is a special control allowing the reduction of the specular highlights coming from the
  115565. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115566. */
  115567. specularIntensity: number;
  115568. /**
  115569. * Debug Control allowing disabling the bump map on this material.
  115570. */
  115571. disableBumpMap: boolean;
  115572. /**
  115573. * AKA Diffuse Texture in standard nomenclature.
  115574. */
  115575. albedoTexture: BaseTexture;
  115576. /**
  115577. * AKA Occlusion Texture in other nomenclature.
  115578. */
  115579. ambientTexture: BaseTexture;
  115580. /**
  115581. * AKA Occlusion Texture Intensity in other nomenclature.
  115582. */
  115583. ambientTextureStrength: number;
  115584. /**
  115585. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115586. * 1 means it completely occludes it
  115587. * 0 mean it has no impact
  115588. */
  115589. ambientTextureImpactOnAnalyticalLights: number;
  115590. /**
  115591. * Stores the alpha values in a texture.
  115592. */
  115593. opacityTexture: BaseTexture;
  115594. /**
  115595. * Stores the reflection values in a texture.
  115596. */
  115597. reflectionTexture: Nullable<BaseTexture>;
  115598. /**
  115599. * Stores the emissive values in a texture.
  115600. */
  115601. emissiveTexture: BaseTexture;
  115602. /**
  115603. * AKA Specular texture in other nomenclature.
  115604. */
  115605. reflectivityTexture: BaseTexture;
  115606. /**
  115607. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115608. */
  115609. metallicTexture: BaseTexture;
  115610. /**
  115611. * Specifies the metallic scalar of the metallic/roughness workflow.
  115612. * Can also be used to scale the metalness values of the metallic texture.
  115613. */
  115614. metallic: Nullable<number>;
  115615. /**
  115616. * Specifies the roughness scalar of the metallic/roughness workflow.
  115617. * Can also be used to scale the roughness values of the metallic texture.
  115618. */
  115619. roughness: Nullable<number>;
  115620. /**
  115621. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115622. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115623. */
  115624. microSurfaceTexture: BaseTexture;
  115625. /**
  115626. * Stores surface normal data used to displace a mesh in a texture.
  115627. */
  115628. bumpTexture: BaseTexture;
  115629. /**
  115630. * Stores the pre-calculated light information of a mesh in a texture.
  115631. */
  115632. lightmapTexture: BaseTexture;
  115633. /**
  115634. * Stores the refracted light information in a texture.
  115635. */
  115636. refractionTexture: Nullable<BaseTexture>;
  115637. /**
  115638. * The color of a material in ambient lighting.
  115639. */
  115640. ambientColor: Color3;
  115641. /**
  115642. * AKA Diffuse Color in other nomenclature.
  115643. */
  115644. albedoColor: Color3;
  115645. /**
  115646. * AKA Specular Color in other nomenclature.
  115647. */
  115648. reflectivityColor: Color3;
  115649. /**
  115650. * The color reflected from the material.
  115651. */
  115652. reflectionColor: Color3;
  115653. /**
  115654. * The color emitted from the material.
  115655. */
  115656. emissiveColor: Color3;
  115657. /**
  115658. * AKA Glossiness in other nomenclature.
  115659. */
  115660. microSurface: number;
  115661. /**
  115662. * source material index of refraction (IOR)' / 'destination material IOR.
  115663. */
  115664. indexOfRefraction: number;
  115665. /**
  115666. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115667. */
  115668. invertRefractionY: boolean;
  115669. /**
  115670. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115671. * Materials half opaque for instance using refraction could benefit from this control.
  115672. */
  115673. linkRefractionWithTransparency: boolean;
  115674. /**
  115675. * If true, the light map contains occlusion information instead of lighting info.
  115676. */
  115677. useLightmapAsShadowmap: boolean;
  115678. /**
  115679. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115680. */
  115681. useAlphaFromAlbedoTexture: boolean;
  115682. /**
  115683. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115684. */
  115685. forceAlphaTest: boolean;
  115686. /**
  115687. * Defines the alpha limits in alpha test mode.
  115688. */
  115689. alphaCutOff: number;
  115690. /**
  115691. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115692. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115693. */
  115694. useSpecularOverAlpha: boolean;
  115695. /**
  115696. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115697. */
  115698. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115699. /**
  115700. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115701. */
  115702. useRoughnessFromMetallicTextureAlpha: boolean;
  115703. /**
  115704. * Specifies if the metallic texture contains the roughness information in its green channel.
  115705. */
  115706. useRoughnessFromMetallicTextureGreen: boolean;
  115707. /**
  115708. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115709. */
  115710. useMetallnessFromMetallicTextureBlue: boolean;
  115711. /**
  115712. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115713. */
  115714. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115715. /**
  115716. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115717. */
  115718. useAmbientInGrayScale: boolean;
  115719. /**
  115720. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115721. * The material will try to infer what glossiness each pixel should be.
  115722. */
  115723. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115724. /**
  115725. * BJS is using an harcoded light falloff based on a manually sets up range.
  115726. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115727. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115728. */
  115729. /**
  115730. * BJS is using an harcoded light falloff based on a manually sets up range.
  115731. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115732. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115733. */
  115734. usePhysicalLightFalloff: boolean;
  115735. /**
  115736. * In order to support the falloff compatibility with gltf, a special mode has been added
  115737. * to reproduce the gltf light falloff.
  115738. */
  115739. /**
  115740. * In order to support the falloff compatibility with gltf, a special mode has been added
  115741. * to reproduce the gltf light falloff.
  115742. */
  115743. useGLTFLightFalloff: boolean;
  115744. /**
  115745. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115746. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115747. */
  115748. useRadianceOverAlpha: boolean;
  115749. /**
  115750. * Allows using an object space normal map (instead of tangent space).
  115751. */
  115752. useObjectSpaceNormalMap: boolean;
  115753. /**
  115754. * Allows using the bump map in parallax mode.
  115755. */
  115756. useParallax: boolean;
  115757. /**
  115758. * Allows using the bump map in parallax occlusion mode.
  115759. */
  115760. useParallaxOcclusion: boolean;
  115761. /**
  115762. * Controls the scale bias of the parallax mode.
  115763. */
  115764. parallaxScaleBias: number;
  115765. /**
  115766. * If sets to true, disables all the lights affecting the material.
  115767. */
  115768. disableLighting: boolean;
  115769. /**
  115770. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115771. */
  115772. forceIrradianceInFragment: boolean;
  115773. /**
  115774. * Number of Simultaneous lights allowed on the material.
  115775. */
  115776. maxSimultaneousLights: number;
  115777. /**
  115778. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115779. */
  115780. invertNormalMapX: boolean;
  115781. /**
  115782. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115783. */
  115784. invertNormalMapY: boolean;
  115785. /**
  115786. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115787. */
  115788. twoSidedLighting: boolean;
  115789. /**
  115790. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115791. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115792. */
  115793. useAlphaFresnel: boolean;
  115794. /**
  115795. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115796. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115797. */
  115798. useLinearAlphaFresnel: boolean;
  115799. /**
  115800. * Let user defines the brdf lookup texture used for IBL.
  115801. * A default 8bit version is embedded but you could point at :
  115802. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115803. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115804. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115805. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115806. */
  115807. environmentBRDFTexture: Nullable<BaseTexture>;
  115808. /**
  115809. * Force normal to face away from face.
  115810. */
  115811. forceNormalForward: boolean;
  115812. /**
  115813. * Enables specular anti aliasing in the PBR shader.
  115814. * It will both interacts on the Geometry for analytical and IBL lighting.
  115815. * It also prefilter the roughness map based on the bump values.
  115816. */
  115817. enableSpecularAntiAliasing: boolean;
  115818. /**
  115819. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115820. * makes the reflect vector face the model (under horizon).
  115821. */
  115822. useHorizonOcclusion: boolean;
  115823. /**
  115824. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115825. * too much the area relying on ambient texture to define their ambient occlusion.
  115826. */
  115827. useRadianceOcclusion: boolean;
  115828. /**
  115829. * If set to true, no lighting calculations will be applied.
  115830. */
  115831. unlit: boolean;
  115832. /**
  115833. * Gets the image processing configuration used either in this material.
  115834. */
  115835. /**
  115836. * Sets the Default image processing configuration used either in the this material.
  115837. *
  115838. * If sets to null, the scene one is in use.
  115839. */
  115840. imageProcessingConfiguration: ImageProcessingConfiguration;
  115841. /**
  115842. * Gets wether the color curves effect is enabled.
  115843. */
  115844. /**
  115845. * Sets wether the color curves effect is enabled.
  115846. */
  115847. cameraColorCurvesEnabled: boolean;
  115848. /**
  115849. * Gets wether the color grading effect is enabled.
  115850. */
  115851. /**
  115852. * Gets wether the color grading effect is enabled.
  115853. */
  115854. cameraColorGradingEnabled: boolean;
  115855. /**
  115856. * Gets wether tonemapping is enabled or not.
  115857. */
  115858. /**
  115859. * Sets wether tonemapping is enabled or not
  115860. */
  115861. cameraToneMappingEnabled: boolean;
  115862. /**
  115863. * The camera exposure used on this material.
  115864. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115865. * This corresponds to a photographic exposure.
  115866. */
  115867. /**
  115868. * The camera exposure used on this material.
  115869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115870. * This corresponds to a photographic exposure.
  115871. */
  115872. cameraExposure: number;
  115873. /**
  115874. * Gets The camera contrast used on this material.
  115875. */
  115876. /**
  115877. * Sets The camera contrast used on this material.
  115878. */
  115879. cameraContrast: number;
  115880. /**
  115881. * Gets the Color Grading 2D Lookup Texture.
  115882. */
  115883. /**
  115884. * Sets the Color Grading 2D Lookup Texture.
  115885. */
  115886. cameraColorGradingTexture: Nullable<BaseTexture>;
  115887. /**
  115888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115890. * 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;
  115891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115892. */
  115893. /**
  115894. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115895. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115896. * 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;
  115897. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115898. */
  115899. cameraColorCurves: Nullable<ColorCurves>;
  115900. /**
  115901. * Instantiates a new PBRMaterial instance.
  115902. *
  115903. * @param name The material name
  115904. * @param scene The scene the material will be use in.
  115905. */
  115906. constructor(name: string, scene: Scene);
  115907. /**
  115908. * Returns the name of this material class.
  115909. */
  115910. getClassName(): string;
  115911. /**
  115912. * Makes a duplicate of the current material.
  115913. * @param name - name to use for the new material.
  115914. */
  115915. clone(name: string): PBRMaterial;
  115916. /**
  115917. * Serializes this PBR Material.
  115918. * @returns - An object with the serialized material.
  115919. */
  115920. serialize(): any;
  115921. /**
  115922. * Parses a PBR Material from a serialized object.
  115923. * @param source - Serialized object.
  115924. * @param scene - BJS scene instance.
  115925. * @param rootUrl - url for the scene object
  115926. * @returns - PBRMaterial
  115927. */
  115928. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115929. }
  115930. }
  115931. declare module BABYLON {
  115932. /**
  115933. * Direct draw surface info
  115934. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115935. */
  115936. export interface DDSInfo {
  115937. /**
  115938. * Width of the texture
  115939. */
  115940. width: number;
  115941. /**
  115942. * Width of the texture
  115943. */
  115944. height: number;
  115945. /**
  115946. * Number of Mipmaps for the texture
  115947. * @see https://en.wikipedia.org/wiki/Mipmap
  115948. */
  115949. mipmapCount: number;
  115950. /**
  115951. * If the textures format is a known fourCC format
  115952. * @see https://www.fourcc.org/
  115953. */
  115954. isFourCC: boolean;
  115955. /**
  115956. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115957. */
  115958. isRGB: boolean;
  115959. /**
  115960. * If the texture is a lumincance format
  115961. */
  115962. isLuminance: boolean;
  115963. /**
  115964. * If this is a cube texture
  115965. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115966. */
  115967. isCube: boolean;
  115968. /**
  115969. * If the texture is a compressed format eg. FOURCC_DXT1
  115970. */
  115971. isCompressed: boolean;
  115972. /**
  115973. * The dxgiFormat of the texture
  115974. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115975. */
  115976. dxgiFormat: number;
  115977. /**
  115978. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115979. */
  115980. textureType: number;
  115981. /**
  115982. * Sphericle polynomial created for the dds texture
  115983. */
  115984. sphericalPolynomial?: SphericalPolynomial;
  115985. }
  115986. /**
  115987. * Class used to provide DDS decompression tools
  115988. */
  115989. export class DDSTools {
  115990. /**
  115991. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115992. */
  115993. static StoreLODInAlphaChannel: boolean;
  115994. /**
  115995. * Gets DDS information from an array buffer
  115996. * @param arrayBuffer defines the array buffer to read data from
  115997. * @returns the DDS information
  115998. */
  115999. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116000. private static _FloatView;
  116001. private static _Int32View;
  116002. private static _ToHalfFloat;
  116003. private static _FromHalfFloat;
  116004. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116005. private static _GetHalfFloatRGBAArrayBuffer;
  116006. private static _GetFloatRGBAArrayBuffer;
  116007. private static _GetFloatAsUIntRGBAArrayBuffer;
  116008. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116009. private static _GetRGBAArrayBuffer;
  116010. private static _ExtractLongWordOrder;
  116011. private static _GetRGBArrayBuffer;
  116012. private static _GetLuminanceArrayBuffer;
  116013. /**
  116014. * Uploads DDS Levels to a Babylon Texture
  116015. * @hidden
  116016. */
  116017. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116018. }
  116019. interface ThinEngine {
  116020. /**
  116021. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116022. * @param rootUrl defines the url where the file to load is located
  116023. * @param scene defines the current scene
  116024. * @param lodScale defines scale to apply to the mip map selection
  116025. * @param lodOffset defines offset to apply to the mip map selection
  116026. * @param onLoad defines an optional callback raised when the texture is loaded
  116027. * @param onError defines an optional callback raised if there is an issue to load the texture
  116028. * @param format defines the format of the data
  116029. * @param forcedExtension defines the extension to use to pick the right loader
  116030. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116031. * @returns the cube texture as an InternalTexture
  116032. */
  116033. 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;
  116034. }
  116035. }
  116036. declare module BABYLON {
  116037. /**
  116038. * Implementation of the DDS Texture Loader.
  116039. * @hidden
  116040. */
  116041. export class _DDSTextureLoader implements IInternalTextureLoader {
  116042. /**
  116043. * Defines wether the loader supports cascade loading the different faces.
  116044. */
  116045. readonly supportCascades: boolean;
  116046. /**
  116047. * This returns if the loader support the current file information.
  116048. * @param extension defines the file extension of the file being loaded
  116049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116050. * @param fallback defines the fallback internal texture if any
  116051. * @param isBase64 defines whether the texture is encoded as a base64
  116052. * @param isBuffer defines whether the texture data are stored as a buffer
  116053. * @returns true if the loader can load the specified file
  116054. */
  116055. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116056. /**
  116057. * Transform the url before loading if required.
  116058. * @param rootUrl the url of the texture
  116059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116060. * @returns the transformed texture
  116061. */
  116062. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116063. /**
  116064. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116065. * @param rootUrl the url of the texture
  116066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116067. * @returns the fallback texture
  116068. */
  116069. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116070. /**
  116071. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116072. * @param data contains the texture data
  116073. * @param texture defines the BabylonJS internal texture
  116074. * @param createPolynomials will be true if polynomials have been requested
  116075. * @param onLoad defines the callback to trigger once the texture is ready
  116076. * @param onError defines the callback to trigger in case of error
  116077. */
  116078. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116079. /**
  116080. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116081. * @param data contains the texture data
  116082. * @param texture defines the BabylonJS internal texture
  116083. * @param callback defines the method to call once ready to upload
  116084. */
  116085. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116086. }
  116087. }
  116088. declare module BABYLON {
  116089. /**
  116090. * Implementation of the ENV Texture Loader.
  116091. * @hidden
  116092. */
  116093. export class _ENVTextureLoader implements IInternalTextureLoader {
  116094. /**
  116095. * Defines wether the loader supports cascade loading the different faces.
  116096. */
  116097. readonly supportCascades: boolean;
  116098. /**
  116099. * This returns if the loader support the current file information.
  116100. * @param extension defines the file extension of the file being loaded
  116101. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116102. * @param fallback defines the fallback internal texture if any
  116103. * @param isBase64 defines whether the texture is encoded as a base64
  116104. * @param isBuffer defines whether the texture data are stored as a buffer
  116105. * @returns true if the loader can load the specified file
  116106. */
  116107. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116108. /**
  116109. * Transform the url before loading if required.
  116110. * @param rootUrl the url of the texture
  116111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116112. * @returns the transformed texture
  116113. */
  116114. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116115. /**
  116116. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116117. * @param rootUrl the url of the texture
  116118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116119. * @returns the fallback texture
  116120. */
  116121. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116122. /**
  116123. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116124. * @param data contains the texture data
  116125. * @param texture defines the BabylonJS internal texture
  116126. * @param createPolynomials will be true if polynomials have been requested
  116127. * @param onLoad defines the callback to trigger once the texture is ready
  116128. * @param onError defines the callback to trigger in case of error
  116129. */
  116130. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116131. /**
  116132. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116133. * @param data contains the texture data
  116134. * @param texture defines the BabylonJS internal texture
  116135. * @param callback defines the method to call once ready to upload
  116136. */
  116137. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116138. }
  116139. }
  116140. declare module BABYLON {
  116141. /**
  116142. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116143. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116144. */
  116145. export class KhronosTextureContainer {
  116146. /** contents of the KTX container file */
  116147. arrayBuffer: any;
  116148. private static HEADER_LEN;
  116149. private static COMPRESSED_2D;
  116150. private static COMPRESSED_3D;
  116151. private static TEX_2D;
  116152. private static TEX_3D;
  116153. /**
  116154. * Gets the openGL type
  116155. */
  116156. glType: number;
  116157. /**
  116158. * Gets the openGL type size
  116159. */
  116160. glTypeSize: number;
  116161. /**
  116162. * Gets the openGL format
  116163. */
  116164. glFormat: number;
  116165. /**
  116166. * Gets the openGL internal format
  116167. */
  116168. glInternalFormat: number;
  116169. /**
  116170. * Gets the base internal format
  116171. */
  116172. glBaseInternalFormat: number;
  116173. /**
  116174. * Gets image width in pixel
  116175. */
  116176. pixelWidth: number;
  116177. /**
  116178. * Gets image height in pixel
  116179. */
  116180. pixelHeight: number;
  116181. /**
  116182. * Gets image depth in pixels
  116183. */
  116184. pixelDepth: number;
  116185. /**
  116186. * Gets the number of array elements
  116187. */
  116188. numberOfArrayElements: number;
  116189. /**
  116190. * Gets the number of faces
  116191. */
  116192. numberOfFaces: number;
  116193. /**
  116194. * Gets the number of mipmap levels
  116195. */
  116196. numberOfMipmapLevels: number;
  116197. /**
  116198. * Gets the bytes of key value data
  116199. */
  116200. bytesOfKeyValueData: number;
  116201. /**
  116202. * Gets the load type
  116203. */
  116204. loadType: number;
  116205. /**
  116206. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116207. */
  116208. isInvalid: boolean;
  116209. /**
  116210. * Creates a new KhronosTextureContainer
  116211. * @param arrayBuffer contents of the KTX container file
  116212. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116213. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116214. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116215. */
  116216. constructor(
  116217. /** contents of the KTX container file */
  116218. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116219. /**
  116220. * Uploads KTX content to a Babylon Texture.
  116221. * It is assumed that the texture has already been created & is currently bound
  116222. * @hidden
  116223. */
  116224. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116225. private _upload2DCompressedLevels;
  116226. }
  116227. }
  116228. declare module BABYLON {
  116229. /**
  116230. * Implementation of the KTX Texture Loader.
  116231. * @hidden
  116232. */
  116233. export class _KTXTextureLoader implements IInternalTextureLoader {
  116234. /**
  116235. * Defines wether the loader supports cascade loading the different faces.
  116236. */
  116237. readonly supportCascades: boolean;
  116238. /**
  116239. * This returns if the loader support the current file information.
  116240. * @param extension defines the file extension of the file being loaded
  116241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116242. * @param fallback defines the fallback internal texture if any
  116243. * @param isBase64 defines whether the texture is encoded as a base64
  116244. * @param isBuffer defines whether the texture data are stored as a buffer
  116245. * @returns true if the loader can load the specified file
  116246. */
  116247. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116248. /**
  116249. * Transform the url before loading if required.
  116250. * @param rootUrl the url of the texture
  116251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116252. * @returns the transformed texture
  116253. */
  116254. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116255. /**
  116256. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116257. * @param rootUrl the url of the texture
  116258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116259. * @returns the fallback texture
  116260. */
  116261. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116262. /**
  116263. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116264. * @param data contains the texture data
  116265. * @param texture defines the BabylonJS internal texture
  116266. * @param createPolynomials will be true if polynomials have been requested
  116267. * @param onLoad defines the callback to trigger once the texture is ready
  116268. * @param onError defines the callback to trigger in case of error
  116269. */
  116270. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116271. /**
  116272. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116273. * @param data contains the texture data
  116274. * @param texture defines the BabylonJS internal texture
  116275. * @param callback defines the method to call once ready to upload
  116276. */
  116277. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116278. }
  116279. }
  116280. declare module BABYLON {
  116281. /**
  116282. * Options for the default xr helper
  116283. */
  116284. export class WebXRDefaultExperienceOptions {
  116285. /**
  116286. * Floor meshes that should be used for teleporting
  116287. */
  116288. floorMeshes: Array<AbstractMesh>;
  116289. }
  116290. /**
  116291. * Default experience which provides a similar setup to the previous webVRExperience
  116292. */
  116293. export class WebXRDefaultExperience {
  116294. /**
  116295. * Base experience
  116296. */
  116297. baseExperience: WebXRExperienceHelper;
  116298. /**
  116299. * Input experience extension
  116300. */
  116301. input: WebXRInput;
  116302. /**
  116303. * Loads the controller models
  116304. */
  116305. controllerModelLoader: WebXRControllerModelLoader;
  116306. /**
  116307. * Enables laser pointer and selection
  116308. */
  116309. pointerSelection: WebXRControllerPointerSelection;
  116310. /**
  116311. * Enables teleportation
  116312. */
  116313. teleportation: WebXRControllerTeleportation;
  116314. /**
  116315. * Enables ui for enetering/exiting xr
  116316. */
  116317. enterExitUI: WebXREnterExitUI;
  116318. /**
  116319. * Default output canvas xr should render to
  116320. */
  116321. outputCanvas: WebXRManagedOutputCanvas;
  116322. /**
  116323. * Creates the default xr experience
  116324. * @param scene scene
  116325. * @param options options for basic configuration
  116326. * @returns resulting WebXRDefaultExperience
  116327. */
  116328. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116329. private constructor();
  116330. /**
  116331. * DIsposes of the experience helper
  116332. */
  116333. dispose(): void;
  116334. }
  116335. }
  116336. declare module BABYLON {
  116337. /** @hidden */
  116338. export var _forceSceneHelpersToBundle: boolean;
  116339. interface Scene {
  116340. /**
  116341. * Creates a default light for the scene.
  116342. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116343. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116344. */
  116345. createDefaultLight(replace?: boolean): void;
  116346. /**
  116347. * Creates a default camera for the scene.
  116348. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116349. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116350. * @param replace has default false, when true replaces the active camera in the scene
  116351. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116352. */
  116353. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116354. /**
  116355. * Creates a default camera and a default light.
  116356. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116357. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116358. * @param replace has the default false, when true replaces the active camera/light in the scene
  116359. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116360. */
  116361. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116362. /**
  116363. * Creates a new sky box
  116364. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116365. * @param environmentTexture defines the texture to use as environment texture
  116366. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116367. * @param scale defines the overall scale of the skybox
  116368. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116369. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116370. * @returns a new mesh holding the sky box
  116371. */
  116372. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116373. /**
  116374. * Creates a new environment
  116375. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116376. * @param options defines the options you can use to configure the environment
  116377. * @returns the new EnvironmentHelper
  116378. */
  116379. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116380. /**
  116381. * Creates a new VREXperienceHelper
  116382. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116383. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116384. * @returns a new VREXperienceHelper
  116385. */
  116386. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116387. /**
  116388. * Creates a new WebXRDefaultExperience
  116389. * @see http://doc.babylonjs.com/how_to/webxr
  116390. * @param options experience options
  116391. * @returns a promise for a new WebXRDefaultExperience
  116392. */
  116393. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116394. }
  116395. }
  116396. declare module BABYLON {
  116397. /**
  116398. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116399. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116400. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116401. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116402. */
  116403. export class VideoDome extends TransformNode {
  116404. /**
  116405. * Define the video source as a Monoscopic panoramic 360 video.
  116406. */
  116407. static readonly MODE_MONOSCOPIC: number;
  116408. /**
  116409. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116410. */
  116411. static readonly MODE_TOPBOTTOM: number;
  116412. /**
  116413. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116414. */
  116415. static readonly MODE_SIDEBYSIDE: number;
  116416. private _halfDome;
  116417. private _useDirectMapping;
  116418. /**
  116419. * The video texture being displayed on the sphere
  116420. */
  116421. protected _videoTexture: VideoTexture;
  116422. /**
  116423. * Gets the video texture being displayed on the sphere
  116424. */
  116425. readonly videoTexture: VideoTexture;
  116426. /**
  116427. * The skybox material
  116428. */
  116429. protected _material: BackgroundMaterial;
  116430. /**
  116431. * The surface used for the skybox
  116432. */
  116433. protected _mesh: Mesh;
  116434. /**
  116435. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116436. */
  116437. private _halfDomeMask;
  116438. /**
  116439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116440. * Also see the options.resolution property.
  116441. */
  116442. fovMultiplier: number;
  116443. private _videoMode;
  116444. /**
  116445. * Gets or set the current video mode for the video. It can be:
  116446. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116447. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116448. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116449. */
  116450. videoMode: number;
  116451. /**
  116452. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116453. *
  116454. */
  116455. /**
  116456. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116457. */
  116458. halfDome: boolean;
  116459. /**
  116460. * Oberserver used in Stereoscopic VR Mode.
  116461. */
  116462. private _onBeforeCameraRenderObserver;
  116463. /**
  116464. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116465. * @param name Element's name, child elements will append suffixes for their own names.
  116466. * @param urlsOrVideo defines the url(s) or the video element to use
  116467. * @param options An object containing optional or exposed sub element properties
  116468. */
  116469. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116470. resolution?: number;
  116471. clickToPlay?: boolean;
  116472. autoPlay?: boolean;
  116473. loop?: boolean;
  116474. size?: number;
  116475. poster?: string;
  116476. faceForward?: boolean;
  116477. useDirectMapping?: boolean;
  116478. halfDomeMode?: boolean;
  116479. }, scene: Scene);
  116480. private _changeVideoMode;
  116481. /**
  116482. * Releases resources associated with this node.
  116483. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116484. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116485. */
  116486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116487. }
  116488. }
  116489. declare module BABYLON {
  116490. /**
  116491. * This class can be used to get instrumentation data from a Babylon engine
  116492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116493. */
  116494. export class EngineInstrumentation implements IDisposable {
  116495. /**
  116496. * Define the instrumented engine.
  116497. */
  116498. engine: Engine;
  116499. private _captureGPUFrameTime;
  116500. private _gpuFrameTimeToken;
  116501. private _gpuFrameTime;
  116502. private _captureShaderCompilationTime;
  116503. private _shaderCompilationTime;
  116504. private _onBeginFrameObserver;
  116505. private _onEndFrameObserver;
  116506. private _onBeforeShaderCompilationObserver;
  116507. private _onAfterShaderCompilationObserver;
  116508. /**
  116509. * Gets the perf counter used for GPU frame time
  116510. */
  116511. readonly gpuFrameTimeCounter: PerfCounter;
  116512. /**
  116513. * Gets the GPU frame time capture status
  116514. */
  116515. /**
  116516. * Enable or disable the GPU frame time capture
  116517. */
  116518. captureGPUFrameTime: boolean;
  116519. /**
  116520. * Gets the perf counter used for shader compilation time
  116521. */
  116522. readonly shaderCompilationTimeCounter: PerfCounter;
  116523. /**
  116524. * Gets the shader compilation time capture status
  116525. */
  116526. /**
  116527. * Enable or disable the shader compilation time capture
  116528. */
  116529. captureShaderCompilationTime: boolean;
  116530. /**
  116531. * Instantiates a new engine instrumentation.
  116532. * This class can be used to get instrumentation data from a Babylon engine
  116533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116534. * @param engine Defines the engine to instrument
  116535. */
  116536. constructor(
  116537. /**
  116538. * Define the instrumented engine.
  116539. */
  116540. engine: Engine);
  116541. /**
  116542. * Dispose and release associated resources.
  116543. */
  116544. dispose(): void;
  116545. }
  116546. }
  116547. declare module BABYLON {
  116548. /**
  116549. * This class can be used to get instrumentation data from a Babylon engine
  116550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116551. */
  116552. export class SceneInstrumentation implements IDisposable {
  116553. /**
  116554. * Defines the scene to instrument
  116555. */
  116556. scene: Scene;
  116557. private _captureActiveMeshesEvaluationTime;
  116558. private _activeMeshesEvaluationTime;
  116559. private _captureRenderTargetsRenderTime;
  116560. private _renderTargetsRenderTime;
  116561. private _captureFrameTime;
  116562. private _frameTime;
  116563. private _captureRenderTime;
  116564. private _renderTime;
  116565. private _captureInterFrameTime;
  116566. private _interFrameTime;
  116567. private _captureParticlesRenderTime;
  116568. private _particlesRenderTime;
  116569. private _captureSpritesRenderTime;
  116570. private _spritesRenderTime;
  116571. private _capturePhysicsTime;
  116572. private _physicsTime;
  116573. private _captureAnimationsTime;
  116574. private _animationsTime;
  116575. private _captureCameraRenderTime;
  116576. private _cameraRenderTime;
  116577. private _onBeforeActiveMeshesEvaluationObserver;
  116578. private _onAfterActiveMeshesEvaluationObserver;
  116579. private _onBeforeRenderTargetsRenderObserver;
  116580. private _onAfterRenderTargetsRenderObserver;
  116581. private _onAfterRenderObserver;
  116582. private _onBeforeDrawPhaseObserver;
  116583. private _onAfterDrawPhaseObserver;
  116584. private _onBeforeAnimationsObserver;
  116585. private _onBeforeParticlesRenderingObserver;
  116586. private _onAfterParticlesRenderingObserver;
  116587. private _onBeforeSpritesRenderingObserver;
  116588. private _onAfterSpritesRenderingObserver;
  116589. private _onBeforePhysicsObserver;
  116590. private _onAfterPhysicsObserver;
  116591. private _onAfterAnimationsObserver;
  116592. private _onBeforeCameraRenderObserver;
  116593. private _onAfterCameraRenderObserver;
  116594. /**
  116595. * Gets the perf counter used for active meshes evaluation time
  116596. */
  116597. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116598. /**
  116599. * Gets the active meshes evaluation time capture status
  116600. */
  116601. /**
  116602. * Enable or disable the active meshes evaluation time capture
  116603. */
  116604. captureActiveMeshesEvaluationTime: boolean;
  116605. /**
  116606. * Gets the perf counter used for render targets render time
  116607. */
  116608. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116609. /**
  116610. * Gets the render targets render time capture status
  116611. */
  116612. /**
  116613. * Enable or disable the render targets render time capture
  116614. */
  116615. captureRenderTargetsRenderTime: boolean;
  116616. /**
  116617. * Gets the perf counter used for particles render time
  116618. */
  116619. readonly particlesRenderTimeCounter: PerfCounter;
  116620. /**
  116621. * Gets the particles render time capture status
  116622. */
  116623. /**
  116624. * Enable or disable the particles render time capture
  116625. */
  116626. captureParticlesRenderTime: boolean;
  116627. /**
  116628. * Gets the perf counter used for sprites render time
  116629. */
  116630. readonly spritesRenderTimeCounter: PerfCounter;
  116631. /**
  116632. * Gets the sprites render time capture status
  116633. */
  116634. /**
  116635. * Enable or disable the sprites render time capture
  116636. */
  116637. captureSpritesRenderTime: boolean;
  116638. /**
  116639. * Gets the perf counter used for physics time
  116640. */
  116641. readonly physicsTimeCounter: PerfCounter;
  116642. /**
  116643. * Gets the physics time capture status
  116644. */
  116645. /**
  116646. * Enable or disable the physics time capture
  116647. */
  116648. capturePhysicsTime: boolean;
  116649. /**
  116650. * Gets the perf counter used for animations time
  116651. */
  116652. readonly animationsTimeCounter: PerfCounter;
  116653. /**
  116654. * Gets the animations time capture status
  116655. */
  116656. /**
  116657. * Enable or disable the animations time capture
  116658. */
  116659. captureAnimationsTime: boolean;
  116660. /**
  116661. * Gets the perf counter used for frame time capture
  116662. */
  116663. readonly frameTimeCounter: PerfCounter;
  116664. /**
  116665. * Gets the frame time capture status
  116666. */
  116667. /**
  116668. * Enable or disable the frame time capture
  116669. */
  116670. captureFrameTime: boolean;
  116671. /**
  116672. * Gets the perf counter used for inter-frames time capture
  116673. */
  116674. readonly interFrameTimeCounter: PerfCounter;
  116675. /**
  116676. * Gets the inter-frames time capture status
  116677. */
  116678. /**
  116679. * Enable or disable the inter-frames time capture
  116680. */
  116681. captureInterFrameTime: boolean;
  116682. /**
  116683. * Gets the perf counter used for render time capture
  116684. */
  116685. readonly renderTimeCounter: PerfCounter;
  116686. /**
  116687. * Gets the render time capture status
  116688. */
  116689. /**
  116690. * Enable or disable the render time capture
  116691. */
  116692. captureRenderTime: boolean;
  116693. /**
  116694. * Gets the perf counter used for camera render time capture
  116695. */
  116696. readonly cameraRenderTimeCounter: PerfCounter;
  116697. /**
  116698. * Gets the camera render time capture status
  116699. */
  116700. /**
  116701. * Enable or disable the camera render time capture
  116702. */
  116703. captureCameraRenderTime: boolean;
  116704. /**
  116705. * Gets the perf counter used for draw calls
  116706. */
  116707. readonly drawCallsCounter: PerfCounter;
  116708. /**
  116709. * Instantiates a new scene instrumentation.
  116710. * This class can be used to get instrumentation data from a Babylon engine
  116711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116712. * @param scene Defines the scene to instrument
  116713. */
  116714. constructor(
  116715. /**
  116716. * Defines the scene to instrument
  116717. */
  116718. scene: Scene);
  116719. /**
  116720. * Dispose and release associated resources.
  116721. */
  116722. dispose(): void;
  116723. }
  116724. }
  116725. declare module BABYLON {
  116726. /** @hidden */
  116727. export var glowMapGenerationPixelShader: {
  116728. name: string;
  116729. shader: string;
  116730. };
  116731. }
  116732. declare module BABYLON {
  116733. /** @hidden */
  116734. export var glowMapGenerationVertexShader: {
  116735. name: string;
  116736. shader: string;
  116737. };
  116738. }
  116739. declare module BABYLON {
  116740. /**
  116741. * Effect layer options. This helps customizing the behaviour
  116742. * of the effect layer.
  116743. */
  116744. export interface IEffectLayerOptions {
  116745. /**
  116746. * Multiplication factor apply to the canvas size to compute the render target size
  116747. * used to generated the objects (the smaller the faster).
  116748. */
  116749. mainTextureRatio: number;
  116750. /**
  116751. * Enforces a fixed size texture to ensure effect stability across devices.
  116752. */
  116753. mainTextureFixedSize?: number;
  116754. /**
  116755. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116756. */
  116757. alphaBlendingMode: number;
  116758. /**
  116759. * The camera attached to the layer.
  116760. */
  116761. camera: Nullable<Camera>;
  116762. /**
  116763. * The rendering group to draw the layer in.
  116764. */
  116765. renderingGroupId: number;
  116766. }
  116767. /**
  116768. * The effect layer Helps adding post process effect blended with the main pass.
  116769. *
  116770. * This can be for instance use to generate glow or higlight effects on the scene.
  116771. *
  116772. * The effect layer class can not be used directly and is intented to inherited from to be
  116773. * customized per effects.
  116774. */
  116775. export abstract class EffectLayer {
  116776. private _vertexBuffers;
  116777. private _indexBuffer;
  116778. private _cachedDefines;
  116779. private _effectLayerMapGenerationEffect;
  116780. private _effectLayerOptions;
  116781. private _mergeEffect;
  116782. protected _scene: Scene;
  116783. protected _engine: Engine;
  116784. protected _maxSize: number;
  116785. protected _mainTextureDesiredSize: ISize;
  116786. protected _mainTexture: RenderTargetTexture;
  116787. protected _shouldRender: boolean;
  116788. protected _postProcesses: PostProcess[];
  116789. protected _textures: BaseTexture[];
  116790. protected _emissiveTextureAndColor: {
  116791. texture: Nullable<BaseTexture>;
  116792. color: Color4;
  116793. };
  116794. /**
  116795. * The name of the layer
  116796. */
  116797. name: string;
  116798. /**
  116799. * The clear color of the texture used to generate the glow map.
  116800. */
  116801. neutralColor: Color4;
  116802. /**
  116803. * Specifies wether the highlight layer is enabled or not.
  116804. */
  116805. isEnabled: boolean;
  116806. /**
  116807. * Gets the camera attached to the layer.
  116808. */
  116809. readonly camera: Nullable<Camera>;
  116810. /**
  116811. * Gets the rendering group id the layer should render in.
  116812. */
  116813. renderingGroupId: number;
  116814. /**
  116815. * An event triggered when the effect layer has been disposed.
  116816. */
  116817. onDisposeObservable: Observable<EffectLayer>;
  116818. /**
  116819. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116820. */
  116821. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116822. /**
  116823. * An event triggered when the generated texture is being merged in the scene.
  116824. */
  116825. onBeforeComposeObservable: Observable<EffectLayer>;
  116826. /**
  116827. * An event triggered when the generated texture has been merged in the scene.
  116828. */
  116829. onAfterComposeObservable: Observable<EffectLayer>;
  116830. /**
  116831. * An event triggered when the efffect layer changes its size.
  116832. */
  116833. onSizeChangedObservable: Observable<EffectLayer>;
  116834. /** @hidden */
  116835. static _SceneComponentInitialization: (scene: Scene) => void;
  116836. /**
  116837. * Instantiates a new effect Layer and references it in the scene.
  116838. * @param name The name of the layer
  116839. * @param scene The scene to use the layer in
  116840. */
  116841. constructor(
  116842. /** The Friendly of the effect in the scene */
  116843. name: string, scene: Scene);
  116844. /**
  116845. * Get the effect name of the layer.
  116846. * @return The effect name
  116847. */
  116848. abstract getEffectName(): string;
  116849. /**
  116850. * Checks for the readiness of the element composing the layer.
  116851. * @param subMesh the mesh to check for
  116852. * @param useInstances specify wether or not to use instances to render the mesh
  116853. * @return true if ready otherwise, false
  116854. */
  116855. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116856. /**
  116857. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116858. * @returns true if the effect requires stencil during the main canvas render pass.
  116859. */
  116860. abstract needStencil(): boolean;
  116861. /**
  116862. * Create the merge effect. This is the shader use to blit the information back
  116863. * to the main canvas at the end of the scene rendering.
  116864. * @returns The effect containing the shader used to merge the effect on the main canvas
  116865. */
  116866. protected abstract _createMergeEffect(): Effect;
  116867. /**
  116868. * Creates the render target textures and post processes used in the effect layer.
  116869. */
  116870. protected abstract _createTextureAndPostProcesses(): void;
  116871. /**
  116872. * Implementation specific of rendering the generating effect on the main canvas.
  116873. * @param effect The effect used to render through
  116874. */
  116875. protected abstract _internalRender(effect: Effect): void;
  116876. /**
  116877. * Sets the required values for both the emissive texture and and the main color.
  116878. */
  116879. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116880. /**
  116881. * Free any resources and references associated to a mesh.
  116882. * Internal use
  116883. * @param mesh The mesh to free.
  116884. */
  116885. abstract _disposeMesh(mesh: Mesh): void;
  116886. /**
  116887. * Serializes this layer (Glow or Highlight for example)
  116888. * @returns a serialized layer object
  116889. */
  116890. abstract serialize?(): any;
  116891. /**
  116892. * Initializes the effect layer with the required options.
  116893. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116894. */
  116895. protected _init(options: Partial<IEffectLayerOptions>): void;
  116896. /**
  116897. * Generates the index buffer of the full screen quad blending to the main canvas.
  116898. */
  116899. private _generateIndexBuffer;
  116900. /**
  116901. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116902. */
  116903. private _generateVertexBuffer;
  116904. /**
  116905. * Sets the main texture desired size which is the closest power of two
  116906. * of the engine canvas size.
  116907. */
  116908. private _setMainTextureSize;
  116909. /**
  116910. * Creates the main texture for the effect layer.
  116911. */
  116912. protected _createMainTexture(): void;
  116913. /**
  116914. * Adds specific effects defines.
  116915. * @param defines The defines to add specifics to.
  116916. */
  116917. protected _addCustomEffectDefines(defines: string[]): void;
  116918. /**
  116919. * Checks for the readiness of the element composing the layer.
  116920. * @param subMesh the mesh to check for
  116921. * @param useInstances specify wether or not to use instances to render the mesh
  116922. * @param emissiveTexture the associated emissive texture used to generate the glow
  116923. * @return true if ready otherwise, false
  116924. */
  116925. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116926. /**
  116927. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116928. */
  116929. render(): void;
  116930. /**
  116931. * Determine if a given mesh will be used in the current effect.
  116932. * @param mesh mesh to test
  116933. * @returns true if the mesh will be used
  116934. */
  116935. hasMesh(mesh: AbstractMesh): boolean;
  116936. /**
  116937. * Returns true if the layer contains information to display, otherwise false.
  116938. * @returns true if the glow layer should be rendered
  116939. */
  116940. shouldRender(): boolean;
  116941. /**
  116942. * Returns true if the mesh should render, otherwise false.
  116943. * @param mesh The mesh to render
  116944. * @returns true if it should render otherwise false
  116945. */
  116946. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116947. /**
  116948. * Returns true if the mesh can be rendered, otherwise false.
  116949. * @param mesh The mesh to render
  116950. * @param material The material used on the mesh
  116951. * @returns true if it can be rendered otherwise false
  116952. */
  116953. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116954. /**
  116955. * Returns true if the mesh should render, otherwise false.
  116956. * @param mesh The mesh to render
  116957. * @returns true if it should render otherwise false
  116958. */
  116959. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116960. /**
  116961. * Renders the submesh passed in parameter to the generation map.
  116962. */
  116963. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116964. /**
  116965. * Rebuild the required buffers.
  116966. * @hidden Internal use only.
  116967. */
  116968. _rebuild(): void;
  116969. /**
  116970. * Dispose only the render target textures and post process.
  116971. */
  116972. private _disposeTextureAndPostProcesses;
  116973. /**
  116974. * Dispose the highlight layer and free resources.
  116975. */
  116976. dispose(): void;
  116977. /**
  116978. * Gets the class name of the effect layer
  116979. * @returns the string with the class name of the effect layer
  116980. */
  116981. getClassName(): string;
  116982. /**
  116983. * Creates an effect layer from parsed effect layer data
  116984. * @param parsedEffectLayer defines effect layer data
  116985. * @param scene defines the current scene
  116986. * @param rootUrl defines the root URL containing the effect layer information
  116987. * @returns a parsed effect Layer
  116988. */
  116989. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116990. }
  116991. }
  116992. declare module BABYLON {
  116993. interface AbstractScene {
  116994. /**
  116995. * The list of effect layers (highlights/glow) added to the scene
  116996. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116997. * @see http://doc.babylonjs.com/how_to/glow_layer
  116998. */
  116999. effectLayers: Array<EffectLayer>;
  117000. /**
  117001. * Removes the given effect layer from this scene.
  117002. * @param toRemove defines the effect layer to remove
  117003. * @returns the index of the removed effect layer
  117004. */
  117005. removeEffectLayer(toRemove: EffectLayer): number;
  117006. /**
  117007. * Adds the given effect layer to this scene
  117008. * @param newEffectLayer defines the effect layer to add
  117009. */
  117010. addEffectLayer(newEffectLayer: EffectLayer): void;
  117011. }
  117012. /**
  117013. * Defines the layer scene component responsible to manage any effect layers
  117014. * in a given scene.
  117015. */
  117016. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117017. /**
  117018. * The component name helpfull to identify the component in the list of scene components.
  117019. */
  117020. readonly name: string;
  117021. /**
  117022. * The scene the component belongs to.
  117023. */
  117024. scene: Scene;
  117025. private _engine;
  117026. private _renderEffects;
  117027. private _needStencil;
  117028. private _previousStencilState;
  117029. /**
  117030. * Creates a new instance of the component for the given scene
  117031. * @param scene Defines the scene to register the component in
  117032. */
  117033. constructor(scene: Scene);
  117034. /**
  117035. * Registers the component in a given scene
  117036. */
  117037. register(): void;
  117038. /**
  117039. * Rebuilds the elements related to this component in case of
  117040. * context lost for instance.
  117041. */
  117042. rebuild(): void;
  117043. /**
  117044. * Serializes the component data to the specified json object
  117045. * @param serializationObject The object to serialize to
  117046. */
  117047. serialize(serializationObject: any): void;
  117048. /**
  117049. * Adds all the elements from the container to the scene
  117050. * @param container the container holding the elements
  117051. */
  117052. addFromContainer(container: AbstractScene): void;
  117053. /**
  117054. * Removes all the elements in the container from the scene
  117055. * @param container contains the elements to remove
  117056. * @param dispose if the removed element should be disposed (default: false)
  117057. */
  117058. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117059. /**
  117060. * Disposes the component and the associated ressources.
  117061. */
  117062. dispose(): void;
  117063. private _isReadyForMesh;
  117064. private _renderMainTexture;
  117065. private _setStencil;
  117066. private _setStencilBack;
  117067. private _draw;
  117068. private _drawCamera;
  117069. private _drawRenderingGroup;
  117070. }
  117071. }
  117072. declare module BABYLON {
  117073. /** @hidden */
  117074. export var glowMapMergePixelShader: {
  117075. name: string;
  117076. shader: string;
  117077. };
  117078. }
  117079. declare module BABYLON {
  117080. /** @hidden */
  117081. export var glowMapMergeVertexShader: {
  117082. name: string;
  117083. shader: string;
  117084. };
  117085. }
  117086. declare module BABYLON {
  117087. interface AbstractScene {
  117088. /**
  117089. * Return a the first highlight layer of the scene with a given name.
  117090. * @param name The name of the highlight layer to look for.
  117091. * @return The highlight layer if found otherwise null.
  117092. */
  117093. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117094. }
  117095. /**
  117096. * Glow layer options. This helps customizing the behaviour
  117097. * of the glow layer.
  117098. */
  117099. export interface IGlowLayerOptions {
  117100. /**
  117101. * Multiplication factor apply to the canvas size to compute the render target size
  117102. * used to generated the glowing objects (the smaller the faster).
  117103. */
  117104. mainTextureRatio: number;
  117105. /**
  117106. * Enforces a fixed size texture to ensure resize independant blur.
  117107. */
  117108. mainTextureFixedSize?: number;
  117109. /**
  117110. * How big is the kernel of the blur texture.
  117111. */
  117112. blurKernelSize: number;
  117113. /**
  117114. * The camera attached to the layer.
  117115. */
  117116. camera: Nullable<Camera>;
  117117. /**
  117118. * Enable MSAA by chosing the number of samples.
  117119. */
  117120. mainTextureSamples?: number;
  117121. /**
  117122. * The rendering group to draw the layer in.
  117123. */
  117124. renderingGroupId: number;
  117125. }
  117126. /**
  117127. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117128. *
  117129. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117130. * glowy meshes to your scene.
  117131. *
  117132. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117133. */
  117134. export class GlowLayer extends EffectLayer {
  117135. /**
  117136. * Effect Name of the layer.
  117137. */
  117138. static readonly EffectName: string;
  117139. /**
  117140. * The default blur kernel size used for the glow.
  117141. */
  117142. static DefaultBlurKernelSize: number;
  117143. /**
  117144. * The default texture size ratio used for the glow.
  117145. */
  117146. static DefaultTextureRatio: number;
  117147. /**
  117148. * Sets the kernel size of the blur.
  117149. */
  117150. /**
  117151. * Gets the kernel size of the blur.
  117152. */
  117153. blurKernelSize: number;
  117154. /**
  117155. * Sets the glow intensity.
  117156. */
  117157. /**
  117158. * Gets the glow intensity.
  117159. */
  117160. intensity: number;
  117161. private _options;
  117162. private _intensity;
  117163. private _horizontalBlurPostprocess1;
  117164. private _verticalBlurPostprocess1;
  117165. private _horizontalBlurPostprocess2;
  117166. private _verticalBlurPostprocess2;
  117167. private _blurTexture1;
  117168. private _blurTexture2;
  117169. private _postProcesses1;
  117170. private _postProcesses2;
  117171. private _includedOnlyMeshes;
  117172. private _excludedMeshes;
  117173. /**
  117174. * Callback used to let the user override the color selection on a per mesh basis
  117175. */
  117176. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117177. /**
  117178. * Callback used to let the user override the texture selection on a per mesh basis
  117179. */
  117180. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117181. /**
  117182. * Instantiates a new glow Layer and references it to the scene.
  117183. * @param name The name of the layer
  117184. * @param scene The scene to use the layer in
  117185. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117186. */
  117187. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117188. /**
  117189. * Get the effect name of the layer.
  117190. * @return The effect name
  117191. */
  117192. getEffectName(): string;
  117193. /**
  117194. * Create the merge effect. This is the shader use to blit the information back
  117195. * to the main canvas at the end of the scene rendering.
  117196. */
  117197. protected _createMergeEffect(): Effect;
  117198. /**
  117199. * Creates the render target textures and post processes used in the glow layer.
  117200. */
  117201. protected _createTextureAndPostProcesses(): void;
  117202. /**
  117203. * Checks for the readiness of the element composing the layer.
  117204. * @param subMesh the mesh to check for
  117205. * @param useInstances specify wether or not to use instances to render the mesh
  117206. * @param emissiveTexture the associated emissive texture used to generate the glow
  117207. * @return true if ready otherwise, false
  117208. */
  117209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117210. /**
  117211. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117212. */
  117213. needStencil(): boolean;
  117214. /**
  117215. * Returns true if the mesh can be rendered, otherwise false.
  117216. * @param mesh The mesh to render
  117217. * @param material The material used on the mesh
  117218. * @returns true if it can be rendered otherwise false
  117219. */
  117220. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117221. /**
  117222. * Implementation specific of rendering the generating effect on the main canvas.
  117223. * @param effect The effect used to render through
  117224. */
  117225. protected _internalRender(effect: Effect): void;
  117226. /**
  117227. * Sets the required values for both the emissive texture and and the main color.
  117228. */
  117229. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117230. /**
  117231. * Returns true if the mesh should render, otherwise false.
  117232. * @param mesh The mesh to render
  117233. * @returns true if it should render otherwise false
  117234. */
  117235. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117236. /**
  117237. * Adds specific effects defines.
  117238. * @param defines The defines to add specifics to.
  117239. */
  117240. protected _addCustomEffectDefines(defines: string[]): void;
  117241. /**
  117242. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117243. * @param mesh The mesh to exclude from the glow layer
  117244. */
  117245. addExcludedMesh(mesh: Mesh): void;
  117246. /**
  117247. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117248. * @param mesh The mesh to remove
  117249. */
  117250. removeExcludedMesh(mesh: Mesh): void;
  117251. /**
  117252. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117253. * @param mesh The mesh to include in the glow layer
  117254. */
  117255. addIncludedOnlyMesh(mesh: Mesh): void;
  117256. /**
  117257. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117258. * @param mesh The mesh to remove
  117259. */
  117260. removeIncludedOnlyMesh(mesh: Mesh): void;
  117261. /**
  117262. * Determine if a given mesh will be used in the glow layer
  117263. * @param mesh The mesh to test
  117264. * @returns true if the mesh will be highlighted by the current glow layer
  117265. */
  117266. hasMesh(mesh: AbstractMesh): boolean;
  117267. /**
  117268. * Free any resources and references associated to a mesh.
  117269. * Internal use
  117270. * @param mesh The mesh to free.
  117271. * @hidden
  117272. */
  117273. _disposeMesh(mesh: Mesh): void;
  117274. /**
  117275. * Gets the class name of the effect layer
  117276. * @returns the string with the class name of the effect layer
  117277. */
  117278. getClassName(): string;
  117279. /**
  117280. * Serializes this glow layer
  117281. * @returns a serialized glow layer object
  117282. */
  117283. serialize(): any;
  117284. /**
  117285. * Creates a Glow Layer from parsed glow layer data
  117286. * @param parsedGlowLayer defines glow layer data
  117287. * @param scene defines the current scene
  117288. * @param rootUrl defines the root URL containing the glow layer information
  117289. * @returns a parsed Glow Layer
  117290. */
  117291. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117292. }
  117293. }
  117294. declare module BABYLON {
  117295. /** @hidden */
  117296. export var glowBlurPostProcessPixelShader: {
  117297. name: string;
  117298. shader: string;
  117299. };
  117300. }
  117301. declare module BABYLON {
  117302. interface AbstractScene {
  117303. /**
  117304. * Return a the first highlight layer of the scene with a given name.
  117305. * @param name The name of the highlight layer to look for.
  117306. * @return The highlight layer if found otherwise null.
  117307. */
  117308. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117309. }
  117310. /**
  117311. * Highlight layer options. This helps customizing the behaviour
  117312. * of the highlight layer.
  117313. */
  117314. export interface IHighlightLayerOptions {
  117315. /**
  117316. * Multiplication factor apply to the canvas size to compute the render target size
  117317. * used to generated the glowing objects (the smaller the faster).
  117318. */
  117319. mainTextureRatio: number;
  117320. /**
  117321. * Enforces a fixed size texture to ensure resize independant blur.
  117322. */
  117323. mainTextureFixedSize?: number;
  117324. /**
  117325. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117326. * of the picture to blur (the smaller the faster).
  117327. */
  117328. blurTextureSizeRatio: number;
  117329. /**
  117330. * How big in texel of the blur texture is the vertical blur.
  117331. */
  117332. blurVerticalSize: number;
  117333. /**
  117334. * How big in texel of the blur texture is the horizontal blur.
  117335. */
  117336. blurHorizontalSize: number;
  117337. /**
  117338. * Alpha blending mode used to apply the blur. Default is combine.
  117339. */
  117340. alphaBlendingMode: number;
  117341. /**
  117342. * The camera attached to the layer.
  117343. */
  117344. camera: Nullable<Camera>;
  117345. /**
  117346. * Should we display highlight as a solid stroke?
  117347. */
  117348. isStroke?: boolean;
  117349. /**
  117350. * The rendering group to draw the layer in.
  117351. */
  117352. renderingGroupId: number;
  117353. }
  117354. /**
  117355. * The highlight layer Helps adding a glow effect around a mesh.
  117356. *
  117357. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117358. * glowy meshes to your scene.
  117359. *
  117360. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117361. */
  117362. export class HighlightLayer extends EffectLayer {
  117363. name: string;
  117364. /**
  117365. * Effect Name of the highlight layer.
  117366. */
  117367. static readonly EffectName: string;
  117368. /**
  117369. * The neutral color used during the preparation of the glow effect.
  117370. * This is black by default as the blend operation is a blend operation.
  117371. */
  117372. static NeutralColor: Color4;
  117373. /**
  117374. * Stencil value used for glowing meshes.
  117375. */
  117376. static GlowingMeshStencilReference: number;
  117377. /**
  117378. * Stencil value used for the other meshes in the scene.
  117379. */
  117380. static NormalMeshStencilReference: number;
  117381. /**
  117382. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117383. */
  117384. innerGlow: boolean;
  117385. /**
  117386. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117387. */
  117388. outerGlow: boolean;
  117389. /**
  117390. * Specifies the horizontal size of the blur.
  117391. */
  117392. /**
  117393. * Gets the horizontal size of the blur.
  117394. */
  117395. blurHorizontalSize: number;
  117396. /**
  117397. * Specifies the vertical size of the blur.
  117398. */
  117399. /**
  117400. * Gets the vertical size of the blur.
  117401. */
  117402. blurVerticalSize: number;
  117403. /**
  117404. * An event triggered when the highlight layer is being blurred.
  117405. */
  117406. onBeforeBlurObservable: Observable<HighlightLayer>;
  117407. /**
  117408. * An event triggered when the highlight layer has been blurred.
  117409. */
  117410. onAfterBlurObservable: Observable<HighlightLayer>;
  117411. private _instanceGlowingMeshStencilReference;
  117412. private _options;
  117413. private _downSamplePostprocess;
  117414. private _horizontalBlurPostprocess;
  117415. private _verticalBlurPostprocess;
  117416. private _blurTexture;
  117417. private _meshes;
  117418. private _excludedMeshes;
  117419. /**
  117420. * Instantiates a new highlight Layer and references it to the scene..
  117421. * @param name The name of the layer
  117422. * @param scene The scene to use the layer in
  117423. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117424. */
  117425. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117426. /**
  117427. * Get the effect name of the layer.
  117428. * @return The effect name
  117429. */
  117430. getEffectName(): string;
  117431. /**
  117432. * Create the merge effect. This is the shader use to blit the information back
  117433. * to the main canvas at the end of the scene rendering.
  117434. */
  117435. protected _createMergeEffect(): Effect;
  117436. /**
  117437. * Creates the render target textures and post processes used in the highlight layer.
  117438. */
  117439. protected _createTextureAndPostProcesses(): void;
  117440. /**
  117441. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117442. */
  117443. needStencil(): boolean;
  117444. /**
  117445. * Checks for the readiness of the element composing the layer.
  117446. * @param subMesh the mesh to check for
  117447. * @param useInstances specify wether or not to use instances to render the mesh
  117448. * @param emissiveTexture the associated emissive texture used to generate the glow
  117449. * @return true if ready otherwise, false
  117450. */
  117451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117452. /**
  117453. * Implementation specific of rendering the generating effect on the main canvas.
  117454. * @param effect The effect used to render through
  117455. */
  117456. protected _internalRender(effect: Effect): void;
  117457. /**
  117458. * Returns true if the layer contains information to display, otherwise false.
  117459. */
  117460. shouldRender(): boolean;
  117461. /**
  117462. * Returns true if the mesh should render, otherwise false.
  117463. * @param mesh The mesh to render
  117464. * @returns true if it should render otherwise false
  117465. */
  117466. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117467. /**
  117468. * Sets the required values for both the emissive texture and and the main color.
  117469. */
  117470. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117471. /**
  117472. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117473. * @param mesh The mesh to exclude from the highlight layer
  117474. */
  117475. addExcludedMesh(mesh: Mesh): void;
  117476. /**
  117477. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117478. * @param mesh The mesh to highlight
  117479. */
  117480. removeExcludedMesh(mesh: Mesh): void;
  117481. /**
  117482. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117483. * @param mesh mesh to test
  117484. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117485. */
  117486. hasMesh(mesh: AbstractMesh): boolean;
  117487. /**
  117488. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117489. * @param mesh The mesh to highlight
  117490. * @param color The color of the highlight
  117491. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117492. */
  117493. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117494. /**
  117495. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117496. * @param mesh The mesh to highlight
  117497. */
  117498. removeMesh(mesh: Mesh): void;
  117499. /**
  117500. * Force the stencil to the normal expected value for none glowing parts
  117501. */
  117502. private _defaultStencilReference;
  117503. /**
  117504. * Free any resources and references associated to a mesh.
  117505. * Internal use
  117506. * @param mesh The mesh to free.
  117507. * @hidden
  117508. */
  117509. _disposeMesh(mesh: Mesh): void;
  117510. /**
  117511. * Dispose the highlight layer and free resources.
  117512. */
  117513. dispose(): void;
  117514. /**
  117515. * Gets the class name of the effect layer
  117516. * @returns the string with the class name of the effect layer
  117517. */
  117518. getClassName(): string;
  117519. /**
  117520. * Serializes this Highlight layer
  117521. * @returns a serialized Highlight layer object
  117522. */
  117523. serialize(): any;
  117524. /**
  117525. * Creates a Highlight layer from parsed Highlight layer data
  117526. * @param parsedHightlightLayer defines the Highlight layer data
  117527. * @param scene defines the current scene
  117528. * @param rootUrl defines the root URL containing the Highlight layer information
  117529. * @returns a parsed Highlight layer
  117530. */
  117531. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117532. }
  117533. }
  117534. declare module BABYLON {
  117535. interface AbstractScene {
  117536. /**
  117537. * The list of layers (background and foreground) of the scene
  117538. */
  117539. layers: Array<Layer>;
  117540. }
  117541. /**
  117542. * Defines the layer scene component responsible to manage any layers
  117543. * in a given scene.
  117544. */
  117545. export class LayerSceneComponent implements ISceneComponent {
  117546. /**
  117547. * The component name helpfull to identify the component in the list of scene components.
  117548. */
  117549. readonly name: string;
  117550. /**
  117551. * The scene the component belongs to.
  117552. */
  117553. scene: Scene;
  117554. private _engine;
  117555. /**
  117556. * Creates a new instance of the component for the given scene
  117557. * @param scene Defines the scene to register the component in
  117558. */
  117559. constructor(scene: Scene);
  117560. /**
  117561. * Registers the component in a given scene
  117562. */
  117563. register(): void;
  117564. /**
  117565. * Rebuilds the elements related to this component in case of
  117566. * context lost for instance.
  117567. */
  117568. rebuild(): void;
  117569. /**
  117570. * Disposes the component and the associated ressources.
  117571. */
  117572. dispose(): void;
  117573. private _draw;
  117574. private _drawCameraPredicate;
  117575. private _drawCameraBackground;
  117576. private _drawCameraForeground;
  117577. private _drawRenderTargetPredicate;
  117578. private _drawRenderTargetBackground;
  117579. private _drawRenderTargetForeground;
  117580. /**
  117581. * Adds all the elements from the container to the scene
  117582. * @param container the container holding the elements
  117583. */
  117584. addFromContainer(container: AbstractScene): void;
  117585. /**
  117586. * Removes all the elements in the container from the scene
  117587. * @param container contains the elements to remove
  117588. * @param dispose if the removed element should be disposed (default: false)
  117589. */
  117590. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /** @hidden */
  117595. export var layerPixelShader: {
  117596. name: string;
  117597. shader: string;
  117598. };
  117599. }
  117600. declare module BABYLON {
  117601. /** @hidden */
  117602. export var layerVertexShader: {
  117603. name: string;
  117604. shader: string;
  117605. };
  117606. }
  117607. declare module BABYLON {
  117608. /**
  117609. * This represents a full screen 2d layer.
  117610. * This can be useful to display a picture in the background of your scene for instance.
  117611. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117612. */
  117613. export class Layer {
  117614. /**
  117615. * Define the name of the layer.
  117616. */
  117617. name: string;
  117618. /**
  117619. * Define the texture the layer should display.
  117620. */
  117621. texture: Nullable<Texture>;
  117622. /**
  117623. * Is the layer in background or foreground.
  117624. */
  117625. isBackground: boolean;
  117626. /**
  117627. * Define the color of the layer (instead of texture).
  117628. */
  117629. color: Color4;
  117630. /**
  117631. * Define the scale of the layer in order to zoom in out of the texture.
  117632. */
  117633. scale: Vector2;
  117634. /**
  117635. * Define an offset for the layer in order to shift the texture.
  117636. */
  117637. offset: Vector2;
  117638. /**
  117639. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117640. */
  117641. alphaBlendingMode: number;
  117642. /**
  117643. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117644. * Alpha test will not mix with the background color in case of transparency.
  117645. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117646. */
  117647. alphaTest: boolean;
  117648. /**
  117649. * Define a mask to restrict the layer to only some of the scene cameras.
  117650. */
  117651. layerMask: number;
  117652. /**
  117653. * Define the list of render target the layer is visible into.
  117654. */
  117655. renderTargetTextures: RenderTargetTexture[];
  117656. /**
  117657. * Define if the layer is only used in renderTarget or if it also
  117658. * renders in the main frame buffer of the canvas.
  117659. */
  117660. renderOnlyInRenderTargetTextures: boolean;
  117661. private _scene;
  117662. private _vertexBuffers;
  117663. private _indexBuffer;
  117664. private _effect;
  117665. private _alphaTestEffect;
  117666. /**
  117667. * An event triggered when the layer is disposed.
  117668. */
  117669. onDisposeObservable: Observable<Layer>;
  117670. private _onDisposeObserver;
  117671. /**
  117672. * Back compatibility with callback before the onDisposeObservable existed.
  117673. * The set callback will be triggered when the layer has been disposed.
  117674. */
  117675. onDispose: () => void;
  117676. /**
  117677. * An event triggered before rendering the scene
  117678. */
  117679. onBeforeRenderObservable: Observable<Layer>;
  117680. private _onBeforeRenderObserver;
  117681. /**
  117682. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117683. * The set callback will be triggered just before rendering the layer.
  117684. */
  117685. onBeforeRender: () => void;
  117686. /**
  117687. * An event triggered after rendering the scene
  117688. */
  117689. onAfterRenderObservable: Observable<Layer>;
  117690. private _onAfterRenderObserver;
  117691. /**
  117692. * Back compatibility with callback before the onAfterRenderObservable existed.
  117693. * The set callback will be triggered just after rendering the layer.
  117694. */
  117695. onAfterRender: () => void;
  117696. /**
  117697. * Instantiates a new layer.
  117698. * This represents a full screen 2d layer.
  117699. * This can be useful to display a picture in the background of your scene for instance.
  117700. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117701. * @param name Define the name of the layer in the scene
  117702. * @param imgUrl Define the url of the texture to display in the layer
  117703. * @param scene Define the scene the layer belongs to
  117704. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117705. * @param color Defines a color for the layer
  117706. */
  117707. constructor(
  117708. /**
  117709. * Define the name of the layer.
  117710. */
  117711. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117712. private _createIndexBuffer;
  117713. /** @hidden */
  117714. _rebuild(): void;
  117715. /**
  117716. * Renders the layer in the scene.
  117717. */
  117718. render(): void;
  117719. /**
  117720. * Disposes and releases the associated ressources.
  117721. */
  117722. dispose(): void;
  117723. }
  117724. }
  117725. declare module BABYLON {
  117726. /** @hidden */
  117727. export var lensFlarePixelShader: {
  117728. name: string;
  117729. shader: string;
  117730. };
  117731. }
  117732. declare module BABYLON {
  117733. /** @hidden */
  117734. export var lensFlareVertexShader: {
  117735. name: string;
  117736. shader: string;
  117737. };
  117738. }
  117739. declare module BABYLON {
  117740. /**
  117741. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117742. * It is usually composed of several `lensFlare`.
  117743. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117744. */
  117745. export class LensFlareSystem {
  117746. /**
  117747. * Define the name of the lens flare system
  117748. */
  117749. name: string;
  117750. /**
  117751. * List of lens flares used in this system.
  117752. */
  117753. lensFlares: LensFlare[];
  117754. /**
  117755. * Define a limit from the border the lens flare can be visible.
  117756. */
  117757. borderLimit: number;
  117758. /**
  117759. * Define a viewport border we do not want to see the lens flare in.
  117760. */
  117761. viewportBorder: number;
  117762. /**
  117763. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117764. */
  117765. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117766. /**
  117767. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117768. */
  117769. layerMask: number;
  117770. /**
  117771. * Define the id of the lens flare system in the scene.
  117772. * (equal to name by default)
  117773. */
  117774. id: string;
  117775. private _scene;
  117776. private _emitter;
  117777. private _vertexBuffers;
  117778. private _indexBuffer;
  117779. private _effect;
  117780. private _positionX;
  117781. private _positionY;
  117782. private _isEnabled;
  117783. /** @hidden */
  117784. static _SceneComponentInitialization: (scene: Scene) => void;
  117785. /**
  117786. * Instantiates a lens flare system.
  117787. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117788. * It is usually composed of several `lensFlare`.
  117789. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117790. * @param name Define the name of the lens flare system in the scene
  117791. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117792. * @param scene Define the scene the lens flare system belongs to
  117793. */
  117794. constructor(
  117795. /**
  117796. * Define the name of the lens flare system
  117797. */
  117798. name: string, emitter: any, scene: Scene);
  117799. /**
  117800. * Define if the lens flare system is enabled.
  117801. */
  117802. isEnabled: boolean;
  117803. /**
  117804. * Get the scene the effects belongs to.
  117805. * @returns the scene holding the lens flare system
  117806. */
  117807. getScene(): Scene;
  117808. /**
  117809. * Get the emitter of the lens flare system.
  117810. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117811. * @returns the emitter of the lens flare system
  117812. */
  117813. getEmitter(): any;
  117814. /**
  117815. * Set the emitter of the lens flare system.
  117816. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117817. * @param newEmitter Define the new emitter of the system
  117818. */
  117819. setEmitter(newEmitter: any): void;
  117820. /**
  117821. * Get the lens flare system emitter position.
  117822. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117823. * @returns the position
  117824. */
  117825. getEmitterPosition(): Vector3;
  117826. /**
  117827. * @hidden
  117828. */
  117829. computeEffectivePosition(globalViewport: Viewport): boolean;
  117830. /** @hidden */
  117831. _isVisible(): boolean;
  117832. /**
  117833. * @hidden
  117834. */
  117835. render(): boolean;
  117836. /**
  117837. * Dispose and release the lens flare with its associated resources.
  117838. */
  117839. dispose(): void;
  117840. /**
  117841. * Parse a lens flare system from a JSON repressentation
  117842. * @param parsedLensFlareSystem Define the JSON to parse
  117843. * @param scene Define the scene the parsed system should be instantiated in
  117844. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117845. * @returns the parsed system
  117846. */
  117847. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117848. /**
  117849. * Serialize the current Lens Flare System into a JSON representation.
  117850. * @returns the serialized JSON
  117851. */
  117852. serialize(): any;
  117853. }
  117854. }
  117855. declare module BABYLON {
  117856. /**
  117857. * This represents one of the lens effect in a `lensFlareSystem`.
  117858. * It controls one of the indiviual texture used in the effect.
  117859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117860. */
  117861. export class LensFlare {
  117862. /**
  117863. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117864. */
  117865. size: number;
  117866. /**
  117867. * 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.
  117868. */
  117869. position: number;
  117870. /**
  117871. * Define the lens color.
  117872. */
  117873. color: Color3;
  117874. /**
  117875. * Define the lens texture.
  117876. */
  117877. texture: Nullable<Texture>;
  117878. /**
  117879. * Define the alpha mode to render this particular lens.
  117880. */
  117881. alphaMode: number;
  117882. private _system;
  117883. /**
  117884. * Creates a new Lens Flare.
  117885. * This represents one of the lens effect in a `lensFlareSystem`.
  117886. * It controls one of the indiviual texture used in the effect.
  117887. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117888. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117889. * @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.
  117890. * @param color Define the lens color
  117891. * @param imgUrl Define the lens texture url
  117892. * @param system Define the `lensFlareSystem` this flare is part of
  117893. * @returns The newly created Lens Flare
  117894. */
  117895. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117896. /**
  117897. * Instantiates a new Lens Flare.
  117898. * This represents one of the lens effect in a `lensFlareSystem`.
  117899. * It controls one of the indiviual texture used in the effect.
  117900. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117901. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117902. * @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.
  117903. * @param color Define the lens color
  117904. * @param imgUrl Define the lens texture url
  117905. * @param system Define the `lensFlareSystem` this flare is part of
  117906. */
  117907. constructor(
  117908. /**
  117909. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117910. */
  117911. size: number,
  117912. /**
  117913. * 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.
  117914. */
  117915. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117916. /**
  117917. * Dispose and release the lens flare with its associated resources.
  117918. */
  117919. dispose(): void;
  117920. }
  117921. }
  117922. declare module BABYLON {
  117923. interface AbstractScene {
  117924. /**
  117925. * The list of lens flare system added to the scene
  117926. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117927. */
  117928. lensFlareSystems: Array<LensFlareSystem>;
  117929. /**
  117930. * Removes the given lens flare system from this scene.
  117931. * @param toRemove The lens flare system to remove
  117932. * @returns The index of the removed lens flare system
  117933. */
  117934. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117935. /**
  117936. * Adds the given lens flare system to this scene
  117937. * @param newLensFlareSystem The lens flare system to add
  117938. */
  117939. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117940. /**
  117941. * Gets a lens flare system using its name
  117942. * @param name defines the name to look for
  117943. * @returns the lens flare system or null if not found
  117944. */
  117945. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117946. /**
  117947. * Gets a lens flare system using its id
  117948. * @param id defines the id to look for
  117949. * @returns the lens flare system or null if not found
  117950. */
  117951. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117952. }
  117953. /**
  117954. * Defines the lens flare scene component responsible to manage any lens flares
  117955. * in a given scene.
  117956. */
  117957. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117958. /**
  117959. * The component name helpfull to identify the component in the list of scene components.
  117960. */
  117961. readonly name: string;
  117962. /**
  117963. * The scene the component belongs to.
  117964. */
  117965. scene: Scene;
  117966. /**
  117967. * Creates a new instance of the component for the given scene
  117968. * @param scene Defines the scene to register the component in
  117969. */
  117970. constructor(scene: Scene);
  117971. /**
  117972. * Registers the component in a given scene
  117973. */
  117974. register(): void;
  117975. /**
  117976. * Rebuilds the elements related to this component in case of
  117977. * context lost for instance.
  117978. */
  117979. rebuild(): void;
  117980. /**
  117981. * Adds all the elements from the container to the scene
  117982. * @param container the container holding the elements
  117983. */
  117984. addFromContainer(container: AbstractScene): void;
  117985. /**
  117986. * Removes all the elements in the container from the scene
  117987. * @param container contains the elements to remove
  117988. * @param dispose if the removed element should be disposed (default: false)
  117989. */
  117990. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117991. /**
  117992. * Serializes the component data to the specified json object
  117993. * @param serializationObject The object to serialize to
  117994. */
  117995. serialize(serializationObject: any): void;
  117996. /**
  117997. * Disposes the component and the associated ressources.
  117998. */
  117999. dispose(): void;
  118000. private _draw;
  118001. }
  118002. }
  118003. declare module BABYLON {
  118004. /**
  118005. * Defines the shadow generator component responsible to manage any shadow generators
  118006. * in a given scene.
  118007. */
  118008. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118009. /**
  118010. * The component name helpfull to identify the component in the list of scene components.
  118011. */
  118012. readonly name: string;
  118013. /**
  118014. * The scene the component belongs to.
  118015. */
  118016. scene: Scene;
  118017. /**
  118018. * Creates a new instance of the component for the given scene
  118019. * @param scene Defines the scene to register the component in
  118020. */
  118021. constructor(scene: Scene);
  118022. /**
  118023. * Registers the component in a given scene
  118024. */
  118025. register(): void;
  118026. /**
  118027. * Rebuilds the elements related to this component in case of
  118028. * context lost for instance.
  118029. */
  118030. rebuild(): void;
  118031. /**
  118032. * Serializes the component data to the specified json object
  118033. * @param serializationObject The object to serialize to
  118034. */
  118035. serialize(serializationObject: any): void;
  118036. /**
  118037. * Adds all the elements from the container to the scene
  118038. * @param container the container holding the elements
  118039. */
  118040. addFromContainer(container: AbstractScene): void;
  118041. /**
  118042. * Removes all the elements in the container from the scene
  118043. * @param container contains the elements to remove
  118044. * @param dispose if the removed element should be disposed (default: false)
  118045. */
  118046. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118047. /**
  118048. * Rebuilds the elements related to this component in case of
  118049. * context lost for instance.
  118050. */
  118051. dispose(): void;
  118052. private _gatherRenderTargets;
  118053. }
  118054. }
  118055. declare module BABYLON {
  118056. /**
  118057. * A point light is a light defined by an unique point in world space.
  118058. * The light is emitted in every direction from this point.
  118059. * A good example of a point light is a standard light bulb.
  118060. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118061. */
  118062. export class PointLight extends ShadowLight {
  118063. private _shadowAngle;
  118064. /**
  118065. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118066. * This specifies what angle the shadow will use to be created.
  118067. *
  118068. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118069. */
  118070. /**
  118071. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118072. * This specifies what angle the shadow will use to be created.
  118073. *
  118074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118075. */
  118076. shadowAngle: number;
  118077. /**
  118078. * Gets the direction if it has been set.
  118079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118080. */
  118081. /**
  118082. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118083. */
  118084. direction: Vector3;
  118085. /**
  118086. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118087. * A PointLight emits the light in every direction.
  118088. * It can cast shadows.
  118089. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118090. * ```javascript
  118091. * var pointLight = new PointLight("pl", camera.position, scene);
  118092. * ```
  118093. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118094. * @param name The light friendly name
  118095. * @param position The position of the point light in the scene
  118096. * @param scene The scene the lights belongs to
  118097. */
  118098. constructor(name: string, position: Vector3, scene: Scene);
  118099. /**
  118100. * Returns the string "PointLight"
  118101. * @returns the class name
  118102. */
  118103. getClassName(): string;
  118104. /**
  118105. * Returns the integer 0.
  118106. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118107. */
  118108. getTypeID(): number;
  118109. /**
  118110. * Specifies wether or not the shadowmap should be a cube texture.
  118111. * @returns true if the shadowmap needs to be a cube texture.
  118112. */
  118113. needCube(): boolean;
  118114. /**
  118115. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118116. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118117. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118118. */
  118119. getShadowDirection(faceIndex?: number): Vector3;
  118120. /**
  118121. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118122. * - fov = PI / 2
  118123. * - aspect ratio : 1.0
  118124. * - z-near and far equal to the active camera minZ and maxZ.
  118125. * Returns the PointLight.
  118126. */
  118127. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118128. protected _buildUniformLayout(): void;
  118129. /**
  118130. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118131. * @param effect The effect to update
  118132. * @param lightIndex The index of the light in the effect to update
  118133. * @returns The point light
  118134. */
  118135. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118136. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118137. /**
  118138. * Prepares the list of defines specific to the light type.
  118139. * @param defines the list of defines
  118140. * @param lightIndex defines the index of the light for the effect
  118141. */
  118142. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118143. }
  118144. }
  118145. declare module BABYLON {
  118146. /**
  118147. * Header information of HDR texture files.
  118148. */
  118149. export interface HDRInfo {
  118150. /**
  118151. * The height of the texture in pixels.
  118152. */
  118153. height: number;
  118154. /**
  118155. * The width of the texture in pixels.
  118156. */
  118157. width: number;
  118158. /**
  118159. * The index of the beginning of the data in the binary file.
  118160. */
  118161. dataPosition: number;
  118162. }
  118163. /**
  118164. * This groups tools to convert HDR texture to native colors array.
  118165. */
  118166. export class HDRTools {
  118167. private static Ldexp;
  118168. private static Rgbe2float;
  118169. private static readStringLine;
  118170. /**
  118171. * Reads header information from an RGBE texture stored in a native array.
  118172. * More information on this format are available here:
  118173. * https://en.wikipedia.org/wiki/RGBE_image_format
  118174. *
  118175. * @param uint8array The binary file stored in native array.
  118176. * @return The header information.
  118177. */
  118178. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118179. /**
  118180. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118181. * This RGBE texture needs to store the information as a panorama.
  118182. *
  118183. * More information on this format are available here:
  118184. * https://en.wikipedia.org/wiki/RGBE_image_format
  118185. *
  118186. * @param buffer The binary file stored in an array buffer.
  118187. * @param size The expected size of the extracted cubemap.
  118188. * @return The Cube Map information.
  118189. */
  118190. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118191. /**
  118192. * Returns the pixels data extracted from an RGBE texture.
  118193. * This pixels will be stored left to right up to down in the R G B order in one array.
  118194. *
  118195. * More information on this format are available here:
  118196. * https://en.wikipedia.org/wiki/RGBE_image_format
  118197. *
  118198. * @param uint8array The binary file stored in an array buffer.
  118199. * @param hdrInfo The header information of the file.
  118200. * @return The pixels data in RGB right to left up to down order.
  118201. */
  118202. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118203. private static RGBE_ReadPixels_RLE;
  118204. }
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * This represents a texture coming from an HDR input.
  118209. *
  118210. * The only supported format is currently panorama picture stored in RGBE format.
  118211. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118212. */
  118213. export class HDRCubeTexture extends BaseTexture {
  118214. private static _facesMapping;
  118215. private _generateHarmonics;
  118216. private _noMipmap;
  118217. private _textureMatrix;
  118218. private _size;
  118219. private _onLoad;
  118220. private _onError;
  118221. /**
  118222. * The texture URL.
  118223. */
  118224. url: string;
  118225. /**
  118226. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118227. */
  118228. coordinatesMode: number;
  118229. protected _isBlocking: boolean;
  118230. /**
  118231. * Sets wether or not the texture is blocking during loading.
  118232. */
  118233. /**
  118234. * Gets wether or not the texture is blocking during loading.
  118235. */
  118236. isBlocking: boolean;
  118237. protected _rotationY: number;
  118238. /**
  118239. * Sets texture matrix rotation angle around Y axis in radians.
  118240. */
  118241. /**
  118242. * Gets texture matrix rotation angle around Y axis radians.
  118243. */
  118244. rotationY: number;
  118245. /**
  118246. * Gets or sets the center of the bounding box associated with the cube texture
  118247. * It must define where the camera used to render the texture was set
  118248. */
  118249. boundingBoxPosition: Vector3;
  118250. private _boundingBoxSize;
  118251. /**
  118252. * Gets or sets the size of the bounding box associated with the cube texture
  118253. * When defined, the cubemap will switch to local mode
  118254. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118255. * @example https://www.babylonjs-playground.com/#RNASML
  118256. */
  118257. boundingBoxSize: Vector3;
  118258. /**
  118259. * Instantiates an HDRTexture from the following parameters.
  118260. *
  118261. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118262. * @param scene The scene the texture will be used in
  118263. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118264. * @param noMipmap Forces to not generate the mipmap if true
  118265. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118266. * @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)
  118267. * @param reserved Reserved flag for internal use.
  118268. */
  118269. 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>);
  118270. /**
  118271. * Get the current class name of the texture useful for serialization or dynamic coding.
  118272. * @returns "HDRCubeTexture"
  118273. */
  118274. getClassName(): string;
  118275. /**
  118276. * Occurs when the file is raw .hdr file.
  118277. */
  118278. private loadTexture;
  118279. clone(): HDRCubeTexture;
  118280. delayLoad(): void;
  118281. /**
  118282. * Get the texture reflection matrix used to rotate/transform the reflection.
  118283. * @returns the reflection matrix
  118284. */
  118285. getReflectionTextureMatrix(): Matrix;
  118286. /**
  118287. * Set the texture reflection matrix used to rotate/transform the reflection.
  118288. * @param value Define the reflection matrix to set
  118289. */
  118290. setReflectionTextureMatrix(value: Matrix): void;
  118291. /**
  118292. * Parses a JSON representation of an HDR Texture in order to create the texture
  118293. * @param parsedTexture Define the JSON representation
  118294. * @param scene Define the scene the texture should be created in
  118295. * @param rootUrl Define the root url in case we need to load relative dependencies
  118296. * @returns the newly created texture after parsing
  118297. */
  118298. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118299. serialize(): any;
  118300. }
  118301. }
  118302. declare module BABYLON {
  118303. /**
  118304. * Class used to control physics engine
  118305. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118306. */
  118307. export class PhysicsEngine implements IPhysicsEngine {
  118308. private _physicsPlugin;
  118309. /**
  118310. * Global value used to control the smallest number supported by the simulation
  118311. */
  118312. static Epsilon: number;
  118313. private _impostors;
  118314. private _joints;
  118315. /**
  118316. * Gets the gravity vector used by the simulation
  118317. */
  118318. gravity: Vector3;
  118319. /**
  118320. * Factory used to create the default physics plugin.
  118321. * @returns The default physics plugin
  118322. */
  118323. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118324. /**
  118325. * Creates a new Physics Engine
  118326. * @param gravity defines the gravity vector used by the simulation
  118327. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118328. */
  118329. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118330. /**
  118331. * Sets the gravity vector used by the simulation
  118332. * @param gravity defines the gravity vector to use
  118333. */
  118334. setGravity(gravity: Vector3): void;
  118335. /**
  118336. * Set the time step of the physics engine.
  118337. * Default is 1/60.
  118338. * To slow it down, enter 1/600 for example.
  118339. * To speed it up, 1/30
  118340. * @param newTimeStep defines the new timestep to apply to this world.
  118341. */
  118342. setTimeStep(newTimeStep?: number): void;
  118343. /**
  118344. * Get the time step of the physics engine.
  118345. * @returns the current time step
  118346. */
  118347. getTimeStep(): number;
  118348. /**
  118349. * Release all resources
  118350. */
  118351. dispose(): void;
  118352. /**
  118353. * Gets the name of the current physics plugin
  118354. * @returns the name of the plugin
  118355. */
  118356. getPhysicsPluginName(): string;
  118357. /**
  118358. * Adding a new impostor for the impostor tracking.
  118359. * This will be done by the impostor itself.
  118360. * @param impostor the impostor to add
  118361. */
  118362. addImpostor(impostor: PhysicsImpostor): void;
  118363. /**
  118364. * Remove an impostor from the engine.
  118365. * This impostor and its mesh will not longer be updated by the physics engine.
  118366. * @param impostor the impostor to remove
  118367. */
  118368. removeImpostor(impostor: PhysicsImpostor): void;
  118369. /**
  118370. * Add a joint to the physics engine
  118371. * @param mainImpostor defines the main impostor to which the joint is added.
  118372. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118373. * @param joint defines the joint that will connect both impostors.
  118374. */
  118375. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118376. /**
  118377. * Removes a joint from the simulation
  118378. * @param mainImpostor defines the impostor used with the joint
  118379. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118380. * @param joint defines the joint to remove
  118381. */
  118382. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118383. /**
  118384. * Called by the scene. No need to call it.
  118385. * @param delta defines the timespam between frames
  118386. */
  118387. _step(delta: number): void;
  118388. /**
  118389. * Gets the current plugin used to run the simulation
  118390. * @returns current plugin
  118391. */
  118392. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118393. /**
  118394. * Gets the list of physic impostors
  118395. * @returns an array of PhysicsImpostor
  118396. */
  118397. getImpostors(): Array<PhysicsImpostor>;
  118398. /**
  118399. * Gets the impostor for a physics enabled object
  118400. * @param object defines the object impersonated by the impostor
  118401. * @returns the PhysicsImpostor or null if not found
  118402. */
  118403. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118404. /**
  118405. * Gets the impostor for a physics body object
  118406. * @param body defines physics body used by the impostor
  118407. * @returns the PhysicsImpostor or null if not found
  118408. */
  118409. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118410. /**
  118411. * Does a raycast in the physics world
  118412. * @param from when should the ray start?
  118413. * @param to when should the ray end?
  118414. * @returns PhysicsRaycastResult
  118415. */
  118416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118417. }
  118418. }
  118419. declare module BABYLON {
  118420. /** @hidden */
  118421. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118422. private _useDeltaForWorldStep;
  118423. world: any;
  118424. name: string;
  118425. private _physicsMaterials;
  118426. private _fixedTimeStep;
  118427. private _cannonRaycastResult;
  118428. private _raycastResult;
  118429. private _physicsBodysToRemoveAfterStep;
  118430. BJSCANNON: any;
  118431. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118432. setGravity(gravity: Vector3): void;
  118433. setTimeStep(timeStep: number): void;
  118434. getTimeStep(): number;
  118435. executeStep(delta: number): void;
  118436. private _removeMarkedPhysicsBodiesFromWorld;
  118437. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118438. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118440. private _processChildMeshes;
  118441. removePhysicsBody(impostor: PhysicsImpostor): void;
  118442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118443. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118444. private _addMaterial;
  118445. private _checkWithEpsilon;
  118446. private _createShape;
  118447. private _createHeightmap;
  118448. private _minus90X;
  118449. private _plus90X;
  118450. private _tmpPosition;
  118451. private _tmpDeltaPosition;
  118452. private _tmpUnityRotation;
  118453. private _updatePhysicsBodyTransformation;
  118454. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118455. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118456. isSupported(): boolean;
  118457. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118458. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118459. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118460. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118461. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118462. getBodyMass(impostor: PhysicsImpostor): number;
  118463. getBodyFriction(impostor: PhysicsImpostor): number;
  118464. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118465. getBodyRestitution(impostor: PhysicsImpostor): number;
  118466. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118467. sleepBody(impostor: PhysicsImpostor): void;
  118468. wakeUpBody(impostor: PhysicsImpostor): void;
  118469. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118470. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118471. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118472. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118473. getRadius(impostor: PhysicsImpostor): number;
  118474. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118475. dispose(): void;
  118476. private _extendNamespace;
  118477. /**
  118478. * Does a raycast in the physics world
  118479. * @param from when should the ray start?
  118480. * @param to when should the ray end?
  118481. * @returns PhysicsRaycastResult
  118482. */
  118483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118484. }
  118485. }
  118486. declare module BABYLON {
  118487. /** @hidden */
  118488. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118489. world: any;
  118490. name: string;
  118491. BJSOIMO: any;
  118492. private _raycastResult;
  118493. constructor(iterations?: number, oimoInjection?: any);
  118494. setGravity(gravity: Vector3): void;
  118495. setTimeStep(timeStep: number): void;
  118496. getTimeStep(): number;
  118497. private _tmpImpostorsArray;
  118498. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118499. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118500. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118501. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118502. private _tmpPositionVector;
  118503. removePhysicsBody(impostor: PhysicsImpostor): void;
  118504. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118505. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118506. isSupported(): boolean;
  118507. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118508. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118509. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118510. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118511. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118513. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118514. getBodyMass(impostor: PhysicsImpostor): number;
  118515. getBodyFriction(impostor: PhysicsImpostor): number;
  118516. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118517. getBodyRestitution(impostor: PhysicsImpostor): number;
  118518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118519. sleepBody(impostor: PhysicsImpostor): void;
  118520. wakeUpBody(impostor: PhysicsImpostor): void;
  118521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118522. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118523. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118524. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118525. getRadius(impostor: PhysicsImpostor): number;
  118526. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118527. dispose(): void;
  118528. /**
  118529. * Does a raycast in the physics world
  118530. * @param from when should the ray start?
  118531. * @param to when should the ray end?
  118532. * @returns PhysicsRaycastResult
  118533. */
  118534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118535. }
  118536. }
  118537. declare module BABYLON {
  118538. /**
  118539. * Class containing static functions to help procedurally build meshes
  118540. */
  118541. export class RibbonBuilder {
  118542. /**
  118543. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118544. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118545. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118546. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118547. * * 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
  118548. * * 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
  118549. * * 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
  118550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118553. * * 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
  118554. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118555. * * 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
  118556. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118558. * @param name defines the name of the mesh
  118559. * @param options defines the options used to create the mesh
  118560. * @param scene defines the hosting scene
  118561. * @returns the ribbon mesh
  118562. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118564. */
  118565. static CreateRibbon(name: string, options: {
  118566. pathArray: Vector3[][];
  118567. closeArray?: boolean;
  118568. closePath?: boolean;
  118569. offset?: number;
  118570. updatable?: boolean;
  118571. sideOrientation?: number;
  118572. frontUVs?: Vector4;
  118573. backUVs?: Vector4;
  118574. instance?: Mesh;
  118575. invertUV?: boolean;
  118576. uvs?: Vector2[];
  118577. colors?: Color4[];
  118578. }, scene?: Nullable<Scene>): Mesh;
  118579. }
  118580. }
  118581. declare module BABYLON {
  118582. /**
  118583. * Class containing static functions to help procedurally build meshes
  118584. */
  118585. export class ShapeBuilder {
  118586. /**
  118587. * 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.
  118588. * * 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.
  118589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118590. * * 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.
  118591. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118592. * * 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
  118593. * * 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
  118594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118599. * @param name defines the name of the mesh
  118600. * @param options defines the options used to create the mesh
  118601. * @param scene defines the hosting scene
  118602. * @returns the extruded shape mesh
  118603. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118605. */
  118606. static ExtrudeShape(name: string, options: {
  118607. shape: Vector3[];
  118608. path: Vector3[];
  118609. scale?: number;
  118610. rotation?: number;
  118611. cap?: number;
  118612. updatable?: boolean;
  118613. sideOrientation?: number;
  118614. frontUVs?: Vector4;
  118615. backUVs?: Vector4;
  118616. instance?: Mesh;
  118617. invertUV?: boolean;
  118618. }, scene?: Nullable<Scene>): Mesh;
  118619. /**
  118620. * Creates an custom extruded shape mesh.
  118621. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118622. * * 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.
  118623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118624. * * 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
  118625. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118626. * * 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
  118627. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118628. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118629. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118630. * * 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
  118631. * * 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
  118632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118637. * @param name defines the name of the mesh
  118638. * @param options defines the options used to create the mesh
  118639. * @param scene defines the hosting scene
  118640. * @returns the custom extruded shape mesh
  118641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118644. */
  118645. static ExtrudeShapeCustom(name: string, options: {
  118646. shape: Vector3[];
  118647. path: Vector3[];
  118648. scaleFunction?: any;
  118649. rotationFunction?: any;
  118650. ribbonCloseArray?: boolean;
  118651. ribbonClosePath?: boolean;
  118652. cap?: number;
  118653. updatable?: boolean;
  118654. sideOrientation?: number;
  118655. frontUVs?: Vector4;
  118656. backUVs?: Vector4;
  118657. instance?: Mesh;
  118658. invertUV?: boolean;
  118659. }, scene?: Nullable<Scene>): Mesh;
  118660. private static _ExtrudeShapeGeneric;
  118661. }
  118662. }
  118663. declare module BABYLON {
  118664. /**
  118665. * AmmoJS Physics plugin
  118666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118667. * @see https://github.com/kripken/ammo.js/
  118668. */
  118669. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118670. private _useDeltaForWorldStep;
  118671. /**
  118672. * Reference to the Ammo library
  118673. */
  118674. bjsAMMO: any;
  118675. /**
  118676. * Created ammoJS world which physics bodies are added to
  118677. */
  118678. world: any;
  118679. /**
  118680. * Name of the plugin
  118681. */
  118682. name: string;
  118683. private _timeStep;
  118684. private _fixedTimeStep;
  118685. private _maxSteps;
  118686. private _tmpQuaternion;
  118687. private _tmpAmmoTransform;
  118688. private _tmpAmmoQuaternion;
  118689. private _tmpAmmoConcreteContactResultCallback;
  118690. private _collisionConfiguration;
  118691. private _dispatcher;
  118692. private _overlappingPairCache;
  118693. private _solver;
  118694. private _softBodySolver;
  118695. private _tmpAmmoVectorA;
  118696. private _tmpAmmoVectorB;
  118697. private _tmpAmmoVectorC;
  118698. private _tmpAmmoVectorD;
  118699. private _tmpContactCallbackResult;
  118700. private _tmpAmmoVectorRCA;
  118701. private _tmpAmmoVectorRCB;
  118702. private _raycastResult;
  118703. private static readonly DISABLE_COLLISION_FLAG;
  118704. private static readonly KINEMATIC_FLAG;
  118705. private static readonly DISABLE_DEACTIVATION_FLAG;
  118706. /**
  118707. * Initializes the ammoJS plugin
  118708. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118709. * @param ammoInjection can be used to inject your own ammo reference
  118710. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118711. */
  118712. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118713. /**
  118714. * Sets the gravity of the physics world (m/(s^2))
  118715. * @param gravity Gravity to set
  118716. */
  118717. setGravity(gravity: Vector3): void;
  118718. /**
  118719. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118720. * @param timeStep timestep to use in seconds
  118721. */
  118722. setTimeStep(timeStep: number): void;
  118723. /**
  118724. * 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)
  118725. * @param fixedTimeStep fixedTimeStep to use in seconds
  118726. */
  118727. setFixedTimeStep(fixedTimeStep: number): void;
  118728. /**
  118729. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118730. * @param maxSteps the maximum number of steps by the physics engine per frame
  118731. */
  118732. setMaxSteps(maxSteps: number): void;
  118733. /**
  118734. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118735. * @returns the current timestep in seconds
  118736. */
  118737. getTimeStep(): number;
  118738. private _isImpostorInContact;
  118739. private _isImpostorPairInContact;
  118740. private _stepSimulation;
  118741. /**
  118742. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118743. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118744. * After the step the babylon meshes are set to the position of the physics imposters
  118745. * @param delta amount of time to step forward
  118746. * @param impostors array of imposters to update before/after the step
  118747. */
  118748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118749. /**
  118750. * Update babylon mesh to match physics world object
  118751. * @param impostor imposter to match
  118752. */
  118753. private _afterSoftStep;
  118754. /**
  118755. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118756. * @param impostor imposter to match
  118757. */
  118758. private _ropeStep;
  118759. /**
  118760. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118761. * @param impostor imposter to match
  118762. */
  118763. private _softbodyOrClothStep;
  118764. private _tmpVector;
  118765. private _tmpMatrix;
  118766. /**
  118767. * Applies an impulse on the imposter
  118768. * @param impostor imposter to apply impulse to
  118769. * @param force amount of force to be applied to the imposter
  118770. * @param contactPoint the location to apply the impulse on the imposter
  118771. */
  118772. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118773. /**
  118774. * Applies a force on the imposter
  118775. * @param impostor imposter to apply force
  118776. * @param force amount of force to be applied to the imposter
  118777. * @param contactPoint the location to apply the force on the imposter
  118778. */
  118779. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118780. /**
  118781. * Creates a physics body using the plugin
  118782. * @param impostor the imposter to create the physics body on
  118783. */
  118784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118785. /**
  118786. * Removes the physics body from the imposter and disposes of the body's memory
  118787. * @param impostor imposter to remove the physics body from
  118788. */
  118789. removePhysicsBody(impostor: PhysicsImpostor): void;
  118790. /**
  118791. * Generates a joint
  118792. * @param impostorJoint the imposter joint to create the joint with
  118793. */
  118794. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118795. /**
  118796. * Removes a joint
  118797. * @param impostorJoint the imposter joint to remove the joint from
  118798. */
  118799. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118800. private _addMeshVerts;
  118801. /**
  118802. * Initialise the soft body vertices to match its object's (mesh) vertices
  118803. * Softbody vertices (nodes) are in world space and to match this
  118804. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118805. * @param impostor to create the softbody for
  118806. */
  118807. private _softVertexData;
  118808. /**
  118809. * Create an impostor's soft body
  118810. * @param impostor to create the softbody for
  118811. */
  118812. private _createSoftbody;
  118813. /**
  118814. * Create cloth for an impostor
  118815. * @param impostor to create the softbody for
  118816. */
  118817. private _createCloth;
  118818. /**
  118819. * Create rope for an impostor
  118820. * @param impostor to create the softbody for
  118821. */
  118822. private _createRope;
  118823. private _addHullVerts;
  118824. private _createShape;
  118825. /**
  118826. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118827. * @param impostor imposter containing the physics body and babylon object
  118828. */
  118829. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118830. /**
  118831. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118832. * @param impostor imposter containing the physics body and babylon object
  118833. * @param newPosition new position
  118834. * @param newRotation new rotation
  118835. */
  118836. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118837. /**
  118838. * If this plugin is supported
  118839. * @returns true if its supported
  118840. */
  118841. isSupported(): boolean;
  118842. /**
  118843. * Sets the linear velocity of the physics body
  118844. * @param impostor imposter to set the velocity on
  118845. * @param velocity velocity to set
  118846. */
  118847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118848. /**
  118849. * Sets the angular velocity of the physics body
  118850. * @param impostor imposter to set the velocity on
  118851. * @param velocity velocity to set
  118852. */
  118853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118854. /**
  118855. * gets the linear velocity
  118856. * @param impostor imposter to get linear velocity from
  118857. * @returns linear velocity
  118858. */
  118859. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118860. /**
  118861. * gets the angular velocity
  118862. * @param impostor imposter to get angular velocity from
  118863. * @returns angular velocity
  118864. */
  118865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118866. /**
  118867. * Sets the mass of physics body
  118868. * @param impostor imposter to set the mass on
  118869. * @param mass mass to set
  118870. */
  118871. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118872. /**
  118873. * Gets the mass of the physics body
  118874. * @param impostor imposter to get the mass from
  118875. * @returns mass
  118876. */
  118877. getBodyMass(impostor: PhysicsImpostor): number;
  118878. /**
  118879. * Gets friction of the impostor
  118880. * @param impostor impostor to get friction from
  118881. * @returns friction value
  118882. */
  118883. getBodyFriction(impostor: PhysicsImpostor): number;
  118884. /**
  118885. * Sets friction of the impostor
  118886. * @param impostor impostor to set friction on
  118887. * @param friction friction value
  118888. */
  118889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118890. /**
  118891. * Gets restitution of the impostor
  118892. * @param impostor impostor to get restitution from
  118893. * @returns restitution value
  118894. */
  118895. getBodyRestitution(impostor: PhysicsImpostor): number;
  118896. /**
  118897. * Sets resitution of the impostor
  118898. * @param impostor impostor to set resitution on
  118899. * @param restitution resitution value
  118900. */
  118901. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118902. /**
  118903. * Gets pressure inside the impostor
  118904. * @param impostor impostor to get pressure from
  118905. * @returns pressure value
  118906. */
  118907. getBodyPressure(impostor: PhysicsImpostor): number;
  118908. /**
  118909. * Sets pressure inside a soft body impostor
  118910. * Cloth and rope must remain 0 pressure
  118911. * @param impostor impostor to set pressure on
  118912. * @param pressure pressure value
  118913. */
  118914. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118915. /**
  118916. * Gets stiffness of the impostor
  118917. * @param impostor impostor to get stiffness from
  118918. * @returns pressure value
  118919. */
  118920. getBodyStiffness(impostor: PhysicsImpostor): number;
  118921. /**
  118922. * Sets stiffness of the impostor
  118923. * @param impostor impostor to set stiffness on
  118924. * @param stiffness stiffness value from 0 to 1
  118925. */
  118926. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118927. /**
  118928. * Gets velocityIterations of the impostor
  118929. * @param impostor impostor to get velocity iterations from
  118930. * @returns velocityIterations value
  118931. */
  118932. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118933. /**
  118934. * Sets velocityIterations of the impostor
  118935. * @param impostor impostor to set velocity iterations on
  118936. * @param velocityIterations velocityIterations value
  118937. */
  118938. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118939. /**
  118940. * Gets positionIterations of the impostor
  118941. * @param impostor impostor to get position iterations from
  118942. * @returns positionIterations value
  118943. */
  118944. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118945. /**
  118946. * Sets positionIterations of the impostor
  118947. * @param impostor impostor to set position on
  118948. * @param positionIterations positionIterations value
  118949. */
  118950. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118951. /**
  118952. * Append an anchor to a cloth object
  118953. * @param impostor is the cloth impostor to add anchor to
  118954. * @param otherImpostor is the rigid impostor to anchor to
  118955. * @param width ratio across width from 0 to 1
  118956. * @param height ratio up height from 0 to 1
  118957. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118958. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118959. */
  118960. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118961. /**
  118962. * Append an hook to a rope object
  118963. * @param impostor is the rope impostor to add hook to
  118964. * @param otherImpostor is the rigid impostor to hook to
  118965. * @param length ratio along the rope from 0 to 1
  118966. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118967. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118968. */
  118969. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118970. /**
  118971. * Sleeps the physics body and stops it from being active
  118972. * @param impostor impostor to sleep
  118973. */
  118974. sleepBody(impostor: PhysicsImpostor): void;
  118975. /**
  118976. * Activates the physics body
  118977. * @param impostor impostor to activate
  118978. */
  118979. wakeUpBody(impostor: PhysicsImpostor): void;
  118980. /**
  118981. * Updates the distance parameters of the joint
  118982. * @param joint joint to update
  118983. * @param maxDistance maximum distance of the joint
  118984. * @param minDistance minimum distance of the joint
  118985. */
  118986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118987. /**
  118988. * Sets a motor on the joint
  118989. * @param joint joint to set motor on
  118990. * @param speed speed of the motor
  118991. * @param maxForce maximum force of the motor
  118992. * @param motorIndex index of the motor
  118993. */
  118994. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118995. /**
  118996. * Sets the motors limit
  118997. * @param joint joint to set limit on
  118998. * @param upperLimit upper limit
  118999. * @param lowerLimit lower limit
  119000. */
  119001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119002. /**
  119003. * Syncs the position and rotation of a mesh with the impostor
  119004. * @param mesh mesh to sync
  119005. * @param impostor impostor to update the mesh with
  119006. */
  119007. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119008. /**
  119009. * Gets the radius of the impostor
  119010. * @param impostor impostor to get radius from
  119011. * @returns the radius
  119012. */
  119013. getRadius(impostor: PhysicsImpostor): number;
  119014. /**
  119015. * Gets the box size of the impostor
  119016. * @param impostor impostor to get box size from
  119017. * @param result the resulting box size
  119018. */
  119019. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119020. /**
  119021. * Disposes of the impostor
  119022. */
  119023. dispose(): void;
  119024. /**
  119025. * Does a raycast in the physics world
  119026. * @param from when should the ray start?
  119027. * @param to when should the ray end?
  119028. * @returns PhysicsRaycastResult
  119029. */
  119030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119031. }
  119032. }
  119033. declare module BABYLON {
  119034. interface AbstractScene {
  119035. /**
  119036. * The list of reflection probes added to the scene
  119037. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119038. */
  119039. reflectionProbes: Array<ReflectionProbe>;
  119040. /**
  119041. * Removes the given reflection probe from this scene.
  119042. * @param toRemove The reflection probe to remove
  119043. * @returns The index of the removed reflection probe
  119044. */
  119045. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119046. /**
  119047. * Adds the given reflection probe to this scene.
  119048. * @param newReflectionProbe The reflection probe to add
  119049. */
  119050. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119051. }
  119052. /**
  119053. * Class used to generate realtime reflection / refraction cube textures
  119054. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119055. */
  119056. export class ReflectionProbe {
  119057. /** defines the name of the probe */
  119058. name: string;
  119059. private _scene;
  119060. private _renderTargetTexture;
  119061. private _projectionMatrix;
  119062. private _viewMatrix;
  119063. private _target;
  119064. private _add;
  119065. private _attachedMesh;
  119066. private _invertYAxis;
  119067. /** Gets or sets probe position (center of the cube map) */
  119068. position: Vector3;
  119069. /**
  119070. * Creates a new reflection probe
  119071. * @param name defines the name of the probe
  119072. * @param size defines the texture resolution (for each face)
  119073. * @param scene defines the hosting scene
  119074. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119075. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119076. */
  119077. constructor(
  119078. /** defines the name of the probe */
  119079. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119080. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119081. samples: number;
  119082. /** Gets or sets the refresh rate to use (on every frame by default) */
  119083. refreshRate: number;
  119084. /**
  119085. * Gets the hosting scene
  119086. * @returns a Scene
  119087. */
  119088. getScene(): Scene;
  119089. /** Gets the internal CubeTexture used to render to */
  119090. readonly cubeTexture: RenderTargetTexture;
  119091. /** Gets the list of meshes to render */
  119092. readonly renderList: Nullable<AbstractMesh[]>;
  119093. /**
  119094. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119095. * @param mesh defines the mesh to attach to
  119096. */
  119097. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119098. /**
  119099. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119100. * @param renderingGroupId The rendering group id corresponding to its index
  119101. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119102. */
  119103. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119104. /**
  119105. * Clean all associated resources
  119106. */
  119107. dispose(): void;
  119108. /**
  119109. * Converts the reflection probe information to a readable string for debug purpose.
  119110. * @param fullDetails Supports for multiple levels of logging within scene loading
  119111. * @returns the human readable reflection probe info
  119112. */
  119113. toString(fullDetails?: boolean): string;
  119114. /**
  119115. * Get the class name of the relfection probe.
  119116. * @returns "ReflectionProbe"
  119117. */
  119118. getClassName(): string;
  119119. /**
  119120. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119121. * @returns The JSON representation of the texture
  119122. */
  119123. serialize(): any;
  119124. /**
  119125. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119126. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119127. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119128. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119129. * @returns The parsed reflection probe if successful
  119130. */
  119131. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119132. }
  119133. }
  119134. declare module BABYLON {
  119135. /** @hidden */
  119136. export var _BabylonLoaderRegistered: boolean;
  119137. }
  119138. declare module BABYLON {
  119139. /**
  119140. * The Physically based simple base material of BJS.
  119141. *
  119142. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119143. * It is used as the base class for both the specGloss and metalRough conventions.
  119144. */
  119145. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119146. /**
  119147. * Number of Simultaneous lights allowed on the material.
  119148. */
  119149. maxSimultaneousLights: number;
  119150. /**
  119151. * If sets to true, disables all the lights affecting the material.
  119152. */
  119153. disableLighting: boolean;
  119154. /**
  119155. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119156. */
  119157. environmentTexture: BaseTexture;
  119158. /**
  119159. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119160. */
  119161. invertNormalMapX: boolean;
  119162. /**
  119163. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119164. */
  119165. invertNormalMapY: boolean;
  119166. /**
  119167. * Normal map used in the model.
  119168. */
  119169. normalTexture: BaseTexture;
  119170. /**
  119171. * Emissivie color used to self-illuminate the model.
  119172. */
  119173. emissiveColor: Color3;
  119174. /**
  119175. * Emissivie texture used to self-illuminate the model.
  119176. */
  119177. emissiveTexture: BaseTexture;
  119178. /**
  119179. * Occlusion Channel Strenght.
  119180. */
  119181. occlusionStrength: number;
  119182. /**
  119183. * Occlusion Texture of the material (adding extra occlusion effects).
  119184. */
  119185. occlusionTexture: BaseTexture;
  119186. /**
  119187. * Defines the alpha limits in alpha test mode.
  119188. */
  119189. alphaCutOff: number;
  119190. /**
  119191. * Gets the current double sided mode.
  119192. */
  119193. /**
  119194. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119195. */
  119196. doubleSided: boolean;
  119197. /**
  119198. * Stores the pre-calculated light information of a mesh in a texture.
  119199. */
  119200. lightmapTexture: BaseTexture;
  119201. /**
  119202. * If true, the light map contains occlusion information instead of lighting info.
  119203. */
  119204. useLightmapAsShadowmap: boolean;
  119205. /**
  119206. * Instantiates a new PBRMaterial instance.
  119207. *
  119208. * @param name The material name
  119209. * @param scene The scene the material will be use in.
  119210. */
  119211. constructor(name: string, scene: Scene);
  119212. getClassName(): string;
  119213. }
  119214. }
  119215. declare module BABYLON {
  119216. /**
  119217. * The PBR material of BJS following the metal roughness convention.
  119218. *
  119219. * This fits to the PBR convention in the GLTF definition:
  119220. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119221. */
  119222. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119223. /**
  119224. * The base color has two different interpretations depending on the value of metalness.
  119225. * When the material is a metal, the base color is the specific measured reflectance value
  119226. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119227. * of the material.
  119228. */
  119229. baseColor: Color3;
  119230. /**
  119231. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119232. * well as opacity information in the alpha channel.
  119233. */
  119234. baseTexture: BaseTexture;
  119235. /**
  119236. * Specifies the metallic scalar value of the material.
  119237. * Can also be used to scale the metalness values of the metallic texture.
  119238. */
  119239. metallic: number;
  119240. /**
  119241. * Specifies the roughness scalar value of the material.
  119242. * Can also be used to scale the roughness values of the metallic texture.
  119243. */
  119244. roughness: number;
  119245. /**
  119246. * Texture containing both the metallic value in the B channel and the
  119247. * roughness value in the G channel to keep better precision.
  119248. */
  119249. metallicRoughnessTexture: BaseTexture;
  119250. /**
  119251. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119252. *
  119253. * @param name The material name
  119254. * @param scene The scene the material will be use in.
  119255. */
  119256. constructor(name: string, scene: Scene);
  119257. /**
  119258. * Return the currrent class name of the material.
  119259. */
  119260. getClassName(): string;
  119261. /**
  119262. * Makes a duplicate of the current material.
  119263. * @param name - name to use for the new material.
  119264. */
  119265. clone(name: string): PBRMetallicRoughnessMaterial;
  119266. /**
  119267. * Serialize the material to a parsable JSON object.
  119268. */
  119269. serialize(): any;
  119270. /**
  119271. * Parses a JSON object correponding to the serialize function.
  119272. */
  119273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119274. }
  119275. }
  119276. declare module BABYLON {
  119277. /**
  119278. * The PBR material of BJS following the specular glossiness convention.
  119279. *
  119280. * This fits to the PBR convention in the GLTF definition:
  119281. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119282. */
  119283. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119284. /**
  119285. * Specifies the diffuse color of the material.
  119286. */
  119287. diffuseColor: Color3;
  119288. /**
  119289. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119290. * channel.
  119291. */
  119292. diffuseTexture: BaseTexture;
  119293. /**
  119294. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119295. */
  119296. specularColor: Color3;
  119297. /**
  119298. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119299. */
  119300. glossiness: number;
  119301. /**
  119302. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119303. */
  119304. specularGlossinessTexture: BaseTexture;
  119305. /**
  119306. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119307. *
  119308. * @param name The material name
  119309. * @param scene The scene the material will be use in.
  119310. */
  119311. constructor(name: string, scene: Scene);
  119312. /**
  119313. * Return the currrent class name of the material.
  119314. */
  119315. getClassName(): string;
  119316. /**
  119317. * Makes a duplicate of the current material.
  119318. * @param name - name to use for the new material.
  119319. */
  119320. clone(name: string): PBRSpecularGlossinessMaterial;
  119321. /**
  119322. * Serialize the material to a parsable JSON object.
  119323. */
  119324. serialize(): any;
  119325. /**
  119326. * Parses a JSON object correponding to the serialize function.
  119327. */
  119328. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119329. }
  119330. }
  119331. declare module BABYLON {
  119332. /**
  119333. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119334. * It can help converting any input color in a desired output one. This can then be used to create effects
  119335. * from sepia, black and white to sixties or futuristic rendering...
  119336. *
  119337. * The only supported format is currently 3dl.
  119338. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119339. */
  119340. export class ColorGradingTexture extends BaseTexture {
  119341. /**
  119342. * The current texture matrix. (will always be identity in color grading texture)
  119343. */
  119344. private _textureMatrix;
  119345. /**
  119346. * The texture URL.
  119347. */
  119348. url: string;
  119349. /**
  119350. * Empty line regex stored for GC.
  119351. */
  119352. private static _noneEmptyLineRegex;
  119353. private _engine;
  119354. /**
  119355. * Instantiates a ColorGradingTexture from the following parameters.
  119356. *
  119357. * @param url The location of the color gradind data (currently only supporting 3dl)
  119358. * @param scene The scene the texture will be used in
  119359. */
  119360. constructor(url: string, scene: Scene);
  119361. /**
  119362. * Returns the texture matrix used in most of the material.
  119363. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119364. */
  119365. getTextureMatrix(): Matrix;
  119366. /**
  119367. * Occurs when the file being loaded is a .3dl LUT file.
  119368. */
  119369. private load3dlTexture;
  119370. /**
  119371. * Starts the loading process of the texture.
  119372. */
  119373. private loadTexture;
  119374. /**
  119375. * Clones the color gradind texture.
  119376. */
  119377. clone(): ColorGradingTexture;
  119378. /**
  119379. * Called during delayed load for textures.
  119380. */
  119381. delayLoad(): void;
  119382. /**
  119383. * Parses a color grading texture serialized by Babylon.
  119384. * @param parsedTexture The texture information being parsedTexture
  119385. * @param scene The scene to load the texture in
  119386. * @param rootUrl The root url of the data assets to load
  119387. * @return A color gradind texture
  119388. */
  119389. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119390. /**
  119391. * Serializes the LUT texture to json format.
  119392. */
  119393. serialize(): any;
  119394. }
  119395. }
  119396. declare module BABYLON {
  119397. /**
  119398. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119399. */
  119400. export class EquiRectangularCubeTexture extends BaseTexture {
  119401. /** The six faces of the cube. */
  119402. private static _FacesMapping;
  119403. private _noMipmap;
  119404. private _onLoad;
  119405. private _onError;
  119406. /** The size of the cubemap. */
  119407. private _size;
  119408. /** The buffer of the image. */
  119409. private _buffer;
  119410. /** The width of the input image. */
  119411. private _width;
  119412. /** The height of the input image. */
  119413. private _height;
  119414. /** The URL to the image. */
  119415. url: string;
  119416. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119417. coordinatesMode: number;
  119418. /**
  119419. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119420. * @param url The location of the image
  119421. * @param scene The scene the texture will be used in
  119422. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119423. * @param noMipmap Forces to not generate the mipmap if true
  119424. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119425. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119426. * @param onLoad — defines a callback called when texture is loaded
  119427. * @param onError — defines a callback called if there is an error
  119428. */
  119429. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119430. /**
  119431. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119432. */
  119433. private loadImage;
  119434. /**
  119435. * Convert the image buffer into a cubemap and create a CubeTexture.
  119436. */
  119437. private loadTexture;
  119438. /**
  119439. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119440. * @param buffer The ArrayBuffer that should be converted.
  119441. * @returns The buffer as Float32Array.
  119442. */
  119443. private getFloat32ArrayFromArrayBuffer;
  119444. /**
  119445. * Get the current class name of the texture useful for serialization or dynamic coding.
  119446. * @returns "EquiRectangularCubeTexture"
  119447. */
  119448. getClassName(): string;
  119449. /**
  119450. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119451. * @returns A clone of the current EquiRectangularCubeTexture.
  119452. */
  119453. clone(): EquiRectangularCubeTexture;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Based on jsTGALoader - Javascript loader for TGA file
  119459. * By Vincent Thibault
  119460. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119461. */
  119462. export class TGATools {
  119463. private static _TYPE_INDEXED;
  119464. private static _TYPE_RGB;
  119465. private static _TYPE_GREY;
  119466. private static _TYPE_RLE_INDEXED;
  119467. private static _TYPE_RLE_RGB;
  119468. private static _TYPE_RLE_GREY;
  119469. private static _ORIGIN_MASK;
  119470. private static _ORIGIN_SHIFT;
  119471. private static _ORIGIN_BL;
  119472. private static _ORIGIN_BR;
  119473. private static _ORIGIN_UL;
  119474. private static _ORIGIN_UR;
  119475. /**
  119476. * Gets the header of a TGA file
  119477. * @param data defines the TGA data
  119478. * @returns the header
  119479. */
  119480. static GetTGAHeader(data: Uint8Array): any;
  119481. /**
  119482. * Uploads TGA content to a Babylon Texture
  119483. * @hidden
  119484. */
  119485. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119486. /** @hidden */
  119487. 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;
  119488. /** @hidden */
  119489. 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;
  119490. /** @hidden */
  119491. 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;
  119492. /** @hidden */
  119493. 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;
  119494. /** @hidden */
  119495. 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;
  119496. /** @hidden */
  119497. 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;
  119498. }
  119499. }
  119500. declare module BABYLON {
  119501. /**
  119502. * Implementation of the TGA Texture Loader.
  119503. * @hidden
  119504. */
  119505. export class _TGATextureLoader implements IInternalTextureLoader {
  119506. /**
  119507. * Defines wether the loader supports cascade loading the different faces.
  119508. */
  119509. readonly supportCascades: boolean;
  119510. /**
  119511. * This returns if the loader support the current file information.
  119512. * @param extension defines the file extension of the file being loaded
  119513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119514. * @param fallback defines the fallback internal texture if any
  119515. * @param isBase64 defines whether the texture is encoded as a base64
  119516. * @param isBuffer defines whether the texture data are stored as a buffer
  119517. * @returns true if the loader can load the specified file
  119518. */
  119519. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119520. /**
  119521. * Transform the url before loading if required.
  119522. * @param rootUrl the url of the texture
  119523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119524. * @returns the transformed texture
  119525. */
  119526. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119527. /**
  119528. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119529. * @param rootUrl the url of the texture
  119530. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119531. * @returns the fallback texture
  119532. */
  119533. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119534. /**
  119535. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119536. * @param data contains the texture data
  119537. * @param texture defines the BabylonJS internal texture
  119538. * @param createPolynomials will be true if polynomials have been requested
  119539. * @param onLoad defines the callback to trigger once the texture is ready
  119540. * @param onError defines the callback to trigger in case of error
  119541. */
  119542. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119543. /**
  119544. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119545. * @param data contains the texture data
  119546. * @param texture defines the BabylonJS internal texture
  119547. * @param callback defines the method to call once ready to upload
  119548. */
  119549. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119550. }
  119551. }
  119552. declare module BABYLON {
  119553. /**
  119554. * Info about the .basis files
  119555. */
  119556. class BasisFileInfo {
  119557. /**
  119558. * If the file has alpha
  119559. */
  119560. hasAlpha: boolean;
  119561. /**
  119562. * Info about each image of the basis file
  119563. */
  119564. images: Array<{
  119565. levels: Array<{
  119566. width: number;
  119567. height: number;
  119568. transcodedPixels: ArrayBufferView;
  119569. }>;
  119570. }>;
  119571. }
  119572. /**
  119573. * Result of transcoding a basis file
  119574. */
  119575. class TranscodeResult {
  119576. /**
  119577. * Info about the .basis file
  119578. */
  119579. fileInfo: BasisFileInfo;
  119580. /**
  119581. * Format to use when loading the file
  119582. */
  119583. format: number;
  119584. }
  119585. /**
  119586. * Configuration options for the Basis transcoder
  119587. */
  119588. export class BasisTranscodeConfiguration {
  119589. /**
  119590. * Supported compression formats used to determine the supported output format of the transcoder
  119591. */
  119592. supportedCompressionFormats?: {
  119593. /**
  119594. * etc1 compression format
  119595. */
  119596. etc1?: boolean;
  119597. /**
  119598. * s3tc compression format
  119599. */
  119600. s3tc?: boolean;
  119601. /**
  119602. * pvrtc compression format
  119603. */
  119604. pvrtc?: boolean;
  119605. /**
  119606. * etc2 compression format
  119607. */
  119608. etc2?: boolean;
  119609. };
  119610. /**
  119611. * If mipmap levels should be loaded for transcoded images (Default: true)
  119612. */
  119613. loadMipmapLevels?: boolean;
  119614. /**
  119615. * Index of a single image to load (Default: all images)
  119616. */
  119617. loadSingleImage?: number;
  119618. }
  119619. /**
  119620. * Used to load .Basis files
  119621. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119622. */
  119623. export class BasisTools {
  119624. private static _IgnoreSupportedFormats;
  119625. /**
  119626. * URL to use when loading the basis transcoder
  119627. */
  119628. static JSModuleURL: string;
  119629. /**
  119630. * URL to use when loading the wasm module for the transcoder
  119631. */
  119632. static WasmModuleURL: string;
  119633. /**
  119634. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119635. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119636. * @returns internal format corresponding to the Basis format
  119637. */
  119638. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119639. private static _WorkerPromise;
  119640. private static _Worker;
  119641. private static _actionId;
  119642. private static _CreateWorkerAsync;
  119643. /**
  119644. * Transcodes a loaded image file to compressed pixel data
  119645. * @param imageData image data to transcode
  119646. * @param config configuration options for the transcoding
  119647. * @returns a promise resulting in the transcoded image
  119648. */
  119649. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119650. /**
  119651. * Loads a texture from the transcode result
  119652. * @param texture texture load to
  119653. * @param transcodeResult the result of transcoding the basis file to load from
  119654. */
  119655. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119656. }
  119657. }
  119658. declare module BABYLON {
  119659. /**
  119660. * Loader for .basis file format
  119661. */
  119662. export class _BasisTextureLoader implements IInternalTextureLoader {
  119663. /**
  119664. * Defines whether the loader supports cascade loading the different faces.
  119665. */
  119666. readonly supportCascades: boolean;
  119667. /**
  119668. * This returns if the loader support the current file information.
  119669. * @param extension defines the file extension of the file being loaded
  119670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119671. * @param fallback defines the fallback internal texture if any
  119672. * @param isBase64 defines whether the texture is encoded as a base64
  119673. * @param isBuffer defines whether the texture data are stored as a buffer
  119674. * @returns true if the loader can load the specified file
  119675. */
  119676. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119677. /**
  119678. * Transform the url before loading if required.
  119679. * @param rootUrl the url of the texture
  119680. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119681. * @returns the transformed texture
  119682. */
  119683. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119684. /**
  119685. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119686. * @param rootUrl the url of the texture
  119687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119688. * @returns the fallback texture
  119689. */
  119690. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119691. /**
  119692. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119693. * @param data contains the texture data
  119694. * @param texture defines the BabylonJS internal texture
  119695. * @param createPolynomials will be true if polynomials have been requested
  119696. * @param onLoad defines the callback to trigger once the texture is ready
  119697. * @param onError defines the callback to trigger in case of error
  119698. */
  119699. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119700. /**
  119701. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119702. * @param data contains the texture data
  119703. * @param texture defines the BabylonJS internal texture
  119704. * @param callback defines the method to call once ready to upload
  119705. */
  119706. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119707. }
  119708. }
  119709. declare module BABYLON {
  119710. /**
  119711. * 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.
  119712. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119713. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119714. */
  119715. export class CustomProceduralTexture extends ProceduralTexture {
  119716. private _animate;
  119717. private _time;
  119718. private _config;
  119719. private _texturePath;
  119720. /**
  119721. * Instantiates a new Custom Procedural Texture.
  119722. * 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.
  119723. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119724. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119725. * @param name Define the name of the texture
  119726. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119727. * @param size Define the size of the texture to create
  119728. * @param scene Define the scene the texture belongs to
  119729. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119730. * @param generateMipMaps Define if the texture should creates mip maps or not
  119731. */
  119732. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119733. private _loadJson;
  119734. /**
  119735. * Is the texture ready to be used ? (rendered at least once)
  119736. * @returns true if ready, otherwise, false.
  119737. */
  119738. isReady(): boolean;
  119739. /**
  119740. * Render the texture to its associated render target.
  119741. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119742. */
  119743. render(useCameraPostProcess?: boolean): void;
  119744. /**
  119745. * Update the list of dependant textures samplers in the shader.
  119746. */
  119747. updateTextures(): void;
  119748. /**
  119749. * Update the uniform values of the procedural texture in the shader.
  119750. */
  119751. updateShaderUniforms(): void;
  119752. /**
  119753. * Define if the texture animates or not.
  119754. */
  119755. animate: boolean;
  119756. }
  119757. }
  119758. declare module BABYLON {
  119759. /** @hidden */
  119760. export var noisePixelShader: {
  119761. name: string;
  119762. shader: string;
  119763. };
  119764. }
  119765. declare module BABYLON {
  119766. /**
  119767. * Class used to generate noise procedural textures
  119768. */
  119769. export class NoiseProceduralTexture extends ProceduralTexture {
  119770. private _time;
  119771. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119772. brightness: number;
  119773. /** Defines the number of octaves to process */
  119774. octaves: number;
  119775. /** Defines the level of persistence (0.8 by default) */
  119776. persistence: number;
  119777. /** Gets or sets animation speed factor (default is 1) */
  119778. animationSpeedFactor: number;
  119779. /**
  119780. * Creates a new NoiseProceduralTexture
  119781. * @param name defines the name fo the texture
  119782. * @param size defines the size of the texture (default is 256)
  119783. * @param scene defines the hosting scene
  119784. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119785. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119786. */
  119787. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119788. private _updateShaderUniforms;
  119789. protected _getDefines(): string;
  119790. /** Generate the current state of the procedural texture */
  119791. render(useCameraPostProcess?: boolean): void;
  119792. /**
  119793. * Serializes this noise procedural texture
  119794. * @returns a serialized noise procedural texture object
  119795. */
  119796. serialize(): any;
  119797. /**
  119798. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119799. * @param parsedTexture defines parsed texture data
  119800. * @param scene defines the current scene
  119801. * @param rootUrl defines the root URL containing noise procedural texture information
  119802. * @returns a parsed NoiseProceduralTexture
  119803. */
  119804. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119805. }
  119806. }
  119807. declare module BABYLON {
  119808. /**
  119809. * Raw cube texture where the raw buffers are passed in
  119810. */
  119811. export class RawCubeTexture extends CubeTexture {
  119812. /**
  119813. * Creates a cube texture where the raw buffers are passed in.
  119814. * @param scene defines the scene the texture is attached to
  119815. * @param data defines the array of data to use to create each face
  119816. * @param size defines the size of the textures
  119817. * @param format defines the format of the data
  119818. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119819. * @param generateMipMaps defines if the engine should generate the mip levels
  119820. * @param invertY defines if data must be stored with Y axis inverted
  119821. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119822. * @param compression defines the compression used (null by default)
  119823. */
  119824. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119825. /**
  119826. * Updates the raw cube texture.
  119827. * @param data defines the data to store
  119828. * @param format defines the data format
  119829. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119830. * @param invertY defines if data must be stored with Y axis inverted
  119831. * @param compression defines the compression used (null by default)
  119832. * @param level defines which level of the texture to update
  119833. */
  119834. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119835. /**
  119836. * Updates a raw cube texture with RGBD encoded data.
  119837. * @param data defines the array of data [mipmap][face] to use to create each face
  119838. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119839. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119840. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119841. * @returns a promsie that resolves when the operation is complete
  119842. */
  119843. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119844. /**
  119845. * Clones the raw cube texture.
  119846. * @return a new cube texture
  119847. */
  119848. clone(): CubeTexture;
  119849. /** @hidden */
  119850. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119851. }
  119852. }
  119853. declare module BABYLON {
  119854. /**
  119855. * Class used to store 3D textures containing user data
  119856. */
  119857. export class RawTexture3D extends Texture {
  119858. /** Gets or sets the texture format to use */
  119859. format: number;
  119860. private _engine;
  119861. /**
  119862. * Create a new RawTexture3D
  119863. * @param data defines the data of the texture
  119864. * @param width defines the width of the texture
  119865. * @param height defines the height of the texture
  119866. * @param depth defines the depth of the texture
  119867. * @param format defines the texture format to use
  119868. * @param scene defines the hosting scene
  119869. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119870. * @param invertY defines if texture must be stored with Y axis inverted
  119871. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119873. */
  119874. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119875. /** Gets or sets the texture format to use */
  119876. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119877. /**
  119878. * Update the texture with new data
  119879. * @param data defines the data to store in the texture
  119880. */
  119881. update(data: ArrayBufferView): void;
  119882. }
  119883. }
  119884. declare module BABYLON {
  119885. /**
  119886. * Creates a refraction texture used by refraction channel of the standard material.
  119887. * It is like a mirror but to see through a material.
  119888. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119889. */
  119890. export class RefractionTexture extends RenderTargetTexture {
  119891. /**
  119892. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119893. * 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.
  119894. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119895. */
  119896. refractionPlane: Plane;
  119897. /**
  119898. * Define how deep under the surface we should see.
  119899. */
  119900. depth: number;
  119901. /**
  119902. * Creates a refraction texture used by refraction channel of the standard material.
  119903. * It is like a mirror but to see through a material.
  119904. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119905. * @param name Define the texture name
  119906. * @param size Define the size of the underlying texture
  119907. * @param scene Define the scene the refraction belongs to
  119908. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119909. */
  119910. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119911. /**
  119912. * Clone the refraction texture.
  119913. * @returns the cloned texture
  119914. */
  119915. clone(): RefractionTexture;
  119916. /**
  119917. * Serialize the texture to a JSON representation you could use in Parse later on
  119918. * @returns the serialized JSON representation
  119919. */
  119920. serialize(): any;
  119921. }
  119922. }
  119923. declare module BABYLON {
  119924. /**
  119925. * Defines the options related to the creation of an HtmlElementTexture
  119926. */
  119927. export interface IHtmlElementTextureOptions {
  119928. /**
  119929. * Defines wether mip maps should be created or not.
  119930. */
  119931. generateMipMaps?: boolean;
  119932. /**
  119933. * Defines the sampling mode of the texture.
  119934. */
  119935. samplingMode?: number;
  119936. /**
  119937. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119938. */
  119939. engine: Nullable<ThinEngine>;
  119940. /**
  119941. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119942. */
  119943. scene: Nullable<Scene>;
  119944. }
  119945. /**
  119946. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119947. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119948. * is automatically managed.
  119949. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119950. * in your application.
  119951. *
  119952. * As the update is not automatic, you need to call them manually.
  119953. */
  119954. export class HtmlElementTexture extends BaseTexture {
  119955. /**
  119956. * The texture URL.
  119957. */
  119958. element: HTMLVideoElement | HTMLCanvasElement;
  119959. private static readonly DefaultOptions;
  119960. private _textureMatrix;
  119961. private _engine;
  119962. private _isVideo;
  119963. private _generateMipMaps;
  119964. private _samplingMode;
  119965. /**
  119966. * Instantiates a HtmlElementTexture from the following parameters.
  119967. *
  119968. * @param name Defines the name of the texture
  119969. * @param element Defines the video or canvas the texture is filled with
  119970. * @param options Defines the other none mandatory texture creation options
  119971. */
  119972. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119973. private _createInternalTexture;
  119974. /**
  119975. * Returns the texture matrix used in most of the material.
  119976. */
  119977. getTextureMatrix(): Matrix;
  119978. /**
  119979. * Updates the content of the texture.
  119980. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119981. */
  119982. update(invertY?: Nullable<boolean>): void;
  119983. }
  119984. }
  119985. declare module BABYLON {
  119986. /**
  119987. * Enum used to define the target of a block
  119988. */
  119989. export enum NodeMaterialBlockTargets {
  119990. /** Vertex shader */
  119991. Vertex = 1,
  119992. /** Fragment shader */
  119993. Fragment = 2,
  119994. /** Neutral */
  119995. Neutral = 4,
  119996. /** Vertex and Fragment */
  119997. VertexAndFragment = 3
  119998. }
  119999. }
  120000. declare module BABYLON {
  120001. /**
  120002. * Defines the kind of connection point for node based material
  120003. */
  120004. export enum NodeMaterialBlockConnectionPointTypes {
  120005. /** Float */
  120006. Float = 1,
  120007. /** Int */
  120008. Int = 2,
  120009. /** Vector2 */
  120010. Vector2 = 4,
  120011. /** Vector3 */
  120012. Vector3 = 8,
  120013. /** Vector4 */
  120014. Vector4 = 16,
  120015. /** Color3 */
  120016. Color3 = 32,
  120017. /** Color4 */
  120018. Color4 = 64,
  120019. /** Matrix */
  120020. Matrix = 128,
  120021. /** Detect type based on connection */
  120022. AutoDetect = 1024,
  120023. /** Output type that will be defined by input type */
  120024. BasedOnInput = 2048
  120025. }
  120026. }
  120027. declare module BABYLON {
  120028. /**
  120029. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120030. */
  120031. export enum NodeMaterialBlockConnectionPointMode {
  120032. /** Value is an uniform */
  120033. Uniform = 0,
  120034. /** Value is a mesh attribute */
  120035. Attribute = 1,
  120036. /** Value is a varying between vertex and fragment shaders */
  120037. Varying = 2,
  120038. /** Mode is undefined */
  120039. Undefined = 3
  120040. }
  120041. }
  120042. declare module BABYLON {
  120043. /**
  120044. * Enum used to define system values e.g. values automatically provided by the system
  120045. */
  120046. export enum NodeMaterialSystemValues {
  120047. /** World */
  120048. World = 1,
  120049. /** View */
  120050. View = 2,
  120051. /** Projection */
  120052. Projection = 3,
  120053. /** ViewProjection */
  120054. ViewProjection = 4,
  120055. /** WorldView */
  120056. WorldView = 5,
  120057. /** WorldViewProjection */
  120058. WorldViewProjection = 6,
  120059. /** CameraPosition */
  120060. CameraPosition = 7,
  120061. /** Fog Color */
  120062. FogColor = 8,
  120063. /** Delta time */
  120064. DeltaTime = 9
  120065. }
  120066. }
  120067. declare module BABYLON {
  120068. /**
  120069. * Root class for all node material optimizers
  120070. */
  120071. export class NodeMaterialOptimizer {
  120072. /**
  120073. * Function used to optimize a NodeMaterial graph
  120074. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120075. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120076. */
  120077. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120078. }
  120079. }
  120080. declare module BABYLON {
  120081. /**
  120082. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120083. */
  120084. export class TransformBlock extends NodeMaterialBlock {
  120085. /**
  120086. * Defines the value to use to complement W value to transform it to a Vector4
  120087. */
  120088. complementW: number;
  120089. /**
  120090. * Defines the value to use to complement z value to transform it to a Vector4
  120091. */
  120092. complementZ: number;
  120093. /**
  120094. * Creates a new TransformBlock
  120095. * @param name defines the block name
  120096. */
  120097. constructor(name: string);
  120098. /**
  120099. * Gets the current class name
  120100. * @returns the class name
  120101. */
  120102. getClassName(): string;
  120103. /**
  120104. * Gets the vector input
  120105. */
  120106. readonly vector: NodeMaterialConnectionPoint;
  120107. /**
  120108. * Gets the output component
  120109. */
  120110. readonly output: NodeMaterialConnectionPoint;
  120111. /**
  120112. * Gets the matrix transform input
  120113. */
  120114. readonly transform: NodeMaterialConnectionPoint;
  120115. protected _buildBlock(state: NodeMaterialBuildState): this;
  120116. serialize(): any;
  120117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120118. protected _dumpPropertiesCode(): string;
  120119. }
  120120. }
  120121. declare module BABYLON {
  120122. /**
  120123. * Block used to output the vertex position
  120124. */
  120125. export class VertexOutputBlock extends NodeMaterialBlock {
  120126. /**
  120127. * Creates a new VertexOutputBlock
  120128. * @param name defines the block name
  120129. */
  120130. constructor(name: string);
  120131. /**
  120132. * Gets the current class name
  120133. * @returns the class name
  120134. */
  120135. getClassName(): string;
  120136. /**
  120137. * Gets the vector input component
  120138. */
  120139. readonly vector: NodeMaterialConnectionPoint;
  120140. protected _buildBlock(state: NodeMaterialBuildState): this;
  120141. }
  120142. }
  120143. declare module BABYLON {
  120144. /**
  120145. * Block used to output the final color
  120146. */
  120147. export class FragmentOutputBlock extends NodeMaterialBlock {
  120148. /**
  120149. * Create a new FragmentOutputBlock
  120150. * @param name defines the block name
  120151. */
  120152. constructor(name: string);
  120153. /**
  120154. * Gets the current class name
  120155. * @returns the class name
  120156. */
  120157. getClassName(): string;
  120158. /**
  120159. * Gets the rgba input component
  120160. */
  120161. readonly rgba: NodeMaterialConnectionPoint;
  120162. /**
  120163. * Gets the rgb input component
  120164. */
  120165. readonly rgb: NodeMaterialConnectionPoint;
  120166. /**
  120167. * Gets the a input component
  120168. */
  120169. readonly a: NodeMaterialConnectionPoint;
  120170. protected _buildBlock(state: NodeMaterialBuildState): this;
  120171. }
  120172. }
  120173. declare module BABYLON {
  120174. /**
  120175. * Block used to read a reflection texture from a sampler
  120176. */
  120177. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120178. private _define3DName;
  120179. private _defineCubicName;
  120180. private _defineExplicitName;
  120181. private _defineProjectionName;
  120182. private _defineLocalCubicName;
  120183. private _defineSphericalName;
  120184. private _definePlanarName;
  120185. private _defineEquirectangularName;
  120186. private _defineMirroredEquirectangularFixedName;
  120187. private _defineEquirectangularFixedName;
  120188. private _defineSkyboxName;
  120189. private _cubeSamplerName;
  120190. private _2DSamplerName;
  120191. private _positionUVWName;
  120192. private _directionWName;
  120193. private _reflectionCoordsName;
  120194. private _reflection2DCoordsName;
  120195. private _reflectionColorName;
  120196. private _reflectionMatrixName;
  120197. /**
  120198. * Gets or sets the texture associated with the node
  120199. */
  120200. texture: Nullable<BaseTexture>;
  120201. /**
  120202. * Create a new TextureBlock
  120203. * @param name defines the block name
  120204. */
  120205. constructor(name: string);
  120206. /**
  120207. * Gets the current class name
  120208. * @returns the class name
  120209. */
  120210. getClassName(): string;
  120211. /**
  120212. * Gets the world position input component
  120213. */
  120214. readonly position: NodeMaterialConnectionPoint;
  120215. /**
  120216. * Gets the world position input component
  120217. */
  120218. readonly worldPosition: NodeMaterialConnectionPoint;
  120219. /**
  120220. * Gets the world normal input component
  120221. */
  120222. readonly worldNormal: NodeMaterialConnectionPoint;
  120223. /**
  120224. * Gets the world input component
  120225. */
  120226. readonly world: NodeMaterialConnectionPoint;
  120227. /**
  120228. * Gets the camera (or eye) position component
  120229. */
  120230. readonly cameraPosition: NodeMaterialConnectionPoint;
  120231. /**
  120232. * Gets the view input component
  120233. */
  120234. readonly view: NodeMaterialConnectionPoint;
  120235. /**
  120236. * Gets the rgb output component
  120237. */
  120238. readonly rgb: NodeMaterialConnectionPoint;
  120239. /**
  120240. * Gets the r output component
  120241. */
  120242. readonly r: NodeMaterialConnectionPoint;
  120243. /**
  120244. * Gets the g output component
  120245. */
  120246. readonly g: NodeMaterialConnectionPoint;
  120247. /**
  120248. * Gets the b output component
  120249. */
  120250. readonly b: NodeMaterialConnectionPoint;
  120251. autoConfigure(material: NodeMaterial): void;
  120252. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120253. isReady(): boolean;
  120254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120255. private _injectVertexCode;
  120256. private _writeOutput;
  120257. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120258. serialize(): any;
  120259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120260. }
  120261. }
  120262. declare module BABYLON {
  120263. /**
  120264. * Interface used to configure the node material editor
  120265. */
  120266. export interface INodeMaterialEditorOptions {
  120267. /** Define the URl to load node editor script */
  120268. editorURL?: string;
  120269. }
  120270. /** @hidden */
  120271. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120272. /** BONES */
  120273. NUM_BONE_INFLUENCERS: number;
  120274. BonesPerMesh: number;
  120275. BONETEXTURE: boolean;
  120276. /** MORPH TARGETS */
  120277. MORPHTARGETS: boolean;
  120278. MORPHTARGETS_NORMAL: boolean;
  120279. MORPHTARGETS_TANGENT: boolean;
  120280. MORPHTARGETS_UV: boolean;
  120281. NUM_MORPH_INFLUENCERS: number;
  120282. /** IMAGE PROCESSING */
  120283. IMAGEPROCESSING: boolean;
  120284. VIGNETTE: boolean;
  120285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120286. VIGNETTEBLENDMODEOPAQUE: boolean;
  120287. TONEMAPPING: boolean;
  120288. TONEMAPPING_ACES: boolean;
  120289. CONTRAST: boolean;
  120290. EXPOSURE: boolean;
  120291. COLORCURVES: boolean;
  120292. COLORGRADING: boolean;
  120293. COLORGRADING3D: boolean;
  120294. SAMPLER3DGREENDEPTH: boolean;
  120295. SAMPLER3DBGRMAP: boolean;
  120296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120297. /** MISC. */
  120298. BUMPDIRECTUV: number;
  120299. constructor();
  120300. setValue(name: string, value: boolean): void;
  120301. }
  120302. /**
  120303. * Class used to configure NodeMaterial
  120304. */
  120305. export interface INodeMaterialOptions {
  120306. /**
  120307. * Defines if blocks should emit comments
  120308. */
  120309. emitComments: boolean;
  120310. }
  120311. /**
  120312. * Class used to create a node based material built by assembling shader blocks
  120313. */
  120314. export class NodeMaterial extends PushMaterial {
  120315. private static _BuildIdGenerator;
  120316. private _options;
  120317. private _vertexCompilationState;
  120318. private _fragmentCompilationState;
  120319. private _sharedData;
  120320. private _buildId;
  120321. private _buildWasSuccessful;
  120322. private _cachedWorldViewMatrix;
  120323. private _cachedWorldViewProjectionMatrix;
  120324. private _optimizers;
  120325. private _animationFrame;
  120326. /** Define the URl to load node editor script */
  120327. static EditorURL: string;
  120328. private BJSNODEMATERIALEDITOR;
  120329. /** Get the inspector from bundle or global */
  120330. private _getGlobalNodeMaterialEditor;
  120331. /**
  120332. * 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)
  120333. */
  120334. ignoreAlpha: boolean;
  120335. /**
  120336. * Defines the maximum number of lights that can be used in the material
  120337. */
  120338. maxSimultaneousLights: number;
  120339. /**
  120340. * Observable raised when the material is built
  120341. */
  120342. onBuildObservable: Observable<NodeMaterial>;
  120343. /**
  120344. * Gets or sets the root nodes of the material vertex shader
  120345. */
  120346. _vertexOutputNodes: NodeMaterialBlock[];
  120347. /**
  120348. * Gets or sets the root nodes of the material fragment (pixel) shader
  120349. */
  120350. _fragmentOutputNodes: NodeMaterialBlock[];
  120351. /** Gets or sets options to control the node material overall behavior */
  120352. options: INodeMaterialOptions;
  120353. /**
  120354. * Default configuration related to image processing available in the standard Material.
  120355. */
  120356. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120357. /**
  120358. * Gets the image processing configuration used either in this material.
  120359. */
  120360. /**
  120361. * Sets the Default image processing configuration used either in the this material.
  120362. *
  120363. * If sets to null, the scene one is in use.
  120364. */
  120365. imageProcessingConfiguration: ImageProcessingConfiguration;
  120366. /**
  120367. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120368. */
  120369. attachedBlocks: NodeMaterialBlock[];
  120370. /**
  120371. * Create a new node based material
  120372. * @param name defines the material name
  120373. * @param scene defines the hosting scene
  120374. * @param options defines creation option
  120375. */
  120376. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120377. /**
  120378. * Gets the current class name of the material e.g. "NodeMaterial"
  120379. * @returns the class name
  120380. */
  120381. getClassName(): string;
  120382. /**
  120383. * Keep track of the image processing observer to allow dispose and replace.
  120384. */
  120385. private _imageProcessingObserver;
  120386. /**
  120387. * Attaches a new image processing configuration to the Standard Material.
  120388. * @param configuration
  120389. */
  120390. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120391. /**
  120392. * Get a block by its name
  120393. * @param name defines the name of the block to retrieve
  120394. * @returns the required block or null if not found
  120395. */
  120396. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120397. /**
  120398. * Get a block by its name
  120399. * @param predicate defines the predicate used to find the good candidate
  120400. * @returns the required block or null if not found
  120401. */
  120402. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120403. /**
  120404. * Get an input block by its name
  120405. * @param predicate defines the predicate used to find the good candidate
  120406. * @returns the required input block or null if not found
  120407. */
  120408. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120409. /**
  120410. * Gets the list of input blocks attached to this material
  120411. * @returns an array of InputBlocks
  120412. */
  120413. getInputBlocks(): InputBlock[];
  120414. /**
  120415. * Adds a new optimizer to the list of optimizers
  120416. * @param optimizer defines the optimizers to add
  120417. * @returns the current material
  120418. */
  120419. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120420. /**
  120421. * Remove an optimizer from the list of optimizers
  120422. * @param optimizer defines the optimizers to remove
  120423. * @returns the current material
  120424. */
  120425. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120426. /**
  120427. * Add a new block to the list of output nodes
  120428. * @param node defines the node to add
  120429. * @returns the current material
  120430. */
  120431. addOutputNode(node: NodeMaterialBlock): this;
  120432. /**
  120433. * Remove a block from the list of root nodes
  120434. * @param node defines the node to remove
  120435. * @returns the current material
  120436. */
  120437. removeOutputNode(node: NodeMaterialBlock): this;
  120438. private _addVertexOutputNode;
  120439. private _removeVertexOutputNode;
  120440. private _addFragmentOutputNode;
  120441. private _removeFragmentOutputNode;
  120442. /**
  120443. * Specifies if the material will require alpha blending
  120444. * @returns a boolean specifying if alpha blending is needed
  120445. */
  120446. needAlphaBlending(): boolean;
  120447. /**
  120448. * Specifies if this material should be rendered in alpha test mode
  120449. * @returns a boolean specifying if an alpha test is needed.
  120450. */
  120451. needAlphaTesting(): boolean;
  120452. private _initializeBlock;
  120453. private _resetDualBlocks;
  120454. /**
  120455. * Build the material and generates the inner effect
  120456. * @param verbose defines if the build should log activity
  120457. */
  120458. build(verbose?: boolean): void;
  120459. /**
  120460. * Runs an otpimization phase to try to improve the shader code
  120461. */
  120462. optimize(): void;
  120463. private _prepareDefinesForAttributes;
  120464. /**
  120465. * Get if the submesh is ready to be used and all its information available.
  120466. * Child classes can use it to update shaders
  120467. * @param mesh defines the mesh to check
  120468. * @param subMesh defines which submesh to check
  120469. * @param useInstances specifies that instances should be used
  120470. * @returns a boolean indicating that the submesh is ready or not
  120471. */
  120472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120473. /**
  120474. * Get a string representing the shaders built by the current node graph
  120475. */
  120476. readonly compiledShaders: string;
  120477. /**
  120478. * Binds the world matrix to the material
  120479. * @param world defines the world transformation matrix
  120480. */
  120481. bindOnlyWorldMatrix(world: Matrix): void;
  120482. /**
  120483. * Binds the submesh to this material by preparing the effect and shader to draw
  120484. * @param world defines the world transformation matrix
  120485. * @param mesh defines the mesh containing the submesh
  120486. * @param subMesh defines the submesh to bind the material to
  120487. */
  120488. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120489. /**
  120490. * Gets the active textures from the material
  120491. * @returns an array of textures
  120492. */
  120493. getActiveTextures(): BaseTexture[];
  120494. /**
  120495. * Gets the list of texture blocks
  120496. * @returns an array of texture blocks
  120497. */
  120498. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120499. /**
  120500. * Specifies if the material uses a texture
  120501. * @param texture defines the texture to check against the material
  120502. * @returns a boolean specifying if the material uses the texture
  120503. */
  120504. hasTexture(texture: BaseTexture): boolean;
  120505. /**
  120506. * Disposes the material
  120507. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120508. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120509. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120510. */
  120511. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120512. /** Creates the node editor window. */
  120513. private _createNodeEditor;
  120514. /**
  120515. * Launch the node material editor
  120516. * @param config Define the configuration of the editor
  120517. * @return a promise fulfilled when the node editor is visible
  120518. */
  120519. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120520. /**
  120521. * Clear the current material
  120522. */
  120523. clear(): void;
  120524. /**
  120525. * Clear the current material and set it to a default state
  120526. */
  120527. setToDefault(): void;
  120528. /**
  120529. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120530. * @param url defines the url to load from
  120531. * @returns a promise that will fullfil when the material is fully loaded
  120532. */
  120533. loadAsync(url: string): Promise<unknown>;
  120534. private _gatherBlocks;
  120535. /**
  120536. * Generate a string containing the code declaration required to create an equivalent of this material
  120537. * @returns a string
  120538. */
  120539. generateCode(): string;
  120540. /**
  120541. * Serializes this material in a JSON representation
  120542. * @returns the serialized material object
  120543. */
  120544. serialize(): any;
  120545. private _restoreConnections;
  120546. /**
  120547. * Clear the current graph and load a new one from a serialization object
  120548. * @param source defines the JSON representation of the material
  120549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120550. */
  120551. loadFromSerialization(source: any, rootUrl?: string): void;
  120552. /**
  120553. * Creates a node material from parsed material data
  120554. * @param source defines the JSON representation of the material
  120555. * @param scene defines the hosting scene
  120556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120557. * @returns a new node material
  120558. */
  120559. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120560. /**
  120561. * Creates a new node material set to default basic configuration
  120562. * @param name defines the name of the material
  120563. * @param scene defines the hosting scene
  120564. * @returns a new NodeMaterial
  120565. */
  120566. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120567. }
  120568. }
  120569. declare module BABYLON {
  120570. /**
  120571. * Block used to read a texture from a sampler
  120572. */
  120573. export class TextureBlock extends NodeMaterialBlock {
  120574. private _defineName;
  120575. private _linearDefineName;
  120576. private _samplerName;
  120577. private _transformedUVName;
  120578. private _textureTransformName;
  120579. private _textureInfoName;
  120580. private _mainUVName;
  120581. private _mainUVDefineName;
  120582. /**
  120583. * Gets or sets the texture associated with the node
  120584. */
  120585. texture: Nullable<Texture>;
  120586. /**
  120587. * Create a new TextureBlock
  120588. * @param name defines the block name
  120589. */
  120590. constructor(name: string);
  120591. /**
  120592. * Gets the current class name
  120593. * @returns the class name
  120594. */
  120595. getClassName(): string;
  120596. /**
  120597. * Gets the uv input component
  120598. */
  120599. readonly uv: NodeMaterialConnectionPoint;
  120600. /**
  120601. * Gets the rgba output component
  120602. */
  120603. readonly rgba: NodeMaterialConnectionPoint;
  120604. /**
  120605. * Gets the rgb output component
  120606. */
  120607. readonly rgb: NodeMaterialConnectionPoint;
  120608. /**
  120609. * Gets the r output component
  120610. */
  120611. readonly r: NodeMaterialConnectionPoint;
  120612. /**
  120613. * Gets the g output component
  120614. */
  120615. readonly g: NodeMaterialConnectionPoint;
  120616. /**
  120617. * Gets the b output component
  120618. */
  120619. readonly b: NodeMaterialConnectionPoint;
  120620. /**
  120621. * Gets the a output component
  120622. */
  120623. readonly a: NodeMaterialConnectionPoint;
  120624. readonly target: NodeMaterialBlockTargets;
  120625. autoConfigure(material: NodeMaterial): void;
  120626. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120628. isReady(): boolean;
  120629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120630. private readonly _isMixed;
  120631. private _injectVertexCode;
  120632. private _writeOutput;
  120633. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120634. protected _dumpPropertiesCode(): string;
  120635. serialize(): any;
  120636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120637. }
  120638. }
  120639. declare module BABYLON {
  120640. /**
  120641. * Class used to store shared data between 2 NodeMaterialBuildState
  120642. */
  120643. export class NodeMaterialBuildStateSharedData {
  120644. /**
  120645. * Gets the list of emitted varyings
  120646. */
  120647. temps: string[];
  120648. /**
  120649. * Gets the list of emitted varyings
  120650. */
  120651. varyings: string[];
  120652. /**
  120653. * Gets the varying declaration string
  120654. */
  120655. varyingDeclaration: string;
  120656. /**
  120657. * Input blocks
  120658. */
  120659. inputBlocks: InputBlock[];
  120660. /**
  120661. * Input blocks
  120662. */
  120663. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120664. /**
  120665. * Bindable blocks (Blocks that need to set data to the effect)
  120666. */
  120667. bindableBlocks: NodeMaterialBlock[];
  120668. /**
  120669. * List of blocks that can provide a compilation fallback
  120670. */
  120671. blocksWithFallbacks: NodeMaterialBlock[];
  120672. /**
  120673. * List of blocks that can provide a define update
  120674. */
  120675. blocksWithDefines: NodeMaterialBlock[];
  120676. /**
  120677. * List of blocks that can provide a repeatable content
  120678. */
  120679. repeatableContentBlocks: NodeMaterialBlock[];
  120680. /**
  120681. * List of blocks that can provide a dynamic list of uniforms
  120682. */
  120683. dynamicUniformBlocks: NodeMaterialBlock[];
  120684. /**
  120685. * List of blocks that can block the isReady function for the material
  120686. */
  120687. blockingBlocks: NodeMaterialBlock[];
  120688. /**
  120689. * Gets the list of animated inputs
  120690. */
  120691. animatedInputs: InputBlock[];
  120692. /**
  120693. * Build Id used to avoid multiple recompilations
  120694. */
  120695. buildId: number;
  120696. /** List of emitted variables */
  120697. variableNames: {
  120698. [key: string]: number;
  120699. };
  120700. /** List of emitted defines */
  120701. defineNames: {
  120702. [key: string]: number;
  120703. };
  120704. /** Should emit comments? */
  120705. emitComments: boolean;
  120706. /** Emit build activity */
  120707. verbose: boolean;
  120708. /** Gets or sets the hosting scene */
  120709. scene: Scene;
  120710. /**
  120711. * Gets the compilation hints emitted at compilation time
  120712. */
  120713. hints: {
  120714. needWorldViewMatrix: boolean;
  120715. needWorldViewProjectionMatrix: boolean;
  120716. needAlphaBlending: boolean;
  120717. needAlphaTesting: boolean;
  120718. };
  120719. /**
  120720. * List of compilation checks
  120721. */
  120722. checks: {
  120723. emitVertex: boolean;
  120724. emitFragment: boolean;
  120725. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120726. };
  120727. /** Creates a new shared data */
  120728. constructor();
  120729. /**
  120730. * Emits console errors and exceptions if there is a failing check
  120731. */
  120732. emitErrors(): void;
  120733. }
  120734. }
  120735. declare module BABYLON {
  120736. /**
  120737. * Class used to store node based material build state
  120738. */
  120739. export class NodeMaterialBuildState {
  120740. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120741. supportUniformBuffers: boolean;
  120742. /**
  120743. * Gets the list of emitted attributes
  120744. */
  120745. attributes: string[];
  120746. /**
  120747. * Gets the list of emitted uniforms
  120748. */
  120749. uniforms: string[];
  120750. /**
  120751. * Gets the list of emitted constants
  120752. */
  120753. constants: string[];
  120754. /**
  120755. * Gets the list of emitted samplers
  120756. */
  120757. samplers: string[];
  120758. /**
  120759. * Gets the list of emitted functions
  120760. */
  120761. functions: {
  120762. [key: string]: string;
  120763. };
  120764. /**
  120765. * Gets the list of emitted extensions
  120766. */
  120767. extensions: {
  120768. [key: string]: string;
  120769. };
  120770. /**
  120771. * Gets the target of the compilation state
  120772. */
  120773. target: NodeMaterialBlockTargets;
  120774. /**
  120775. * Gets the list of emitted counters
  120776. */
  120777. counters: {
  120778. [key: string]: number;
  120779. };
  120780. /**
  120781. * Shared data between multiple NodeMaterialBuildState instances
  120782. */
  120783. sharedData: NodeMaterialBuildStateSharedData;
  120784. /** @hidden */
  120785. _vertexState: NodeMaterialBuildState;
  120786. /** @hidden */
  120787. _attributeDeclaration: string;
  120788. /** @hidden */
  120789. _uniformDeclaration: string;
  120790. /** @hidden */
  120791. _constantDeclaration: string;
  120792. /** @hidden */
  120793. _samplerDeclaration: string;
  120794. /** @hidden */
  120795. _varyingTransfer: string;
  120796. private _repeatableContentAnchorIndex;
  120797. /** @hidden */
  120798. _builtCompilationString: string;
  120799. /**
  120800. * Gets the emitted compilation strings
  120801. */
  120802. compilationString: string;
  120803. /**
  120804. * Finalize the compilation strings
  120805. * @param state defines the current compilation state
  120806. */
  120807. finalize(state: NodeMaterialBuildState): void;
  120808. /** @hidden */
  120809. readonly _repeatableContentAnchor: string;
  120810. /** @hidden */
  120811. _getFreeVariableName(prefix: string): string;
  120812. /** @hidden */
  120813. _getFreeDefineName(prefix: string): string;
  120814. /** @hidden */
  120815. _excludeVariableName(name: string): void;
  120816. /** @hidden */
  120817. _emit2DSampler(name: string): void;
  120818. /** @hidden */
  120819. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120820. /** @hidden */
  120821. _emitExtension(name: string, extension: string): void;
  120822. /** @hidden */
  120823. _emitFunction(name: string, code: string, comments: string): void;
  120824. /** @hidden */
  120825. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120826. replaceStrings?: {
  120827. search: RegExp;
  120828. replace: string;
  120829. }[];
  120830. repeatKey?: string;
  120831. }): string;
  120832. /** @hidden */
  120833. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120834. repeatKey?: string;
  120835. removeAttributes?: boolean;
  120836. removeUniforms?: boolean;
  120837. removeVaryings?: boolean;
  120838. removeIfDef?: boolean;
  120839. replaceStrings?: {
  120840. search: RegExp;
  120841. replace: string;
  120842. }[];
  120843. }, storeKey?: string): void;
  120844. /** @hidden */
  120845. _registerTempVariable(name: string): boolean;
  120846. /** @hidden */
  120847. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120848. /** @hidden */
  120849. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120850. /** @hidden */
  120851. _emitFloat(value: number): string;
  120852. }
  120853. }
  120854. declare module BABYLON {
  120855. /**
  120856. * Defines a block that can be used inside a node based material
  120857. */
  120858. export class NodeMaterialBlock {
  120859. private _buildId;
  120860. private _buildTarget;
  120861. private _target;
  120862. private _isFinalMerger;
  120863. private _isInput;
  120864. /** @hidden */
  120865. _codeVariableName: string;
  120866. /** @hidden */
  120867. _inputs: NodeMaterialConnectionPoint[];
  120868. /** @hidden */
  120869. _outputs: NodeMaterialConnectionPoint[];
  120870. /** @hidden */
  120871. _preparationId: number;
  120872. /**
  120873. * Gets or sets the name of the block
  120874. */
  120875. name: string;
  120876. /**
  120877. * Gets or sets the unique id of the node
  120878. */
  120879. uniqueId: number;
  120880. /**
  120881. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120882. */
  120883. readonly isFinalMerger: boolean;
  120884. /**
  120885. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120886. */
  120887. readonly isInput: boolean;
  120888. /**
  120889. * Gets or sets the build Id
  120890. */
  120891. buildId: number;
  120892. /**
  120893. * Gets or sets the target of the block
  120894. */
  120895. target: NodeMaterialBlockTargets;
  120896. /**
  120897. * Gets the list of input points
  120898. */
  120899. readonly inputs: NodeMaterialConnectionPoint[];
  120900. /** Gets the list of output points */
  120901. readonly outputs: NodeMaterialConnectionPoint[];
  120902. /**
  120903. * Find an input by its name
  120904. * @param name defines the name of the input to look for
  120905. * @returns the input or null if not found
  120906. */
  120907. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120908. /**
  120909. * Find an output by its name
  120910. * @param name defines the name of the outputto look for
  120911. * @returns the output or null if not found
  120912. */
  120913. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120914. /**
  120915. * Creates a new NodeMaterialBlock
  120916. * @param name defines the block name
  120917. * @param target defines the target of that block (Vertex by default)
  120918. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120919. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120920. */
  120921. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120922. /**
  120923. * Initialize the block and prepare the context for build
  120924. * @param state defines the state that will be used for the build
  120925. */
  120926. initialize(state: NodeMaterialBuildState): void;
  120927. /**
  120928. * Bind data to effect. Will only be called for blocks with isBindable === true
  120929. * @param effect defines the effect to bind data to
  120930. * @param nodeMaterial defines the hosting NodeMaterial
  120931. * @param mesh defines the mesh that will be rendered
  120932. */
  120933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120934. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120935. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120936. protected _writeFloat(value: number): string;
  120937. /**
  120938. * Gets the current class name e.g. "NodeMaterialBlock"
  120939. * @returns the class name
  120940. */
  120941. getClassName(): string;
  120942. /**
  120943. * Register a new input. Must be called inside a block constructor
  120944. * @param name defines the connection point name
  120945. * @param type defines the connection point type
  120946. * @param isOptional defines a boolean indicating that this input can be omitted
  120947. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120948. * @returns the current block
  120949. */
  120950. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120951. /**
  120952. * Register a new output. Must be called inside a block constructor
  120953. * @param name defines the connection point name
  120954. * @param type defines the connection point type
  120955. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120956. * @returns the current block
  120957. */
  120958. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120959. /**
  120960. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120961. * @param forOutput defines an optional connection point to check compatibility with
  120962. * @returns the first available input or null
  120963. */
  120964. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120965. /**
  120966. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120967. * @param forBlock defines an optional block to check compatibility with
  120968. * @returns the first available input or null
  120969. */
  120970. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120971. /**
  120972. * Gets the sibling of the given output
  120973. * @param current defines the current output
  120974. * @returns the next output in the list or null
  120975. */
  120976. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120977. /**
  120978. * Connect current block with another block
  120979. * @param other defines the block to connect with
  120980. * @param options define the various options to help pick the right connections
  120981. * @returns the current block
  120982. */
  120983. connectTo(other: NodeMaterialBlock, options?: {
  120984. input?: string;
  120985. output?: string;
  120986. outputSwizzle?: string;
  120987. }): this | undefined;
  120988. protected _buildBlock(state: NodeMaterialBuildState): void;
  120989. /**
  120990. * Add uniforms, samplers and uniform buffers at compilation time
  120991. * @param state defines the state to update
  120992. * @param nodeMaterial defines the node material requesting the update
  120993. * @param defines defines the material defines to update
  120994. * @param uniformBuffers defines the list of uniform buffer names
  120995. */
  120996. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  120997. /**
  120998. * Add potential fallbacks if shader compilation fails
  120999. * @param mesh defines the mesh to be rendered
  121000. * @param fallbacks defines the current prioritized list of fallbacks
  121001. */
  121002. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121003. /**
  121004. * Initialize defines for shader compilation
  121005. * @param mesh defines the mesh to be rendered
  121006. * @param nodeMaterial defines the node material requesting the update
  121007. * @param defines defines the material defines to update
  121008. * @param useInstances specifies that instances should be used
  121009. */
  121010. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121011. /**
  121012. * Update defines for shader compilation
  121013. * @param mesh defines the mesh to be rendered
  121014. * @param nodeMaterial defines the node material requesting the update
  121015. * @param defines defines the material defines to update
  121016. * @param useInstances specifies that instances should be used
  121017. */
  121018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121019. /**
  121020. * Lets the block try to connect some inputs automatically
  121021. * @param material defines the hosting NodeMaterial
  121022. */
  121023. autoConfigure(material: NodeMaterial): void;
  121024. /**
  121025. * Function called when a block is declared as repeatable content generator
  121026. * @param vertexShaderState defines the current compilation state for the vertex shader
  121027. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121028. * @param mesh defines the mesh to be rendered
  121029. * @param defines defines the material defines to update
  121030. */
  121031. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121032. /**
  121033. * Checks if the block is ready
  121034. * @param mesh defines the mesh to be rendered
  121035. * @param nodeMaterial defines the node material requesting the update
  121036. * @param defines defines the material defines to update
  121037. * @param useInstances specifies that instances should be used
  121038. * @returns true if the block is ready
  121039. */
  121040. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121041. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121042. private _processBuild;
  121043. /**
  121044. * Compile the current node and generate the shader code
  121045. * @param state defines the current compilation state (uniforms, samplers, current string)
  121046. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121047. * @returns true if already built
  121048. */
  121049. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121050. protected _inputRename(name: string): string;
  121051. protected _outputRename(name: string): string;
  121052. protected _dumpPropertiesCode(): string;
  121053. /** @hidden */
  121054. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121055. /**
  121056. * Clone the current block to a new identical block
  121057. * @param scene defines the hosting scene
  121058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121059. * @returns a copy of the current block
  121060. */
  121061. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121062. /**
  121063. * Serializes this block in a JSON representation
  121064. * @returns the serialized block object
  121065. */
  121066. serialize(): any;
  121067. /** @hidden */
  121068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121069. }
  121070. }
  121071. declare module BABYLON {
  121072. /**
  121073. * Enum defining the type of animations supported by InputBlock
  121074. */
  121075. export enum AnimatedInputBlockTypes {
  121076. /** No animation */
  121077. None = 0,
  121078. /** Time based animation. Will only work for floats */
  121079. Time = 1
  121080. }
  121081. }
  121082. declare module BABYLON {
  121083. /**
  121084. * Block used to expose an input value
  121085. */
  121086. export class InputBlock extends NodeMaterialBlock {
  121087. private _mode;
  121088. private _associatedVariableName;
  121089. private _storedValue;
  121090. private _valueCallback;
  121091. private _type;
  121092. private _animationType;
  121093. /** Gets or set a value used to limit the range of float values */
  121094. min: number;
  121095. /** Gets or set a value used to limit the range of float values */
  121096. max: number;
  121097. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121098. matrixMode: number;
  121099. /** @hidden */
  121100. _systemValue: Nullable<NodeMaterialSystemValues>;
  121101. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121102. visibleInInspector: boolean;
  121103. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121104. isConstant: boolean;
  121105. /**
  121106. * Gets or sets the connection point type (default is float)
  121107. */
  121108. readonly type: NodeMaterialBlockConnectionPointTypes;
  121109. /**
  121110. * Creates a new InputBlock
  121111. * @param name defines the block name
  121112. * @param target defines the target of that block (Vertex by default)
  121113. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121114. */
  121115. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121116. /**
  121117. * Gets the output component
  121118. */
  121119. readonly output: NodeMaterialConnectionPoint;
  121120. /**
  121121. * Set the source of this connection point to a vertex attribute
  121122. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121123. * @returns the current connection point
  121124. */
  121125. setAsAttribute(attributeName?: string): InputBlock;
  121126. /**
  121127. * Set the source of this connection point to a system value
  121128. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121129. * @returns the current connection point
  121130. */
  121131. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121132. /**
  121133. * Gets or sets the value of that point.
  121134. * Please note that this value will be ignored if valueCallback is defined
  121135. */
  121136. value: any;
  121137. /**
  121138. * Gets or sets a callback used to get the value of that point.
  121139. * Please note that setting this value will force the connection point to ignore the value property
  121140. */
  121141. valueCallback: () => any;
  121142. /**
  121143. * Gets or sets the associated variable name in the shader
  121144. */
  121145. associatedVariableName: string;
  121146. /** Gets or sets the type of animation applied to the input */
  121147. animationType: AnimatedInputBlockTypes;
  121148. /**
  121149. * Gets a boolean indicating that this connection point not defined yet
  121150. */
  121151. readonly isUndefined: boolean;
  121152. /**
  121153. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121154. * In this case the connection point name must be the name of the uniform to use.
  121155. * Can only be set on inputs
  121156. */
  121157. isUniform: boolean;
  121158. /**
  121159. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121160. * In this case the connection point name must be the name of the attribute to use
  121161. * Can only be set on inputs
  121162. */
  121163. isAttribute: boolean;
  121164. /**
  121165. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121166. * Can only be set on exit points
  121167. */
  121168. isVarying: boolean;
  121169. /**
  121170. * Gets a boolean indicating that the current connection point is a system value
  121171. */
  121172. readonly isSystemValue: boolean;
  121173. /**
  121174. * Gets or sets the current well known value or null if not defined as a system value
  121175. */
  121176. systemValue: Nullable<NodeMaterialSystemValues>;
  121177. /**
  121178. * Gets the current class name
  121179. * @returns the class name
  121180. */
  121181. getClassName(): string;
  121182. /**
  121183. * Animate the input if animationType !== None
  121184. * @param scene defines the rendering scene
  121185. */
  121186. animate(scene: Scene): void;
  121187. private _emitDefine;
  121188. initialize(state: NodeMaterialBuildState): void;
  121189. /**
  121190. * Set the input block to its default value (based on its type)
  121191. */
  121192. setDefaultValue(): void;
  121193. private _emitConstant;
  121194. private _emit;
  121195. /** @hidden */
  121196. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121197. /** @hidden */
  121198. _transmit(effect: Effect, scene: Scene): void;
  121199. protected _buildBlock(state: NodeMaterialBuildState): void;
  121200. protected _dumpPropertiesCode(): string;
  121201. serialize(): any;
  121202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * Defines a connection point for a block
  121208. */
  121209. export class NodeMaterialConnectionPoint {
  121210. /** @hidden */
  121211. _ownerBlock: NodeMaterialBlock;
  121212. /** @hidden */
  121213. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121214. private _endpoints;
  121215. private _associatedVariableName;
  121216. /** @hidden */
  121217. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121218. /** @hidden */
  121219. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121220. private _type;
  121221. /** @hidden */
  121222. _enforceAssociatedVariableName: boolean;
  121223. /**
  121224. * Gets or sets the additional types supported by this connection point
  121225. */
  121226. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121227. /**
  121228. * Gets or sets the additional types excluded by this connection point
  121229. */
  121230. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121231. /**
  121232. * Gets or sets the associated variable name in the shader
  121233. */
  121234. associatedVariableName: string;
  121235. /**
  121236. * Gets or sets the connection point type (default is float)
  121237. */
  121238. type: NodeMaterialBlockConnectionPointTypes;
  121239. /**
  121240. * Gets or sets the connection point name
  121241. */
  121242. name: string;
  121243. /**
  121244. * Gets or sets a boolean indicating that this connection point can be omitted
  121245. */
  121246. isOptional: boolean;
  121247. /**
  121248. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121249. */
  121250. define: string;
  121251. /** Gets or sets the target of that connection point */
  121252. target: NodeMaterialBlockTargets;
  121253. /**
  121254. * Gets a boolean indicating that the current point is connected
  121255. */
  121256. readonly isConnected: boolean;
  121257. /**
  121258. * Gets a boolean indicating that the current point is connected to an input block
  121259. */
  121260. readonly isConnectedToInputBlock: boolean;
  121261. /**
  121262. * Gets a the connected input block (if any)
  121263. */
  121264. readonly connectInputBlock: Nullable<InputBlock>;
  121265. /** Get the other side of the connection (if any) */
  121266. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121267. /** Get the block that owns this connection point */
  121268. readonly ownerBlock: NodeMaterialBlock;
  121269. /** Get the block connected on the other side of this connection (if any) */
  121270. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121271. /** Get the block connected on the endpoints of this connection (if any) */
  121272. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121273. /** Gets the list of connected endpoints */
  121274. readonly endpoints: NodeMaterialConnectionPoint[];
  121275. /** Gets a boolean indicating if that output point is connected to at least one input */
  121276. readonly hasEndpoints: boolean;
  121277. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121278. readonly isConnectedInVertexShader: boolean;
  121279. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121280. readonly isConnectedInFragmentShader: boolean;
  121281. /**
  121282. * Creates a new connection point
  121283. * @param name defines the connection point name
  121284. * @param ownerBlock defines the block hosting this connection point
  121285. */
  121286. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121287. /**
  121288. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121289. * @returns the class name
  121290. */
  121291. getClassName(): string;
  121292. /**
  121293. * Gets an boolean indicating if the current point can be connected to another point
  121294. * @param connectionPoint defines the other connection point
  121295. * @returns true if the connection is possible
  121296. */
  121297. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121298. /**
  121299. * Connect this point to another connection point
  121300. * @param connectionPoint defines the other connection point
  121301. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121302. * @returns the current connection point
  121303. */
  121304. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121305. /**
  121306. * Disconnect this point from one of his endpoint
  121307. * @param endpoint defines the other connection point
  121308. * @returns the current connection point
  121309. */
  121310. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121311. /**
  121312. * Serializes this point in a JSON representation
  121313. * @returns the serialized point object
  121314. */
  121315. serialize(): any;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. /**
  121320. * Block used to add support for vertex skinning (bones)
  121321. */
  121322. export class BonesBlock extends NodeMaterialBlock {
  121323. /**
  121324. * Creates a new BonesBlock
  121325. * @param name defines the block name
  121326. */
  121327. constructor(name: string);
  121328. /**
  121329. * Initialize the block and prepare the context for build
  121330. * @param state defines the state that will be used for the build
  121331. */
  121332. initialize(state: NodeMaterialBuildState): void;
  121333. /**
  121334. * Gets the current class name
  121335. * @returns the class name
  121336. */
  121337. getClassName(): string;
  121338. /**
  121339. * Gets the matrix indices input component
  121340. */
  121341. readonly matricesIndices: NodeMaterialConnectionPoint;
  121342. /**
  121343. * Gets the matrix weights input component
  121344. */
  121345. readonly matricesWeights: NodeMaterialConnectionPoint;
  121346. /**
  121347. * Gets the extra matrix indices input component
  121348. */
  121349. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121350. /**
  121351. * Gets the extra matrix weights input component
  121352. */
  121353. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121354. /**
  121355. * Gets the world input component
  121356. */
  121357. readonly world: NodeMaterialConnectionPoint;
  121358. /**
  121359. * Gets the output component
  121360. */
  121361. readonly output: NodeMaterialConnectionPoint;
  121362. autoConfigure(material: NodeMaterial): void;
  121363. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121366. protected _buildBlock(state: NodeMaterialBuildState): this;
  121367. }
  121368. }
  121369. declare module BABYLON {
  121370. /**
  121371. * Block used to add support for instances
  121372. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121373. */
  121374. export class InstancesBlock extends NodeMaterialBlock {
  121375. /**
  121376. * Creates a new InstancesBlock
  121377. * @param name defines the block name
  121378. */
  121379. constructor(name: string);
  121380. /**
  121381. * Gets the current class name
  121382. * @returns the class name
  121383. */
  121384. getClassName(): string;
  121385. /**
  121386. * Gets the first world row input component
  121387. */
  121388. readonly world0: NodeMaterialConnectionPoint;
  121389. /**
  121390. * Gets the second world row input component
  121391. */
  121392. readonly world1: NodeMaterialConnectionPoint;
  121393. /**
  121394. * Gets the third world row input component
  121395. */
  121396. readonly world2: NodeMaterialConnectionPoint;
  121397. /**
  121398. * Gets the forth world row input component
  121399. */
  121400. readonly world3: NodeMaterialConnectionPoint;
  121401. /**
  121402. * Gets the world input component
  121403. */
  121404. readonly world: NodeMaterialConnectionPoint;
  121405. /**
  121406. * Gets the output component
  121407. */
  121408. readonly output: NodeMaterialConnectionPoint;
  121409. autoConfigure(material: NodeMaterial): void;
  121410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121411. protected _buildBlock(state: NodeMaterialBuildState): this;
  121412. }
  121413. }
  121414. declare module BABYLON {
  121415. /**
  121416. * Block used to add morph targets support to vertex shader
  121417. */
  121418. export class MorphTargetsBlock extends NodeMaterialBlock {
  121419. private _repeatableContentAnchor;
  121420. private _repeatebleContentGenerated;
  121421. /**
  121422. * Create a new MorphTargetsBlock
  121423. * @param name defines the block name
  121424. */
  121425. constructor(name: string);
  121426. /**
  121427. * Gets the current class name
  121428. * @returns the class name
  121429. */
  121430. getClassName(): string;
  121431. /**
  121432. * Gets the position input component
  121433. */
  121434. readonly position: NodeMaterialConnectionPoint;
  121435. /**
  121436. * Gets the normal input component
  121437. */
  121438. readonly normal: NodeMaterialConnectionPoint;
  121439. /**
  121440. * Gets the tangent input component
  121441. */
  121442. readonly tangent: NodeMaterialConnectionPoint;
  121443. /**
  121444. * Gets the tangent input component
  121445. */
  121446. readonly uv: NodeMaterialConnectionPoint;
  121447. /**
  121448. * Gets the position output component
  121449. */
  121450. readonly positionOutput: NodeMaterialConnectionPoint;
  121451. /**
  121452. * Gets the normal output component
  121453. */
  121454. readonly normalOutput: NodeMaterialConnectionPoint;
  121455. /**
  121456. * Gets the tangent output component
  121457. */
  121458. readonly tangentOutput: NodeMaterialConnectionPoint;
  121459. /**
  121460. * Gets the tangent output component
  121461. */
  121462. readonly uvOutput: NodeMaterialConnectionPoint;
  121463. initialize(state: NodeMaterialBuildState): void;
  121464. autoConfigure(material: NodeMaterial): void;
  121465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121466. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121467. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121468. protected _buildBlock(state: NodeMaterialBuildState): this;
  121469. }
  121470. }
  121471. declare module BABYLON {
  121472. /**
  121473. * Block used to get data information from a light
  121474. */
  121475. export class LightInformationBlock extends NodeMaterialBlock {
  121476. private _lightDataUniformName;
  121477. private _lightColorUniformName;
  121478. private _lightTypeDefineName;
  121479. /**
  121480. * Gets or sets the light associated with this block
  121481. */
  121482. light: Nullable<Light>;
  121483. /**
  121484. * Creates a new LightInformationBlock
  121485. * @param name defines the block name
  121486. */
  121487. constructor(name: string);
  121488. /**
  121489. * Gets the current class name
  121490. * @returns the class name
  121491. */
  121492. getClassName(): string;
  121493. /**
  121494. * Gets the world position input component
  121495. */
  121496. readonly worldPosition: NodeMaterialConnectionPoint;
  121497. /**
  121498. * Gets the direction output component
  121499. */
  121500. readonly direction: NodeMaterialConnectionPoint;
  121501. /**
  121502. * Gets the direction output component
  121503. */
  121504. readonly color: NodeMaterialConnectionPoint;
  121505. /**
  121506. * Gets the direction output component
  121507. */
  121508. readonly intensity: NodeMaterialConnectionPoint;
  121509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121511. protected _buildBlock(state: NodeMaterialBuildState): this;
  121512. serialize(): any;
  121513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121514. }
  121515. }
  121516. declare module BABYLON {
  121517. /**
  121518. * Block used to add image processing support to fragment shader
  121519. */
  121520. export class ImageProcessingBlock extends NodeMaterialBlock {
  121521. /**
  121522. * Create a new ImageProcessingBlock
  121523. * @param name defines the block name
  121524. */
  121525. constructor(name: string);
  121526. /**
  121527. * Gets the current class name
  121528. * @returns the class name
  121529. */
  121530. getClassName(): string;
  121531. /**
  121532. * Gets the color input component
  121533. */
  121534. readonly color: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the output component
  121537. */
  121538. readonly output: NodeMaterialConnectionPoint;
  121539. /**
  121540. * Initialize the block and prepare the context for build
  121541. * @param state defines the state that will be used for the build
  121542. */
  121543. initialize(state: NodeMaterialBuildState): void;
  121544. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121547. protected _buildBlock(state: NodeMaterialBuildState): this;
  121548. }
  121549. }
  121550. declare module BABYLON {
  121551. /**
  121552. * Block used to pertub normals based on a normal map
  121553. */
  121554. export class PerturbNormalBlock extends NodeMaterialBlock {
  121555. private _tangentSpaceParameterName;
  121556. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121557. invertX: boolean;
  121558. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121559. invertY: boolean;
  121560. /**
  121561. * Create a new PerturbNormalBlock
  121562. * @param name defines the block name
  121563. */
  121564. constructor(name: string);
  121565. /**
  121566. * Gets the current class name
  121567. * @returns the class name
  121568. */
  121569. getClassName(): string;
  121570. /**
  121571. * Gets the world position input component
  121572. */
  121573. readonly worldPosition: NodeMaterialConnectionPoint;
  121574. /**
  121575. * Gets the world normal input component
  121576. */
  121577. readonly worldNormal: NodeMaterialConnectionPoint;
  121578. /**
  121579. * Gets the uv input component
  121580. */
  121581. readonly uv: NodeMaterialConnectionPoint;
  121582. /**
  121583. * Gets the normal map color input component
  121584. */
  121585. readonly normalMapColor: NodeMaterialConnectionPoint;
  121586. /**
  121587. * Gets the strength input component
  121588. */
  121589. readonly strength: NodeMaterialConnectionPoint;
  121590. /**
  121591. * Gets the output component
  121592. */
  121593. readonly output: NodeMaterialConnectionPoint;
  121594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121596. autoConfigure(material: NodeMaterial): void;
  121597. protected _buildBlock(state: NodeMaterialBuildState): this;
  121598. protected _dumpPropertiesCode(): string;
  121599. serialize(): any;
  121600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121601. }
  121602. }
  121603. declare module BABYLON {
  121604. /**
  121605. * Block used to discard a pixel if a value is smaller than a cutoff
  121606. */
  121607. export class DiscardBlock extends NodeMaterialBlock {
  121608. /**
  121609. * Create a new DiscardBlock
  121610. * @param name defines the block name
  121611. */
  121612. constructor(name: string);
  121613. /**
  121614. * Gets the current class name
  121615. * @returns the class name
  121616. */
  121617. getClassName(): string;
  121618. /**
  121619. * Gets the color input component
  121620. */
  121621. readonly value: NodeMaterialConnectionPoint;
  121622. /**
  121623. * Gets the cutoff input component
  121624. */
  121625. readonly cutoff: NodeMaterialConnectionPoint;
  121626. protected _buildBlock(state: NodeMaterialBuildState): this;
  121627. }
  121628. }
  121629. declare module BABYLON {
  121630. /**
  121631. * Block used to add support for scene fog
  121632. */
  121633. export class FogBlock extends NodeMaterialBlock {
  121634. private _fogDistanceName;
  121635. private _fogParameters;
  121636. /**
  121637. * Create a new FogBlock
  121638. * @param name defines the block name
  121639. */
  121640. constructor(name: string);
  121641. /**
  121642. * Gets the current class name
  121643. * @returns the class name
  121644. */
  121645. getClassName(): string;
  121646. /**
  121647. * Gets the world position input component
  121648. */
  121649. readonly worldPosition: NodeMaterialConnectionPoint;
  121650. /**
  121651. * Gets the view input component
  121652. */
  121653. readonly view: NodeMaterialConnectionPoint;
  121654. /**
  121655. * Gets the color input component
  121656. */
  121657. readonly input: NodeMaterialConnectionPoint;
  121658. /**
  121659. * Gets the fog color input component
  121660. */
  121661. readonly fogColor: NodeMaterialConnectionPoint;
  121662. /**
  121663. * Gets the output component
  121664. */
  121665. readonly output: NodeMaterialConnectionPoint;
  121666. autoConfigure(material: NodeMaterial): void;
  121667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121669. protected _buildBlock(state: NodeMaterialBuildState): this;
  121670. }
  121671. }
  121672. declare module BABYLON {
  121673. /**
  121674. * Block used to add light in the fragment shader
  121675. */
  121676. export class LightBlock extends NodeMaterialBlock {
  121677. private _lightId;
  121678. /**
  121679. * Gets or sets the light associated with this block
  121680. */
  121681. light: Nullable<Light>;
  121682. /**
  121683. * Create a new LightBlock
  121684. * @param name defines the block name
  121685. */
  121686. constructor(name: string);
  121687. /**
  121688. * Gets the current class name
  121689. * @returns the class name
  121690. */
  121691. getClassName(): string;
  121692. /**
  121693. * Gets the world position input component
  121694. */
  121695. readonly worldPosition: NodeMaterialConnectionPoint;
  121696. /**
  121697. * Gets the world normal input component
  121698. */
  121699. readonly worldNormal: NodeMaterialConnectionPoint;
  121700. /**
  121701. * Gets the camera (or eye) position component
  121702. */
  121703. readonly cameraPosition: NodeMaterialConnectionPoint;
  121704. /**
  121705. * Gets the glossiness component
  121706. */
  121707. readonly glossiness: NodeMaterialConnectionPoint;
  121708. /**
  121709. * Gets the glossinness power component
  121710. */
  121711. readonly glossPower: NodeMaterialConnectionPoint;
  121712. /**
  121713. * Gets the diffuse color component
  121714. */
  121715. readonly diffuseColor: NodeMaterialConnectionPoint;
  121716. /**
  121717. * Gets the specular color component
  121718. */
  121719. readonly specularColor: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the diffuse output component
  121722. */
  121723. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121724. /**
  121725. * Gets the specular output component
  121726. */
  121727. readonly specularOutput: NodeMaterialConnectionPoint;
  121728. autoConfigure(material: NodeMaterial): void;
  121729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121730. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121732. private _injectVertexCode;
  121733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121734. serialize(): any;
  121735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121736. }
  121737. }
  121738. declare module BABYLON {
  121739. /**
  121740. * Block used to multiply 2 values
  121741. */
  121742. export class MultiplyBlock extends NodeMaterialBlock {
  121743. /**
  121744. * Creates a new MultiplyBlock
  121745. * @param name defines the block name
  121746. */
  121747. constructor(name: string);
  121748. /**
  121749. * Gets the current class name
  121750. * @returns the class name
  121751. */
  121752. getClassName(): string;
  121753. /**
  121754. * Gets the left operand input component
  121755. */
  121756. readonly left: NodeMaterialConnectionPoint;
  121757. /**
  121758. * Gets the right operand input component
  121759. */
  121760. readonly right: NodeMaterialConnectionPoint;
  121761. /**
  121762. * Gets the output component
  121763. */
  121764. readonly output: NodeMaterialConnectionPoint;
  121765. protected _buildBlock(state: NodeMaterialBuildState): this;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * Block used to add 2 vectors
  121771. */
  121772. export class AddBlock extends NodeMaterialBlock {
  121773. /**
  121774. * Creates a new AddBlock
  121775. * @param name defines the block name
  121776. */
  121777. constructor(name: string);
  121778. /**
  121779. * Gets the current class name
  121780. * @returns the class name
  121781. */
  121782. getClassName(): string;
  121783. /**
  121784. * Gets the left operand input component
  121785. */
  121786. readonly left: NodeMaterialConnectionPoint;
  121787. /**
  121788. * Gets the right operand input component
  121789. */
  121790. readonly right: NodeMaterialConnectionPoint;
  121791. /**
  121792. * Gets the output component
  121793. */
  121794. readonly output: NodeMaterialConnectionPoint;
  121795. protected _buildBlock(state: NodeMaterialBuildState): this;
  121796. }
  121797. }
  121798. declare module BABYLON {
  121799. /**
  121800. * Block used to scale a vector by a float
  121801. */
  121802. export class ScaleBlock extends NodeMaterialBlock {
  121803. /**
  121804. * Creates a new ScaleBlock
  121805. * @param name defines the block name
  121806. */
  121807. constructor(name: string);
  121808. /**
  121809. * Gets the current class name
  121810. * @returns the class name
  121811. */
  121812. getClassName(): string;
  121813. /**
  121814. * Gets the input component
  121815. */
  121816. readonly input: NodeMaterialConnectionPoint;
  121817. /**
  121818. * Gets the factor input component
  121819. */
  121820. readonly factor: NodeMaterialConnectionPoint;
  121821. /**
  121822. * Gets the output component
  121823. */
  121824. readonly output: NodeMaterialConnectionPoint;
  121825. protected _buildBlock(state: NodeMaterialBuildState): this;
  121826. }
  121827. }
  121828. declare module BABYLON {
  121829. /**
  121830. * Block used to clamp a float
  121831. */
  121832. export class ClampBlock extends NodeMaterialBlock {
  121833. /** Gets or sets the minimum range */
  121834. minimum: number;
  121835. /** Gets or sets the maximum range */
  121836. maximum: number;
  121837. /**
  121838. * Creates a new ClampBlock
  121839. * @param name defines the block name
  121840. */
  121841. constructor(name: string);
  121842. /**
  121843. * Gets the current class name
  121844. * @returns the class name
  121845. */
  121846. getClassName(): string;
  121847. /**
  121848. * Gets the value input component
  121849. */
  121850. readonly value: NodeMaterialConnectionPoint;
  121851. /**
  121852. * Gets the output component
  121853. */
  121854. readonly output: NodeMaterialConnectionPoint;
  121855. protected _buildBlock(state: NodeMaterialBuildState): this;
  121856. protected _dumpPropertiesCode(): string;
  121857. serialize(): any;
  121858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121859. }
  121860. }
  121861. declare module BABYLON {
  121862. /**
  121863. * Block used to apply a cross product between 2 vectors
  121864. */
  121865. export class CrossBlock extends NodeMaterialBlock {
  121866. /**
  121867. * Creates a new CrossBlock
  121868. * @param name defines the block name
  121869. */
  121870. constructor(name: string);
  121871. /**
  121872. * Gets the current class name
  121873. * @returns the class name
  121874. */
  121875. getClassName(): string;
  121876. /**
  121877. * Gets the left operand input component
  121878. */
  121879. readonly left: NodeMaterialConnectionPoint;
  121880. /**
  121881. * Gets the right operand input component
  121882. */
  121883. readonly right: NodeMaterialConnectionPoint;
  121884. /**
  121885. * Gets the output component
  121886. */
  121887. readonly output: NodeMaterialConnectionPoint;
  121888. protected _buildBlock(state: NodeMaterialBuildState): this;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * Block used to apply a dot product between 2 vectors
  121894. */
  121895. export class DotBlock extends NodeMaterialBlock {
  121896. /**
  121897. * Creates a new DotBlock
  121898. * @param name defines the block name
  121899. */
  121900. constructor(name: string);
  121901. /**
  121902. * Gets the current class name
  121903. * @returns the class name
  121904. */
  121905. getClassName(): string;
  121906. /**
  121907. * Gets the left operand input component
  121908. */
  121909. readonly left: NodeMaterialConnectionPoint;
  121910. /**
  121911. * Gets the right operand input component
  121912. */
  121913. readonly right: NodeMaterialConnectionPoint;
  121914. /**
  121915. * Gets the output component
  121916. */
  121917. readonly output: NodeMaterialConnectionPoint;
  121918. protected _buildBlock(state: NodeMaterialBuildState): this;
  121919. }
  121920. }
  121921. declare module BABYLON {
  121922. /**
  121923. * Block used to remap a float from a range to a new one
  121924. */
  121925. export class RemapBlock extends NodeMaterialBlock {
  121926. /**
  121927. * Gets or sets the source range
  121928. */
  121929. sourceRange: Vector2;
  121930. /**
  121931. * Gets or sets the target range
  121932. */
  121933. targetRange: Vector2;
  121934. /**
  121935. * Creates a new RemapBlock
  121936. * @param name defines the block name
  121937. */
  121938. constructor(name: string);
  121939. /**
  121940. * Gets the current class name
  121941. * @returns the class name
  121942. */
  121943. getClassName(): string;
  121944. /**
  121945. * Gets the input component
  121946. */
  121947. readonly input: NodeMaterialConnectionPoint;
  121948. /**
  121949. * Gets the source min input component
  121950. */
  121951. readonly sourceMin: NodeMaterialConnectionPoint;
  121952. /**
  121953. * Gets the source max input component
  121954. */
  121955. readonly sourceMax: NodeMaterialConnectionPoint;
  121956. /**
  121957. * Gets the target min input component
  121958. */
  121959. readonly targetMin: NodeMaterialConnectionPoint;
  121960. /**
  121961. * Gets the target max input component
  121962. */
  121963. readonly targetMax: NodeMaterialConnectionPoint;
  121964. /**
  121965. * Gets the output component
  121966. */
  121967. readonly output: NodeMaterialConnectionPoint;
  121968. protected _buildBlock(state: NodeMaterialBuildState): this;
  121969. protected _dumpPropertiesCode(): string;
  121970. serialize(): any;
  121971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121972. }
  121973. }
  121974. declare module BABYLON {
  121975. /**
  121976. * Block used to normalize a vector
  121977. */
  121978. export class NormalizeBlock extends NodeMaterialBlock {
  121979. /**
  121980. * Creates a new NormalizeBlock
  121981. * @param name defines the block name
  121982. */
  121983. constructor(name: string);
  121984. /**
  121985. * Gets the current class name
  121986. * @returns the class name
  121987. */
  121988. getClassName(): string;
  121989. /**
  121990. * Gets the input component
  121991. */
  121992. readonly input: NodeMaterialConnectionPoint;
  121993. /**
  121994. * Gets the output component
  121995. */
  121996. readonly output: NodeMaterialConnectionPoint;
  121997. protected _buildBlock(state: NodeMaterialBuildState): this;
  121998. }
  121999. }
  122000. declare module BABYLON {
  122001. /**
  122002. * Operations supported by the Trigonometry block
  122003. */
  122004. export enum TrigonometryBlockOperations {
  122005. /** Cos */
  122006. Cos = 0,
  122007. /** Sin */
  122008. Sin = 1,
  122009. /** Abs */
  122010. Abs = 2,
  122011. /** Exp */
  122012. Exp = 3,
  122013. /** Exp2 */
  122014. Exp2 = 4,
  122015. /** Round */
  122016. Round = 5,
  122017. /** Floor */
  122018. Floor = 6,
  122019. /** Ceiling */
  122020. Ceiling = 7,
  122021. /** Square root */
  122022. Sqrt = 8,
  122023. /** Log */
  122024. Log = 9,
  122025. /** Tangent */
  122026. Tan = 10,
  122027. /** Arc tangent */
  122028. ArcTan = 11,
  122029. /** Arc cosinus */
  122030. ArcCos = 12,
  122031. /** Arc sinus */
  122032. ArcSin = 13,
  122033. /** Fraction */
  122034. Fract = 14,
  122035. /** Sign */
  122036. Sign = 15,
  122037. /** To radians (from degrees) */
  122038. Radians = 16,
  122039. /** To degrees (from radians) */
  122040. Degrees = 17
  122041. }
  122042. /**
  122043. * Block used to apply trigonometry operation to floats
  122044. */
  122045. export class TrigonometryBlock extends NodeMaterialBlock {
  122046. /**
  122047. * Gets or sets the operation applied by the block
  122048. */
  122049. operation: TrigonometryBlockOperations;
  122050. /**
  122051. * Creates a new TrigonometryBlock
  122052. * @param name defines the block name
  122053. */
  122054. constructor(name: string);
  122055. /**
  122056. * Gets the current class name
  122057. * @returns the class name
  122058. */
  122059. getClassName(): string;
  122060. /**
  122061. * Gets the input component
  122062. */
  122063. readonly input: NodeMaterialConnectionPoint;
  122064. /**
  122065. * Gets the output component
  122066. */
  122067. readonly output: NodeMaterialConnectionPoint;
  122068. protected _buildBlock(state: NodeMaterialBuildState): this;
  122069. serialize(): any;
  122070. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122071. }
  122072. }
  122073. declare module BABYLON {
  122074. /**
  122075. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122076. */
  122077. export class ColorMergerBlock extends NodeMaterialBlock {
  122078. /**
  122079. * Create a new ColorMergerBlock
  122080. * @param name defines the block name
  122081. */
  122082. constructor(name: string);
  122083. /**
  122084. * Gets the current class name
  122085. * @returns the class name
  122086. */
  122087. getClassName(): string;
  122088. /**
  122089. * Gets the r component (input)
  122090. */
  122091. readonly r: NodeMaterialConnectionPoint;
  122092. /**
  122093. * Gets the g component (input)
  122094. */
  122095. readonly g: NodeMaterialConnectionPoint;
  122096. /**
  122097. * Gets the b component (input)
  122098. */
  122099. readonly b: NodeMaterialConnectionPoint;
  122100. /**
  122101. * Gets the a component (input)
  122102. */
  122103. readonly a: NodeMaterialConnectionPoint;
  122104. /**
  122105. * Gets the rgba component (output)
  122106. */
  122107. readonly rgba: NodeMaterialConnectionPoint;
  122108. /**
  122109. * Gets the rgb component (output)
  122110. */
  122111. readonly rgb: NodeMaterialConnectionPoint;
  122112. protected _buildBlock(state: NodeMaterialBuildState): this;
  122113. }
  122114. }
  122115. declare module BABYLON {
  122116. /**
  122117. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122118. */
  122119. export class VectorMergerBlock extends NodeMaterialBlock {
  122120. /**
  122121. * Create a new VectorMergerBlock
  122122. * @param name defines the block name
  122123. */
  122124. constructor(name: string);
  122125. /**
  122126. * Gets the current class name
  122127. * @returns the class name
  122128. */
  122129. getClassName(): string;
  122130. /**
  122131. * Gets the x component (input)
  122132. */
  122133. readonly x: NodeMaterialConnectionPoint;
  122134. /**
  122135. * Gets the y component (input)
  122136. */
  122137. readonly y: NodeMaterialConnectionPoint;
  122138. /**
  122139. * Gets the z component (input)
  122140. */
  122141. readonly z: NodeMaterialConnectionPoint;
  122142. /**
  122143. * Gets the w component (input)
  122144. */
  122145. readonly w: NodeMaterialConnectionPoint;
  122146. /**
  122147. * Gets the xyzw component (output)
  122148. */
  122149. readonly xyzw: NodeMaterialConnectionPoint;
  122150. /**
  122151. * Gets the xyz component (output)
  122152. */
  122153. readonly xyz: NodeMaterialConnectionPoint;
  122154. /**
  122155. * Gets the xy component (output)
  122156. */
  122157. readonly xy: NodeMaterialConnectionPoint;
  122158. protected _buildBlock(state: NodeMaterialBuildState): this;
  122159. }
  122160. }
  122161. declare module BABYLON {
  122162. /**
  122163. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122164. */
  122165. export class ColorSplitterBlock extends NodeMaterialBlock {
  122166. /**
  122167. * Create a new ColorSplitterBlock
  122168. * @param name defines the block name
  122169. */
  122170. constructor(name: string);
  122171. /**
  122172. * Gets the current class name
  122173. * @returns the class name
  122174. */
  122175. getClassName(): string;
  122176. /**
  122177. * Gets the rgba component (input)
  122178. */
  122179. readonly rgba: NodeMaterialConnectionPoint;
  122180. /**
  122181. * Gets the rgb component (input)
  122182. */
  122183. readonly rgbIn: NodeMaterialConnectionPoint;
  122184. /**
  122185. * Gets the rgb component (output)
  122186. */
  122187. readonly rgbOut: NodeMaterialConnectionPoint;
  122188. /**
  122189. * Gets the r component (output)
  122190. */
  122191. readonly r: NodeMaterialConnectionPoint;
  122192. /**
  122193. * Gets the g component (output)
  122194. */
  122195. readonly g: NodeMaterialConnectionPoint;
  122196. /**
  122197. * Gets the b component (output)
  122198. */
  122199. readonly b: NodeMaterialConnectionPoint;
  122200. /**
  122201. * Gets the a component (output)
  122202. */
  122203. readonly a: NodeMaterialConnectionPoint;
  122204. protected _inputRename(name: string): string;
  122205. protected _outputRename(name: string): string;
  122206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122207. }
  122208. }
  122209. declare module BABYLON {
  122210. /**
  122211. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122212. */
  122213. export class VectorSplitterBlock extends NodeMaterialBlock {
  122214. /**
  122215. * Create a new VectorSplitterBlock
  122216. * @param name defines the block name
  122217. */
  122218. constructor(name: string);
  122219. /**
  122220. * Gets the current class name
  122221. * @returns the class name
  122222. */
  122223. getClassName(): string;
  122224. /**
  122225. * Gets the xyzw component (input)
  122226. */
  122227. readonly xyzw: NodeMaterialConnectionPoint;
  122228. /**
  122229. * Gets the xyz component (input)
  122230. */
  122231. readonly xyzIn: NodeMaterialConnectionPoint;
  122232. /**
  122233. * Gets the xy component (input)
  122234. */
  122235. readonly xyIn: NodeMaterialConnectionPoint;
  122236. /**
  122237. * Gets the xyz component (output)
  122238. */
  122239. readonly xyzOut: NodeMaterialConnectionPoint;
  122240. /**
  122241. * Gets the xy component (output)
  122242. */
  122243. readonly xyOut: NodeMaterialConnectionPoint;
  122244. /**
  122245. * Gets the x component (output)
  122246. */
  122247. readonly x: NodeMaterialConnectionPoint;
  122248. /**
  122249. * Gets the y component (output)
  122250. */
  122251. readonly y: NodeMaterialConnectionPoint;
  122252. /**
  122253. * Gets the z component (output)
  122254. */
  122255. readonly z: NodeMaterialConnectionPoint;
  122256. /**
  122257. * Gets the w component (output)
  122258. */
  122259. readonly w: NodeMaterialConnectionPoint;
  122260. protected _inputRename(name: string): string;
  122261. protected _outputRename(name: string): string;
  122262. protected _buildBlock(state: NodeMaterialBuildState): this;
  122263. }
  122264. }
  122265. declare module BABYLON {
  122266. /**
  122267. * Block used to lerp between 2 values
  122268. */
  122269. export class LerpBlock extends NodeMaterialBlock {
  122270. /**
  122271. * Creates a new LerpBlock
  122272. * @param name defines the block name
  122273. */
  122274. constructor(name: string);
  122275. /**
  122276. * Gets the current class name
  122277. * @returns the class name
  122278. */
  122279. getClassName(): string;
  122280. /**
  122281. * Gets the left operand input component
  122282. */
  122283. readonly left: NodeMaterialConnectionPoint;
  122284. /**
  122285. * Gets the right operand input component
  122286. */
  122287. readonly right: NodeMaterialConnectionPoint;
  122288. /**
  122289. * Gets the gradient operand input component
  122290. */
  122291. readonly gradient: NodeMaterialConnectionPoint;
  122292. /**
  122293. * Gets the output component
  122294. */
  122295. readonly output: NodeMaterialConnectionPoint;
  122296. protected _buildBlock(state: NodeMaterialBuildState): this;
  122297. }
  122298. }
  122299. declare module BABYLON {
  122300. /**
  122301. * Block used to divide 2 vectors
  122302. */
  122303. export class DivideBlock extends NodeMaterialBlock {
  122304. /**
  122305. * Creates a new DivideBlock
  122306. * @param name defines the block name
  122307. */
  122308. constructor(name: string);
  122309. /**
  122310. * Gets the current class name
  122311. * @returns the class name
  122312. */
  122313. getClassName(): string;
  122314. /**
  122315. * Gets the left operand input component
  122316. */
  122317. readonly left: NodeMaterialConnectionPoint;
  122318. /**
  122319. * Gets the right operand input component
  122320. */
  122321. readonly right: NodeMaterialConnectionPoint;
  122322. /**
  122323. * Gets the output component
  122324. */
  122325. readonly output: NodeMaterialConnectionPoint;
  122326. protected _buildBlock(state: NodeMaterialBuildState): this;
  122327. }
  122328. }
  122329. declare module BABYLON {
  122330. /**
  122331. * Block used to subtract 2 vectors
  122332. */
  122333. export class SubtractBlock extends NodeMaterialBlock {
  122334. /**
  122335. * Creates a new SubtractBlock
  122336. * @param name defines the block name
  122337. */
  122338. constructor(name: string);
  122339. /**
  122340. * Gets the current class name
  122341. * @returns the class name
  122342. */
  122343. getClassName(): string;
  122344. /**
  122345. * Gets the left operand input component
  122346. */
  122347. readonly left: NodeMaterialConnectionPoint;
  122348. /**
  122349. * Gets the right operand input component
  122350. */
  122351. readonly right: NodeMaterialConnectionPoint;
  122352. /**
  122353. * Gets the output component
  122354. */
  122355. readonly output: NodeMaterialConnectionPoint;
  122356. protected _buildBlock(state: NodeMaterialBuildState): this;
  122357. }
  122358. }
  122359. declare module BABYLON {
  122360. /**
  122361. * Block used to step a value
  122362. */
  122363. export class StepBlock extends NodeMaterialBlock {
  122364. /**
  122365. * Creates a new StepBlock
  122366. * @param name defines the block name
  122367. */
  122368. constructor(name: string);
  122369. /**
  122370. * Gets the current class name
  122371. * @returns the class name
  122372. */
  122373. getClassName(): string;
  122374. /**
  122375. * Gets the value operand input component
  122376. */
  122377. readonly value: NodeMaterialConnectionPoint;
  122378. /**
  122379. * Gets the edge operand input component
  122380. */
  122381. readonly edge: NodeMaterialConnectionPoint;
  122382. /**
  122383. * Gets the output component
  122384. */
  122385. readonly output: NodeMaterialConnectionPoint;
  122386. protected _buildBlock(state: NodeMaterialBuildState): this;
  122387. }
  122388. }
  122389. declare module BABYLON {
  122390. /**
  122391. * Block used to get the opposite (1 - x) of a value
  122392. */
  122393. export class OneMinusBlock extends NodeMaterialBlock {
  122394. /**
  122395. * Creates a new OneMinusBlock
  122396. * @param name defines the block name
  122397. */
  122398. constructor(name: string);
  122399. /**
  122400. * Gets the current class name
  122401. * @returns the class name
  122402. */
  122403. getClassName(): string;
  122404. /**
  122405. * Gets the input component
  122406. */
  122407. readonly input: NodeMaterialConnectionPoint;
  122408. /**
  122409. * Gets the output component
  122410. */
  122411. readonly output: NodeMaterialConnectionPoint;
  122412. protected _buildBlock(state: NodeMaterialBuildState): this;
  122413. }
  122414. }
  122415. declare module BABYLON {
  122416. /**
  122417. * Block used to get the view direction
  122418. */
  122419. export class ViewDirectionBlock extends NodeMaterialBlock {
  122420. /**
  122421. * Creates a new ViewDirectionBlock
  122422. * @param name defines the block name
  122423. */
  122424. constructor(name: string);
  122425. /**
  122426. * Gets the current class name
  122427. * @returns the class name
  122428. */
  122429. getClassName(): string;
  122430. /**
  122431. * Gets the world position component
  122432. */
  122433. readonly worldPosition: NodeMaterialConnectionPoint;
  122434. /**
  122435. * Gets the camera position component
  122436. */
  122437. readonly cameraPosition: NodeMaterialConnectionPoint;
  122438. /**
  122439. * Gets the output component
  122440. */
  122441. readonly output: NodeMaterialConnectionPoint;
  122442. autoConfigure(material: NodeMaterial): void;
  122443. protected _buildBlock(state: NodeMaterialBuildState): this;
  122444. }
  122445. }
  122446. declare module BABYLON {
  122447. /**
  122448. * Block used to compute fresnel value
  122449. */
  122450. export class FresnelBlock extends NodeMaterialBlock {
  122451. /**
  122452. * Create a new FresnelBlock
  122453. * @param name defines the block name
  122454. */
  122455. constructor(name: string);
  122456. /**
  122457. * Gets the current class name
  122458. * @returns the class name
  122459. */
  122460. getClassName(): string;
  122461. /**
  122462. * Gets the world normal input component
  122463. */
  122464. readonly worldNormal: NodeMaterialConnectionPoint;
  122465. /**
  122466. * Gets the view direction input component
  122467. */
  122468. readonly viewDirection: NodeMaterialConnectionPoint;
  122469. /**
  122470. * Gets the bias input component
  122471. */
  122472. readonly bias: NodeMaterialConnectionPoint;
  122473. /**
  122474. * Gets the camera (or eye) position component
  122475. */
  122476. readonly power: NodeMaterialConnectionPoint;
  122477. /**
  122478. * Gets the fresnel output component
  122479. */
  122480. readonly fresnel: NodeMaterialConnectionPoint;
  122481. autoConfigure(material: NodeMaterial): void;
  122482. protected _buildBlock(state: NodeMaterialBuildState): this;
  122483. }
  122484. }
  122485. declare module BABYLON {
  122486. /**
  122487. * Block used to get the max of 2 values
  122488. */
  122489. export class MaxBlock extends NodeMaterialBlock {
  122490. /**
  122491. * Creates a new MaxBlock
  122492. * @param name defines the block name
  122493. */
  122494. constructor(name: string);
  122495. /**
  122496. * Gets the current class name
  122497. * @returns the class name
  122498. */
  122499. getClassName(): string;
  122500. /**
  122501. * Gets the left operand input component
  122502. */
  122503. readonly left: NodeMaterialConnectionPoint;
  122504. /**
  122505. * Gets the right operand input component
  122506. */
  122507. readonly right: NodeMaterialConnectionPoint;
  122508. /**
  122509. * Gets the output component
  122510. */
  122511. readonly output: NodeMaterialConnectionPoint;
  122512. protected _buildBlock(state: NodeMaterialBuildState): this;
  122513. }
  122514. }
  122515. declare module BABYLON {
  122516. /**
  122517. * Block used to get the min of 2 values
  122518. */
  122519. export class MinBlock extends NodeMaterialBlock {
  122520. /**
  122521. * Creates a new MinBlock
  122522. * @param name defines the block name
  122523. */
  122524. constructor(name: string);
  122525. /**
  122526. * Gets the current class name
  122527. * @returns the class name
  122528. */
  122529. getClassName(): string;
  122530. /**
  122531. * Gets the left operand input component
  122532. */
  122533. readonly left: NodeMaterialConnectionPoint;
  122534. /**
  122535. * Gets the right operand input component
  122536. */
  122537. readonly right: NodeMaterialConnectionPoint;
  122538. /**
  122539. * Gets the output component
  122540. */
  122541. readonly output: NodeMaterialConnectionPoint;
  122542. protected _buildBlock(state: NodeMaterialBuildState): this;
  122543. }
  122544. }
  122545. declare module BABYLON {
  122546. /**
  122547. * Block used to get the distance between 2 values
  122548. */
  122549. export class DistanceBlock extends NodeMaterialBlock {
  122550. /**
  122551. * Creates a new DistanceBlock
  122552. * @param name defines the block name
  122553. */
  122554. constructor(name: string);
  122555. /**
  122556. * Gets the current class name
  122557. * @returns the class name
  122558. */
  122559. getClassName(): string;
  122560. /**
  122561. * Gets the left operand input component
  122562. */
  122563. readonly left: NodeMaterialConnectionPoint;
  122564. /**
  122565. * Gets the right operand input component
  122566. */
  122567. readonly right: NodeMaterialConnectionPoint;
  122568. /**
  122569. * Gets the output component
  122570. */
  122571. readonly output: NodeMaterialConnectionPoint;
  122572. protected _buildBlock(state: NodeMaterialBuildState): this;
  122573. }
  122574. }
  122575. declare module BABYLON {
  122576. /**
  122577. * Block used to get the length of a vector
  122578. */
  122579. export class LengthBlock extends NodeMaterialBlock {
  122580. /**
  122581. * Creates a new LengthBlock
  122582. * @param name defines the block name
  122583. */
  122584. constructor(name: string);
  122585. /**
  122586. * Gets the current class name
  122587. * @returns the class name
  122588. */
  122589. getClassName(): string;
  122590. /**
  122591. * Gets the value input component
  122592. */
  122593. readonly value: NodeMaterialConnectionPoint;
  122594. /**
  122595. * Gets the output component
  122596. */
  122597. readonly output: NodeMaterialConnectionPoint;
  122598. protected _buildBlock(state: NodeMaterialBuildState): this;
  122599. }
  122600. }
  122601. declare module BABYLON {
  122602. /**
  122603. * Block used to get negative version of a value (i.e. x * -1)
  122604. */
  122605. export class NegateBlock extends NodeMaterialBlock {
  122606. /**
  122607. * Creates a new NegateBlock
  122608. * @param name defines the block name
  122609. */
  122610. constructor(name: string);
  122611. /**
  122612. * Gets the current class name
  122613. * @returns the class name
  122614. */
  122615. getClassName(): string;
  122616. /**
  122617. * Gets the value input component
  122618. */
  122619. readonly value: NodeMaterialConnectionPoint;
  122620. /**
  122621. * Gets the output component
  122622. */
  122623. readonly output: NodeMaterialConnectionPoint;
  122624. protected _buildBlock(state: NodeMaterialBuildState): this;
  122625. }
  122626. }
  122627. declare module BABYLON {
  122628. /**
  122629. * Block used to get the value of the first parameter raised to the power of the second
  122630. */
  122631. export class PowBlock extends NodeMaterialBlock {
  122632. /**
  122633. * Creates a new PowBlock
  122634. * @param name defines the block name
  122635. */
  122636. constructor(name: string);
  122637. /**
  122638. * Gets the current class name
  122639. * @returns the class name
  122640. */
  122641. getClassName(): string;
  122642. /**
  122643. * Gets the value operand input component
  122644. */
  122645. readonly value: NodeMaterialConnectionPoint;
  122646. /**
  122647. * Gets the power operand input component
  122648. */
  122649. readonly power: NodeMaterialConnectionPoint;
  122650. /**
  122651. * Gets the output component
  122652. */
  122653. readonly output: NodeMaterialConnectionPoint;
  122654. protected _buildBlock(state: NodeMaterialBuildState): this;
  122655. }
  122656. }
  122657. declare module BABYLON {
  122658. /**
  122659. * Block used to get a random number
  122660. */
  122661. export class RandomNumberBlock extends NodeMaterialBlock {
  122662. /**
  122663. * Creates a new RandomNumberBlock
  122664. * @param name defines the block name
  122665. */
  122666. constructor(name: string);
  122667. /**
  122668. * Gets the current class name
  122669. * @returns the class name
  122670. */
  122671. getClassName(): string;
  122672. /**
  122673. * Gets the seed input component
  122674. */
  122675. readonly seed: NodeMaterialConnectionPoint;
  122676. /**
  122677. * Gets the output component
  122678. */
  122679. readonly output: NodeMaterialConnectionPoint;
  122680. protected _buildBlock(state: NodeMaterialBuildState): this;
  122681. }
  122682. }
  122683. declare module BABYLON {
  122684. /**
  122685. * Block used to compute arc tangent of 2 values
  122686. */
  122687. export class ArcTan2Block extends NodeMaterialBlock {
  122688. /**
  122689. * Creates a new ArcTan2Block
  122690. * @param name defines the block name
  122691. */
  122692. constructor(name: string);
  122693. /**
  122694. * Gets the current class name
  122695. * @returns the class name
  122696. */
  122697. getClassName(): string;
  122698. /**
  122699. * Gets the x operand input component
  122700. */
  122701. readonly x: NodeMaterialConnectionPoint;
  122702. /**
  122703. * Gets the y operand input component
  122704. */
  122705. readonly y: NodeMaterialConnectionPoint;
  122706. /**
  122707. * Gets the output component
  122708. */
  122709. readonly output: NodeMaterialConnectionPoint;
  122710. protected _buildBlock(state: NodeMaterialBuildState): this;
  122711. }
  122712. }
  122713. declare module BABYLON {
  122714. /**
  122715. * Block used to smooth step a value
  122716. */
  122717. export class SmoothStepBlock extends NodeMaterialBlock {
  122718. /**
  122719. * Creates a new SmoothStepBlock
  122720. * @param name defines the block name
  122721. */
  122722. constructor(name: string);
  122723. /**
  122724. * Gets the current class name
  122725. * @returns the class name
  122726. */
  122727. getClassName(): string;
  122728. /**
  122729. * Gets the value operand input component
  122730. */
  122731. readonly value: NodeMaterialConnectionPoint;
  122732. /**
  122733. * Gets the first edge operand input component
  122734. */
  122735. readonly edge0: NodeMaterialConnectionPoint;
  122736. /**
  122737. * Gets the second edge operand input component
  122738. */
  122739. readonly edge1: NodeMaterialConnectionPoint;
  122740. /**
  122741. * Gets the output component
  122742. */
  122743. readonly output: NodeMaterialConnectionPoint;
  122744. protected _buildBlock(state: NodeMaterialBuildState): this;
  122745. }
  122746. }
  122747. declare module BABYLON {
  122748. /**
  122749. * Block used to get the reciprocal (1 / x) of a value
  122750. */
  122751. export class ReciprocalBlock extends NodeMaterialBlock {
  122752. /**
  122753. * Creates a new ReciprocalBlock
  122754. * @param name defines the block name
  122755. */
  122756. constructor(name: string);
  122757. /**
  122758. * Gets the current class name
  122759. * @returns the class name
  122760. */
  122761. getClassName(): string;
  122762. /**
  122763. * Gets the input component
  122764. */
  122765. readonly input: NodeMaterialConnectionPoint;
  122766. /**
  122767. * Gets the output component
  122768. */
  122769. readonly output: NodeMaterialConnectionPoint;
  122770. protected _buildBlock(state: NodeMaterialBuildState): this;
  122771. }
  122772. }
  122773. declare module BABYLON {
  122774. /**
  122775. * Block used to replace a color by another one
  122776. */
  122777. export class ReplaceColorBlock extends NodeMaterialBlock {
  122778. /**
  122779. * Creates a new ReplaceColorBlock
  122780. * @param name defines the block name
  122781. */
  122782. constructor(name: string);
  122783. /**
  122784. * Gets the current class name
  122785. * @returns the class name
  122786. */
  122787. getClassName(): string;
  122788. /**
  122789. * Gets the value input component
  122790. */
  122791. readonly value: NodeMaterialConnectionPoint;
  122792. /**
  122793. * Gets the reference input component
  122794. */
  122795. readonly reference: NodeMaterialConnectionPoint;
  122796. /**
  122797. * Gets the distance input component
  122798. */
  122799. readonly distance: NodeMaterialConnectionPoint;
  122800. /**
  122801. * Gets the replacement input component
  122802. */
  122803. readonly replacement: NodeMaterialConnectionPoint;
  122804. /**
  122805. * Gets the output component
  122806. */
  122807. readonly output: NodeMaterialConnectionPoint;
  122808. protected _buildBlock(state: NodeMaterialBuildState): this;
  122809. }
  122810. }
  122811. declare module BABYLON {
  122812. /**
  122813. * Block used to posterize a value
  122814. * @see https://en.wikipedia.org/wiki/Posterization
  122815. */
  122816. export class PosterizeBlock extends NodeMaterialBlock {
  122817. /**
  122818. * Creates a new PosterizeBlock
  122819. * @param name defines the block name
  122820. */
  122821. constructor(name: string);
  122822. /**
  122823. * Gets the current class name
  122824. * @returns the class name
  122825. */
  122826. getClassName(): string;
  122827. /**
  122828. * Gets the value input component
  122829. */
  122830. readonly value: NodeMaterialConnectionPoint;
  122831. /**
  122832. * Gets the steps input component
  122833. */
  122834. readonly steps: NodeMaterialConnectionPoint;
  122835. /**
  122836. * Gets the output component
  122837. */
  122838. readonly output: NodeMaterialConnectionPoint;
  122839. protected _buildBlock(state: NodeMaterialBuildState): this;
  122840. }
  122841. }
  122842. declare module BABYLON {
  122843. /**
  122844. * Operations supported by the Wave block
  122845. */
  122846. export enum WaveBlockKind {
  122847. /** SawTooth */
  122848. SawTooth = 0,
  122849. /** Square */
  122850. Square = 1,
  122851. /** Triangle */
  122852. Triangle = 2
  122853. }
  122854. /**
  122855. * Block used to apply wave operation to floats
  122856. */
  122857. export class WaveBlock extends NodeMaterialBlock {
  122858. /**
  122859. * Gets or sets the kibnd of wave to be applied by the block
  122860. */
  122861. kind: WaveBlockKind;
  122862. /**
  122863. * Creates a new WaveBlock
  122864. * @param name defines the block name
  122865. */
  122866. constructor(name: string);
  122867. /**
  122868. * Gets the current class name
  122869. * @returns the class name
  122870. */
  122871. getClassName(): string;
  122872. /**
  122873. * Gets the input component
  122874. */
  122875. readonly input: NodeMaterialConnectionPoint;
  122876. /**
  122877. * Gets the output component
  122878. */
  122879. readonly output: NodeMaterialConnectionPoint;
  122880. protected _buildBlock(state: NodeMaterialBuildState): this;
  122881. serialize(): any;
  122882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122883. }
  122884. }
  122885. declare module BABYLON {
  122886. /**
  122887. * Class used to store a color step for the GradientBlock
  122888. */
  122889. export class GradientBlockColorStep {
  122890. /**
  122891. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122892. */
  122893. step: number;
  122894. /**
  122895. * Gets or sets the color associated with this step
  122896. */
  122897. color: Color3;
  122898. /**
  122899. * Creates a new GradientBlockColorStep
  122900. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122901. * @param color defines the color associated with this step
  122902. */
  122903. constructor(
  122904. /**
  122905. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122906. */
  122907. step: number,
  122908. /**
  122909. * Gets or sets the color associated with this step
  122910. */
  122911. color: Color3);
  122912. }
  122913. /**
  122914. * Block used to return a color from a gradient based on an input value between 0 and 1
  122915. */
  122916. export class GradientBlock extends NodeMaterialBlock {
  122917. /**
  122918. * Gets or sets the list of color steps
  122919. */
  122920. colorSteps: GradientBlockColorStep[];
  122921. /**
  122922. * Creates a new GradientBlock
  122923. * @param name defines the block name
  122924. */
  122925. constructor(name: string);
  122926. /**
  122927. * Gets the current class name
  122928. * @returns the class name
  122929. */
  122930. getClassName(): string;
  122931. /**
  122932. * Gets the gradient input component
  122933. */
  122934. readonly gradient: NodeMaterialConnectionPoint;
  122935. /**
  122936. * Gets the output component
  122937. */
  122938. readonly output: NodeMaterialConnectionPoint;
  122939. private _writeColorConstant;
  122940. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122941. serialize(): any;
  122942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122943. protected _dumpPropertiesCode(): string;
  122944. }
  122945. }
  122946. declare module BABYLON {
  122947. /**
  122948. * Block used to normalize lerp between 2 values
  122949. */
  122950. export class NLerpBlock extends NodeMaterialBlock {
  122951. /**
  122952. * Creates a new NLerpBlock
  122953. * @param name defines the block name
  122954. */
  122955. constructor(name: string);
  122956. /**
  122957. * Gets the current class name
  122958. * @returns the class name
  122959. */
  122960. getClassName(): string;
  122961. /**
  122962. * Gets the left operand input component
  122963. */
  122964. readonly left: NodeMaterialConnectionPoint;
  122965. /**
  122966. * Gets the right operand input component
  122967. */
  122968. readonly right: NodeMaterialConnectionPoint;
  122969. /**
  122970. * Gets the gradient operand input component
  122971. */
  122972. readonly gradient: NodeMaterialConnectionPoint;
  122973. /**
  122974. * Gets the output component
  122975. */
  122976. readonly output: NodeMaterialConnectionPoint;
  122977. protected _buildBlock(state: NodeMaterialBuildState): this;
  122978. }
  122979. }
  122980. declare module BABYLON {
  122981. /**
  122982. * Effect Render Options
  122983. */
  122984. export interface IEffectRendererOptions {
  122985. /**
  122986. * Defines the vertices positions.
  122987. */
  122988. positions?: number[];
  122989. /**
  122990. * Defines the indices.
  122991. */
  122992. indices?: number[];
  122993. }
  122994. /**
  122995. * Helper class to render one or more effects
  122996. */
  122997. export class EffectRenderer {
  122998. private engine;
  122999. private static _DefaultOptions;
  123000. private _vertexBuffers;
  123001. private _indexBuffer;
  123002. private _ringBufferIndex;
  123003. private _ringScreenBuffer;
  123004. private _fullscreenViewport;
  123005. private _getNextFrameBuffer;
  123006. /**
  123007. * Creates an effect renderer
  123008. * @param engine the engine to use for rendering
  123009. * @param options defines the options of the effect renderer
  123010. */
  123011. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123012. /**
  123013. * Sets the current viewport in normalized coordinates 0-1
  123014. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123015. */
  123016. setViewport(viewport?: Viewport): void;
  123017. /**
  123018. * Binds the embedded attributes buffer to the effect.
  123019. * @param effect Defines the effect to bind the attributes for
  123020. */
  123021. bindBuffers(effect: Effect): void;
  123022. /**
  123023. * Sets the current effect wrapper to use during draw.
  123024. * The effect needs to be ready before calling this api.
  123025. * This also sets the default full screen position attribute.
  123026. * @param effectWrapper Defines the effect to draw with
  123027. */
  123028. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123029. /**
  123030. * Draws a full screen quad.
  123031. */
  123032. draw(): void;
  123033. /**
  123034. * renders one or more effects to a specified texture
  123035. * @param effectWrappers list of effects to renderer
  123036. * @param outputTexture texture to draw to, if null it will render to the screen
  123037. */
  123038. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123039. /**
  123040. * Disposes of the effect renderer
  123041. */
  123042. dispose(): void;
  123043. }
  123044. /**
  123045. * Options to create an EffectWrapper
  123046. */
  123047. interface EffectWrapperCreationOptions {
  123048. /**
  123049. * Engine to use to create the effect
  123050. */
  123051. engine: ThinEngine;
  123052. /**
  123053. * Fragment shader for the effect
  123054. */
  123055. fragmentShader: string;
  123056. /**
  123057. * Vertex shader for the effect
  123058. */
  123059. vertexShader?: string;
  123060. /**
  123061. * Attributes to use in the shader
  123062. */
  123063. attributeNames?: Array<string>;
  123064. /**
  123065. * Uniforms to use in the shader
  123066. */
  123067. uniformNames?: Array<string>;
  123068. /**
  123069. * Texture sampler names to use in the shader
  123070. */
  123071. samplerNames?: Array<string>;
  123072. /**
  123073. * The friendly name of the effect displayed in Spector.
  123074. */
  123075. name?: string;
  123076. }
  123077. /**
  123078. * Wraps an effect to be used for rendering
  123079. */
  123080. export class EffectWrapper {
  123081. /**
  123082. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123083. */
  123084. onApplyObservable: Observable<{}>;
  123085. /**
  123086. * The underlying effect
  123087. */
  123088. effect: Effect;
  123089. /**
  123090. * Creates an effect to be renderer
  123091. * @param creationOptions options to create the effect
  123092. */
  123093. constructor(creationOptions: EffectWrapperCreationOptions);
  123094. /**
  123095. * Disposes of the effect wrapper
  123096. */
  123097. dispose(): void;
  123098. }
  123099. }
  123100. declare module BABYLON {
  123101. /**
  123102. * Helper class to push actions to a pool of workers.
  123103. */
  123104. export class WorkerPool implements IDisposable {
  123105. private _workerInfos;
  123106. private _pendingActions;
  123107. /**
  123108. * Constructor
  123109. * @param workers Array of workers to use for actions
  123110. */
  123111. constructor(workers: Array<Worker>);
  123112. /**
  123113. * Terminates all workers and clears any pending actions.
  123114. */
  123115. dispose(): void;
  123116. /**
  123117. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123118. * pended until a worker has completed its action.
  123119. * @param action The action to perform. Call onComplete when the action is complete.
  123120. */
  123121. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123122. private _execute;
  123123. }
  123124. }
  123125. declare module BABYLON {
  123126. /**
  123127. * Configuration for Draco compression
  123128. */
  123129. export interface IDracoCompressionConfiguration {
  123130. /**
  123131. * Configuration for the decoder.
  123132. */
  123133. decoder: {
  123134. /**
  123135. * The url to the WebAssembly module.
  123136. */
  123137. wasmUrl?: string;
  123138. /**
  123139. * The url to the WebAssembly binary.
  123140. */
  123141. wasmBinaryUrl?: string;
  123142. /**
  123143. * The url to the fallback JavaScript module.
  123144. */
  123145. fallbackUrl?: string;
  123146. };
  123147. }
  123148. /**
  123149. * Draco compression (https://google.github.io/draco/)
  123150. *
  123151. * This class wraps the Draco module.
  123152. *
  123153. * **Encoder**
  123154. *
  123155. * The encoder is not currently implemented.
  123156. *
  123157. * **Decoder**
  123158. *
  123159. * 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.
  123160. *
  123161. * To update the configuration, use the following code:
  123162. * ```javascript
  123163. * DracoCompression.Configuration = {
  123164. * decoder: {
  123165. * wasmUrl: "<url to the WebAssembly library>",
  123166. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123167. * fallbackUrl: "<url to the fallback JavaScript library>",
  123168. * }
  123169. * };
  123170. * ```
  123171. *
  123172. * 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.
  123173. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123174. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123175. *
  123176. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123177. * ```javascript
  123178. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123179. * ```
  123180. *
  123181. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123182. */
  123183. export class DracoCompression implements IDisposable {
  123184. private _workerPoolPromise?;
  123185. private _decoderModulePromise?;
  123186. /**
  123187. * The configuration. Defaults to the following urls:
  123188. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123189. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123190. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123191. */
  123192. static Configuration: IDracoCompressionConfiguration;
  123193. /**
  123194. * Returns true if the decoder configuration is available.
  123195. */
  123196. static readonly DecoderAvailable: boolean;
  123197. /**
  123198. * Default number of workers to create when creating the draco compression object.
  123199. */
  123200. static DefaultNumWorkers: number;
  123201. private static GetDefaultNumWorkers;
  123202. private static _Default;
  123203. /**
  123204. * Default instance for the draco compression object.
  123205. */
  123206. static readonly Default: DracoCompression;
  123207. /**
  123208. * Constructor
  123209. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123210. */
  123211. constructor(numWorkers?: number);
  123212. /**
  123213. * Stop all async operations and release resources.
  123214. */
  123215. dispose(): void;
  123216. /**
  123217. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123218. * @returns a promise that resolves when ready
  123219. */
  123220. whenReadyAsync(): Promise<void>;
  123221. /**
  123222. * Decode Draco compressed mesh data to vertex data.
  123223. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123224. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123225. * @returns A promise that resolves with the decoded vertex data
  123226. */
  123227. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123228. [kind: string]: number;
  123229. }): Promise<VertexData>;
  123230. }
  123231. }
  123232. declare module BABYLON {
  123233. /**
  123234. * Class for building Constructive Solid Geometry
  123235. */
  123236. export class CSG {
  123237. private polygons;
  123238. /**
  123239. * The world matrix
  123240. */
  123241. matrix: Matrix;
  123242. /**
  123243. * Stores the position
  123244. */
  123245. position: Vector3;
  123246. /**
  123247. * Stores the rotation
  123248. */
  123249. rotation: Vector3;
  123250. /**
  123251. * Stores the rotation quaternion
  123252. */
  123253. rotationQuaternion: Nullable<Quaternion>;
  123254. /**
  123255. * Stores the scaling vector
  123256. */
  123257. scaling: Vector3;
  123258. /**
  123259. * Convert the Mesh to CSG
  123260. * @param mesh The Mesh to convert to CSG
  123261. * @returns A new CSG from the Mesh
  123262. */
  123263. static FromMesh(mesh: Mesh): CSG;
  123264. /**
  123265. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123266. * @param polygons Polygons used to construct a CSG solid
  123267. */
  123268. private static FromPolygons;
  123269. /**
  123270. * Clones, or makes a deep copy, of the CSG
  123271. * @returns A new CSG
  123272. */
  123273. clone(): CSG;
  123274. /**
  123275. * Unions this CSG with another CSG
  123276. * @param csg The CSG to union against this CSG
  123277. * @returns The unioned CSG
  123278. */
  123279. union(csg: CSG): CSG;
  123280. /**
  123281. * Unions this CSG with another CSG in place
  123282. * @param csg The CSG to union against this CSG
  123283. */
  123284. unionInPlace(csg: CSG): void;
  123285. /**
  123286. * Subtracts this CSG with another CSG
  123287. * @param csg The CSG to subtract against this CSG
  123288. * @returns A new CSG
  123289. */
  123290. subtract(csg: CSG): CSG;
  123291. /**
  123292. * Subtracts this CSG with another CSG in place
  123293. * @param csg The CSG to subtact against this CSG
  123294. */
  123295. subtractInPlace(csg: CSG): void;
  123296. /**
  123297. * Intersect this CSG with another CSG
  123298. * @param csg The CSG to intersect against this CSG
  123299. * @returns A new CSG
  123300. */
  123301. intersect(csg: CSG): CSG;
  123302. /**
  123303. * Intersects this CSG with another CSG in place
  123304. * @param csg The CSG to intersect against this CSG
  123305. */
  123306. intersectInPlace(csg: CSG): void;
  123307. /**
  123308. * Return a new CSG solid with solid and empty space switched. This solid is
  123309. * not modified.
  123310. * @returns A new CSG solid with solid and empty space switched
  123311. */
  123312. inverse(): CSG;
  123313. /**
  123314. * Inverses the CSG in place
  123315. */
  123316. inverseInPlace(): void;
  123317. /**
  123318. * This is used to keep meshes transformations so they can be restored
  123319. * when we build back a Babylon Mesh
  123320. * NB : All CSG operations are performed in world coordinates
  123321. * @param csg The CSG to copy the transform attributes from
  123322. * @returns This CSG
  123323. */
  123324. copyTransformAttributes(csg: CSG): CSG;
  123325. /**
  123326. * Build Raw mesh from CSG
  123327. * Coordinates here are in world space
  123328. * @param name The name of the mesh geometry
  123329. * @param scene The Scene
  123330. * @param keepSubMeshes Specifies if the submeshes should be kept
  123331. * @returns A new Mesh
  123332. */
  123333. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123334. /**
  123335. * Build Mesh from CSG taking material and transforms into account
  123336. * @param name The name of the Mesh
  123337. * @param material The material of the Mesh
  123338. * @param scene The Scene
  123339. * @param keepSubMeshes Specifies if submeshes should be kept
  123340. * @returns The new Mesh
  123341. */
  123342. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123343. }
  123344. }
  123345. declare module BABYLON {
  123346. /**
  123347. * Class used to create a trail following a mesh
  123348. */
  123349. export class TrailMesh extends Mesh {
  123350. private _generator;
  123351. private _autoStart;
  123352. private _running;
  123353. private _diameter;
  123354. private _length;
  123355. private _sectionPolygonPointsCount;
  123356. private _sectionVectors;
  123357. private _sectionNormalVectors;
  123358. private _beforeRenderObserver;
  123359. /**
  123360. * @constructor
  123361. * @param name The value used by scene.getMeshByName() to do a lookup.
  123362. * @param generator The mesh to generate a trail.
  123363. * @param scene The scene to add this mesh to.
  123364. * @param diameter Diameter of trailing mesh. Default is 1.
  123365. * @param length Length of trailing mesh. Default is 60.
  123366. * @param autoStart Automatically start trailing mesh. Default true.
  123367. */
  123368. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123369. /**
  123370. * "TrailMesh"
  123371. * @returns "TrailMesh"
  123372. */
  123373. getClassName(): string;
  123374. private _createMesh;
  123375. /**
  123376. * Start trailing mesh.
  123377. */
  123378. start(): void;
  123379. /**
  123380. * Stop trailing mesh.
  123381. */
  123382. stop(): void;
  123383. /**
  123384. * Update trailing mesh geometry.
  123385. */
  123386. update(): void;
  123387. /**
  123388. * Returns a new TrailMesh object.
  123389. * @param name is a string, the name given to the new mesh
  123390. * @param newGenerator use new generator object for cloned trail mesh
  123391. * @returns a new mesh
  123392. */
  123393. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123394. /**
  123395. * Serializes this trail mesh
  123396. * @param serializationObject object to write serialization to
  123397. */
  123398. serialize(serializationObject: any): void;
  123399. /**
  123400. * Parses a serialized trail mesh
  123401. * @param parsedMesh the serialized mesh
  123402. * @param scene the scene to create the trail mesh in
  123403. * @returns the created trail mesh
  123404. */
  123405. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123406. }
  123407. }
  123408. declare module BABYLON {
  123409. /**
  123410. * Class containing static functions to help procedurally build meshes
  123411. */
  123412. export class TiledBoxBuilder {
  123413. /**
  123414. * Creates a box mesh
  123415. * 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)
  123416. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123420. * @param name defines the name of the mesh
  123421. * @param options defines the options used to create the mesh
  123422. * @param scene defines the hosting scene
  123423. * @returns the box mesh
  123424. */
  123425. static CreateTiledBox(name: string, options: {
  123426. pattern?: number;
  123427. width?: number;
  123428. height?: number;
  123429. depth?: number;
  123430. tileSize?: number;
  123431. tileWidth?: number;
  123432. tileHeight?: number;
  123433. alignHorizontal?: number;
  123434. alignVertical?: number;
  123435. faceUV?: Vector4[];
  123436. faceColors?: Color4[];
  123437. sideOrientation?: number;
  123438. updatable?: boolean;
  123439. }, scene?: Nullable<Scene>): Mesh;
  123440. }
  123441. }
  123442. declare module BABYLON {
  123443. /**
  123444. * Class containing static functions to help procedurally build meshes
  123445. */
  123446. export class TorusKnotBuilder {
  123447. /**
  123448. * Creates a torus knot mesh
  123449. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123450. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123451. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123452. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123456. * @param name defines the name of the mesh
  123457. * @param options defines the options used to create the mesh
  123458. * @param scene defines the hosting scene
  123459. * @returns the torus knot mesh
  123460. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123461. */
  123462. static CreateTorusKnot(name: string, options: {
  123463. radius?: number;
  123464. tube?: number;
  123465. radialSegments?: number;
  123466. tubularSegments?: number;
  123467. p?: number;
  123468. q?: number;
  123469. updatable?: boolean;
  123470. sideOrientation?: number;
  123471. frontUVs?: Vector4;
  123472. backUVs?: Vector4;
  123473. }, scene: any): Mesh;
  123474. }
  123475. }
  123476. declare module BABYLON {
  123477. /**
  123478. * Polygon
  123479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123480. */
  123481. export class Polygon {
  123482. /**
  123483. * Creates a rectangle
  123484. * @param xmin bottom X coord
  123485. * @param ymin bottom Y coord
  123486. * @param xmax top X coord
  123487. * @param ymax top Y coord
  123488. * @returns points that make the resulting rectation
  123489. */
  123490. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123491. /**
  123492. * Creates a circle
  123493. * @param radius radius of circle
  123494. * @param cx scale in x
  123495. * @param cy scale in y
  123496. * @param numberOfSides number of sides that make up the circle
  123497. * @returns points that make the resulting circle
  123498. */
  123499. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123500. /**
  123501. * Creates a polygon from input string
  123502. * @param input Input polygon data
  123503. * @returns the parsed points
  123504. */
  123505. static Parse(input: string): Vector2[];
  123506. /**
  123507. * Starts building a polygon from x and y coordinates
  123508. * @param x x coordinate
  123509. * @param y y coordinate
  123510. * @returns the started path2
  123511. */
  123512. static StartingAt(x: number, y: number): Path2;
  123513. }
  123514. /**
  123515. * Builds a polygon
  123516. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123517. */
  123518. export class PolygonMeshBuilder {
  123519. private _points;
  123520. private _outlinepoints;
  123521. private _holes;
  123522. private _name;
  123523. private _scene;
  123524. private _epoints;
  123525. private _eholes;
  123526. private _addToepoint;
  123527. /**
  123528. * Babylon reference to the earcut plugin.
  123529. */
  123530. bjsEarcut: any;
  123531. /**
  123532. * Creates a PolygonMeshBuilder
  123533. * @param name name of the builder
  123534. * @param contours Path of the polygon
  123535. * @param scene scene to add to when creating the mesh
  123536. * @param earcutInjection can be used to inject your own earcut reference
  123537. */
  123538. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123539. /**
  123540. * Adds a whole within the polygon
  123541. * @param hole Array of points defining the hole
  123542. * @returns this
  123543. */
  123544. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123545. /**
  123546. * Creates the polygon
  123547. * @param updatable If the mesh should be updatable
  123548. * @param depth The depth of the mesh created
  123549. * @returns the created mesh
  123550. */
  123551. build(updatable?: boolean, depth?: number): Mesh;
  123552. /**
  123553. * Creates the polygon
  123554. * @param depth The depth of the mesh created
  123555. * @returns the created VertexData
  123556. */
  123557. buildVertexData(depth?: number): VertexData;
  123558. /**
  123559. * Adds a side to the polygon
  123560. * @param positions points that make the polygon
  123561. * @param normals normals of the polygon
  123562. * @param uvs uvs of the polygon
  123563. * @param indices indices of the polygon
  123564. * @param bounds bounds of the polygon
  123565. * @param points points of the polygon
  123566. * @param depth depth of the polygon
  123567. * @param flip flip of the polygon
  123568. */
  123569. private addSide;
  123570. }
  123571. }
  123572. declare module BABYLON {
  123573. /**
  123574. * Class containing static functions to help procedurally build meshes
  123575. */
  123576. export class PolygonBuilder {
  123577. /**
  123578. * Creates a polygon mesh
  123579. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123580. * * 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
  123581. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123584. * * Remember you can only change the shape positions, not their number when updating a polygon
  123585. * @param name defines the name of the mesh
  123586. * @param options defines the options used to create the mesh
  123587. * @param scene defines the hosting scene
  123588. * @param earcutInjection can be used to inject your own earcut reference
  123589. * @returns the polygon mesh
  123590. */
  123591. static CreatePolygon(name: string, options: {
  123592. shape: Vector3[];
  123593. holes?: Vector3[][];
  123594. depth?: number;
  123595. faceUV?: Vector4[];
  123596. faceColors?: Color4[];
  123597. updatable?: boolean;
  123598. sideOrientation?: number;
  123599. frontUVs?: Vector4;
  123600. backUVs?: Vector4;
  123601. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123602. /**
  123603. * Creates an extruded polygon mesh, with depth in the Y direction.
  123604. * * 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)
  123605. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123606. * @param name defines the name of the mesh
  123607. * @param options defines the options used to create the mesh
  123608. * @param scene defines the hosting scene
  123609. * @param earcutInjection can be used to inject your own earcut reference
  123610. * @returns the polygon mesh
  123611. */
  123612. static ExtrudePolygon(name: string, options: {
  123613. shape: Vector3[];
  123614. holes?: Vector3[][];
  123615. depth?: number;
  123616. faceUV?: Vector4[];
  123617. faceColors?: Color4[];
  123618. updatable?: boolean;
  123619. sideOrientation?: number;
  123620. frontUVs?: Vector4;
  123621. backUVs?: Vector4;
  123622. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123623. }
  123624. }
  123625. declare module BABYLON {
  123626. /**
  123627. * Class containing static functions to help procedurally build meshes
  123628. */
  123629. export class LatheBuilder {
  123630. /**
  123631. * Creates lathe mesh.
  123632. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123633. * * 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
  123634. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123635. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123636. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123637. * * 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
  123638. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123639. * * 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
  123640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123644. * @param name defines the name of the mesh
  123645. * @param options defines the options used to create the mesh
  123646. * @param scene defines the hosting scene
  123647. * @returns the lathe mesh
  123648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123649. */
  123650. static CreateLathe(name: string, options: {
  123651. shape: Vector3[];
  123652. radius?: number;
  123653. tessellation?: number;
  123654. clip?: number;
  123655. arc?: number;
  123656. closed?: boolean;
  123657. updatable?: boolean;
  123658. sideOrientation?: number;
  123659. frontUVs?: Vector4;
  123660. backUVs?: Vector4;
  123661. cap?: number;
  123662. invertUV?: boolean;
  123663. }, scene?: Nullable<Scene>): Mesh;
  123664. }
  123665. }
  123666. declare module BABYLON {
  123667. /**
  123668. * Class containing static functions to help procedurally build meshes
  123669. */
  123670. export class TiledPlaneBuilder {
  123671. /**
  123672. * Creates a tiled plane mesh
  123673. * * The parameter `pattern` will, depending on value, do nothing or
  123674. * * * flip (reflect about central vertical) alternate tiles across and up
  123675. * * * flip every tile on alternate rows
  123676. * * * rotate (180 degs) alternate tiles across and up
  123677. * * * rotate every tile on alternate rows
  123678. * * * flip and rotate alternate tiles across and up
  123679. * * * flip and rotate every tile on alternate rows
  123680. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123681. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123684. * * 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)
  123685. * * 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)
  123686. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123687. * @param name defines the name of the mesh
  123688. * @param options defines the options used to create the mesh
  123689. * @param scene defines the hosting scene
  123690. * @returns the box mesh
  123691. */
  123692. static CreateTiledPlane(name: string, options: {
  123693. pattern?: number;
  123694. tileSize?: number;
  123695. tileWidth?: number;
  123696. tileHeight?: number;
  123697. size?: number;
  123698. width?: number;
  123699. height?: number;
  123700. alignHorizontal?: number;
  123701. alignVertical?: number;
  123702. sideOrientation?: number;
  123703. frontUVs?: Vector4;
  123704. backUVs?: Vector4;
  123705. updatable?: boolean;
  123706. }, scene?: Nullable<Scene>): Mesh;
  123707. }
  123708. }
  123709. declare module BABYLON {
  123710. /**
  123711. * Class containing static functions to help procedurally build meshes
  123712. */
  123713. export class TubeBuilder {
  123714. /**
  123715. * Creates a tube mesh.
  123716. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123717. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123718. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123719. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123720. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123721. * * 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)
  123722. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123723. * * 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
  123724. * * 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
  123725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123729. * @param name defines the name of the mesh
  123730. * @param options defines the options used to create the mesh
  123731. * @param scene defines the hosting scene
  123732. * @returns the tube mesh
  123733. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123734. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123735. */
  123736. static CreateTube(name: string, options: {
  123737. path: Vector3[];
  123738. radius?: number;
  123739. tessellation?: number;
  123740. radiusFunction?: {
  123741. (i: number, distance: number): number;
  123742. };
  123743. cap?: number;
  123744. arc?: number;
  123745. updatable?: boolean;
  123746. sideOrientation?: number;
  123747. frontUVs?: Vector4;
  123748. backUVs?: Vector4;
  123749. instance?: Mesh;
  123750. invertUV?: boolean;
  123751. }, scene?: Nullable<Scene>): Mesh;
  123752. }
  123753. }
  123754. declare module BABYLON {
  123755. /**
  123756. * Class containing static functions to help procedurally build meshes
  123757. */
  123758. export class IcoSphereBuilder {
  123759. /**
  123760. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123761. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123762. * * 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`)
  123763. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123764. * * 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
  123765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123768. * @param name defines the name of the mesh
  123769. * @param options defines the options used to create the mesh
  123770. * @param scene defines the hosting scene
  123771. * @returns the icosahedron mesh
  123772. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123773. */
  123774. static CreateIcoSphere(name: string, options: {
  123775. radius?: number;
  123776. radiusX?: number;
  123777. radiusY?: number;
  123778. radiusZ?: number;
  123779. flat?: boolean;
  123780. subdivisions?: number;
  123781. sideOrientation?: number;
  123782. frontUVs?: Vector4;
  123783. backUVs?: Vector4;
  123784. updatable?: boolean;
  123785. }, scene?: Nullable<Scene>): Mesh;
  123786. }
  123787. }
  123788. declare module BABYLON {
  123789. /**
  123790. * Class containing static functions to help procedurally build meshes
  123791. */
  123792. export class DecalBuilder {
  123793. /**
  123794. * Creates a decal mesh.
  123795. * 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
  123796. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123797. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123798. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123799. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123800. * @param name defines the name of the mesh
  123801. * @param sourceMesh defines the mesh where the decal must be applied
  123802. * @param options defines the options used to create the mesh
  123803. * @param scene defines the hosting scene
  123804. * @returns the decal mesh
  123805. * @see https://doc.babylonjs.com/how_to/decals
  123806. */
  123807. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123808. position?: Vector3;
  123809. normal?: Vector3;
  123810. size?: Vector3;
  123811. angle?: number;
  123812. }): Mesh;
  123813. }
  123814. }
  123815. declare module BABYLON {
  123816. /**
  123817. * Class containing static functions to help procedurally build meshes
  123818. */
  123819. export class MeshBuilder {
  123820. /**
  123821. * Creates a box mesh
  123822. * * The parameter `size` sets the size (float) of each box side (default 1)
  123823. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123824. * * 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)
  123825. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123829. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123830. * @param name defines the name of the mesh
  123831. * @param options defines the options used to create the mesh
  123832. * @param scene defines the hosting scene
  123833. * @returns the box mesh
  123834. */
  123835. static CreateBox(name: string, options: {
  123836. size?: number;
  123837. width?: number;
  123838. height?: number;
  123839. depth?: number;
  123840. faceUV?: Vector4[];
  123841. faceColors?: Color4[];
  123842. sideOrientation?: number;
  123843. frontUVs?: Vector4;
  123844. backUVs?: Vector4;
  123845. updatable?: boolean;
  123846. }, scene?: Nullable<Scene>): Mesh;
  123847. /**
  123848. * Creates a tiled box mesh
  123849. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123851. * @param name defines the name of the mesh
  123852. * @param options defines the options used to create the mesh
  123853. * @param scene defines the hosting scene
  123854. * @returns the tiled box mesh
  123855. */
  123856. static CreateTiledBox(name: string, options: {
  123857. pattern?: number;
  123858. size?: number;
  123859. width?: number;
  123860. height?: number;
  123861. depth: number;
  123862. tileSize?: number;
  123863. tileWidth?: number;
  123864. tileHeight?: number;
  123865. faceUV?: Vector4[];
  123866. faceColors?: Color4[];
  123867. alignHorizontal?: number;
  123868. alignVertical?: number;
  123869. sideOrientation?: number;
  123870. updatable?: boolean;
  123871. }, scene?: Nullable<Scene>): Mesh;
  123872. /**
  123873. * Creates a sphere mesh
  123874. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123875. * * 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`)
  123876. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123877. * * 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
  123878. * * 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)
  123879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123882. * @param name defines the name of the mesh
  123883. * @param options defines the options used to create the mesh
  123884. * @param scene defines the hosting scene
  123885. * @returns the sphere mesh
  123886. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123887. */
  123888. static CreateSphere(name: string, options: {
  123889. segments?: number;
  123890. diameter?: number;
  123891. diameterX?: number;
  123892. diameterY?: number;
  123893. diameterZ?: number;
  123894. arc?: number;
  123895. slice?: number;
  123896. sideOrientation?: number;
  123897. frontUVs?: Vector4;
  123898. backUVs?: Vector4;
  123899. updatable?: boolean;
  123900. }, scene?: Nullable<Scene>): Mesh;
  123901. /**
  123902. * Creates a plane polygonal mesh. By default, this is a disc
  123903. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123904. * * 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
  123905. * * 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
  123906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123909. * @param name defines the name of the mesh
  123910. * @param options defines the options used to create the mesh
  123911. * @param scene defines the hosting scene
  123912. * @returns the plane polygonal mesh
  123913. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123914. */
  123915. static CreateDisc(name: string, options: {
  123916. radius?: number;
  123917. tessellation?: number;
  123918. arc?: number;
  123919. updatable?: boolean;
  123920. sideOrientation?: number;
  123921. frontUVs?: Vector4;
  123922. backUVs?: Vector4;
  123923. }, scene?: Nullable<Scene>): Mesh;
  123924. /**
  123925. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123926. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123927. * * 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`)
  123928. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123929. * * 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
  123930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123933. * @param name defines the name of the mesh
  123934. * @param options defines the options used to create the mesh
  123935. * @param scene defines the hosting scene
  123936. * @returns the icosahedron mesh
  123937. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123938. */
  123939. static CreateIcoSphere(name: string, options: {
  123940. radius?: number;
  123941. radiusX?: number;
  123942. radiusY?: number;
  123943. radiusZ?: number;
  123944. flat?: boolean;
  123945. subdivisions?: number;
  123946. sideOrientation?: number;
  123947. frontUVs?: Vector4;
  123948. backUVs?: Vector4;
  123949. updatable?: boolean;
  123950. }, scene?: Nullable<Scene>): Mesh;
  123951. /**
  123952. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123953. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123954. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123955. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123956. * * 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
  123957. * * 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
  123958. * * 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
  123959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123962. * * 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
  123963. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123964. * * 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
  123965. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123967. * @param name defines the name of the mesh
  123968. * @param options defines the options used to create the mesh
  123969. * @param scene defines the hosting scene
  123970. * @returns the ribbon mesh
  123971. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123973. */
  123974. static CreateRibbon(name: string, options: {
  123975. pathArray: Vector3[][];
  123976. closeArray?: boolean;
  123977. closePath?: boolean;
  123978. offset?: number;
  123979. updatable?: boolean;
  123980. sideOrientation?: number;
  123981. frontUVs?: Vector4;
  123982. backUVs?: Vector4;
  123983. instance?: Mesh;
  123984. invertUV?: boolean;
  123985. uvs?: Vector2[];
  123986. colors?: Color4[];
  123987. }, scene?: Nullable<Scene>): Mesh;
  123988. /**
  123989. * Creates a cylinder or a cone mesh
  123990. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123991. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123992. * * 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.
  123993. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123994. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123995. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123996. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123997. * * 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).
  123998. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123999. * * 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).
  124000. * * 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
  124001. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124002. * * 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
  124003. * * 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.
  124004. * * If `enclose` is false, a ring surface is one element.
  124005. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124006. * * 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
  124007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124010. * @param name defines the name of the mesh
  124011. * @param options defines the options used to create the mesh
  124012. * @param scene defines the hosting scene
  124013. * @returns the cylinder mesh
  124014. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124015. */
  124016. static CreateCylinder(name: string, options: {
  124017. height?: number;
  124018. diameterTop?: number;
  124019. diameterBottom?: number;
  124020. diameter?: number;
  124021. tessellation?: number;
  124022. subdivisions?: number;
  124023. arc?: number;
  124024. faceColors?: Color4[];
  124025. faceUV?: Vector4[];
  124026. updatable?: boolean;
  124027. hasRings?: boolean;
  124028. enclose?: boolean;
  124029. cap?: number;
  124030. sideOrientation?: number;
  124031. frontUVs?: Vector4;
  124032. backUVs?: Vector4;
  124033. }, scene?: Nullable<Scene>): Mesh;
  124034. /**
  124035. * Creates a torus mesh
  124036. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124037. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124038. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124042. * @param name defines the name of the mesh
  124043. * @param options defines the options used to create the mesh
  124044. * @param scene defines the hosting scene
  124045. * @returns the torus mesh
  124046. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124047. */
  124048. static CreateTorus(name: string, options: {
  124049. diameter?: number;
  124050. thickness?: number;
  124051. tessellation?: number;
  124052. updatable?: boolean;
  124053. sideOrientation?: number;
  124054. frontUVs?: Vector4;
  124055. backUVs?: Vector4;
  124056. }, scene?: Nullable<Scene>): Mesh;
  124057. /**
  124058. * Creates a torus knot mesh
  124059. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124060. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124061. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124062. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124066. * @param name defines the name of the mesh
  124067. * @param options defines the options used to create the mesh
  124068. * @param scene defines the hosting scene
  124069. * @returns the torus knot mesh
  124070. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124071. */
  124072. static CreateTorusKnot(name: string, options: {
  124073. radius?: number;
  124074. tube?: number;
  124075. radialSegments?: number;
  124076. tubularSegments?: number;
  124077. p?: number;
  124078. q?: number;
  124079. updatable?: boolean;
  124080. sideOrientation?: number;
  124081. frontUVs?: Vector4;
  124082. backUVs?: Vector4;
  124083. }, scene?: Nullable<Scene>): Mesh;
  124084. /**
  124085. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124086. * * 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
  124087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124088. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124089. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124090. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124091. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124092. * * 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
  124093. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124096. * @param name defines the name of the new line system
  124097. * @param options defines the options used to create the line system
  124098. * @param scene defines the hosting scene
  124099. * @returns a new line system mesh
  124100. */
  124101. static CreateLineSystem(name: string, options: {
  124102. lines: Vector3[][];
  124103. updatable?: boolean;
  124104. instance?: Nullable<LinesMesh>;
  124105. colors?: Nullable<Color4[][]>;
  124106. useVertexAlpha?: boolean;
  124107. }, scene: Nullable<Scene>): LinesMesh;
  124108. /**
  124109. * Creates a line mesh
  124110. * 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
  124111. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124112. * * The parameter `points` is an array successive Vector3
  124113. * * 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
  124114. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124116. * * When updating an instance, remember that only point positions can change, not the number of points
  124117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124119. * @param name defines the name of the new line system
  124120. * @param options defines the options used to create the line system
  124121. * @param scene defines the hosting scene
  124122. * @returns a new line mesh
  124123. */
  124124. static CreateLines(name: string, options: {
  124125. points: Vector3[];
  124126. updatable?: boolean;
  124127. instance?: Nullable<LinesMesh>;
  124128. colors?: Color4[];
  124129. useVertexAlpha?: boolean;
  124130. }, scene?: Nullable<Scene>): LinesMesh;
  124131. /**
  124132. * Creates a dashed line mesh
  124133. * * 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
  124134. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124135. * * The parameter `points` is an array successive Vector3
  124136. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124137. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124138. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124139. * * 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
  124140. * * When updating an instance, remember that only point positions can change, not the number of points
  124141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124142. * @param name defines the name of the mesh
  124143. * @param options defines the options used to create the mesh
  124144. * @param scene defines the hosting scene
  124145. * @returns the dashed line mesh
  124146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124147. */
  124148. static CreateDashedLines(name: string, options: {
  124149. points: Vector3[];
  124150. dashSize?: number;
  124151. gapSize?: number;
  124152. dashNb?: number;
  124153. updatable?: boolean;
  124154. instance?: LinesMesh;
  124155. }, scene?: Nullable<Scene>): LinesMesh;
  124156. /**
  124157. * 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.
  124158. * * 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.
  124159. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124160. * * 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.
  124161. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124162. * * 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
  124163. * * 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
  124164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124169. * @param name defines the name of the mesh
  124170. * @param options defines the options used to create the mesh
  124171. * @param scene defines the hosting scene
  124172. * @returns the extruded shape mesh
  124173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124175. */
  124176. static ExtrudeShape(name: string, options: {
  124177. shape: Vector3[];
  124178. path: Vector3[];
  124179. scale?: number;
  124180. rotation?: number;
  124181. cap?: number;
  124182. updatable?: boolean;
  124183. sideOrientation?: number;
  124184. frontUVs?: Vector4;
  124185. backUVs?: Vector4;
  124186. instance?: Mesh;
  124187. invertUV?: boolean;
  124188. }, scene?: Nullable<Scene>): Mesh;
  124189. /**
  124190. * Creates an custom extruded shape mesh.
  124191. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124192. * * 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.
  124193. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124194. * * 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
  124195. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124196. * * 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
  124197. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124198. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124199. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124200. * * 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
  124201. * * 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
  124202. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124207. * @param name defines the name of the mesh
  124208. * @param options defines the options used to create the mesh
  124209. * @param scene defines the hosting scene
  124210. * @returns the custom extruded shape mesh
  124211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124212. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124214. */
  124215. static ExtrudeShapeCustom(name: string, options: {
  124216. shape: Vector3[];
  124217. path: Vector3[];
  124218. scaleFunction?: any;
  124219. rotationFunction?: any;
  124220. ribbonCloseArray?: boolean;
  124221. ribbonClosePath?: boolean;
  124222. cap?: number;
  124223. updatable?: boolean;
  124224. sideOrientation?: number;
  124225. frontUVs?: Vector4;
  124226. backUVs?: Vector4;
  124227. instance?: Mesh;
  124228. invertUV?: boolean;
  124229. }, scene?: Nullable<Scene>): Mesh;
  124230. /**
  124231. * Creates lathe mesh.
  124232. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124233. * * 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
  124234. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124235. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124236. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124237. * * 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
  124238. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124239. * * 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
  124240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124244. * @param name defines the name of the mesh
  124245. * @param options defines the options used to create the mesh
  124246. * @param scene defines the hosting scene
  124247. * @returns the lathe mesh
  124248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124249. */
  124250. static CreateLathe(name: string, options: {
  124251. shape: Vector3[];
  124252. radius?: number;
  124253. tessellation?: number;
  124254. clip?: number;
  124255. arc?: number;
  124256. closed?: boolean;
  124257. updatable?: boolean;
  124258. sideOrientation?: number;
  124259. frontUVs?: Vector4;
  124260. backUVs?: Vector4;
  124261. cap?: number;
  124262. invertUV?: boolean;
  124263. }, scene?: Nullable<Scene>): Mesh;
  124264. /**
  124265. * Creates a tiled plane mesh
  124266. * * You can set a limited pattern arrangement with the tiles
  124267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124270. * @param name defines the name of the mesh
  124271. * @param options defines the options used to create the mesh
  124272. * @param scene defines the hosting scene
  124273. * @returns the plane mesh
  124274. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124275. */
  124276. static CreateTiledPlane(name: string, options: {
  124277. pattern?: number;
  124278. tileSize?: number;
  124279. tileWidth?: number;
  124280. tileHeight?: number;
  124281. size?: number;
  124282. width?: number;
  124283. height?: number;
  124284. alignHorizontal?: number;
  124285. alignVertical?: number;
  124286. sideOrientation?: number;
  124287. frontUVs?: Vector4;
  124288. backUVs?: Vector4;
  124289. updatable?: boolean;
  124290. }, scene?: Nullable<Scene>): Mesh;
  124291. /**
  124292. * Creates a plane mesh
  124293. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124294. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124295. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124299. * @param name defines the name of the mesh
  124300. * @param options defines the options used to create the mesh
  124301. * @param scene defines the hosting scene
  124302. * @returns the plane mesh
  124303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124304. */
  124305. static CreatePlane(name: string, options: {
  124306. size?: number;
  124307. width?: number;
  124308. height?: number;
  124309. sideOrientation?: number;
  124310. frontUVs?: Vector4;
  124311. backUVs?: Vector4;
  124312. updatable?: boolean;
  124313. sourcePlane?: Plane;
  124314. }, scene?: Nullable<Scene>): Mesh;
  124315. /**
  124316. * Creates a ground mesh
  124317. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124318. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124320. * @param name defines the name of the mesh
  124321. * @param options defines the options used to create the mesh
  124322. * @param scene defines the hosting scene
  124323. * @returns the ground mesh
  124324. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124325. */
  124326. static CreateGround(name: string, options: {
  124327. width?: number;
  124328. height?: number;
  124329. subdivisions?: number;
  124330. subdivisionsX?: number;
  124331. subdivisionsY?: number;
  124332. updatable?: boolean;
  124333. }, scene?: Nullable<Scene>): Mesh;
  124334. /**
  124335. * Creates a tiled ground mesh
  124336. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124337. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124338. * * 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
  124339. * * 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
  124340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124341. * @param name defines the name of the mesh
  124342. * @param options defines the options used to create the mesh
  124343. * @param scene defines the hosting scene
  124344. * @returns the tiled ground mesh
  124345. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124346. */
  124347. static CreateTiledGround(name: string, options: {
  124348. xmin: number;
  124349. zmin: number;
  124350. xmax: number;
  124351. zmax: number;
  124352. subdivisions?: {
  124353. w: number;
  124354. h: number;
  124355. };
  124356. precision?: {
  124357. w: number;
  124358. h: number;
  124359. };
  124360. updatable?: boolean;
  124361. }, scene?: Nullable<Scene>): Mesh;
  124362. /**
  124363. * Creates a ground mesh from a height map
  124364. * * The parameter `url` sets the URL of the height map image resource.
  124365. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124366. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124367. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124368. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124369. * * 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.
  124370. * * 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).
  124371. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124373. * @param name defines the name of the mesh
  124374. * @param url defines the url to the height map
  124375. * @param options defines the options used to create the mesh
  124376. * @param scene defines the hosting scene
  124377. * @returns the ground mesh
  124378. * @see https://doc.babylonjs.com/babylon101/height_map
  124379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124380. */
  124381. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124382. width?: number;
  124383. height?: number;
  124384. subdivisions?: number;
  124385. minHeight?: number;
  124386. maxHeight?: number;
  124387. colorFilter?: Color3;
  124388. alphaFilter?: number;
  124389. updatable?: boolean;
  124390. onReady?: (mesh: GroundMesh) => void;
  124391. }, scene?: Nullable<Scene>): GroundMesh;
  124392. /**
  124393. * Creates a polygon mesh
  124394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124395. * * 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
  124396. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124399. * * Remember you can only change the shape positions, not their number when updating a polygon
  124400. * @param name defines the name of the mesh
  124401. * @param options defines the options used to create the mesh
  124402. * @param scene defines the hosting scene
  124403. * @param earcutInjection can be used to inject your own earcut reference
  124404. * @returns the polygon mesh
  124405. */
  124406. static CreatePolygon(name: string, options: {
  124407. shape: Vector3[];
  124408. holes?: Vector3[][];
  124409. depth?: number;
  124410. faceUV?: Vector4[];
  124411. faceColors?: Color4[];
  124412. updatable?: boolean;
  124413. sideOrientation?: number;
  124414. frontUVs?: Vector4;
  124415. backUVs?: Vector4;
  124416. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124417. /**
  124418. * Creates an extruded polygon mesh, with depth in the Y direction.
  124419. * * 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)
  124420. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124421. * @param name defines the name of the mesh
  124422. * @param options defines the options used to create the mesh
  124423. * @param scene defines the hosting scene
  124424. * @param earcutInjection can be used to inject your own earcut reference
  124425. * @returns the polygon mesh
  124426. */
  124427. static ExtrudePolygon(name: string, options: {
  124428. shape: Vector3[];
  124429. holes?: Vector3[][];
  124430. depth?: number;
  124431. faceUV?: Vector4[];
  124432. faceColors?: Color4[];
  124433. updatable?: boolean;
  124434. sideOrientation?: number;
  124435. frontUVs?: Vector4;
  124436. backUVs?: Vector4;
  124437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124438. /**
  124439. * Creates a tube mesh.
  124440. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124441. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124442. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124443. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124444. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124445. * * 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)
  124446. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124447. * * 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
  124448. * * 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
  124449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124453. * @param name defines the name of the mesh
  124454. * @param options defines the options used to create the mesh
  124455. * @param scene defines the hosting scene
  124456. * @returns the tube mesh
  124457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124458. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124459. */
  124460. static CreateTube(name: string, options: {
  124461. path: Vector3[];
  124462. radius?: number;
  124463. tessellation?: number;
  124464. radiusFunction?: {
  124465. (i: number, distance: number): number;
  124466. };
  124467. cap?: number;
  124468. arc?: number;
  124469. updatable?: boolean;
  124470. sideOrientation?: number;
  124471. frontUVs?: Vector4;
  124472. backUVs?: Vector4;
  124473. instance?: Mesh;
  124474. invertUV?: boolean;
  124475. }, scene?: Nullable<Scene>): Mesh;
  124476. /**
  124477. * Creates a polyhedron mesh
  124478. * * 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
  124479. * * The parameter `size` (positive float, default 1) sets the polygon size
  124480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124481. * * 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`
  124482. * * 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
  124483. * * 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)`)
  124484. * * 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
  124485. * * 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
  124486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124489. * @param name defines the name of the mesh
  124490. * @param options defines the options used to create the mesh
  124491. * @param scene defines the hosting scene
  124492. * @returns the polyhedron mesh
  124493. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124494. */
  124495. static CreatePolyhedron(name: string, options: {
  124496. type?: number;
  124497. size?: number;
  124498. sizeX?: number;
  124499. sizeY?: number;
  124500. sizeZ?: number;
  124501. custom?: any;
  124502. faceUV?: Vector4[];
  124503. faceColors?: Color4[];
  124504. flat?: boolean;
  124505. updatable?: boolean;
  124506. sideOrientation?: number;
  124507. frontUVs?: Vector4;
  124508. backUVs?: Vector4;
  124509. }, scene?: Nullable<Scene>): Mesh;
  124510. /**
  124511. * Creates a decal mesh.
  124512. * 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
  124513. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124514. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124515. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124516. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124517. * @param name defines the name of the mesh
  124518. * @param sourceMesh defines the mesh where the decal must be applied
  124519. * @param options defines the options used to create the mesh
  124520. * @param scene defines the hosting scene
  124521. * @returns the decal mesh
  124522. * @see https://doc.babylonjs.com/how_to/decals
  124523. */
  124524. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124525. position?: Vector3;
  124526. normal?: Vector3;
  124527. size?: Vector3;
  124528. angle?: number;
  124529. }): Mesh;
  124530. }
  124531. }
  124532. declare module BABYLON {
  124533. /**
  124534. * A simplifier interface for future simplification implementations
  124535. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124536. */
  124537. export interface ISimplifier {
  124538. /**
  124539. * Simplification of a given mesh according to the given settings.
  124540. * Since this requires computation, it is assumed that the function runs async.
  124541. * @param settings The settings of the simplification, including quality and distance
  124542. * @param successCallback A callback that will be called after the mesh was simplified.
  124543. * @param errorCallback in case of an error, this callback will be called. optional.
  124544. */
  124545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124546. }
  124547. /**
  124548. * Expected simplification settings.
  124549. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124550. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124551. */
  124552. export interface ISimplificationSettings {
  124553. /**
  124554. * Gets or sets the expected quality
  124555. */
  124556. quality: number;
  124557. /**
  124558. * Gets or sets the distance when this optimized version should be used
  124559. */
  124560. distance: number;
  124561. /**
  124562. * Gets an already optimized mesh
  124563. */
  124564. optimizeMesh?: boolean;
  124565. }
  124566. /**
  124567. * Class used to specify simplification options
  124568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124569. */
  124570. export class SimplificationSettings implements ISimplificationSettings {
  124571. /** expected quality */
  124572. quality: number;
  124573. /** distance when this optimized version should be used */
  124574. distance: number;
  124575. /** already optimized mesh */
  124576. optimizeMesh?: boolean | undefined;
  124577. /**
  124578. * Creates a SimplificationSettings
  124579. * @param quality expected quality
  124580. * @param distance distance when this optimized version should be used
  124581. * @param optimizeMesh already optimized mesh
  124582. */
  124583. constructor(
  124584. /** expected quality */
  124585. quality: number,
  124586. /** distance when this optimized version should be used */
  124587. distance: number,
  124588. /** already optimized mesh */
  124589. optimizeMesh?: boolean | undefined);
  124590. }
  124591. /**
  124592. * Interface used to define a simplification task
  124593. */
  124594. export interface ISimplificationTask {
  124595. /**
  124596. * Array of settings
  124597. */
  124598. settings: Array<ISimplificationSettings>;
  124599. /**
  124600. * Simplification type
  124601. */
  124602. simplificationType: SimplificationType;
  124603. /**
  124604. * Mesh to simplify
  124605. */
  124606. mesh: Mesh;
  124607. /**
  124608. * Callback called on success
  124609. */
  124610. successCallback?: () => void;
  124611. /**
  124612. * Defines if parallel processing can be used
  124613. */
  124614. parallelProcessing: boolean;
  124615. }
  124616. /**
  124617. * Queue used to order the simplification tasks
  124618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124619. */
  124620. export class SimplificationQueue {
  124621. private _simplificationArray;
  124622. /**
  124623. * Gets a boolean indicating that the process is still running
  124624. */
  124625. running: boolean;
  124626. /**
  124627. * Creates a new queue
  124628. */
  124629. constructor();
  124630. /**
  124631. * Adds a new simplification task
  124632. * @param task defines a task to add
  124633. */
  124634. addTask(task: ISimplificationTask): void;
  124635. /**
  124636. * Execute next task
  124637. */
  124638. executeNext(): void;
  124639. /**
  124640. * Execute a simplification task
  124641. * @param task defines the task to run
  124642. */
  124643. runSimplification(task: ISimplificationTask): void;
  124644. private getSimplifier;
  124645. }
  124646. /**
  124647. * The implemented types of simplification
  124648. * At the moment only Quadratic Error Decimation is implemented
  124649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124650. */
  124651. export enum SimplificationType {
  124652. /** Quadratic error decimation */
  124653. QUADRATIC = 0
  124654. }
  124655. }
  124656. declare module BABYLON {
  124657. interface Scene {
  124658. /** @hidden (Backing field) */
  124659. _simplificationQueue: SimplificationQueue;
  124660. /**
  124661. * Gets or sets the simplification queue attached to the scene
  124662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124663. */
  124664. simplificationQueue: SimplificationQueue;
  124665. }
  124666. interface Mesh {
  124667. /**
  124668. * Simplify the mesh according to the given array of settings.
  124669. * Function will return immediately and will simplify async
  124670. * @param settings a collection of simplification settings
  124671. * @param parallelProcessing should all levels calculate parallel or one after the other
  124672. * @param simplificationType the type of simplification to run
  124673. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124674. * @returns the current mesh
  124675. */
  124676. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124677. }
  124678. /**
  124679. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124680. * created in a scene
  124681. */
  124682. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124683. /**
  124684. * The component name helpfull to identify the component in the list of scene components.
  124685. */
  124686. readonly name: string;
  124687. /**
  124688. * The scene the component belongs to.
  124689. */
  124690. scene: Scene;
  124691. /**
  124692. * Creates a new instance of the component for the given scene
  124693. * @param scene Defines the scene to register the component in
  124694. */
  124695. constructor(scene: Scene);
  124696. /**
  124697. * Registers the component in a given scene
  124698. */
  124699. register(): void;
  124700. /**
  124701. * Rebuilds the elements related to this component in case of
  124702. * context lost for instance.
  124703. */
  124704. rebuild(): void;
  124705. /**
  124706. * Disposes the component and the associated ressources
  124707. */
  124708. dispose(): void;
  124709. private _beforeCameraUpdate;
  124710. }
  124711. }
  124712. declare module BABYLON {
  124713. /**
  124714. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124715. */
  124716. export interface INavigationEnginePlugin {
  124717. /**
  124718. * plugin name
  124719. */
  124720. name: string;
  124721. /**
  124722. * Creates a navigation mesh
  124723. * @param meshes array of all the geometry used to compute the navigatio mesh
  124724. * @param parameters bunch of parameters used to filter geometry
  124725. */
  124726. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124727. /**
  124728. * Create a navigation mesh debug mesh
  124729. * @param scene is where the mesh will be added
  124730. * @returns debug display mesh
  124731. */
  124732. createDebugNavMesh(scene: Scene): Mesh;
  124733. /**
  124734. * Get a navigation mesh constrained position, closest to the parameter position
  124735. * @param position world position
  124736. * @returns the closest point to position constrained by the navigation mesh
  124737. */
  124738. getClosestPoint(position: Vector3): Vector3;
  124739. /**
  124740. * Get a navigation mesh constrained position, within a particular radius
  124741. * @param position world position
  124742. * @param maxRadius the maximum distance to the constrained world position
  124743. * @returns the closest point to position constrained by the navigation mesh
  124744. */
  124745. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124746. /**
  124747. * Compute the final position from a segment made of destination-position
  124748. * @param position world position
  124749. * @param destination world position
  124750. * @returns the resulting point along the navmesh
  124751. */
  124752. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124753. /**
  124754. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124755. * @param start world position
  124756. * @param end world position
  124757. * @returns array containing world position composing the path
  124758. */
  124759. computePath(start: Vector3, end: Vector3): Vector3[];
  124760. /**
  124761. * If this plugin is supported
  124762. * @returns true if plugin is supported
  124763. */
  124764. isSupported(): boolean;
  124765. /**
  124766. * Create a new Crowd so you can add agents
  124767. * @param maxAgents the maximum agent count in the crowd
  124768. * @param maxAgentRadius the maximum radius an agent can have
  124769. * @param scene to attach the crowd to
  124770. * @returns the crowd you can add agents to
  124771. */
  124772. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124773. /**
  124774. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124775. * The queries will try to find a solution within those bounds
  124776. * default is (1,1,1)
  124777. * @param extent x,y,z value that define the extent around the queries point of reference
  124778. */
  124779. setDefaultQueryExtent(extent: Vector3): void;
  124780. /**
  124781. * Get the Bounding box extent specified by setDefaultQueryExtent
  124782. * @returns the box extent values
  124783. */
  124784. getDefaultQueryExtent(): Vector3;
  124785. /**
  124786. * Release all resources
  124787. */
  124788. dispose(): void;
  124789. }
  124790. /**
  124791. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124792. */
  124793. export interface ICrowd {
  124794. /**
  124795. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124796. * You can attach anything to that node. The node position is updated in the scene update tick.
  124797. * @param pos world position that will be constrained by the navigation mesh
  124798. * @param parameters agent parameters
  124799. * @param transform hooked to the agent that will be update by the scene
  124800. * @returns agent index
  124801. */
  124802. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124803. /**
  124804. * Returns the agent position in world space
  124805. * @param index agent index returned by addAgent
  124806. * @returns world space position
  124807. */
  124808. getAgentPosition(index: number): Vector3;
  124809. /**
  124810. * Gets the agent velocity in world space
  124811. * @param index agent index returned by addAgent
  124812. * @returns world space velocity
  124813. */
  124814. getAgentVelocity(index: number): Vector3;
  124815. /**
  124816. * remove a particular agent previously created
  124817. * @param index agent index returned by addAgent
  124818. */
  124819. removeAgent(index: number): void;
  124820. /**
  124821. * get the list of all agents attached to this crowd
  124822. * @returns list of agent indices
  124823. */
  124824. getAgents(): number[];
  124825. /**
  124826. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124827. * @param deltaTime in seconds
  124828. */
  124829. update(deltaTime: number): void;
  124830. /**
  124831. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124832. * @param index agent index returned by addAgent
  124833. * @param destination targeted world position
  124834. */
  124835. agentGoto(index: number, destination: Vector3): void;
  124836. /**
  124837. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124838. * The queries will try to find a solution within those bounds
  124839. * default is (1,1,1)
  124840. * @param extent x,y,z value that define the extent around the queries point of reference
  124841. */
  124842. setDefaultQueryExtent(extent: Vector3): void;
  124843. /**
  124844. * Get the Bounding box extent specified by setDefaultQueryExtent
  124845. * @returns the box extent values
  124846. */
  124847. getDefaultQueryExtent(): Vector3;
  124848. /**
  124849. * Release all resources
  124850. */
  124851. dispose(): void;
  124852. }
  124853. /**
  124854. * Configures an agent
  124855. */
  124856. export interface IAgentParameters {
  124857. /**
  124858. * Agent radius. [Limit: >= 0]
  124859. */
  124860. radius: number;
  124861. /**
  124862. * Agent height. [Limit: > 0]
  124863. */
  124864. height: number;
  124865. /**
  124866. * Maximum allowed acceleration. [Limit: >= 0]
  124867. */
  124868. maxAcceleration: number;
  124869. /**
  124870. * Maximum allowed speed. [Limit: >= 0]
  124871. */
  124872. maxSpeed: number;
  124873. /**
  124874. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124875. */
  124876. collisionQueryRange: number;
  124877. /**
  124878. * The path visibility optimization range. [Limit: > 0]
  124879. */
  124880. pathOptimizationRange: number;
  124881. /**
  124882. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124883. */
  124884. separationWeight: number;
  124885. }
  124886. /**
  124887. * Configures the navigation mesh creation
  124888. */
  124889. export interface INavMeshParameters {
  124890. /**
  124891. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124892. */
  124893. cs: number;
  124894. /**
  124895. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124896. */
  124897. ch: number;
  124898. /**
  124899. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124900. */
  124901. walkableSlopeAngle: number;
  124902. /**
  124903. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124904. * be considered walkable. [Limit: >= 3] [Units: vx]
  124905. */
  124906. walkableHeight: number;
  124907. /**
  124908. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124909. */
  124910. walkableClimb: number;
  124911. /**
  124912. * The distance to erode/shrink the walkable area of the heightfield away from
  124913. * obstructions. [Limit: >=0] [Units: vx]
  124914. */
  124915. walkableRadius: number;
  124916. /**
  124917. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124918. */
  124919. maxEdgeLen: number;
  124920. /**
  124921. * The maximum distance a simplfied contour's border edges should deviate
  124922. * the original raw contour. [Limit: >=0] [Units: vx]
  124923. */
  124924. maxSimplificationError: number;
  124925. /**
  124926. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124927. */
  124928. minRegionArea: number;
  124929. /**
  124930. * Any regions with a span count smaller than this value will, if possible,
  124931. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124932. */
  124933. mergeRegionArea: number;
  124934. /**
  124935. * The maximum number of vertices allowed for polygons generated during the
  124936. * contour to polygon conversion process. [Limit: >= 3]
  124937. */
  124938. maxVertsPerPoly: number;
  124939. /**
  124940. * Sets the sampling distance to use when generating the detail mesh.
  124941. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124942. */
  124943. detailSampleDist: number;
  124944. /**
  124945. * The maximum distance the detail mesh surface should deviate from heightfield
  124946. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124947. */
  124948. detailSampleMaxError: number;
  124949. }
  124950. }
  124951. declare module BABYLON {
  124952. /**
  124953. * RecastJS navigation plugin
  124954. */
  124955. export class RecastJSPlugin implements INavigationEnginePlugin {
  124956. /**
  124957. * Reference to the Recast library
  124958. */
  124959. bjsRECAST: any;
  124960. /**
  124961. * plugin name
  124962. */
  124963. name: string;
  124964. /**
  124965. * the first navmesh created. We might extend this to support multiple navmeshes
  124966. */
  124967. navMesh: any;
  124968. /**
  124969. * Initializes the recastJS plugin
  124970. * @param recastInjection can be used to inject your own recast reference
  124971. */
  124972. constructor(recastInjection?: any);
  124973. /**
  124974. * Creates a navigation mesh
  124975. * @param meshes array of all the geometry used to compute the navigatio mesh
  124976. * @param parameters bunch of parameters used to filter geometry
  124977. */
  124978. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124979. /**
  124980. * Create a navigation mesh debug mesh
  124981. * @param scene is where the mesh will be added
  124982. * @returns debug display mesh
  124983. */
  124984. createDebugNavMesh(scene: Scene): Mesh;
  124985. /**
  124986. * Get a navigation mesh constrained position, closest to the parameter position
  124987. * @param position world position
  124988. * @returns the closest point to position constrained by the navigation mesh
  124989. */
  124990. getClosestPoint(position: Vector3): Vector3;
  124991. /**
  124992. * Get a navigation mesh constrained position, within a particular radius
  124993. * @param position world position
  124994. * @param maxRadius the maximum distance to the constrained world position
  124995. * @returns the closest point to position constrained by the navigation mesh
  124996. */
  124997. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124998. /**
  124999. * Compute the final position from a segment made of destination-position
  125000. * @param position world position
  125001. * @param destination world position
  125002. * @returns the resulting point along the navmesh
  125003. */
  125004. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125005. /**
  125006. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125007. * @param start world position
  125008. * @param end world position
  125009. * @returns array containing world position composing the path
  125010. */
  125011. computePath(start: Vector3, end: Vector3): Vector3[];
  125012. /**
  125013. * Create a new Crowd so you can add agents
  125014. * @param maxAgents the maximum agent count in the crowd
  125015. * @param maxAgentRadius the maximum radius an agent can have
  125016. * @param scene to attach the crowd to
  125017. * @returns the crowd you can add agents to
  125018. */
  125019. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125020. /**
  125021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125022. * The queries will try to find a solution within those bounds
  125023. * default is (1,1,1)
  125024. * @param extent x,y,z value that define the extent around the queries point of reference
  125025. */
  125026. setDefaultQueryExtent(extent: Vector3): void;
  125027. /**
  125028. * Get the Bounding box extent specified by setDefaultQueryExtent
  125029. * @returns the box extent values
  125030. */
  125031. getDefaultQueryExtent(): Vector3;
  125032. /**
  125033. * Disposes
  125034. */
  125035. dispose(): void;
  125036. /**
  125037. * If this plugin is supported
  125038. * @returns true if plugin is supported
  125039. */
  125040. isSupported(): boolean;
  125041. }
  125042. /**
  125043. * Recast detour crowd implementation
  125044. */
  125045. export class RecastJSCrowd implements ICrowd {
  125046. /**
  125047. * Recast/detour plugin
  125048. */
  125049. bjsRECASTPlugin: RecastJSPlugin;
  125050. /**
  125051. * Link to the detour crowd
  125052. */
  125053. recastCrowd: any;
  125054. /**
  125055. * One transform per agent
  125056. */
  125057. transforms: TransformNode[];
  125058. /**
  125059. * All agents created
  125060. */
  125061. agents: number[];
  125062. /**
  125063. * Link to the scene is kept to unregister the crowd from the scene
  125064. */
  125065. private _scene;
  125066. /**
  125067. * Observer for crowd updates
  125068. */
  125069. private _onBeforeAnimationsObserver;
  125070. /**
  125071. * Constructor
  125072. * @param plugin recastJS plugin
  125073. * @param maxAgents the maximum agent count in the crowd
  125074. * @param maxAgentRadius the maximum radius an agent can have
  125075. * @param scene to attach the crowd to
  125076. * @returns the crowd you can add agents to
  125077. */
  125078. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125079. /**
  125080. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125081. * You can attach anything to that node. The node position is updated in the scene update tick.
  125082. * @param pos world position that will be constrained by the navigation mesh
  125083. * @param parameters agent parameters
  125084. * @param transform hooked to the agent that will be update by the scene
  125085. * @returns agent index
  125086. */
  125087. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125088. /**
  125089. * Returns the agent position in world space
  125090. * @param index agent index returned by addAgent
  125091. * @returns world space position
  125092. */
  125093. getAgentPosition(index: number): Vector3;
  125094. /**
  125095. * Returns the agent velocity in world space
  125096. * @param index agent index returned by addAgent
  125097. * @returns world space velocity
  125098. */
  125099. getAgentVelocity(index: number): Vector3;
  125100. /**
  125101. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125102. * @param index agent index returned by addAgent
  125103. * @param destination targeted world position
  125104. */
  125105. agentGoto(index: number, destination: Vector3): void;
  125106. /**
  125107. * remove a particular agent previously created
  125108. * @param index agent index returned by addAgent
  125109. */
  125110. removeAgent(index: number): void;
  125111. /**
  125112. * get the list of all agents attached to this crowd
  125113. * @returns list of agent indices
  125114. */
  125115. getAgents(): number[];
  125116. /**
  125117. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125118. * @param deltaTime in seconds
  125119. */
  125120. update(deltaTime: number): void;
  125121. /**
  125122. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125123. * The queries will try to find a solution within those bounds
  125124. * default is (1,1,1)
  125125. * @param extent x,y,z value that define the extent around the queries point of reference
  125126. */
  125127. setDefaultQueryExtent(extent: Vector3): void;
  125128. /**
  125129. * Get the Bounding box extent specified by setDefaultQueryExtent
  125130. * @returns the box extent values
  125131. */
  125132. getDefaultQueryExtent(): Vector3;
  125133. /**
  125134. * Release all resources
  125135. */
  125136. dispose(): void;
  125137. }
  125138. }
  125139. declare module BABYLON {
  125140. /**
  125141. * Class used to enable access to IndexedDB
  125142. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125143. */
  125144. export class Database implements IOfflineProvider {
  125145. private _callbackManifestChecked;
  125146. private _currentSceneUrl;
  125147. private _db;
  125148. private _enableSceneOffline;
  125149. private _enableTexturesOffline;
  125150. private _manifestVersionFound;
  125151. private _mustUpdateRessources;
  125152. private _hasReachedQuota;
  125153. private _isSupported;
  125154. private _idbFactory;
  125155. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125156. private static IsUASupportingBlobStorage;
  125157. /**
  125158. * Gets a boolean indicating if Database storate is enabled (off by default)
  125159. */
  125160. static IDBStorageEnabled: boolean;
  125161. /**
  125162. * Gets a boolean indicating if scene must be saved in the database
  125163. */
  125164. readonly enableSceneOffline: boolean;
  125165. /**
  125166. * Gets a boolean indicating if textures must be saved in the database
  125167. */
  125168. readonly enableTexturesOffline: boolean;
  125169. /**
  125170. * Creates a new Database
  125171. * @param urlToScene defines the url to load the scene
  125172. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125173. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125174. */
  125175. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125176. private static _ParseURL;
  125177. private static _ReturnFullUrlLocation;
  125178. private _checkManifestFile;
  125179. /**
  125180. * Open the database and make it available
  125181. * @param successCallback defines the callback to call on success
  125182. * @param errorCallback defines the callback to call on error
  125183. */
  125184. open(successCallback: () => void, errorCallback: () => void): void;
  125185. /**
  125186. * Loads an image from the database
  125187. * @param url defines the url to load from
  125188. * @param image defines the target DOM image
  125189. */
  125190. loadImage(url: string, image: HTMLImageElement): void;
  125191. private _loadImageFromDBAsync;
  125192. private _saveImageIntoDBAsync;
  125193. private _checkVersionFromDB;
  125194. private _loadVersionFromDBAsync;
  125195. private _saveVersionIntoDBAsync;
  125196. /**
  125197. * Loads a file from database
  125198. * @param url defines the URL to load from
  125199. * @param sceneLoaded defines a callback to call on success
  125200. * @param progressCallBack defines a callback to call when progress changed
  125201. * @param errorCallback defines a callback to call on error
  125202. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125203. */
  125204. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125205. private _loadFileAsync;
  125206. private _saveFileAsync;
  125207. /**
  125208. * Validates if xhr data is correct
  125209. * @param xhr defines the request to validate
  125210. * @param dataType defines the expected data type
  125211. * @returns true if data is correct
  125212. */
  125213. private static _ValidateXHRData;
  125214. }
  125215. }
  125216. declare module BABYLON {
  125217. /** @hidden */
  125218. export var gpuUpdateParticlesPixelShader: {
  125219. name: string;
  125220. shader: string;
  125221. };
  125222. }
  125223. declare module BABYLON {
  125224. /** @hidden */
  125225. export var gpuUpdateParticlesVertexShader: {
  125226. name: string;
  125227. shader: string;
  125228. };
  125229. }
  125230. declare module BABYLON {
  125231. /** @hidden */
  125232. export var clipPlaneFragmentDeclaration2: {
  125233. name: string;
  125234. shader: string;
  125235. };
  125236. }
  125237. declare module BABYLON {
  125238. /** @hidden */
  125239. export var gpuRenderParticlesPixelShader: {
  125240. name: string;
  125241. shader: string;
  125242. };
  125243. }
  125244. declare module BABYLON {
  125245. /** @hidden */
  125246. export var clipPlaneVertexDeclaration2: {
  125247. name: string;
  125248. shader: string;
  125249. };
  125250. }
  125251. declare module BABYLON {
  125252. /** @hidden */
  125253. export var gpuRenderParticlesVertexShader: {
  125254. name: string;
  125255. shader: string;
  125256. };
  125257. }
  125258. declare module BABYLON {
  125259. /**
  125260. * This represents a GPU particle system in Babylon
  125261. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125262. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125263. */
  125264. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125265. /**
  125266. * The layer mask we are rendering the particles through.
  125267. */
  125268. layerMask: number;
  125269. private _capacity;
  125270. private _activeCount;
  125271. private _currentActiveCount;
  125272. private _accumulatedCount;
  125273. private _renderEffect;
  125274. private _updateEffect;
  125275. private _buffer0;
  125276. private _buffer1;
  125277. private _spriteBuffer;
  125278. private _updateVAO;
  125279. private _renderVAO;
  125280. private _targetIndex;
  125281. private _sourceBuffer;
  125282. private _targetBuffer;
  125283. private _engine;
  125284. private _currentRenderId;
  125285. private _started;
  125286. private _stopped;
  125287. private _timeDelta;
  125288. private _randomTexture;
  125289. private _randomTexture2;
  125290. private _attributesStrideSize;
  125291. private _updateEffectOptions;
  125292. private _randomTextureSize;
  125293. private _actualFrame;
  125294. private readonly _rawTextureWidth;
  125295. /**
  125296. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125297. */
  125298. static readonly IsSupported: boolean;
  125299. /**
  125300. * An event triggered when the system is disposed.
  125301. */
  125302. onDisposeObservable: Observable<GPUParticleSystem>;
  125303. /**
  125304. * Gets the maximum number of particles active at the same time.
  125305. * @returns The max number of active particles.
  125306. */
  125307. getCapacity(): number;
  125308. /**
  125309. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125310. * to override the particles.
  125311. */
  125312. forceDepthWrite: boolean;
  125313. /**
  125314. * Gets or set the number of active particles
  125315. */
  125316. activeParticleCount: number;
  125317. private _preWarmDone;
  125318. /**
  125319. * Is this system ready to be used/rendered
  125320. * @return true if the system is ready
  125321. */
  125322. isReady(): boolean;
  125323. /**
  125324. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125325. * @returns True if it has been started, otherwise false.
  125326. */
  125327. isStarted(): boolean;
  125328. /**
  125329. * Starts the particle system and begins to emit
  125330. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125331. */
  125332. start(delay?: number): void;
  125333. /**
  125334. * Stops the particle system.
  125335. */
  125336. stop(): void;
  125337. /**
  125338. * Remove all active particles
  125339. */
  125340. reset(): void;
  125341. /**
  125342. * Returns the string "GPUParticleSystem"
  125343. * @returns a string containing the class name
  125344. */
  125345. getClassName(): string;
  125346. private _colorGradientsTexture;
  125347. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125348. /**
  125349. * Adds a new color gradient
  125350. * @param gradient defines the gradient to use (between 0 and 1)
  125351. * @param color1 defines the color to affect to the specified gradient
  125352. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125353. * @returns the current particle system
  125354. */
  125355. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125356. /**
  125357. * Remove a specific color gradient
  125358. * @param gradient defines the gradient to remove
  125359. * @returns the current particle system
  125360. */
  125361. removeColorGradient(gradient: number): GPUParticleSystem;
  125362. private _angularSpeedGradientsTexture;
  125363. private _sizeGradientsTexture;
  125364. private _velocityGradientsTexture;
  125365. private _limitVelocityGradientsTexture;
  125366. private _dragGradientsTexture;
  125367. private _addFactorGradient;
  125368. /**
  125369. * Adds a new size gradient
  125370. * @param gradient defines the gradient to use (between 0 and 1)
  125371. * @param factor defines the size factor to affect to the specified gradient
  125372. * @returns the current particle system
  125373. */
  125374. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125375. /**
  125376. * Remove a specific size gradient
  125377. * @param gradient defines the gradient to remove
  125378. * @returns the current particle system
  125379. */
  125380. removeSizeGradient(gradient: number): GPUParticleSystem;
  125381. /**
  125382. * Adds a new angular speed gradient
  125383. * @param gradient defines the gradient to use (between 0 and 1)
  125384. * @param factor defines the angular speed to affect to the specified gradient
  125385. * @returns the current particle system
  125386. */
  125387. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125388. /**
  125389. * Remove a specific angular speed gradient
  125390. * @param gradient defines the gradient to remove
  125391. * @returns the current particle system
  125392. */
  125393. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125394. /**
  125395. * Adds a new velocity gradient
  125396. * @param gradient defines the gradient to use (between 0 and 1)
  125397. * @param factor defines the velocity to affect to the specified gradient
  125398. * @returns the current particle system
  125399. */
  125400. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125401. /**
  125402. * Remove a specific velocity gradient
  125403. * @param gradient defines the gradient to remove
  125404. * @returns the current particle system
  125405. */
  125406. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125407. /**
  125408. * Adds a new limit velocity gradient
  125409. * @param gradient defines the gradient to use (between 0 and 1)
  125410. * @param factor defines the limit velocity value to affect to the specified gradient
  125411. * @returns the current particle system
  125412. */
  125413. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125414. /**
  125415. * Remove a specific limit velocity gradient
  125416. * @param gradient defines the gradient to remove
  125417. * @returns the current particle system
  125418. */
  125419. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125420. /**
  125421. * Adds a new drag gradient
  125422. * @param gradient defines the gradient to use (between 0 and 1)
  125423. * @param factor defines the drag value to affect to the specified gradient
  125424. * @returns the current particle system
  125425. */
  125426. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125427. /**
  125428. * Remove a specific drag gradient
  125429. * @param gradient defines the gradient to remove
  125430. * @returns the current particle system
  125431. */
  125432. removeDragGradient(gradient: number): GPUParticleSystem;
  125433. /**
  125434. * Not supported by GPUParticleSystem
  125435. * @param gradient defines the gradient to use (between 0 and 1)
  125436. * @param factor defines the emit rate value to affect to the specified gradient
  125437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125438. * @returns the current particle system
  125439. */
  125440. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125441. /**
  125442. * Not supported by GPUParticleSystem
  125443. * @param gradient defines the gradient to remove
  125444. * @returns the current particle system
  125445. */
  125446. removeEmitRateGradient(gradient: number): IParticleSystem;
  125447. /**
  125448. * Not supported by GPUParticleSystem
  125449. * @param gradient defines the gradient to use (between 0 and 1)
  125450. * @param factor defines the start size value to affect to the specified gradient
  125451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125452. * @returns the current particle system
  125453. */
  125454. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125455. /**
  125456. * Not supported by GPUParticleSystem
  125457. * @param gradient defines the gradient to remove
  125458. * @returns the current particle system
  125459. */
  125460. removeStartSizeGradient(gradient: number): IParticleSystem;
  125461. /**
  125462. * Not supported by GPUParticleSystem
  125463. * @param gradient defines the gradient to use (between 0 and 1)
  125464. * @param min defines the color remap minimal range
  125465. * @param max defines the color remap maximal range
  125466. * @returns the current particle system
  125467. */
  125468. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125469. /**
  125470. * Not supported by GPUParticleSystem
  125471. * @param gradient defines the gradient to remove
  125472. * @returns the current particle system
  125473. */
  125474. removeColorRemapGradient(): IParticleSystem;
  125475. /**
  125476. * Not supported by GPUParticleSystem
  125477. * @param gradient defines the gradient to use (between 0 and 1)
  125478. * @param min defines the alpha remap minimal range
  125479. * @param max defines the alpha remap maximal range
  125480. * @returns the current particle system
  125481. */
  125482. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125483. /**
  125484. * Not supported by GPUParticleSystem
  125485. * @param gradient defines the gradient to remove
  125486. * @returns the current particle system
  125487. */
  125488. removeAlphaRemapGradient(): IParticleSystem;
  125489. /**
  125490. * Not supported by GPUParticleSystem
  125491. * @param gradient defines the gradient to use (between 0 and 1)
  125492. * @param color defines the color to affect to the specified gradient
  125493. * @returns the current particle system
  125494. */
  125495. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125496. /**
  125497. * Not supported by GPUParticleSystem
  125498. * @param gradient defines the gradient to remove
  125499. * @returns the current particle system
  125500. */
  125501. removeRampGradient(): IParticleSystem;
  125502. /**
  125503. * Not supported by GPUParticleSystem
  125504. * @returns the list of ramp gradients
  125505. */
  125506. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125507. /**
  125508. * Not supported by GPUParticleSystem
  125509. * Gets or sets a boolean indicating that ramp gradients must be used
  125510. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125511. */
  125512. useRampGradients: boolean;
  125513. /**
  125514. * Not supported by GPUParticleSystem
  125515. * @param gradient defines the gradient to use (between 0 and 1)
  125516. * @param factor defines the life time factor to affect to the specified gradient
  125517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125518. * @returns the current particle system
  125519. */
  125520. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125521. /**
  125522. * Not supported by GPUParticleSystem
  125523. * @param gradient defines the gradient to remove
  125524. * @returns the current particle system
  125525. */
  125526. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125527. /**
  125528. * Instantiates a GPU particle system.
  125529. * 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.
  125530. * @param name The name of the particle system
  125531. * @param options The options used to create the system
  125532. * @param scene The scene the particle system belongs to
  125533. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125534. */
  125535. constructor(name: string, options: Partial<{
  125536. capacity: number;
  125537. randomTextureSize: number;
  125538. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125539. protected _reset(): void;
  125540. private _createUpdateVAO;
  125541. private _createRenderVAO;
  125542. private _initialize;
  125543. /** @hidden */
  125544. _recreateUpdateEffect(): void;
  125545. /** @hidden */
  125546. _recreateRenderEffect(): void;
  125547. /**
  125548. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125549. * @param preWarm defines if we are in the pre-warmimg phase
  125550. */
  125551. animate(preWarm?: boolean): void;
  125552. private _createFactorGradientTexture;
  125553. private _createSizeGradientTexture;
  125554. private _createAngularSpeedGradientTexture;
  125555. private _createVelocityGradientTexture;
  125556. private _createLimitVelocityGradientTexture;
  125557. private _createDragGradientTexture;
  125558. private _createColorGradientTexture;
  125559. /**
  125560. * Renders the particle system in its current state
  125561. * @param preWarm defines if the system should only update the particles but not render them
  125562. * @returns the current number of particles
  125563. */
  125564. render(preWarm?: boolean): number;
  125565. /**
  125566. * Rebuilds the particle system
  125567. */
  125568. rebuild(): void;
  125569. private _releaseBuffers;
  125570. private _releaseVAOs;
  125571. /**
  125572. * Disposes the particle system and free the associated resources
  125573. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125574. */
  125575. dispose(disposeTexture?: boolean): void;
  125576. /**
  125577. * Clones the particle system.
  125578. * @param name The name of the cloned object
  125579. * @param newEmitter The new emitter to use
  125580. * @returns the cloned particle system
  125581. */
  125582. clone(name: string, newEmitter: any): GPUParticleSystem;
  125583. /**
  125584. * Serializes the particle system to a JSON object.
  125585. * @returns the JSON object
  125586. */
  125587. serialize(): any;
  125588. /**
  125589. * Parses a JSON object to create a GPU particle system.
  125590. * @param parsedParticleSystem The JSON object to parse
  125591. * @param scene The scene to create the particle system in
  125592. * @param rootUrl The root url to use to load external dependencies like texture
  125593. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125594. * @returns the parsed GPU particle system
  125595. */
  125596. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125597. }
  125598. }
  125599. declare module BABYLON {
  125600. /**
  125601. * Represents a set of particle systems working together to create a specific effect
  125602. */
  125603. export class ParticleSystemSet implements IDisposable {
  125604. /**
  125605. * Gets or sets base Assets URL
  125606. */
  125607. static BaseAssetsUrl: string;
  125608. private _emitterCreationOptions;
  125609. private _emitterNode;
  125610. /**
  125611. * Gets the particle system list
  125612. */
  125613. systems: IParticleSystem[];
  125614. /**
  125615. * Gets the emitter node used with this set
  125616. */
  125617. readonly emitterNode: Nullable<TransformNode>;
  125618. /**
  125619. * Creates a new emitter mesh as a sphere
  125620. * @param options defines the options used to create the sphere
  125621. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125622. * @param scene defines the hosting scene
  125623. */
  125624. setEmitterAsSphere(options: {
  125625. diameter: number;
  125626. segments: number;
  125627. color: Color3;
  125628. }, renderingGroupId: number, scene: Scene): void;
  125629. /**
  125630. * Starts all particle systems of the set
  125631. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125632. */
  125633. start(emitter?: AbstractMesh): void;
  125634. /**
  125635. * Release all associated resources
  125636. */
  125637. dispose(): void;
  125638. /**
  125639. * Serialize the set into a JSON compatible object
  125640. * @returns a JSON compatible representation of the set
  125641. */
  125642. serialize(): any;
  125643. /**
  125644. * Parse a new ParticleSystemSet from a serialized source
  125645. * @param data defines a JSON compatible representation of the set
  125646. * @param scene defines the hosting scene
  125647. * @param gpu defines if we want GPU particles or CPU particles
  125648. * @returns a new ParticleSystemSet
  125649. */
  125650. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125651. }
  125652. }
  125653. declare module BABYLON {
  125654. /**
  125655. * This class is made for on one-liner static method to help creating particle system set.
  125656. */
  125657. export class ParticleHelper {
  125658. /**
  125659. * Gets or sets base Assets URL
  125660. */
  125661. static BaseAssetsUrl: string;
  125662. /**
  125663. * Create a default particle system that you can tweak
  125664. * @param emitter defines the emitter to use
  125665. * @param capacity defines the system capacity (default is 500 particles)
  125666. * @param scene defines the hosting scene
  125667. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125668. * @returns the new Particle system
  125669. */
  125670. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125671. /**
  125672. * This is the main static method (one-liner) of this helper to create different particle systems
  125673. * @param type This string represents the type to the particle system to create
  125674. * @param scene The scene where the particle system should live
  125675. * @param gpu If the system will use gpu
  125676. * @returns the ParticleSystemSet created
  125677. */
  125678. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125679. /**
  125680. * Static function used to export a particle system to a ParticleSystemSet variable.
  125681. * Please note that the emitter shape is not exported
  125682. * @param systems defines the particle systems to export
  125683. * @returns the created particle system set
  125684. */
  125685. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125686. }
  125687. }
  125688. declare module BABYLON {
  125689. interface Engine {
  125690. /**
  125691. * Create an effect to use with particle systems.
  125692. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125693. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125694. * @param uniformsNames defines a list of attribute names
  125695. * @param samplers defines an array of string used to represent textures
  125696. * @param defines defines the string containing the defines to use to compile the shaders
  125697. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125698. * @param onCompiled defines a function to call when the effect creation is successful
  125699. * @param onError defines a function to call when the effect creation has failed
  125700. * @returns the new Effect
  125701. */
  125702. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125703. }
  125704. interface Mesh {
  125705. /**
  125706. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125707. * @returns an array of IParticleSystem
  125708. */
  125709. getEmittedParticleSystems(): IParticleSystem[];
  125710. /**
  125711. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125712. * @returns an array of IParticleSystem
  125713. */
  125714. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125715. }
  125716. /**
  125717. * @hidden
  125718. */
  125719. export var _IDoNeedToBeInTheBuild: number;
  125720. }
  125721. declare module BABYLON {
  125722. /** Defines the 4 color options */
  125723. export enum PointColor {
  125724. /** color value */
  125725. Color = 2,
  125726. /** uv value */
  125727. UV = 1,
  125728. /** random value */
  125729. Random = 0,
  125730. /** stated value */
  125731. Stated = 3
  125732. }
  125733. /**
  125734. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125735. * 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.
  125736. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125737. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125738. *
  125739. * Full documentation here : TO BE ENTERED
  125740. */
  125741. export class PointsCloudSystem implements IDisposable {
  125742. /**
  125743. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125744. * Example : var p = SPS.particles[i];
  125745. */
  125746. particles: CloudPoint[];
  125747. /**
  125748. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125749. */
  125750. nbParticles: number;
  125751. /**
  125752. * This a counter for your own usage. It's not set by any SPS functions.
  125753. */
  125754. counter: number;
  125755. /**
  125756. * The PCS name. This name is also given to the underlying mesh.
  125757. */
  125758. name: string;
  125759. /**
  125760. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125761. */
  125762. mesh: Mesh;
  125763. /**
  125764. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125765. * Please read :
  125766. */
  125767. vars: any;
  125768. /**
  125769. * @hidden
  125770. */
  125771. _size: number;
  125772. private _scene;
  125773. private _promises;
  125774. private _positions;
  125775. private _indices;
  125776. private _normals;
  125777. private _colors;
  125778. private _uvs;
  125779. private _indices32;
  125780. private _positions32;
  125781. private _colors32;
  125782. private _uvs32;
  125783. private _updatable;
  125784. private _isVisibilityBoxLocked;
  125785. private _alwaysVisible;
  125786. private _groups;
  125787. private _groupCounter;
  125788. private _computeParticleColor;
  125789. private _computeParticleTexture;
  125790. private _computeParticleRotation;
  125791. private _computeBoundingBox;
  125792. private _isReady;
  125793. /**
  125794. * Creates a PCS (Points Cloud System) object
  125795. * @param name (String) is the PCS name, this will be the underlying mesh name
  125796. * @param pointSize (number) is the size for each point
  125797. * @param scene (Scene) is the scene in which the PCS is added
  125798. * @param options defines the options of the PCS e.g.
  125799. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125800. */
  125801. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125802. updatable?: boolean;
  125803. });
  125804. /**
  125805. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125806. * If no points were added to the PCS, the returned mesh is just a single point.
  125807. * @returns a promise for the created mesh
  125808. */
  125809. buildMeshAsync(): Promise<Mesh>;
  125810. /**
  125811. * @hidden
  125812. */
  125813. private _buildMesh;
  125814. private _addParticle;
  125815. private _randomUnitVector;
  125816. private _getColorIndicesForCoord;
  125817. private _setPointsColorOrUV;
  125818. private _colorFromTexture;
  125819. private _calculateDensity;
  125820. /**
  125821. * Adds points to the PCS in random positions within a unit sphere
  125822. * @param nb (positive integer) the number of particles to be created from this model
  125823. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  125824. * @returns the number of groups in the system
  125825. */
  125826. addPoints(nb: number, pointFunction?: any): number;
  125827. /**
  125828. * Adds points to the PCS from the surface of the model shape
  125829. * @param mesh is any Mesh object that will be used as a surface model for the points
  125830. * @param nb (positive integer) the number of particles to be created from this model
  125831. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  125832. * @param color (color3) to be used when colorWith is stated
  125833. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125834. * @returns the number of groups in the system
  125835. */
  125836. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125837. /**
  125838. * Adds points to the PCS inside the model shape
  125839. * @param mesh is any Mesh object that will be used as a surface model for the points
  125840. * @param nb (positive integer) the number of particles to be created from this model
  125841. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  125842. * @param color (color4) to be used when colorWith is stated
  125843. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125844. * @returns the number of groups in the system
  125845. */
  125846. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125847. /**
  125848. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125849. * This method calls `updateParticle()` for each particle of the SPS.
  125850. * For an animated SPS, it is usually called within the render loop.
  125851. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125852. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125853. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125854. * @returns the PCS.
  125855. */
  125856. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  125857. /**
  125858. * Disposes the PCS.
  125859. */
  125860. dispose(): void;
  125861. /**
  125862. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125863. * doc :
  125864. * @returns the PCS.
  125865. */
  125866. refreshVisibleSize(): PointsCloudSystem;
  125867. /**
  125868. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  125869. * @param size the size (float) of the visibility box
  125870. * note : this doesn't lock the PCS mesh bounding box.
  125871. * doc :
  125872. */
  125873. setVisibilityBox(size: number): void;
  125874. /**
  125875. * Gets whether the PCS is always visible or not
  125876. * doc :
  125877. */
  125878. /**
  125879. * Sets the PCS as always visible or not
  125880. * doc :
  125881. */
  125882. isAlwaysVisible: boolean;
  125883. /**
  125884. * Tells to `setParticles()` to compute the particle rotations or not
  125885. * Default value : false. The PCS is faster when it's set to false
  125886. * Note : particle rotations are only applied to parent particles
  125887. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  125888. */
  125889. computeParticleRotation: boolean;
  125890. /**
  125891. * Tells to `setParticles()` to compute the particle colors or not.
  125892. * Default value : true. The PCS is faster when it's set to false.
  125893. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125894. */
  125895. /**
  125896. * Gets if `setParticles()` computes the particle colors or not.
  125897. * Default value : false. The PCS is faster when it's set to false.
  125898. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125899. */
  125900. computeParticleColor: boolean;
  125901. /**
  125902. * Gets if `setParticles()` computes the particle textures or not.
  125903. * Default value : false. The PCS is faster when it's set to false.
  125904. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  125905. */
  125906. computeParticleTexture: boolean;
  125907. /**
  125908. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  125909. */
  125910. /**
  125911. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  125912. */
  125913. computeBoundingBox: boolean;
  125914. /**
  125915. * This function does nothing. It may be overwritten to set all the particle first values.
  125916. * The PCS doesn't call this function, you may have to call it by your own.
  125917. * doc :
  125918. */
  125919. initParticles(): void;
  125920. /**
  125921. * This function does nothing. It may be overwritten to recycle a particle
  125922. * The PCS doesn't call this function, you can to call it
  125923. * doc :
  125924. * @param particle The particle to recycle
  125925. * @returns the recycled particle
  125926. */
  125927. recycleParticle(particle: CloudPoint): CloudPoint;
  125928. /**
  125929. * Updates a particle : this function should be overwritten by the user.
  125930. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  125931. * doc :
  125932. * @example : just set a particle position or velocity and recycle conditions
  125933. * @param particle The particle to update
  125934. * @returns the updated particle
  125935. */
  125936. updateParticle(particle: CloudPoint): CloudPoint;
  125937. /**
  125938. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  125939. * This does nothing and may be overwritten by the user.
  125940. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125941. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125942. * @param update the boolean update value actually passed to setParticles()
  125943. */
  125944. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125945. /**
  125946. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  125947. * This will be passed three parameters.
  125948. * This does nothing and may be overwritten by the user.
  125949. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125950. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125951. * @param update the boolean update value actually passed to setParticles()
  125952. */
  125953. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125954. }
  125955. }
  125956. declare module BABYLON {
  125957. /**
  125958. * Represents one particle of a points cloud system.
  125959. */
  125960. export class CloudPoint {
  125961. /**
  125962. * particle global index
  125963. */
  125964. idx: number;
  125965. /**
  125966. * The color of the particle
  125967. */
  125968. color: Nullable<Color4>;
  125969. /**
  125970. * The world space position of the particle.
  125971. */
  125972. position: Vector3;
  125973. /**
  125974. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  125975. */
  125976. rotation: Vector3;
  125977. /**
  125978. * The world space rotation quaternion of the particle.
  125979. */
  125980. rotationQuaternion: Nullable<Quaternion>;
  125981. /**
  125982. * The uv of the particle.
  125983. */
  125984. uv: Nullable<Vector2>;
  125985. /**
  125986. * The current speed of the particle.
  125987. */
  125988. velocity: Vector3;
  125989. /**
  125990. * The pivot point in the particle local space.
  125991. */
  125992. pivot: Vector3;
  125993. /**
  125994. * Must the particle be translated from its pivot point in its local space ?
  125995. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  125996. * Default : false
  125997. */
  125998. translateFromPivot: boolean;
  125999. /**
  126000. * Index of this particle in the global "positions" array (Internal use)
  126001. * @hidden
  126002. */
  126003. _pos: number;
  126004. /**
  126005. * @hidden Index of this particle in the global "indices" array (Internal use)
  126006. */
  126007. _ind: number;
  126008. /**
  126009. * Group this particle belongs to
  126010. */
  126011. _group: PointsGroup;
  126012. /**
  126013. * Group id of this particle
  126014. */
  126015. groupId: number;
  126016. /**
  126017. * Index of the particle in its group id (Internal use)
  126018. */
  126019. idxInGroup: number;
  126020. /**
  126021. * @hidden Particle BoundingInfo object (Internal use)
  126022. */
  126023. _boundingInfo: BoundingInfo;
  126024. /**
  126025. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126026. */
  126027. _pcs: PointsCloudSystem;
  126028. /**
  126029. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126030. */
  126031. _stillInvisible: boolean;
  126032. /**
  126033. * @hidden Last computed particle rotation matrix
  126034. */
  126035. _rotationMatrix: number[];
  126036. /**
  126037. * Parent particle Id, if any.
  126038. * Default null.
  126039. */
  126040. parentId: Nullable<number>;
  126041. /**
  126042. * @hidden Internal global position in the PCS.
  126043. */
  126044. _globalPosition: Vector3;
  126045. /**
  126046. * Creates a Point Cloud object.
  126047. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126048. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126049. * @param group (PointsGroup) is the group the particle belongs to
  126050. * @param groupId (integer) is the group identifier in the PCS.
  126051. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126052. * @param pcs defines the PCS it is associated to
  126053. */
  126054. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126055. /**
  126056. * get point size
  126057. */
  126058. /**
  126059. * Set point size
  126060. */
  126061. size: Vector3;
  126062. /**
  126063. * Legacy support, changed quaternion to rotationQuaternion
  126064. */
  126065. /**
  126066. * Legacy support, changed quaternion to rotationQuaternion
  126067. */
  126068. quaternion: Nullable<Quaternion>;
  126069. /**
  126070. * Returns a boolean. True if the particle intersects a mesh, else false
  126071. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126072. * @param target is the object (point or mesh) what the intersection is computed against
  126073. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126074. * @returns true if it intersects
  126075. */
  126076. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126077. /**
  126078. * get the rotation matrix of the particle
  126079. * @hidden
  126080. */
  126081. getRotationMatrix(m: Matrix): void;
  126082. }
  126083. /**
  126084. * Represents a group of points in a points cloud system
  126085. * * PCS internal tool, don't use it manually.
  126086. */
  126087. export class PointsGroup {
  126088. /**
  126089. * The group id
  126090. * @hidden
  126091. */
  126092. groupID: number;
  126093. /**
  126094. * image data for group (internal use)
  126095. * @hidden
  126096. */
  126097. _groupImageData: Nullable<ArrayBufferView>;
  126098. /**
  126099. * Image Width (internal use)
  126100. * @hidden
  126101. */
  126102. _groupImgWidth: number;
  126103. /**
  126104. * Image Height (internal use)
  126105. * @hidden
  126106. */
  126107. _groupImgHeight: number;
  126108. /**
  126109. * Custom position function (internal use)
  126110. * @hidden
  126111. */
  126112. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126113. /**
  126114. * density per facet for surface points
  126115. * @hidden
  126116. */
  126117. _groupDensity: number[];
  126118. /**
  126119. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126120. * PCS internal tool, don't use it manually.
  126121. * @hidden
  126122. */
  126123. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126124. }
  126125. }
  126126. declare module BABYLON {
  126127. interface Scene {
  126128. /** @hidden (Backing field) */
  126129. _physicsEngine: Nullable<IPhysicsEngine>;
  126130. /**
  126131. * Gets the current physics engine
  126132. * @returns a IPhysicsEngine or null if none attached
  126133. */
  126134. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126135. /**
  126136. * Enables physics to the current scene
  126137. * @param gravity defines the scene's gravity for the physics engine
  126138. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126139. * @return a boolean indicating if the physics engine was initialized
  126140. */
  126141. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126142. /**
  126143. * Disables and disposes the physics engine associated with the scene
  126144. */
  126145. disablePhysicsEngine(): void;
  126146. /**
  126147. * Gets a boolean indicating if there is an active physics engine
  126148. * @returns a boolean indicating if there is an active physics engine
  126149. */
  126150. isPhysicsEnabled(): boolean;
  126151. /**
  126152. * Deletes a physics compound impostor
  126153. * @param compound defines the compound to delete
  126154. */
  126155. deleteCompoundImpostor(compound: any): void;
  126156. /**
  126157. * An event triggered when physic simulation is about to be run
  126158. */
  126159. onBeforePhysicsObservable: Observable<Scene>;
  126160. /**
  126161. * An event triggered when physic simulation has been done
  126162. */
  126163. onAfterPhysicsObservable: Observable<Scene>;
  126164. }
  126165. interface AbstractMesh {
  126166. /** @hidden */
  126167. _physicsImpostor: Nullable<PhysicsImpostor>;
  126168. /**
  126169. * Gets or sets impostor used for physic simulation
  126170. * @see http://doc.babylonjs.com/features/physics_engine
  126171. */
  126172. physicsImpostor: Nullable<PhysicsImpostor>;
  126173. /**
  126174. * Gets the current physics impostor
  126175. * @see http://doc.babylonjs.com/features/physics_engine
  126176. * @returns a physics impostor or null
  126177. */
  126178. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126179. /** Apply a physic impulse to the mesh
  126180. * @param force defines the force to apply
  126181. * @param contactPoint defines where to apply the force
  126182. * @returns the current mesh
  126183. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126184. */
  126185. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126186. /**
  126187. * Creates a physic joint between two meshes
  126188. * @param otherMesh defines the other mesh to use
  126189. * @param pivot1 defines the pivot to use on this mesh
  126190. * @param pivot2 defines the pivot to use on the other mesh
  126191. * @param options defines additional options (can be plugin dependent)
  126192. * @returns the current mesh
  126193. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126194. */
  126195. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126196. /** @hidden */
  126197. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126198. }
  126199. /**
  126200. * Defines the physics engine scene component responsible to manage a physics engine
  126201. */
  126202. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126203. /**
  126204. * The component name helpful to identify the component in the list of scene components.
  126205. */
  126206. readonly name: string;
  126207. /**
  126208. * The scene the component belongs to.
  126209. */
  126210. scene: Scene;
  126211. /**
  126212. * Creates a new instance of the component for the given scene
  126213. * @param scene Defines the scene to register the component in
  126214. */
  126215. constructor(scene: Scene);
  126216. /**
  126217. * Registers the component in a given scene
  126218. */
  126219. register(): void;
  126220. /**
  126221. * Rebuilds the elements related to this component in case of
  126222. * context lost for instance.
  126223. */
  126224. rebuild(): void;
  126225. /**
  126226. * Disposes the component and the associated ressources
  126227. */
  126228. dispose(): void;
  126229. }
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * A helper for physics simulations
  126234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126235. */
  126236. export class PhysicsHelper {
  126237. private _scene;
  126238. private _physicsEngine;
  126239. /**
  126240. * Initializes the Physics helper
  126241. * @param scene Babylon.js scene
  126242. */
  126243. constructor(scene: Scene);
  126244. /**
  126245. * Applies a radial explosion impulse
  126246. * @param origin the origin of the explosion
  126247. * @param radiusOrEventOptions the radius or the options of radial explosion
  126248. * @param strength the explosion strength
  126249. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126250. * @returns A physics radial explosion event, or null
  126251. */
  126252. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126253. /**
  126254. * Applies a radial explosion force
  126255. * @param origin the origin of the explosion
  126256. * @param radiusOrEventOptions the radius or the options of radial explosion
  126257. * @param strength the explosion strength
  126258. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126259. * @returns A physics radial explosion event, or null
  126260. */
  126261. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126262. /**
  126263. * Creates a gravitational field
  126264. * @param origin the origin of the explosion
  126265. * @param radiusOrEventOptions the radius or the options of radial explosion
  126266. * @param strength the explosion strength
  126267. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126268. * @returns A physics gravitational field event, or null
  126269. */
  126270. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126271. /**
  126272. * Creates a physics updraft event
  126273. * @param origin the origin of the updraft
  126274. * @param radiusOrEventOptions the radius or the options of the updraft
  126275. * @param strength the strength of the updraft
  126276. * @param height the height of the updraft
  126277. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126278. * @returns A physics updraft event, or null
  126279. */
  126280. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126281. /**
  126282. * Creates a physics vortex event
  126283. * @param origin the of the vortex
  126284. * @param radiusOrEventOptions the radius or the options of the vortex
  126285. * @param strength the strength of the vortex
  126286. * @param height the height of the vortex
  126287. * @returns a Physics vortex event, or null
  126288. * A physics vortex event or null
  126289. */
  126290. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126291. }
  126292. /**
  126293. * Represents a physics radial explosion event
  126294. */
  126295. class PhysicsRadialExplosionEvent {
  126296. private _scene;
  126297. private _options;
  126298. private _sphere;
  126299. private _dataFetched;
  126300. /**
  126301. * Initializes a radial explosioin event
  126302. * @param _scene BabylonJS scene
  126303. * @param _options The options for the vortex event
  126304. */
  126305. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126306. /**
  126307. * Returns the data related to the radial explosion event (sphere).
  126308. * @returns The radial explosion event data
  126309. */
  126310. getData(): PhysicsRadialExplosionEventData;
  126311. /**
  126312. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126313. * @param impostor A physics imposter
  126314. * @param origin the origin of the explosion
  126315. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126316. */
  126317. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126318. /**
  126319. * Triggers affecterd impostors callbacks
  126320. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126321. */
  126322. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126323. /**
  126324. * Disposes the sphere.
  126325. * @param force Specifies if the sphere should be disposed by force
  126326. */
  126327. dispose(force?: boolean): void;
  126328. /*** Helpers ***/
  126329. private _prepareSphere;
  126330. private _intersectsWithSphere;
  126331. }
  126332. /**
  126333. * Represents a gravitational field event
  126334. */
  126335. class PhysicsGravitationalFieldEvent {
  126336. private _physicsHelper;
  126337. private _scene;
  126338. private _origin;
  126339. private _options;
  126340. private _tickCallback;
  126341. private _sphere;
  126342. private _dataFetched;
  126343. /**
  126344. * Initializes the physics gravitational field event
  126345. * @param _physicsHelper A physics helper
  126346. * @param _scene BabylonJS scene
  126347. * @param _origin The origin position of the gravitational field event
  126348. * @param _options The options for the vortex event
  126349. */
  126350. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126351. /**
  126352. * Returns the data related to the gravitational field event (sphere).
  126353. * @returns A gravitational field event
  126354. */
  126355. getData(): PhysicsGravitationalFieldEventData;
  126356. /**
  126357. * Enables the gravitational field.
  126358. */
  126359. enable(): void;
  126360. /**
  126361. * Disables the gravitational field.
  126362. */
  126363. disable(): void;
  126364. /**
  126365. * Disposes the sphere.
  126366. * @param force The force to dispose from the gravitational field event
  126367. */
  126368. dispose(force?: boolean): void;
  126369. private _tick;
  126370. }
  126371. /**
  126372. * Represents a physics updraft event
  126373. */
  126374. class PhysicsUpdraftEvent {
  126375. private _scene;
  126376. private _origin;
  126377. private _options;
  126378. private _physicsEngine;
  126379. private _originTop;
  126380. private _originDirection;
  126381. private _tickCallback;
  126382. private _cylinder;
  126383. private _cylinderPosition;
  126384. private _dataFetched;
  126385. /**
  126386. * Initializes the physics updraft event
  126387. * @param _scene BabylonJS scene
  126388. * @param _origin The origin position of the updraft
  126389. * @param _options The options for the updraft event
  126390. */
  126391. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126392. /**
  126393. * Returns the data related to the updraft event (cylinder).
  126394. * @returns A physics updraft event
  126395. */
  126396. getData(): PhysicsUpdraftEventData;
  126397. /**
  126398. * Enables the updraft.
  126399. */
  126400. enable(): void;
  126401. /**
  126402. * Disables the updraft.
  126403. */
  126404. disable(): void;
  126405. /**
  126406. * Disposes the cylinder.
  126407. * @param force Specifies if the updraft should be disposed by force
  126408. */
  126409. dispose(force?: boolean): void;
  126410. private getImpostorHitData;
  126411. private _tick;
  126412. /*** Helpers ***/
  126413. private _prepareCylinder;
  126414. private _intersectsWithCylinder;
  126415. }
  126416. /**
  126417. * Represents a physics vortex event
  126418. */
  126419. class PhysicsVortexEvent {
  126420. private _scene;
  126421. private _origin;
  126422. private _options;
  126423. private _physicsEngine;
  126424. private _originTop;
  126425. private _tickCallback;
  126426. private _cylinder;
  126427. private _cylinderPosition;
  126428. private _dataFetched;
  126429. /**
  126430. * Initializes the physics vortex event
  126431. * @param _scene The BabylonJS scene
  126432. * @param _origin The origin position of the vortex
  126433. * @param _options The options for the vortex event
  126434. */
  126435. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126436. /**
  126437. * Returns the data related to the vortex event (cylinder).
  126438. * @returns The physics vortex event data
  126439. */
  126440. getData(): PhysicsVortexEventData;
  126441. /**
  126442. * Enables the vortex.
  126443. */
  126444. enable(): void;
  126445. /**
  126446. * Disables the cortex.
  126447. */
  126448. disable(): void;
  126449. /**
  126450. * Disposes the sphere.
  126451. * @param force
  126452. */
  126453. dispose(force?: boolean): void;
  126454. private getImpostorHitData;
  126455. private _tick;
  126456. /*** Helpers ***/
  126457. private _prepareCylinder;
  126458. private _intersectsWithCylinder;
  126459. }
  126460. /**
  126461. * Options fot the radial explosion event
  126462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126463. */
  126464. export class PhysicsRadialExplosionEventOptions {
  126465. /**
  126466. * The radius of the sphere for the radial explosion.
  126467. */
  126468. radius: number;
  126469. /**
  126470. * The strenth of the explosion.
  126471. */
  126472. strength: number;
  126473. /**
  126474. * The strenght of the force in correspondence to the distance of the affected object
  126475. */
  126476. falloff: PhysicsRadialImpulseFalloff;
  126477. /**
  126478. * Sphere options for the radial explosion.
  126479. */
  126480. sphere: {
  126481. segments: number;
  126482. diameter: number;
  126483. };
  126484. /**
  126485. * Sphere options for the radial explosion.
  126486. */
  126487. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126488. }
  126489. /**
  126490. * Options fot the updraft event
  126491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126492. */
  126493. export class PhysicsUpdraftEventOptions {
  126494. /**
  126495. * The radius of the cylinder for the vortex
  126496. */
  126497. radius: number;
  126498. /**
  126499. * The strenth of the updraft.
  126500. */
  126501. strength: number;
  126502. /**
  126503. * The height of the cylinder for the updraft.
  126504. */
  126505. height: number;
  126506. /**
  126507. * The mode for the the updraft.
  126508. */
  126509. updraftMode: PhysicsUpdraftMode;
  126510. }
  126511. /**
  126512. * Options fot the vortex event
  126513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126514. */
  126515. export class PhysicsVortexEventOptions {
  126516. /**
  126517. * The radius of the cylinder for the vortex
  126518. */
  126519. radius: number;
  126520. /**
  126521. * The strenth of the vortex.
  126522. */
  126523. strength: number;
  126524. /**
  126525. * The height of the cylinder for the vortex.
  126526. */
  126527. height: number;
  126528. /**
  126529. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126530. */
  126531. centripetalForceThreshold: number;
  126532. /**
  126533. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126534. */
  126535. centripetalForceMultiplier: number;
  126536. /**
  126537. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126538. */
  126539. centrifugalForceMultiplier: number;
  126540. /**
  126541. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126542. */
  126543. updraftForceMultiplier: number;
  126544. }
  126545. /**
  126546. * The strenght of the force in correspondence to the distance of the affected object
  126547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126548. */
  126549. export enum PhysicsRadialImpulseFalloff {
  126550. /** Defines that impulse is constant in strength across it's whole radius */
  126551. Constant = 0,
  126552. /** Defines that impulse gets weaker if it's further from the origin */
  126553. Linear = 1
  126554. }
  126555. /**
  126556. * The strength of the force in correspondence to the distance of the affected object
  126557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126558. */
  126559. export enum PhysicsUpdraftMode {
  126560. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126561. Center = 0,
  126562. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126563. Perpendicular = 1
  126564. }
  126565. /**
  126566. * Interface for a physics hit data
  126567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126568. */
  126569. export interface PhysicsHitData {
  126570. /**
  126571. * The force applied at the contact point
  126572. */
  126573. force: Vector3;
  126574. /**
  126575. * The contact point
  126576. */
  126577. contactPoint: Vector3;
  126578. /**
  126579. * The distance from the origin to the contact point
  126580. */
  126581. distanceFromOrigin: number;
  126582. }
  126583. /**
  126584. * Interface for radial explosion event data
  126585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126586. */
  126587. export interface PhysicsRadialExplosionEventData {
  126588. /**
  126589. * A sphere used for the radial explosion event
  126590. */
  126591. sphere: Mesh;
  126592. }
  126593. /**
  126594. * Interface for gravitational field event data
  126595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126596. */
  126597. export interface PhysicsGravitationalFieldEventData {
  126598. /**
  126599. * A sphere mesh used for the gravitational field event
  126600. */
  126601. sphere: Mesh;
  126602. }
  126603. /**
  126604. * Interface for updraft event data
  126605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126606. */
  126607. export interface PhysicsUpdraftEventData {
  126608. /**
  126609. * A cylinder used for the updraft event
  126610. */
  126611. cylinder: Mesh;
  126612. }
  126613. /**
  126614. * Interface for vortex event data
  126615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126616. */
  126617. export interface PhysicsVortexEventData {
  126618. /**
  126619. * A cylinder used for the vortex event
  126620. */
  126621. cylinder: Mesh;
  126622. }
  126623. /**
  126624. * Interface for an affected physics impostor
  126625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126626. */
  126627. export interface PhysicsAffectedImpostorWithData {
  126628. /**
  126629. * The impostor affected by the effect
  126630. */
  126631. impostor: PhysicsImpostor;
  126632. /**
  126633. * The data about the hit/horce from the explosion
  126634. */
  126635. hitData: PhysicsHitData;
  126636. }
  126637. }
  126638. declare module BABYLON {
  126639. /** @hidden */
  126640. export var blackAndWhitePixelShader: {
  126641. name: string;
  126642. shader: string;
  126643. };
  126644. }
  126645. declare module BABYLON {
  126646. /**
  126647. * Post process used to render in black and white
  126648. */
  126649. export class BlackAndWhitePostProcess extends PostProcess {
  126650. /**
  126651. * Linear about to convert he result to black and white (default: 1)
  126652. */
  126653. degree: number;
  126654. /**
  126655. * Creates a black and white post process
  126656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126657. * @param name The name of the effect.
  126658. * @param options The required width/height ratio to downsize to before computing the render pass.
  126659. * @param camera The camera to apply the render pass to.
  126660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126661. * @param engine The engine which the post process will be applied. (default: current engine)
  126662. * @param reusable If the post process can be reused on the same frame. (default: false)
  126663. */
  126664. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126665. }
  126666. }
  126667. declare module BABYLON {
  126668. /**
  126669. * This represents a set of one or more post processes in Babylon.
  126670. * A post process can be used to apply a shader to a texture after it is rendered.
  126671. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126672. */
  126673. export class PostProcessRenderEffect {
  126674. private _postProcesses;
  126675. private _getPostProcesses;
  126676. private _singleInstance;
  126677. private _cameras;
  126678. private _indicesForCamera;
  126679. /**
  126680. * Name of the effect
  126681. * @hidden
  126682. */
  126683. _name: string;
  126684. /**
  126685. * Instantiates a post process render effect.
  126686. * A post process can be used to apply a shader to a texture after it is rendered.
  126687. * @param engine The engine the effect is tied to
  126688. * @param name The name of the effect
  126689. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126690. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126691. */
  126692. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126693. /**
  126694. * Checks if all the post processes in the effect are supported.
  126695. */
  126696. readonly isSupported: boolean;
  126697. /**
  126698. * Updates the current state of the effect
  126699. * @hidden
  126700. */
  126701. _update(): void;
  126702. /**
  126703. * Attaches the effect on cameras
  126704. * @param cameras The camera to attach to.
  126705. * @hidden
  126706. */
  126707. _attachCameras(cameras: Camera): void;
  126708. /**
  126709. * Attaches the effect on cameras
  126710. * @param cameras The camera to attach to.
  126711. * @hidden
  126712. */
  126713. _attachCameras(cameras: Camera[]): void;
  126714. /**
  126715. * Detaches the effect on cameras
  126716. * @param cameras The camera to detatch from.
  126717. * @hidden
  126718. */
  126719. _detachCameras(cameras: Camera): void;
  126720. /**
  126721. * Detatches the effect on cameras
  126722. * @param cameras The camera to detatch from.
  126723. * @hidden
  126724. */
  126725. _detachCameras(cameras: Camera[]): void;
  126726. /**
  126727. * Enables the effect on given cameras
  126728. * @param cameras The camera to enable.
  126729. * @hidden
  126730. */
  126731. _enable(cameras: Camera): void;
  126732. /**
  126733. * Enables the effect on given cameras
  126734. * @param cameras The camera to enable.
  126735. * @hidden
  126736. */
  126737. _enable(cameras: Nullable<Camera[]>): void;
  126738. /**
  126739. * Disables the effect on the given cameras
  126740. * @param cameras The camera to disable.
  126741. * @hidden
  126742. */
  126743. _disable(cameras: Camera): void;
  126744. /**
  126745. * Disables the effect on the given cameras
  126746. * @param cameras The camera to disable.
  126747. * @hidden
  126748. */
  126749. _disable(cameras: Nullable<Camera[]>): void;
  126750. /**
  126751. * Gets a list of the post processes contained in the effect.
  126752. * @param camera The camera to get the post processes on.
  126753. * @returns The list of the post processes in the effect.
  126754. */
  126755. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126756. }
  126757. }
  126758. declare module BABYLON {
  126759. /** @hidden */
  126760. export var extractHighlightsPixelShader: {
  126761. name: string;
  126762. shader: string;
  126763. };
  126764. }
  126765. declare module BABYLON {
  126766. /**
  126767. * 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.
  126768. */
  126769. export class ExtractHighlightsPostProcess extends PostProcess {
  126770. /**
  126771. * The luminance threshold, pixels below this value will be set to black.
  126772. */
  126773. threshold: number;
  126774. /** @hidden */
  126775. _exposure: number;
  126776. /**
  126777. * Post process which has the input texture to be used when performing highlight extraction
  126778. * @hidden
  126779. */
  126780. _inputPostProcess: Nullable<PostProcess>;
  126781. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126782. }
  126783. }
  126784. declare module BABYLON {
  126785. /** @hidden */
  126786. export var bloomMergePixelShader: {
  126787. name: string;
  126788. shader: string;
  126789. };
  126790. }
  126791. declare module BABYLON {
  126792. /**
  126793. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126794. */
  126795. export class BloomMergePostProcess extends PostProcess {
  126796. /** Weight of the bloom to be added to the original input. */
  126797. weight: number;
  126798. /**
  126799. * Creates a new instance of @see BloomMergePostProcess
  126800. * @param name The name of the effect.
  126801. * @param originalFromInput Post process which's input will be used for the merge.
  126802. * @param blurred Blurred highlights post process which's output will be used.
  126803. * @param weight Weight of the bloom to be added to the original input.
  126804. * @param options The required width/height ratio to downsize to before computing the render pass.
  126805. * @param camera The camera to apply the render pass to.
  126806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126807. * @param engine The engine which the post process will be applied. (default: current engine)
  126808. * @param reusable If the post process can be reused on the same frame. (default: false)
  126809. * @param textureType Type of textures used when performing the post process. (default: 0)
  126810. * @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)
  126811. */
  126812. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126813. /** Weight of the bloom to be added to the original input. */
  126814. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126815. }
  126816. }
  126817. declare module BABYLON {
  126818. /**
  126819. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126820. */
  126821. export class BloomEffect extends PostProcessRenderEffect {
  126822. private bloomScale;
  126823. /**
  126824. * @hidden Internal
  126825. */
  126826. _effects: Array<PostProcess>;
  126827. /**
  126828. * @hidden Internal
  126829. */
  126830. _downscale: ExtractHighlightsPostProcess;
  126831. private _blurX;
  126832. private _blurY;
  126833. private _merge;
  126834. /**
  126835. * The luminance threshold to find bright areas of the image to bloom.
  126836. */
  126837. threshold: number;
  126838. /**
  126839. * The strength of the bloom.
  126840. */
  126841. weight: number;
  126842. /**
  126843. * Specifies the size of the bloom blur kernel, relative to the final output size
  126844. */
  126845. kernel: number;
  126846. /**
  126847. * Creates a new instance of @see BloomEffect
  126848. * @param scene The scene the effect belongs to.
  126849. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  126850. * @param bloomKernel The size of the kernel to be used when applying the blur.
  126851. * @param bloomWeight The the strength of bloom.
  126852. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126853. * @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)
  126854. */
  126855. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  126856. /**
  126857. * Disposes each of the internal effects for a given camera.
  126858. * @param camera The camera to dispose the effect on.
  126859. */
  126860. disposeEffects(camera: Camera): void;
  126861. /**
  126862. * @hidden Internal
  126863. */
  126864. _updateEffects(): void;
  126865. /**
  126866. * Internal
  126867. * @returns if all the contained post processes are ready.
  126868. * @hidden
  126869. */
  126870. _isReady(): boolean;
  126871. }
  126872. }
  126873. declare module BABYLON {
  126874. /** @hidden */
  126875. export var chromaticAberrationPixelShader: {
  126876. name: string;
  126877. shader: string;
  126878. };
  126879. }
  126880. declare module BABYLON {
  126881. /**
  126882. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  126883. */
  126884. export class ChromaticAberrationPostProcess extends PostProcess {
  126885. /**
  126886. * The amount of seperation of rgb channels (default: 30)
  126887. */
  126888. aberrationAmount: number;
  126889. /**
  126890. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  126891. */
  126892. radialIntensity: number;
  126893. /**
  126894. * 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))
  126895. */
  126896. direction: Vector2;
  126897. /**
  126898. * 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))
  126899. */
  126900. centerPosition: Vector2;
  126901. /**
  126902. * Creates a new instance ChromaticAberrationPostProcess
  126903. * @param name The name of the effect.
  126904. * @param screenWidth The width of the screen to apply the effect on.
  126905. * @param screenHeight The height of the screen to apply the effect on.
  126906. * @param options The required width/height ratio to downsize to before computing the render pass.
  126907. * @param camera The camera to apply the render pass to.
  126908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126909. * @param engine The engine which the post process will be applied. (default: current engine)
  126910. * @param reusable If the post process can be reused on the same frame. (default: false)
  126911. * @param textureType Type of textures used when performing the post process. (default: 0)
  126912. * @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)
  126913. */
  126914. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126915. }
  126916. }
  126917. declare module BABYLON {
  126918. /** @hidden */
  126919. export var circleOfConfusionPixelShader: {
  126920. name: string;
  126921. shader: string;
  126922. };
  126923. }
  126924. declare module BABYLON {
  126925. /**
  126926. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  126927. */
  126928. export class CircleOfConfusionPostProcess extends PostProcess {
  126929. /**
  126930. * 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.
  126931. */
  126932. lensSize: number;
  126933. /**
  126934. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126935. */
  126936. fStop: number;
  126937. /**
  126938. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126939. */
  126940. focusDistance: number;
  126941. /**
  126942. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  126943. */
  126944. focalLength: number;
  126945. private _depthTexture;
  126946. /**
  126947. * Creates a new instance CircleOfConfusionPostProcess
  126948. * @param name The name of the effect.
  126949. * @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.
  126950. * @param options The required width/height ratio to downsize to before computing the render pass.
  126951. * @param camera The camera to apply the render pass to.
  126952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126953. * @param engine The engine which the post process will be applied. (default: current engine)
  126954. * @param reusable If the post process can be reused on the same frame. (default: false)
  126955. * @param textureType Type of textures used when performing the post process. (default: 0)
  126956. * @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)
  126957. */
  126958. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126959. /**
  126960. * 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.
  126961. */
  126962. depthTexture: RenderTargetTexture;
  126963. }
  126964. }
  126965. declare module BABYLON {
  126966. /** @hidden */
  126967. export var colorCorrectionPixelShader: {
  126968. name: string;
  126969. shader: string;
  126970. };
  126971. }
  126972. declare module BABYLON {
  126973. /**
  126974. *
  126975. * This post-process allows the modification of rendered colors by using
  126976. * a 'look-up table' (LUT). This effect is also called Color Grading.
  126977. *
  126978. * The object needs to be provided an url to a texture containing the color
  126979. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  126980. * Use an image editing software to tweak the LUT to match your needs.
  126981. *
  126982. * For an example of a color LUT, see here:
  126983. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  126984. * For explanations on color grading, see here:
  126985. * @see http://udn.epicgames.com/Three/ColorGrading.html
  126986. *
  126987. */
  126988. export class ColorCorrectionPostProcess extends PostProcess {
  126989. private _colorTableTexture;
  126990. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126991. }
  126992. }
  126993. declare module BABYLON {
  126994. /** @hidden */
  126995. export var convolutionPixelShader: {
  126996. name: string;
  126997. shader: string;
  126998. };
  126999. }
  127000. declare module BABYLON {
  127001. /**
  127002. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127003. * input texture to perform effects such as edge detection or sharpening
  127004. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127005. */
  127006. export class ConvolutionPostProcess extends PostProcess {
  127007. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127008. kernel: number[];
  127009. /**
  127010. * Creates a new instance ConvolutionPostProcess
  127011. * @param name The name of the effect.
  127012. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127013. * @param options The required width/height ratio to downsize to before computing the render pass.
  127014. * @param camera The camera to apply the render pass to.
  127015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127016. * @param engine The engine which the post process will be applied. (default: current engine)
  127017. * @param reusable If the post process can be reused on the same frame. (default: false)
  127018. * @param textureType Type of textures used when performing the post process. (default: 0)
  127019. */
  127020. constructor(name: string,
  127021. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127022. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127023. /**
  127024. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127025. */
  127026. static EdgeDetect0Kernel: number[];
  127027. /**
  127028. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127029. */
  127030. static EdgeDetect1Kernel: number[];
  127031. /**
  127032. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127033. */
  127034. static EdgeDetect2Kernel: number[];
  127035. /**
  127036. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127037. */
  127038. static SharpenKernel: number[];
  127039. /**
  127040. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127041. */
  127042. static EmbossKernel: number[];
  127043. /**
  127044. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127045. */
  127046. static GaussianKernel: number[];
  127047. }
  127048. }
  127049. declare module BABYLON {
  127050. /**
  127051. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127052. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127053. * based on samples that have a large difference in distance than the center pixel.
  127054. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127055. */
  127056. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127057. direction: Vector2;
  127058. /**
  127059. * Creates a new instance CircleOfConfusionPostProcess
  127060. * @param name The name of the effect.
  127061. * @param scene The scene the effect belongs to.
  127062. * @param direction The direction the blur should be applied.
  127063. * @param kernel The size of the kernel used to blur.
  127064. * @param options The required width/height ratio to downsize to before computing the render pass.
  127065. * @param camera The camera to apply the render pass to.
  127066. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127067. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127069. * @param engine The engine which the post process will be applied. (default: current engine)
  127070. * @param reusable If the post process can be reused on the same frame. (default: false)
  127071. * @param textureType Type of textures used when performing the post process. (default: 0)
  127072. * @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)
  127073. */
  127074. 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);
  127075. }
  127076. }
  127077. declare module BABYLON {
  127078. /** @hidden */
  127079. export var depthOfFieldMergePixelShader: {
  127080. name: string;
  127081. shader: string;
  127082. };
  127083. }
  127084. declare module BABYLON {
  127085. /**
  127086. * Options to be set when merging outputs from the default pipeline.
  127087. */
  127088. export class DepthOfFieldMergePostProcessOptions {
  127089. /**
  127090. * The original image to merge on top of
  127091. */
  127092. originalFromInput: PostProcess;
  127093. /**
  127094. * Parameters to perform the merge of the depth of field effect
  127095. */
  127096. depthOfField?: {
  127097. circleOfConfusion: PostProcess;
  127098. blurSteps: Array<PostProcess>;
  127099. };
  127100. /**
  127101. * Parameters to perform the merge of bloom effect
  127102. */
  127103. bloom?: {
  127104. blurred: PostProcess;
  127105. weight: number;
  127106. };
  127107. }
  127108. /**
  127109. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127110. */
  127111. export class DepthOfFieldMergePostProcess extends PostProcess {
  127112. private blurSteps;
  127113. /**
  127114. * Creates a new instance of DepthOfFieldMergePostProcess
  127115. * @param name The name of the effect.
  127116. * @param originalFromInput Post process which's input will be used for the merge.
  127117. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127118. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127119. * @param options The required width/height ratio to downsize to before computing the render pass.
  127120. * @param camera The camera to apply the render pass to.
  127121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127122. * @param engine The engine which the post process will be applied. (default: current engine)
  127123. * @param reusable If the post process can be reused on the same frame. (default: false)
  127124. * @param textureType Type of textures used when performing the post process. (default: 0)
  127125. * @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)
  127126. */
  127127. 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);
  127128. /**
  127129. * Updates the effect with the current post process compile time values and recompiles the shader.
  127130. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127131. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127132. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127133. * @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
  127134. * @param onCompiled Called when the shader has been compiled.
  127135. * @param onError Called if there is an error when compiling a shader.
  127136. */
  127137. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127138. }
  127139. }
  127140. declare module BABYLON {
  127141. /**
  127142. * Specifies the level of max blur that should be applied when using the depth of field effect
  127143. */
  127144. export enum DepthOfFieldEffectBlurLevel {
  127145. /**
  127146. * Subtle blur
  127147. */
  127148. Low = 0,
  127149. /**
  127150. * Medium blur
  127151. */
  127152. Medium = 1,
  127153. /**
  127154. * Large blur
  127155. */
  127156. High = 2
  127157. }
  127158. /**
  127159. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127160. */
  127161. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127162. private _circleOfConfusion;
  127163. /**
  127164. * @hidden Internal, blurs from high to low
  127165. */
  127166. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127167. private _depthOfFieldBlurY;
  127168. private _dofMerge;
  127169. /**
  127170. * @hidden Internal post processes in depth of field effect
  127171. */
  127172. _effects: Array<PostProcess>;
  127173. /**
  127174. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127175. */
  127176. focalLength: number;
  127177. /**
  127178. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127179. */
  127180. fStop: number;
  127181. /**
  127182. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127183. */
  127184. focusDistance: number;
  127185. /**
  127186. * 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.
  127187. */
  127188. lensSize: number;
  127189. /**
  127190. * Creates a new instance DepthOfFieldEffect
  127191. * @param scene The scene the effect belongs to.
  127192. * @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.
  127193. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127194. * @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)
  127195. */
  127196. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127197. /**
  127198. * Get the current class name of the current effet
  127199. * @returns "DepthOfFieldEffect"
  127200. */
  127201. getClassName(): string;
  127202. /**
  127203. * 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.
  127204. */
  127205. depthTexture: RenderTargetTexture;
  127206. /**
  127207. * Disposes each of the internal effects for a given camera.
  127208. * @param camera The camera to dispose the effect on.
  127209. */
  127210. disposeEffects(camera: Camera): void;
  127211. /**
  127212. * @hidden Internal
  127213. */
  127214. _updateEffects(): void;
  127215. /**
  127216. * Internal
  127217. * @returns if all the contained post processes are ready.
  127218. * @hidden
  127219. */
  127220. _isReady(): boolean;
  127221. }
  127222. }
  127223. declare module BABYLON {
  127224. /** @hidden */
  127225. export var displayPassPixelShader: {
  127226. name: string;
  127227. shader: string;
  127228. };
  127229. }
  127230. declare module BABYLON {
  127231. /**
  127232. * DisplayPassPostProcess which produces an output the same as it's input
  127233. */
  127234. export class DisplayPassPostProcess extends PostProcess {
  127235. /**
  127236. * Creates the DisplayPassPostProcess
  127237. * @param name The name of the effect.
  127238. * @param options The required width/height ratio to downsize to before computing the render pass.
  127239. * @param camera The camera to apply the render pass to.
  127240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127241. * @param engine The engine which the post process will be applied. (default: current engine)
  127242. * @param reusable If the post process can be reused on the same frame. (default: false)
  127243. */
  127244. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127245. }
  127246. }
  127247. declare module BABYLON {
  127248. /** @hidden */
  127249. export var filterPixelShader: {
  127250. name: string;
  127251. shader: string;
  127252. };
  127253. }
  127254. declare module BABYLON {
  127255. /**
  127256. * Applies a kernel filter to the image
  127257. */
  127258. export class FilterPostProcess extends PostProcess {
  127259. /** The matrix to be applied to the image */
  127260. kernelMatrix: Matrix;
  127261. /**
  127262. *
  127263. * @param name The name of the effect.
  127264. * @param kernelMatrix The matrix to be applied to the image
  127265. * @param options The required width/height ratio to downsize to before computing the render pass.
  127266. * @param camera The camera to apply the render pass to.
  127267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127268. * @param engine The engine which the post process will be applied. (default: current engine)
  127269. * @param reusable If the post process can be reused on the same frame. (default: false)
  127270. */
  127271. constructor(name: string,
  127272. /** The matrix to be applied to the image */
  127273. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127274. }
  127275. }
  127276. declare module BABYLON {
  127277. /** @hidden */
  127278. export var fxaaPixelShader: {
  127279. name: string;
  127280. shader: string;
  127281. };
  127282. }
  127283. declare module BABYLON {
  127284. /** @hidden */
  127285. export var fxaaVertexShader: {
  127286. name: string;
  127287. shader: string;
  127288. };
  127289. }
  127290. declare module BABYLON {
  127291. /**
  127292. * Fxaa post process
  127293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127294. */
  127295. export class FxaaPostProcess extends PostProcess {
  127296. /** @hidden */
  127297. texelWidth: number;
  127298. /** @hidden */
  127299. texelHeight: number;
  127300. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127301. private _getDefines;
  127302. }
  127303. }
  127304. declare module BABYLON {
  127305. /** @hidden */
  127306. export var grainPixelShader: {
  127307. name: string;
  127308. shader: string;
  127309. };
  127310. }
  127311. declare module BABYLON {
  127312. /**
  127313. * The GrainPostProcess adds noise to the image at mid luminance levels
  127314. */
  127315. export class GrainPostProcess extends PostProcess {
  127316. /**
  127317. * The intensity of the grain added (default: 30)
  127318. */
  127319. intensity: number;
  127320. /**
  127321. * If the grain should be randomized on every frame
  127322. */
  127323. animated: boolean;
  127324. /**
  127325. * Creates a new instance of @see GrainPostProcess
  127326. * @param name The name of the effect.
  127327. * @param options The required width/height ratio to downsize to before computing the render pass.
  127328. * @param camera The camera to apply the render pass to.
  127329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127330. * @param engine The engine which the post process will be applied. (default: current engine)
  127331. * @param reusable If the post process can be reused on the same frame. (default: false)
  127332. * @param textureType Type of textures used when performing the post process. (default: 0)
  127333. * @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)
  127334. */
  127335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127336. }
  127337. }
  127338. declare module BABYLON {
  127339. /** @hidden */
  127340. export var highlightsPixelShader: {
  127341. name: string;
  127342. shader: string;
  127343. };
  127344. }
  127345. declare module BABYLON {
  127346. /**
  127347. * Extracts highlights from the image
  127348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127349. */
  127350. export class HighlightsPostProcess extends PostProcess {
  127351. /**
  127352. * Extracts highlights from the image
  127353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127354. * @param name The name of the effect.
  127355. * @param options The required width/height ratio to downsize to before computing the render pass.
  127356. * @param camera The camera to apply the render pass to.
  127357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127358. * @param engine The engine which the post process will be applied. (default: current engine)
  127359. * @param reusable If the post process can be reused on the same frame. (default: false)
  127360. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127361. */
  127362. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127363. }
  127364. }
  127365. declare module BABYLON {
  127366. /** @hidden */
  127367. export var mrtFragmentDeclaration: {
  127368. name: string;
  127369. shader: string;
  127370. };
  127371. }
  127372. declare module BABYLON {
  127373. /** @hidden */
  127374. export var geometryPixelShader: {
  127375. name: string;
  127376. shader: string;
  127377. };
  127378. }
  127379. declare module BABYLON {
  127380. /** @hidden */
  127381. export var geometryVertexShader: {
  127382. name: string;
  127383. shader: string;
  127384. };
  127385. }
  127386. declare module BABYLON {
  127387. /** @hidden */
  127388. interface ISavedTransformationMatrix {
  127389. world: Matrix;
  127390. viewProjection: Matrix;
  127391. }
  127392. /**
  127393. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127394. */
  127395. export class GeometryBufferRenderer {
  127396. /**
  127397. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127398. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127399. */
  127400. static readonly POSITION_TEXTURE_TYPE: number;
  127401. /**
  127402. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127403. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127404. */
  127405. static readonly VELOCITY_TEXTURE_TYPE: number;
  127406. /**
  127407. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127408. * in order to compute objects velocities when enableVelocity is set to "true"
  127409. * @hidden
  127410. */
  127411. _previousTransformationMatrices: {
  127412. [index: number]: ISavedTransformationMatrix;
  127413. };
  127414. /**
  127415. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127416. * in order to compute objects velocities when enableVelocity is set to "true"
  127417. * @hidden
  127418. */
  127419. _previousBonesTransformationMatrices: {
  127420. [index: number]: Float32Array;
  127421. };
  127422. /**
  127423. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127424. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127425. */
  127426. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127427. private _scene;
  127428. private _multiRenderTarget;
  127429. private _ratio;
  127430. private _enablePosition;
  127431. private _enableVelocity;
  127432. private _positionIndex;
  127433. private _velocityIndex;
  127434. protected _effect: Effect;
  127435. protected _cachedDefines: string;
  127436. /**
  127437. * Set the render list (meshes to be rendered) used in the G buffer.
  127438. */
  127439. renderList: Mesh[];
  127440. /**
  127441. * Gets wether or not G buffer are supported by the running hardware.
  127442. * This requires draw buffer supports
  127443. */
  127444. readonly isSupported: boolean;
  127445. /**
  127446. * Returns the index of the given texture type in the G-Buffer textures array
  127447. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127448. * @returns the index of the given texture type in the G-Buffer textures array
  127449. */
  127450. getTextureIndex(textureType: number): number;
  127451. /**
  127452. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127453. */
  127454. /**
  127455. * Sets whether or not objects positions are enabled for the G buffer.
  127456. */
  127457. enablePosition: boolean;
  127458. /**
  127459. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127460. */
  127461. /**
  127462. * Sets wether or not objects velocities are enabled for the G buffer.
  127463. */
  127464. enableVelocity: boolean;
  127465. /**
  127466. * Gets the scene associated with the buffer.
  127467. */
  127468. readonly scene: Scene;
  127469. /**
  127470. * Gets the ratio used by the buffer during its creation.
  127471. * How big is the buffer related to the main canvas.
  127472. */
  127473. readonly ratio: number;
  127474. /** @hidden */
  127475. static _SceneComponentInitialization: (scene: Scene) => void;
  127476. /**
  127477. * Creates a new G Buffer for the scene
  127478. * @param scene The scene the buffer belongs to
  127479. * @param ratio How big is the buffer related to the main canvas.
  127480. */
  127481. constructor(scene: Scene, ratio?: number);
  127482. /**
  127483. * Checks wether everything is ready to render a submesh to the G buffer.
  127484. * @param subMesh the submesh to check readiness for
  127485. * @param useInstances is the mesh drawn using instance or not
  127486. * @returns true if ready otherwise false
  127487. */
  127488. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127489. /**
  127490. * Gets the current underlying G Buffer.
  127491. * @returns the buffer
  127492. */
  127493. getGBuffer(): MultiRenderTarget;
  127494. /**
  127495. * Gets the number of samples used to render the buffer (anti aliasing).
  127496. */
  127497. /**
  127498. * Sets the number of samples used to render the buffer (anti aliasing).
  127499. */
  127500. samples: number;
  127501. /**
  127502. * Disposes the renderer and frees up associated resources.
  127503. */
  127504. dispose(): void;
  127505. protected _createRenderTargets(): void;
  127506. private _copyBonesTransformationMatrices;
  127507. }
  127508. }
  127509. declare module BABYLON {
  127510. interface Scene {
  127511. /** @hidden (Backing field) */
  127512. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127513. /**
  127514. * Gets or Sets the current geometry buffer associated to the scene.
  127515. */
  127516. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127517. /**
  127518. * Enables a GeometryBufferRender and associates it with the scene
  127519. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127520. * @returns the GeometryBufferRenderer
  127521. */
  127522. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127523. /**
  127524. * Disables the GeometryBufferRender associated with the scene
  127525. */
  127526. disableGeometryBufferRenderer(): void;
  127527. }
  127528. /**
  127529. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127530. * in several rendering techniques.
  127531. */
  127532. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127533. /**
  127534. * The component name helpful to identify the component in the list of scene components.
  127535. */
  127536. readonly name: string;
  127537. /**
  127538. * The scene the component belongs to.
  127539. */
  127540. scene: Scene;
  127541. /**
  127542. * Creates a new instance of the component for the given scene
  127543. * @param scene Defines the scene to register the component in
  127544. */
  127545. constructor(scene: Scene);
  127546. /**
  127547. * Registers the component in a given scene
  127548. */
  127549. register(): void;
  127550. /**
  127551. * Rebuilds the elements related to this component in case of
  127552. * context lost for instance.
  127553. */
  127554. rebuild(): void;
  127555. /**
  127556. * Disposes the component and the associated ressources
  127557. */
  127558. dispose(): void;
  127559. private _gatherRenderTargets;
  127560. }
  127561. }
  127562. declare module BABYLON {
  127563. /** @hidden */
  127564. export var motionBlurPixelShader: {
  127565. name: string;
  127566. shader: string;
  127567. };
  127568. }
  127569. declare module BABYLON {
  127570. /**
  127571. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127572. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127573. * As an example, all you have to do is to create the post-process:
  127574. * var mb = new BABYLON.MotionBlurPostProcess(
  127575. * 'mb', // The name of the effect.
  127576. * scene, // The scene containing the objects to blur according to their velocity.
  127577. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127578. * camera // The camera to apply the render pass to.
  127579. * );
  127580. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127581. */
  127582. export class MotionBlurPostProcess extends PostProcess {
  127583. /**
  127584. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127585. */
  127586. motionStrength: number;
  127587. /**
  127588. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127589. */
  127590. /**
  127591. * Sets the number of iterations to be used for motion blur quality
  127592. */
  127593. motionBlurSamples: number;
  127594. private _motionBlurSamples;
  127595. private _geometryBufferRenderer;
  127596. /**
  127597. * Creates a new instance MotionBlurPostProcess
  127598. * @param name The name of the effect.
  127599. * @param scene The scene containing the objects to blur according to their velocity.
  127600. * @param options The required width/height ratio to downsize to before computing the render pass.
  127601. * @param camera The camera to apply the render pass to.
  127602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127603. * @param engine The engine which the post process will be applied. (default: current engine)
  127604. * @param reusable If the post process can be reused on the same frame. (default: false)
  127605. * @param textureType Type of textures used when performing the post process. (default: 0)
  127606. * @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)
  127607. */
  127608. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127609. /**
  127610. * Excludes the given skinned mesh from computing bones velocities.
  127611. * 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.
  127612. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127613. */
  127614. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127615. /**
  127616. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127617. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127618. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127619. */
  127620. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127621. /**
  127622. * Disposes the post process.
  127623. * @param camera The camera to dispose the post process on.
  127624. */
  127625. dispose(camera?: Camera): void;
  127626. }
  127627. }
  127628. declare module BABYLON {
  127629. /** @hidden */
  127630. export var refractionPixelShader: {
  127631. name: string;
  127632. shader: string;
  127633. };
  127634. }
  127635. declare module BABYLON {
  127636. /**
  127637. * Post process which applies a refractin texture
  127638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127639. */
  127640. export class RefractionPostProcess extends PostProcess {
  127641. /** the base color of the refraction (used to taint the rendering) */
  127642. color: Color3;
  127643. /** simulated refraction depth */
  127644. depth: number;
  127645. /** the coefficient of the base color (0 to remove base color tainting) */
  127646. colorLevel: number;
  127647. private _refTexture;
  127648. private _ownRefractionTexture;
  127649. /**
  127650. * Gets or sets the refraction texture
  127651. * Please note that you are responsible for disposing the texture if you set it manually
  127652. */
  127653. refractionTexture: Texture;
  127654. /**
  127655. * Initializes the RefractionPostProcess
  127656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127657. * @param name The name of the effect.
  127658. * @param refractionTextureUrl Url of the refraction texture to use
  127659. * @param color the base color of the refraction (used to taint the rendering)
  127660. * @param depth simulated refraction depth
  127661. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127662. * @param camera The camera to apply the render pass to.
  127663. * @param options The required width/height ratio to downsize to before computing the render pass.
  127664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127665. * @param engine The engine which the post process will be applied. (default: current engine)
  127666. * @param reusable If the post process can be reused on the same frame. (default: false)
  127667. */
  127668. constructor(name: string, refractionTextureUrl: string,
  127669. /** the base color of the refraction (used to taint the rendering) */
  127670. color: Color3,
  127671. /** simulated refraction depth */
  127672. depth: number,
  127673. /** the coefficient of the base color (0 to remove base color tainting) */
  127674. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127675. /**
  127676. * Disposes of the post process
  127677. * @param camera Camera to dispose post process on
  127678. */
  127679. dispose(camera: Camera): void;
  127680. }
  127681. }
  127682. declare module BABYLON {
  127683. /** @hidden */
  127684. export var sharpenPixelShader: {
  127685. name: string;
  127686. shader: string;
  127687. };
  127688. }
  127689. declare module BABYLON {
  127690. /**
  127691. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127692. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127693. */
  127694. export class SharpenPostProcess extends PostProcess {
  127695. /**
  127696. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127697. */
  127698. colorAmount: number;
  127699. /**
  127700. * How much sharpness should be applied (default: 0.3)
  127701. */
  127702. edgeAmount: number;
  127703. /**
  127704. * Creates a new instance ConvolutionPostProcess
  127705. * @param name The name of the effect.
  127706. * @param options The required width/height ratio to downsize to before computing the render pass.
  127707. * @param camera The camera to apply the render pass to.
  127708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127709. * @param engine The engine which the post process will be applied. (default: current engine)
  127710. * @param reusable If the post process can be reused on the same frame. (default: false)
  127711. * @param textureType Type of textures used when performing the post process. (default: 0)
  127712. * @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)
  127713. */
  127714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127715. }
  127716. }
  127717. declare module BABYLON {
  127718. /**
  127719. * PostProcessRenderPipeline
  127720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127721. */
  127722. export class PostProcessRenderPipeline {
  127723. private engine;
  127724. private _renderEffects;
  127725. private _renderEffectsForIsolatedPass;
  127726. /**
  127727. * List of inspectable custom properties (used by the Inspector)
  127728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127729. */
  127730. inspectableCustomProperties: IInspectable[];
  127731. /**
  127732. * @hidden
  127733. */
  127734. protected _cameras: Camera[];
  127735. /** @hidden */
  127736. _name: string;
  127737. /**
  127738. * Gets pipeline name
  127739. */
  127740. readonly name: string;
  127741. /**
  127742. * Initializes a PostProcessRenderPipeline
  127743. * @param engine engine to add the pipeline to
  127744. * @param name name of the pipeline
  127745. */
  127746. constructor(engine: Engine, name: string);
  127747. /**
  127748. * Gets the class name
  127749. * @returns "PostProcessRenderPipeline"
  127750. */
  127751. getClassName(): string;
  127752. /**
  127753. * If all the render effects in the pipeline are supported
  127754. */
  127755. readonly isSupported: boolean;
  127756. /**
  127757. * Adds an effect to the pipeline
  127758. * @param renderEffect the effect to add
  127759. */
  127760. addEffect(renderEffect: PostProcessRenderEffect): void;
  127761. /** @hidden */
  127762. _rebuild(): void;
  127763. /** @hidden */
  127764. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127765. /** @hidden */
  127766. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127767. /** @hidden */
  127768. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127769. /** @hidden */
  127770. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127771. /** @hidden */
  127772. _attachCameras(cameras: Camera, unique: boolean): void;
  127773. /** @hidden */
  127774. _attachCameras(cameras: Camera[], unique: boolean): void;
  127775. /** @hidden */
  127776. _detachCameras(cameras: Camera): void;
  127777. /** @hidden */
  127778. _detachCameras(cameras: Nullable<Camera[]>): void;
  127779. /** @hidden */
  127780. _update(): void;
  127781. /** @hidden */
  127782. _reset(): void;
  127783. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127784. /**
  127785. * Disposes of the pipeline
  127786. */
  127787. dispose(): void;
  127788. }
  127789. }
  127790. declare module BABYLON {
  127791. /**
  127792. * PostProcessRenderPipelineManager class
  127793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127794. */
  127795. export class PostProcessRenderPipelineManager {
  127796. private _renderPipelines;
  127797. /**
  127798. * Initializes a PostProcessRenderPipelineManager
  127799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127800. */
  127801. constructor();
  127802. /**
  127803. * Gets the list of supported render pipelines
  127804. */
  127805. readonly supportedPipelines: PostProcessRenderPipeline[];
  127806. /**
  127807. * Adds a pipeline to the manager
  127808. * @param renderPipeline The pipeline to add
  127809. */
  127810. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127811. /**
  127812. * Attaches a camera to the pipeline
  127813. * @param renderPipelineName The name of the pipeline to attach to
  127814. * @param cameras the camera to attach
  127815. * @param unique if the camera can be attached multiple times to the pipeline
  127816. */
  127817. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127818. /**
  127819. * Detaches a camera from the pipeline
  127820. * @param renderPipelineName The name of the pipeline to detach from
  127821. * @param cameras the camera to detach
  127822. */
  127823. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  127824. /**
  127825. * Enables an effect by name on a pipeline
  127826. * @param renderPipelineName the name of the pipeline to enable the effect in
  127827. * @param renderEffectName the name of the effect to enable
  127828. * @param cameras the cameras that the effect should be enabled on
  127829. */
  127830. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127831. /**
  127832. * Disables an effect by name on a pipeline
  127833. * @param renderPipelineName the name of the pipeline to disable the effect in
  127834. * @param renderEffectName the name of the effect to disable
  127835. * @param cameras the cameras that the effect should be disabled on
  127836. */
  127837. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127838. /**
  127839. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  127840. */
  127841. update(): void;
  127842. /** @hidden */
  127843. _rebuild(): void;
  127844. /**
  127845. * Disposes of the manager and pipelines
  127846. */
  127847. dispose(): void;
  127848. }
  127849. }
  127850. declare module BABYLON {
  127851. interface Scene {
  127852. /** @hidden (Backing field) */
  127853. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127854. /**
  127855. * Gets the postprocess render pipeline manager
  127856. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127857. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127858. */
  127859. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127860. }
  127861. /**
  127862. * Defines the Render Pipeline scene component responsible to rendering pipelines
  127863. */
  127864. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  127865. /**
  127866. * The component name helpfull to identify the component in the list of scene components.
  127867. */
  127868. readonly name: string;
  127869. /**
  127870. * The scene the component belongs to.
  127871. */
  127872. scene: Scene;
  127873. /**
  127874. * Creates a new instance of the component for the given scene
  127875. * @param scene Defines the scene to register the component in
  127876. */
  127877. constructor(scene: Scene);
  127878. /**
  127879. * Registers the component in a given scene
  127880. */
  127881. register(): void;
  127882. /**
  127883. * Rebuilds the elements related to this component in case of
  127884. * context lost for instance.
  127885. */
  127886. rebuild(): void;
  127887. /**
  127888. * Disposes the component and the associated ressources
  127889. */
  127890. dispose(): void;
  127891. private _gatherRenderTargets;
  127892. }
  127893. }
  127894. declare module BABYLON {
  127895. /**
  127896. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  127897. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127898. */
  127899. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127900. private _scene;
  127901. private _camerasToBeAttached;
  127902. /**
  127903. * ID of the sharpen post process,
  127904. */
  127905. private readonly SharpenPostProcessId;
  127906. /**
  127907. * @ignore
  127908. * ID of the image processing post process;
  127909. */
  127910. readonly ImageProcessingPostProcessId: string;
  127911. /**
  127912. * @ignore
  127913. * ID of the Fast Approximate Anti-Aliasing post process;
  127914. */
  127915. readonly FxaaPostProcessId: string;
  127916. /**
  127917. * ID of the chromatic aberration post process,
  127918. */
  127919. private readonly ChromaticAberrationPostProcessId;
  127920. /**
  127921. * ID of the grain post process
  127922. */
  127923. private readonly GrainPostProcessId;
  127924. /**
  127925. * Sharpen post process which will apply a sharpen convolution to enhance edges
  127926. */
  127927. sharpen: SharpenPostProcess;
  127928. private _sharpenEffect;
  127929. private bloom;
  127930. /**
  127931. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  127932. */
  127933. depthOfField: DepthOfFieldEffect;
  127934. /**
  127935. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127936. */
  127937. fxaa: FxaaPostProcess;
  127938. /**
  127939. * Image post processing pass used to perform operations such as tone mapping or color grading.
  127940. */
  127941. imageProcessing: ImageProcessingPostProcess;
  127942. /**
  127943. * Chromatic aberration post process which will shift rgb colors in the image
  127944. */
  127945. chromaticAberration: ChromaticAberrationPostProcess;
  127946. private _chromaticAberrationEffect;
  127947. /**
  127948. * Grain post process which add noise to the image
  127949. */
  127950. grain: GrainPostProcess;
  127951. private _grainEffect;
  127952. /**
  127953. * Glow post process which adds a glow to emissive areas of the image
  127954. */
  127955. private _glowLayer;
  127956. /**
  127957. * Animations which can be used to tweak settings over a period of time
  127958. */
  127959. animations: Animation[];
  127960. private _imageProcessingConfigurationObserver;
  127961. private _sharpenEnabled;
  127962. private _bloomEnabled;
  127963. private _depthOfFieldEnabled;
  127964. private _depthOfFieldBlurLevel;
  127965. private _fxaaEnabled;
  127966. private _imageProcessingEnabled;
  127967. private _defaultPipelineTextureType;
  127968. private _bloomScale;
  127969. private _chromaticAberrationEnabled;
  127970. private _grainEnabled;
  127971. private _buildAllowed;
  127972. /**
  127973. * Gets active scene
  127974. */
  127975. readonly scene: Scene;
  127976. /**
  127977. * Enable or disable the sharpen process from the pipeline
  127978. */
  127979. sharpenEnabled: boolean;
  127980. private _resizeObserver;
  127981. private _hardwareScaleLevel;
  127982. private _bloomKernel;
  127983. /**
  127984. * Specifies the size of the bloom blur kernel, relative to the final output size
  127985. */
  127986. bloomKernel: number;
  127987. /**
  127988. * Specifies the weight of the bloom in the final rendering
  127989. */
  127990. private _bloomWeight;
  127991. /**
  127992. * Specifies the luma threshold for the area that will be blurred by the bloom
  127993. */
  127994. private _bloomThreshold;
  127995. private _hdr;
  127996. /**
  127997. * The strength of the bloom.
  127998. */
  127999. bloomWeight: number;
  128000. /**
  128001. * The strength of the bloom.
  128002. */
  128003. bloomThreshold: number;
  128004. /**
  128005. * The scale of the bloom, lower value will provide better performance.
  128006. */
  128007. bloomScale: number;
  128008. /**
  128009. * Enable or disable the bloom from the pipeline
  128010. */
  128011. bloomEnabled: boolean;
  128012. private _rebuildBloom;
  128013. /**
  128014. * If the depth of field is enabled.
  128015. */
  128016. depthOfFieldEnabled: boolean;
  128017. /**
  128018. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128019. */
  128020. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128021. /**
  128022. * If the anti aliasing is enabled.
  128023. */
  128024. fxaaEnabled: boolean;
  128025. private _samples;
  128026. /**
  128027. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128028. */
  128029. samples: number;
  128030. /**
  128031. * If image processing is enabled.
  128032. */
  128033. imageProcessingEnabled: boolean;
  128034. /**
  128035. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128036. */
  128037. glowLayerEnabled: boolean;
  128038. /**
  128039. * Gets the glow layer (or null if not defined)
  128040. */
  128041. readonly glowLayer: Nullable<GlowLayer>;
  128042. /**
  128043. * Enable or disable the chromaticAberration process from the pipeline
  128044. */
  128045. chromaticAberrationEnabled: boolean;
  128046. /**
  128047. * Enable or disable the grain process from the pipeline
  128048. */
  128049. grainEnabled: boolean;
  128050. /**
  128051. * @constructor
  128052. * @param name - The rendering pipeline name (default: "")
  128053. * @param hdr - If high dynamic range textures should be used (default: true)
  128054. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128055. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128056. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128057. */
  128058. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128059. /**
  128060. * Get the class name
  128061. * @returns "DefaultRenderingPipeline"
  128062. */
  128063. getClassName(): string;
  128064. /**
  128065. * Force the compilation of the entire pipeline.
  128066. */
  128067. prepare(): void;
  128068. private _hasCleared;
  128069. private _prevPostProcess;
  128070. private _prevPrevPostProcess;
  128071. private _setAutoClearAndTextureSharing;
  128072. private _depthOfFieldSceneObserver;
  128073. private _buildPipeline;
  128074. private _disposePostProcesses;
  128075. /**
  128076. * Adds a camera to the pipeline
  128077. * @param camera the camera to be added
  128078. */
  128079. addCamera(camera: Camera): void;
  128080. /**
  128081. * Removes a camera from the pipeline
  128082. * @param camera the camera to remove
  128083. */
  128084. removeCamera(camera: Camera): void;
  128085. /**
  128086. * Dispose of the pipeline and stop all post processes
  128087. */
  128088. dispose(): void;
  128089. /**
  128090. * Serialize the rendering pipeline (Used when exporting)
  128091. * @returns the serialized object
  128092. */
  128093. serialize(): any;
  128094. /**
  128095. * Parse the serialized pipeline
  128096. * @param source Source pipeline.
  128097. * @param scene The scene to load the pipeline to.
  128098. * @param rootUrl The URL of the serialized pipeline.
  128099. * @returns An instantiated pipeline from the serialized object.
  128100. */
  128101. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128102. }
  128103. }
  128104. declare module BABYLON {
  128105. /** @hidden */
  128106. export var lensHighlightsPixelShader: {
  128107. name: string;
  128108. shader: string;
  128109. };
  128110. }
  128111. declare module BABYLON {
  128112. /** @hidden */
  128113. export var depthOfFieldPixelShader: {
  128114. name: string;
  128115. shader: string;
  128116. };
  128117. }
  128118. declare module BABYLON {
  128119. /**
  128120. * BABYLON.JS Chromatic Aberration GLSL Shader
  128121. * Author: Olivier Guyot
  128122. * Separates very slightly R, G and B colors on the edges of the screen
  128123. * Inspired by Francois Tarlier & Martins Upitis
  128124. */
  128125. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128126. /**
  128127. * @ignore
  128128. * The chromatic aberration PostProcess id in the pipeline
  128129. */
  128130. LensChromaticAberrationEffect: string;
  128131. /**
  128132. * @ignore
  128133. * The highlights enhancing PostProcess id in the pipeline
  128134. */
  128135. HighlightsEnhancingEffect: string;
  128136. /**
  128137. * @ignore
  128138. * The depth-of-field PostProcess id in the pipeline
  128139. */
  128140. LensDepthOfFieldEffect: string;
  128141. private _scene;
  128142. private _depthTexture;
  128143. private _grainTexture;
  128144. private _chromaticAberrationPostProcess;
  128145. private _highlightsPostProcess;
  128146. private _depthOfFieldPostProcess;
  128147. private _edgeBlur;
  128148. private _grainAmount;
  128149. private _chromaticAberration;
  128150. private _distortion;
  128151. private _highlightsGain;
  128152. private _highlightsThreshold;
  128153. private _dofDistance;
  128154. private _dofAperture;
  128155. private _dofDarken;
  128156. private _dofPentagon;
  128157. private _blurNoise;
  128158. /**
  128159. * @constructor
  128160. *
  128161. * Effect parameters are as follow:
  128162. * {
  128163. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128164. * edge_blur: number; // from 0 to x (1 for realism)
  128165. * distortion: number; // from 0 to x (1 for realism)
  128166. * grain_amount: number; // from 0 to 1
  128167. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128168. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128169. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128170. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128171. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128172. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128173. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128174. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128175. * }
  128176. * Note: if an effect parameter is unset, effect is disabled
  128177. *
  128178. * @param name The rendering pipeline name
  128179. * @param parameters - An object containing all parameters (see above)
  128180. * @param scene The scene linked to this pipeline
  128181. * @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)
  128182. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128183. */
  128184. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128185. /**
  128186. * Get the class name
  128187. * @returns "LensRenderingPipeline"
  128188. */
  128189. getClassName(): string;
  128190. /**
  128191. * Gets associated scene
  128192. */
  128193. readonly scene: Scene;
  128194. /**
  128195. * Gets or sets the edge blur
  128196. */
  128197. edgeBlur: number;
  128198. /**
  128199. * Gets or sets the grain amount
  128200. */
  128201. grainAmount: number;
  128202. /**
  128203. * Gets or sets the chromatic aberration amount
  128204. */
  128205. chromaticAberration: number;
  128206. /**
  128207. * Gets or sets the depth of field aperture
  128208. */
  128209. dofAperture: number;
  128210. /**
  128211. * Gets or sets the edge distortion
  128212. */
  128213. edgeDistortion: number;
  128214. /**
  128215. * Gets or sets the depth of field distortion
  128216. */
  128217. dofDistortion: number;
  128218. /**
  128219. * Gets or sets the darken out of focus amount
  128220. */
  128221. darkenOutOfFocus: number;
  128222. /**
  128223. * Gets or sets a boolean indicating if blur noise is enabled
  128224. */
  128225. blurNoise: boolean;
  128226. /**
  128227. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128228. */
  128229. pentagonBokeh: boolean;
  128230. /**
  128231. * Gets or sets the highlight grain amount
  128232. */
  128233. highlightsGain: number;
  128234. /**
  128235. * Gets or sets the highlight threshold
  128236. */
  128237. highlightsThreshold: number;
  128238. /**
  128239. * Sets the amount of blur at the edges
  128240. * @param amount blur amount
  128241. */
  128242. setEdgeBlur(amount: number): void;
  128243. /**
  128244. * Sets edge blur to 0
  128245. */
  128246. disableEdgeBlur(): void;
  128247. /**
  128248. * Sets the amout of grain
  128249. * @param amount Amount of grain
  128250. */
  128251. setGrainAmount(amount: number): void;
  128252. /**
  128253. * Set grain amount to 0
  128254. */
  128255. disableGrain(): void;
  128256. /**
  128257. * Sets the chromatic aberration amount
  128258. * @param amount amount of chromatic aberration
  128259. */
  128260. setChromaticAberration(amount: number): void;
  128261. /**
  128262. * Sets chromatic aberration amount to 0
  128263. */
  128264. disableChromaticAberration(): void;
  128265. /**
  128266. * Sets the EdgeDistortion amount
  128267. * @param amount amount of EdgeDistortion
  128268. */
  128269. setEdgeDistortion(amount: number): void;
  128270. /**
  128271. * Sets edge distortion to 0
  128272. */
  128273. disableEdgeDistortion(): void;
  128274. /**
  128275. * Sets the FocusDistance amount
  128276. * @param amount amount of FocusDistance
  128277. */
  128278. setFocusDistance(amount: number): void;
  128279. /**
  128280. * Disables depth of field
  128281. */
  128282. disableDepthOfField(): void;
  128283. /**
  128284. * Sets the Aperture amount
  128285. * @param amount amount of Aperture
  128286. */
  128287. setAperture(amount: number): void;
  128288. /**
  128289. * Sets the DarkenOutOfFocus amount
  128290. * @param amount amount of DarkenOutOfFocus
  128291. */
  128292. setDarkenOutOfFocus(amount: number): void;
  128293. private _pentagonBokehIsEnabled;
  128294. /**
  128295. * Creates a pentagon bokeh effect
  128296. */
  128297. enablePentagonBokeh(): void;
  128298. /**
  128299. * Disables the pentagon bokeh effect
  128300. */
  128301. disablePentagonBokeh(): void;
  128302. /**
  128303. * Enables noise blur
  128304. */
  128305. enableNoiseBlur(): void;
  128306. /**
  128307. * Disables noise blur
  128308. */
  128309. disableNoiseBlur(): void;
  128310. /**
  128311. * Sets the HighlightsGain amount
  128312. * @param amount amount of HighlightsGain
  128313. */
  128314. setHighlightsGain(amount: number): void;
  128315. /**
  128316. * Sets the HighlightsThreshold amount
  128317. * @param amount amount of HighlightsThreshold
  128318. */
  128319. setHighlightsThreshold(amount: number): void;
  128320. /**
  128321. * Disables highlights
  128322. */
  128323. disableHighlights(): void;
  128324. /**
  128325. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128326. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128327. */
  128328. dispose(disableDepthRender?: boolean): void;
  128329. private _createChromaticAberrationPostProcess;
  128330. private _createHighlightsPostProcess;
  128331. private _createDepthOfFieldPostProcess;
  128332. private _createGrainTexture;
  128333. }
  128334. }
  128335. declare module BABYLON {
  128336. /** @hidden */
  128337. export var ssao2PixelShader: {
  128338. name: string;
  128339. shader: string;
  128340. };
  128341. }
  128342. declare module BABYLON {
  128343. /** @hidden */
  128344. export var ssaoCombinePixelShader: {
  128345. name: string;
  128346. shader: string;
  128347. };
  128348. }
  128349. declare module BABYLON {
  128350. /**
  128351. * Render pipeline to produce ssao effect
  128352. */
  128353. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128354. /**
  128355. * @ignore
  128356. * The PassPostProcess id in the pipeline that contains the original scene color
  128357. */
  128358. SSAOOriginalSceneColorEffect: string;
  128359. /**
  128360. * @ignore
  128361. * The SSAO PostProcess id in the pipeline
  128362. */
  128363. SSAORenderEffect: string;
  128364. /**
  128365. * @ignore
  128366. * The horizontal blur PostProcess id in the pipeline
  128367. */
  128368. SSAOBlurHRenderEffect: string;
  128369. /**
  128370. * @ignore
  128371. * The vertical blur PostProcess id in the pipeline
  128372. */
  128373. SSAOBlurVRenderEffect: string;
  128374. /**
  128375. * @ignore
  128376. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128377. */
  128378. SSAOCombineRenderEffect: string;
  128379. /**
  128380. * The output strength of the SSAO post-process. Default value is 1.0.
  128381. */
  128382. totalStrength: number;
  128383. /**
  128384. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128385. */
  128386. maxZ: number;
  128387. /**
  128388. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128389. */
  128390. minZAspect: number;
  128391. private _samples;
  128392. /**
  128393. * Number of samples used for the SSAO calculations. Default value is 8
  128394. */
  128395. samples: number;
  128396. private _textureSamples;
  128397. /**
  128398. * Number of samples to use for antialiasing
  128399. */
  128400. textureSamples: number;
  128401. /**
  128402. * Ratio object used for SSAO ratio and blur ratio
  128403. */
  128404. private _ratio;
  128405. /**
  128406. * Dynamically generated sphere sampler.
  128407. */
  128408. private _sampleSphere;
  128409. /**
  128410. * Blur filter offsets
  128411. */
  128412. private _samplerOffsets;
  128413. private _expensiveBlur;
  128414. /**
  128415. * If bilateral blur should be used
  128416. */
  128417. expensiveBlur: boolean;
  128418. /**
  128419. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128420. */
  128421. radius: number;
  128422. /**
  128423. * The base color of the SSAO post-process
  128424. * The final result is "base + ssao" between [0, 1]
  128425. */
  128426. base: number;
  128427. /**
  128428. * Support test.
  128429. */
  128430. static readonly IsSupported: boolean;
  128431. private _scene;
  128432. private _depthTexture;
  128433. private _normalTexture;
  128434. private _randomTexture;
  128435. private _originalColorPostProcess;
  128436. private _ssaoPostProcess;
  128437. private _blurHPostProcess;
  128438. private _blurVPostProcess;
  128439. private _ssaoCombinePostProcess;
  128440. private _firstUpdate;
  128441. /**
  128442. * Gets active scene
  128443. */
  128444. readonly scene: Scene;
  128445. /**
  128446. * @constructor
  128447. * @param name The rendering pipeline name
  128448. * @param scene The scene linked to this pipeline
  128449. * @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 }
  128450. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128451. */
  128452. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128453. /**
  128454. * Get the class name
  128455. * @returns "SSAO2RenderingPipeline"
  128456. */
  128457. getClassName(): string;
  128458. /**
  128459. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128460. */
  128461. dispose(disableGeometryBufferRenderer?: boolean): void;
  128462. private _createBlurPostProcess;
  128463. /** @hidden */
  128464. _rebuild(): void;
  128465. private _bits;
  128466. private _radicalInverse_VdC;
  128467. private _hammersley;
  128468. private _hemisphereSample_uniform;
  128469. private _generateHemisphere;
  128470. private _createSSAOPostProcess;
  128471. private _createSSAOCombinePostProcess;
  128472. private _createRandomTexture;
  128473. /**
  128474. * Serialize the rendering pipeline (Used when exporting)
  128475. * @returns the serialized object
  128476. */
  128477. serialize(): any;
  128478. /**
  128479. * Parse the serialized pipeline
  128480. * @param source Source pipeline.
  128481. * @param scene The scene to load the pipeline to.
  128482. * @param rootUrl The URL of the serialized pipeline.
  128483. * @returns An instantiated pipeline from the serialized object.
  128484. */
  128485. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128486. }
  128487. }
  128488. declare module BABYLON {
  128489. /** @hidden */
  128490. export var ssaoPixelShader: {
  128491. name: string;
  128492. shader: string;
  128493. };
  128494. }
  128495. declare module BABYLON {
  128496. /**
  128497. * Render pipeline to produce ssao effect
  128498. */
  128499. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128500. /**
  128501. * @ignore
  128502. * The PassPostProcess id in the pipeline that contains the original scene color
  128503. */
  128504. SSAOOriginalSceneColorEffect: string;
  128505. /**
  128506. * @ignore
  128507. * The SSAO PostProcess id in the pipeline
  128508. */
  128509. SSAORenderEffect: string;
  128510. /**
  128511. * @ignore
  128512. * The horizontal blur PostProcess id in the pipeline
  128513. */
  128514. SSAOBlurHRenderEffect: string;
  128515. /**
  128516. * @ignore
  128517. * The vertical blur PostProcess id in the pipeline
  128518. */
  128519. SSAOBlurVRenderEffect: string;
  128520. /**
  128521. * @ignore
  128522. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128523. */
  128524. SSAOCombineRenderEffect: string;
  128525. /**
  128526. * The output strength of the SSAO post-process. Default value is 1.0.
  128527. */
  128528. totalStrength: number;
  128529. /**
  128530. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128531. */
  128532. radius: number;
  128533. /**
  128534. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128535. * Must not be equal to fallOff and superior to fallOff.
  128536. * Default value is 0.0075
  128537. */
  128538. area: number;
  128539. /**
  128540. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128541. * Must not be equal to area and inferior to area.
  128542. * Default value is 0.000001
  128543. */
  128544. fallOff: number;
  128545. /**
  128546. * The base color of the SSAO post-process
  128547. * The final result is "base + ssao" between [0, 1]
  128548. */
  128549. base: number;
  128550. private _scene;
  128551. private _depthTexture;
  128552. private _randomTexture;
  128553. private _originalColorPostProcess;
  128554. private _ssaoPostProcess;
  128555. private _blurHPostProcess;
  128556. private _blurVPostProcess;
  128557. private _ssaoCombinePostProcess;
  128558. private _firstUpdate;
  128559. /**
  128560. * Gets active scene
  128561. */
  128562. readonly scene: Scene;
  128563. /**
  128564. * @constructor
  128565. * @param name - The rendering pipeline name
  128566. * @param scene - The scene linked to this pipeline
  128567. * @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 }
  128568. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128569. */
  128570. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128571. /**
  128572. * Get the class name
  128573. * @returns "SSAORenderingPipeline"
  128574. */
  128575. getClassName(): string;
  128576. /**
  128577. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128578. */
  128579. dispose(disableDepthRender?: boolean): void;
  128580. private _createBlurPostProcess;
  128581. /** @hidden */
  128582. _rebuild(): void;
  128583. private _createSSAOPostProcess;
  128584. private _createSSAOCombinePostProcess;
  128585. private _createRandomTexture;
  128586. }
  128587. }
  128588. declare module BABYLON {
  128589. /** @hidden */
  128590. export var standardPixelShader: {
  128591. name: string;
  128592. shader: string;
  128593. };
  128594. }
  128595. declare module BABYLON {
  128596. /**
  128597. * Standard rendering pipeline
  128598. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128599. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128600. */
  128601. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128602. /**
  128603. * Public members
  128604. */
  128605. /**
  128606. * Post-process which contains the original scene color before the pipeline applies all the effects
  128607. */
  128608. originalPostProcess: Nullable<PostProcess>;
  128609. /**
  128610. * Post-process used to down scale an image x4
  128611. */
  128612. downSampleX4PostProcess: Nullable<PostProcess>;
  128613. /**
  128614. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128615. */
  128616. brightPassPostProcess: Nullable<PostProcess>;
  128617. /**
  128618. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128619. */
  128620. blurHPostProcesses: PostProcess[];
  128621. /**
  128622. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128623. */
  128624. blurVPostProcesses: PostProcess[];
  128625. /**
  128626. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128627. */
  128628. textureAdderPostProcess: Nullable<PostProcess>;
  128629. /**
  128630. * Post-process used to create volumetric lighting effect
  128631. */
  128632. volumetricLightPostProcess: Nullable<PostProcess>;
  128633. /**
  128634. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128635. */
  128636. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128637. /**
  128638. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128639. */
  128640. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128641. /**
  128642. * Post-process used to merge the volumetric light effect and the real scene color
  128643. */
  128644. volumetricLightMergePostProces: Nullable<PostProcess>;
  128645. /**
  128646. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128647. */
  128648. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128649. /**
  128650. * Base post-process used to calculate the average luminance of the final image for HDR
  128651. */
  128652. luminancePostProcess: Nullable<PostProcess>;
  128653. /**
  128654. * Post-processes used to create down sample post-processes in order to get
  128655. * the average luminance of the final image for HDR
  128656. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128657. */
  128658. luminanceDownSamplePostProcesses: PostProcess[];
  128659. /**
  128660. * Post-process used to create a HDR effect (light adaptation)
  128661. */
  128662. hdrPostProcess: Nullable<PostProcess>;
  128663. /**
  128664. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128665. */
  128666. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128667. /**
  128668. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128669. */
  128670. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128671. /**
  128672. * Post-process used to merge the final HDR post-process and the real scene color
  128673. */
  128674. hdrFinalPostProcess: Nullable<PostProcess>;
  128675. /**
  128676. * Post-process used to create a lens flare effect
  128677. */
  128678. lensFlarePostProcess: Nullable<PostProcess>;
  128679. /**
  128680. * Post-process that merges the result of the lens flare post-process and the real scene color
  128681. */
  128682. lensFlareComposePostProcess: Nullable<PostProcess>;
  128683. /**
  128684. * Post-process used to create a motion blur effect
  128685. */
  128686. motionBlurPostProcess: Nullable<PostProcess>;
  128687. /**
  128688. * Post-process used to create a depth of field effect
  128689. */
  128690. depthOfFieldPostProcess: Nullable<PostProcess>;
  128691. /**
  128692. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128693. */
  128694. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128695. /**
  128696. * Represents the brightness threshold in order to configure the illuminated surfaces
  128697. */
  128698. brightThreshold: number;
  128699. /**
  128700. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128701. */
  128702. blurWidth: number;
  128703. /**
  128704. * Sets if the blur for highlighted surfaces must be only horizontal
  128705. */
  128706. horizontalBlur: boolean;
  128707. /**
  128708. * Gets the overall exposure used by the pipeline
  128709. */
  128710. /**
  128711. * Sets the overall exposure used by the pipeline
  128712. */
  128713. exposure: number;
  128714. /**
  128715. * Texture used typically to simulate "dirty" on camera lens
  128716. */
  128717. lensTexture: Nullable<Texture>;
  128718. /**
  128719. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128720. */
  128721. volumetricLightCoefficient: number;
  128722. /**
  128723. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128724. */
  128725. volumetricLightPower: number;
  128726. /**
  128727. * Used the set the blur intensity to smooth the volumetric lights
  128728. */
  128729. volumetricLightBlurScale: number;
  128730. /**
  128731. * Light (spot or directional) used to generate the volumetric lights rays
  128732. * The source light must have a shadow generate so the pipeline can get its
  128733. * depth map
  128734. */
  128735. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128736. /**
  128737. * For eye adaptation, represents the minimum luminance the eye can see
  128738. */
  128739. hdrMinimumLuminance: number;
  128740. /**
  128741. * For eye adaptation, represents the decrease luminance speed
  128742. */
  128743. hdrDecreaseRate: number;
  128744. /**
  128745. * For eye adaptation, represents the increase luminance speed
  128746. */
  128747. hdrIncreaseRate: number;
  128748. /**
  128749. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128750. */
  128751. /**
  128752. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128753. */
  128754. hdrAutoExposure: boolean;
  128755. /**
  128756. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128757. */
  128758. lensColorTexture: Nullable<Texture>;
  128759. /**
  128760. * The overall strengh for the lens flare effect
  128761. */
  128762. lensFlareStrength: number;
  128763. /**
  128764. * Dispersion coefficient for lens flare ghosts
  128765. */
  128766. lensFlareGhostDispersal: number;
  128767. /**
  128768. * Main lens flare halo width
  128769. */
  128770. lensFlareHaloWidth: number;
  128771. /**
  128772. * Based on the lens distortion effect, defines how much the lens flare result
  128773. * is distorted
  128774. */
  128775. lensFlareDistortionStrength: number;
  128776. /**
  128777. * Configures the blur intensity used for for lens flare (halo)
  128778. */
  128779. lensFlareBlurWidth: number;
  128780. /**
  128781. * Lens star texture must be used to simulate rays on the flares and is available
  128782. * in the documentation
  128783. */
  128784. lensStarTexture: Nullable<Texture>;
  128785. /**
  128786. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128787. * flare effect by taking account of the dirt texture
  128788. */
  128789. lensFlareDirtTexture: Nullable<Texture>;
  128790. /**
  128791. * Represents the focal length for the depth of field effect
  128792. */
  128793. depthOfFieldDistance: number;
  128794. /**
  128795. * Represents the blur intensity for the blurred part of the depth of field effect
  128796. */
  128797. depthOfFieldBlurWidth: number;
  128798. /**
  128799. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128800. */
  128801. /**
  128802. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128803. */
  128804. motionStrength: number;
  128805. /**
  128806. * Gets wether or not the motion blur post-process is object based or screen based.
  128807. */
  128808. /**
  128809. * Sets wether or not the motion blur post-process should be object based or screen based
  128810. */
  128811. objectBasedMotionBlur: boolean;
  128812. /**
  128813. * List of animations for the pipeline (IAnimatable implementation)
  128814. */
  128815. animations: Animation[];
  128816. /**
  128817. * Private members
  128818. */
  128819. private _scene;
  128820. private _currentDepthOfFieldSource;
  128821. private _basePostProcess;
  128822. private _fixedExposure;
  128823. private _currentExposure;
  128824. private _hdrAutoExposure;
  128825. private _hdrCurrentLuminance;
  128826. private _motionStrength;
  128827. private _isObjectBasedMotionBlur;
  128828. private _floatTextureType;
  128829. private _camerasToBeAttached;
  128830. private _ratio;
  128831. private _bloomEnabled;
  128832. private _depthOfFieldEnabled;
  128833. private _vlsEnabled;
  128834. private _lensFlareEnabled;
  128835. private _hdrEnabled;
  128836. private _motionBlurEnabled;
  128837. private _fxaaEnabled;
  128838. private _motionBlurSamples;
  128839. private _volumetricLightStepsCount;
  128840. private _samples;
  128841. /**
  128842. * @ignore
  128843. * Specifies if the bloom pipeline is enabled
  128844. */
  128845. BloomEnabled: boolean;
  128846. /**
  128847. * @ignore
  128848. * Specifies if the depth of field pipeline is enabed
  128849. */
  128850. DepthOfFieldEnabled: boolean;
  128851. /**
  128852. * @ignore
  128853. * Specifies if the lens flare pipeline is enabed
  128854. */
  128855. LensFlareEnabled: boolean;
  128856. /**
  128857. * @ignore
  128858. * Specifies if the HDR pipeline is enabled
  128859. */
  128860. HDREnabled: boolean;
  128861. /**
  128862. * @ignore
  128863. * Specifies if the volumetric lights scattering effect is enabled
  128864. */
  128865. VLSEnabled: boolean;
  128866. /**
  128867. * @ignore
  128868. * Specifies if the motion blur effect is enabled
  128869. */
  128870. MotionBlurEnabled: boolean;
  128871. /**
  128872. * Specifies if anti-aliasing is enabled
  128873. */
  128874. fxaaEnabled: boolean;
  128875. /**
  128876. * Specifies the number of steps used to calculate the volumetric lights
  128877. * Typically in interval [50, 200]
  128878. */
  128879. volumetricLightStepsCount: number;
  128880. /**
  128881. * Specifies the number of samples used for the motion blur effect
  128882. * Typically in interval [16, 64]
  128883. */
  128884. motionBlurSamples: number;
  128885. /**
  128886. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128887. */
  128888. samples: number;
  128889. /**
  128890. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128891. * @constructor
  128892. * @param name The rendering pipeline name
  128893. * @param scene The scene linked to this pipeline
  128894. * @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)
  128895. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  128896. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128897. */
  128898. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  128899. private _buildPipeline;
  128900. private _createDownSampleX4PostProcess;
  128901. private _createBrightPassPostProcess;
  128902. private _createBlurPostProcesses;
  128903. private _createTextureAdderPostProcess;
  128904. private _createVolumetricLightPostProcess;
  128905. private _createLuminancePostProcesses;
  128906. private _createHdrPostProcess;
  128907. private _createLensFlarePostProcess;
  128908. private _createDepthOfFieldPostProcess;
  128909. private _createMotionBlurPostProcess;
  128910. private _getDepthTexture;
  128911. private _disposePostProcesses;
  128912. /**
  128913. * Dispose of the pipeline and stop all post processes
  128914. */
  128915. dispose(): void;
  128916. /**
  128917. * Serialize the rendering pipeline (Used when exporting)
  128918. * @returns the serialized object
  128919. */
  128920. serialize(): any;
  128921. /**
  128922. * Parse the serialized pipeline
  128923. * @param source Source pipeline.
  128924. * @param scene The scene to load the pipeline to.
  128925. * @param rootUrl The URL of the serialized pipeline.
  128926. * @returns An instantiated pipeline from the serialized object.
  128927. */
  128928. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  128929. /**
  128930. * Luminance steps
  128931. */
  128932. static LuminanceSteps: number;
  128933. }
  128934. }
  128935. declare module BABYLON {
  128936. /** @hidden */
  128937. export var tonemapPixelShader: {
  128938. name: string;
  128939. shader: string;
  128940. };
  128941. }
  128942. declare module BABYLON {
  128943. /** Defines operator used for tonemapping */
  128944. export enum TonemappingOperator {
  128945. /** Hable */
  128946. Hable = 0,
  128947. /** Reinhard */
  128948. Reinhard = 1,
  128949. /** HejiDawson */
  128950. HejiDawson = 2,
  128951. /** Photographic */
  128952. Photographic = 3
  128953. }
  128954. /**
  128955. * Defines a post process to apply tone mapping
  128956. */
  128957. export class TonemapPostProcess extends PostProcess {
  128958. private _operator;
  128959. /** Defines the required exposure adjustement */
  128960. exposureAdjustment: number;
  128961. /**
  128962. * Creates a new TonemapPostProcess
  128963. * @param name defines the name of the postprocess
  128964. * @param _operator defines the operator to use
  128965. * @param exposureAdjustment defines the required exposure adjustement
  128966. * @param camera defines the camera to use (can be null)
  128967. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  128968. * @param engine defines the hosting engine (can be ignore if camera is set)
  128969. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128970. */
  128971. constructor(name: string, _operator: TonemappingOperator,
  128972. /** Defines the required exposure adjustement */
  128973. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  128974. }
  128975. }
  128976. declare module BABYLON {
  128977. /** @hidden */
  128978. export var depthVertexShader: {
  128979. name: string;
  128980. shader: string;
  128981. };
  128982. }
  128983. declare module BABYLON {
  128984. /** @hidden */
  128985. export var volumetricLightScatteringPixelShader: {
  128986. name: string;
  128987. shader: string;
  128988. };
  128989. }
  128990. declare module BABYLON {
  128991. /** @hidden */
  128992. export var volumetricLightScatteringPassVertexShader: {
  128993. name: string;
  128994. shader: string;
  128995. };
  128996. }
  128997. declare module BABYLON {
  128998. /** @hidden */
  128999. export var volumetricLightScatteringPassPixelShader: {
  129000. name: string;
  129001. shader: string;
  129002. };
  129003. }
  129004. declare module BABYLON {
  129005. /**
  129006. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129007. */
  129008. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129009. private _volumetricLightScatteringPass;
  129010. private _volumetricLightScatteringRTT;
  129011. private _viewPort;
  129012. private _screenCoordinates;
  129013. private _cachedDefines;
  129014. /**
  129015. * If not undefined, the mesh position is computed from the attached node position
  129016. */
  129017. attachedNode: {
  129018. position: Vector3;
  129019. };
  129020. /**
  129021. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129022. */
  129023. customMeshPosition: Vector3;
  129024. /**
  129025. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129026. */
  129027. useCustomMeshPosition: boolean;
  129028. /**
  129029. * If the post-process should inverse the light scattering direction
  129030. */
  129031. invert: boolean;
  129032. /**
  129033. * The internal mesh used by the post-process
  129034. */
  129035. mesh: Mesh;
  129036. /**
  129037. * @hidden
  129038. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129039. */
  129040. useDiffuseColor: boolean;
  129041. /**
  129042. * Array containing the excluded meshes not rendered in the internal pass
  129043. */
  129044. excludedMeshes: AbstractMesh[];
  129045. /**
  129046. * Controls the overall intensity of the post-process
  129047. */
  129048. exposure: number;
  129049. /**
  129050. * Dissipates each sample's contribution in range [0, 1]
  129051. */
  129052. decay: number;
  129053. /**
  129054. * Controls the overall intensity of each sample
  129055. */
  129056. weight: number;
  129057. /**
  129058. * Controls the density of each sample
  129059. */
  129060. density: number;
  129061. /**
  129062. * @constructor
  129063. * @param name The post-process name
  129064. * @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)
  129065. * @param camera The camera that the post-process will be attached to
  129066. * @param mesh The mesh used to create the light scattering
  129067. * @param samples The post-process quality, default 100
  129068. * @param samplingModeThe post-process filtering mode
  129069. * @param engine The babylon engine
  129070. * @param reusable If the post-process is reusable
  129071. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129072. */
  129073. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129074. /**
  129075. * Returns the string "VolumetricLightScatteringPostProcess"
  129076. * @returns "VolumetricLightScatteringPostProcess"
  129077. */
  129078. getClassName(): string;
  129079. private _isReady;
  129080. /**
  129081. * Sets the new light position for light scattering effect
  129082. * @param position The new custom light position
  129083. */
  129084. setCustomMeshPosition(position: Vector3): void;
  129085. /**
  129086. * Returns the light position for light scattering effect
  129087. * @return Vector3 The custom light position
  129088. */
  129089. getCustomMeshPosition(): Vector3;
  129090. /**
  129091. * Disposes the internal assets and detaches the post-process from the camera
  129092. */
  129093. dispose(camera: Camera): void;
  129094. /**
  129095. * Returns the render target texture used by the post-process
  129096. * @return the render target texture used by the post-process
  129097. */
  129098. getPass(): RenderTargetTexture;
  129099. private _meshExcluded;
  129100. private _createPass;
  129101. private _updateMeshScreenCoordinates;
  129102. /**
  129103. * Creates a default mesh for the Volumeric Light Scattering post-process
  129104. * @param name The mesh name
  129105. * @param scene The scene where to create the mesh
  129106. * @return the default mesh
  129107. */
  129108. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129109. }
  129110. }
  129111. declare module BABYLON {
  129112. interface Scene {
  129113. /** @hidden (Backing field) */
  129114. _boundingBoxRenderer: BoundingBoxRenderer;
  129115. /** @hidden (Backing field) */
  129116. _forceShowBoundingBoxes: boolean;
  129117. /**
  129118. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129119. */
  129120. forceShowBoundingBoxes: boolean;
  129121. /**
  129122. * Gets the bounding box renderer associated with the scene
  129123. * @returns a BoundingBoxRenderer
  129124. */
  129125. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129126. }
  129127. interface AbstractMesh {
  129128. /** @hidden (Backing field) */
  129129. _showBoundingBox: boolean;
  129130. /**
  129131. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129132. */
  129133. showBoundingBox: boolean;
  129134. }
  129135. /**
  129136. * Component responsible of rendering the bounding box of the meshes in a scene.
  129137. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129138. */
  129139. export class BoundingBoxRenderer implements ISceneComponent {
  129140. /**
  129141. * The component name helpfull to identify the component in the list of scene components.
  129142. */
  129143. readonly name: string;
  129144. /**
  129145. * The scene the component belongs to.
  129146. */
  129147. scene: Scene;
  129148. /**
  129149. * Color of the bounding box lines placed in front of an object
  129150. */
  129151. frontColor: Color3;
  129152. /**
  129153. * Color of the bounding box lines placed behind an object
  129154. */
  129155. backColor: Color3;
  129156. /**
  129157. * Defines if the renderer should show the back lines or not
  129158. */
  129159. showBackLines: boolean;
  129160. /**
  129161. * @hidden
  129162. */
  129163. renderList: SmartArray<BoundingBox>;
  129164. private _colorShader;
  129165. private _vertexBuffers;
  129166. private _indexBuffer;
  129167. private _fillIndexBuffer;
  129168. private _fillIndexData;
  129169. /**
  129170. * Instantiates a new bounding box renderer in a scene.
  129171. * @param scene the scene the renderer renders in
  129172. */
  129173. constructor(scene: Scene);
  129174. /**
  129175. * Registers the component in a given scene
  129176. */
  129177. register(): void;
  129178. private _evaluateSubMesh;
  129179. private _activeMesh;
  129180. private _prepareRessources;
  129181. private _createIndexBuffer;
  129182. /**
  129183. * Rebuilds the elements related to this component in case of
  129184. * context lost for instance.
  129185. */
  129186. rebuild(): void;
  129187. /**
  129188. * @hidden
  129189. */
  129190. reset(): void;
  129191. /**
  129192. * Render the bounding boxes of a specific rendering group
  129193. * @param renderingGroupId defines the rendering group to render
  129194. */
  129195. render(renderingGroupId: number): void;
  129196. /**
  129197. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129198. * @param mesh Define the mesh to render the occlusion bounding box for
  129199. */
  129200. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129201. /**
  129202. * Dispose and release the resources attached to this renderer.
  129203. */
  129204. dispose(): void;
  129205. }
  129206. }
  129207. declare module BABYLON {
  129208. /** @hidden */
  129209. export var depthPixelShader: {
  129210. name: string;
  129211. shader: string;
  129212. };
  129213. }
  129214. declare module BABYLON {
  129215. /**
  129216. * This represents a depth renderer in Babylon.
  129217. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129218. */
  129219. export class DepthRenderer {
  129220. private _scene;
  129221. private _depthMap;
  129222. private _effect;
  129223. private readonly _storeNonLinearDepth;
  129224. private readonly _clearColor;
  129225. /** Get if the depth renderer is using packed depth or not */
  129226. readonly isPacked: boolean;
  129227. private _cachedDefines;
  129228. private _camera;
  129229. /**
  129230. * Specifiess that the depth renderer will only be used within
  129231. * the camera it is created for.
  129232. * This can help forcing its rendering during the camera processing.
  129233. */
  129234. useOnlyInActiveCamera: boolean;
  129235. /** @hidden */
  129236. static _SceneComponentInitialization: (scene: Scene) => void;
  129237. /**
  129238. * Instantiates a depth renderer
  129239. * @param scene The scene the renderer belongs to
  129240. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129241. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129242. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129243. */
  129244. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129245. /**
  129246. * Creates the depth rendering effect and checks if the effect is ready.
  129247. * @param subMesh The submesh to be used to render the depth map of
  129248. * @param useInstances If multiple world instances should be used
  129249. * @returns if the depth renderer is ready to render the depth map
  129250. */
  129251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129252. /**
  129253. * Gets the texture which the depth map will be written to.
  129254. * @returns The depth map texture
  129255. */
  129256. getDepthMap(): RenderTargetTexture;
  129257. /**
  129258. * Disposes of the depth renderer.
  129259. */
  129260. dispose(): void;
  129261. }
  129262. }
  129263. declare module BABYLON {
  129264. interface Scene {
  129265. /** @hidden (Backing field) */
  129266. _depthRenderer: {
  129267. [id: string]: DepthRenderer;
  129268. };
  129269. /**
  129270. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129271. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129272. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129273. * @returns the created depth renderer
  129274. */
  129275. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129276. /**
  129277. * Disables a depth renderer for a given camera
  129278. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129279. */
  129280. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129281. }
  129282. /**
  129283. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129284. * in several rendering techniques.
  129285. */
  129286. export class DepthRendererSceneComponent implements ISceneComponent {
  129287. /**
  129288. * The component name helpfull to identify the component in the list of scene components.
  129289. */
  129290. readonly name: string;
  129291. /**
  129292. * The scene the component belongs to.
  129293. */
  129294. scene: Scene;
  129295. /**
  129296. * Creates a new instance of the component for the given scene
  129297. * @param scene Defines the scene to register the component in
  129298. */
  129299. constructor(scene: Scene);
  129300. /**
  129301. * Registers the component in a given scene
  129302. */
  129303. register(): void;
  129304. /**
  129305. * Rebuilds the elements related to this component in case of
  129306. * context lost for instance.
  129307. */
  129308. rebuild(): void;
  129309. /**
  129310. * Disposes the component and the associated ressources
  129311. */
  129312. dispose(): void;
  129313. private _gatherRenderTargets;
  129314. private _gatherActiveCameraRenderTargets;
  129315. }
  129316. }
  129317. declare module BABYLON {
  129318. /** @hidden */
  129319. export var outlinePixelShader: {
  129320. name: string;
  129321. shader: string;
  129322. };
  129323. }
  129324. declare module BABYLON {
  129325. /** @hidden */
  129326. export var outlineVertexShader: {
  129327. name: string;
  129328. shader: string;
  129329. };
  129330. }
  129331. declare module BABYLON {
  129332. interface Scene {
  129333. /** @hidden */
  129334. _outlineRenderer: OutlineRenderer;
  129335. /**
  129336. * Gets the outline renderer associated with the scene
  129337. * @returns a OutlineRenderer
  129338. */
  129339. getOutlineRenderer(): OutlineRenderer;
  129340. }
  129341. interface AbstractMesh {
  129342. /** @hidden (Backing field) */
  129343. _renderOutline: boolean;
  129344. /**
  129345. * Gets or sets a boolean indicating if the outline must be rendered as well
  129346. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129347. */
  129348. renderOutline: boolean;
  129349. /** @hidden (Backing field) */
  129350. _renderOverlay: boolean;
  129351. /**
  129352. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129353. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129354. */
  129355. renderOverlay: boolean;
  129356. }
  129357. /**
  129358. * This class is responsible to draw bothe outline/overlay of meshes.
  129359. * It should not be used directly but through the available method on mesh.
  129360. */
  129361. export class OutlineRenderer implements ISceneComponent {
  129362. /**
  129363. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129364. */
  129365. private static _StencilReference;
  129366. /**
  129367. * The name of the component. Each component must have a unique name.
  129368. */
  129369. name: string;
  129370. /**
  129371. * The scene the component belongs to.
  129372. */
  129373. scene: Scene;
  129374. /**
  129375. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129376. */
  129377. zOffset: number;
  129378. private _engine;
  129379. private _effect;
  129380. private _cachedDefines;
  129381. private _savedDepthWrite;
  129382. /**
  129383. * Instantiates a new outline renderer. (There could be only one per scene).
  129384. * @param scene Defines the scene it belongs to
  129385. */
  129386. constructor(scene: Scene);
  129387. /**
  129388. * Register the component to one instance of a scene.
  129389. */
  129390. register(): void;
  129391. /**
  129392. * Rebuilds the elements related to this component in case of
  129393. * context lost for instance.
  129394. */
  129395. rebuild(): void;
  129396. /**
  129397. * Disposes the component and the associated ressources.
  129398. */
  129399. dispose(): void;
  129400. /**
  129401. * Renders the outline in the canvas.
  129402. * @param subMesh Defines the sumesh to render
  129403. * @param batch Defines the batch of meshes in case of instances
  129404. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129405. */
  129406. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129407. /**
  129408. * Returns whether or not the outline renderer is ready for a given submesh.
  129409. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129410. * @param subMesh Defines the submesh to check readyness for
  129411. * @param useInstances Defines wheter wee are trying to render instances or not
  129412. * @returns true if ready otherwise false
  129413. */
  129414. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129415. private _beforeRenderingMesh;
  129416. private _afterRenderingMesh;
  129417. }
  129418. }
  129419. declare module BABYLON {
  129420. /**
  129421. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129422. * @see http://doc.babylonjs.com/babylon101/sprites
  129423. */
  129424. export class SpritePackedManager extends SpriteManager {
  129425. /** defines the packed manager's name */
  129426. name: string;
  129427. /**
  129428. * Creates a new sprite manager from a packed sprite sheet
  129429. * @param name defines the manager's name
  129430. * @param imgUrl defines the sprite sheet url
  129431. * @param capacity defines the maximum allowed number of sprites
  129432. * @param scene defines the hosting scene
  129433. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129434. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129435. * @param samplingMode defines the smapling mode to use with spritesheet
  129436. * @param fromPacked set to true; do not alter
  129437. */
  129438. constructor(
  129439. /** defines the packed manager's name */
  129440. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129441. }
  129442. }
  129443. declare module BABYLON {
  129444. /**
  129445. * Defines the list of states available for a task inside a AssetsManager
  129446. */
  129447. export enum AssetTaskState {
  129448. /**
  129449. * Initialization
  129450. */
  129451. INIT = 0,
  129452. /**
  129453. * Running
  129454. */
  129455. RUNNING = 1,
  129456. /**
  129457. * Done
  129458. */
  129459. DONE = 2,
  129460. /**
  129461. * Error
  129462. */
  129463. ERROR = 3
  129464. }
  129465. /**
  129466. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129467. */
  129468. export abstract class AbstractAssetTask {
  129469. /**
  129470. * Task name
  129471. */ name: string;
  129472. /**
  129473. * Callback called when the task is successful
  129474. */
  129475. onSuccess: (task: any) => void;
  129476. /**
  129477. * Callback called when the task is not successful
  129478. */
  129479. onError: (task: any, message?: string, exception?: any) => void;
  129480. /**
  129481. * Creates a new AssetsManager
  129482. * @param name defines the name of the task
  129483. */
  129484. constructor(
  129485. /**
  129486. * Task name
  129487. */ name: string);
  129488. private _isCompleted;
  129489. private _taskState;
  129490. private _errorObject;
  129491. /**
  129492. * Get if the task is completed
  129493. */
  129494. readonly isCompleted: boolean;
  129495. /**
  129496. * Gets the current state of the task
  129497. */
  129498. readonly taskState: AssetTaskState;
  129499. /**
  129500. * Gets the current error object (if task is in error)
  129501. */
  129502. readonly errorObject: {
  129503. message?: string;
  129504. exception?: any;
  129505. };
  129506. /**
  129507. * Internal only
  129508. * @hidden
  129509. */
  129510. _setErrorObject(message?: string, exception?: any): void;
  129511. /**
  129512. * Execute the current task
  129513. * @param scene defines the scene where you want your assets to be loaded
  129514. * @param onSuccess is a callback called when the task is successfully executed
  129515. * @param onError is a callback called if an error occurs
  129516. */
  129517. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129518. /**
  129519. * Execute the current task
  129520. * @param scene defines the scene where you want your assets to be loaded
  129521. * @param onSuccess is a callback called when the task is successfully executed
  129522. * @param onError is a callback called if an error occurs
  129523. */
  129524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129525. /**
  129526. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129527. * This can be used with failed tasks that have the reason for failure fixed.
  129528. */
  129529. reset(): void;
  129530. private onErrorCallback;
  129531. private onDoneCallback;
  129532. }
  129533. /**
  129534. * Define the interface used by progress events raised during assets loading
  129535. */
  129536. export interface IAssetsProgressEvent {
  129537. /**
  129538. * Defines the number of remaining tasks to process
  129539. */
  129540. remainingCount: number;
  129541. /**
  129542. * Defines the total number of tasks
  129543. */
  129544. totalCount: number;
  129545. /**
  129546. * Defines the task that was just processed
  129547. */
  129548. task: AbstractAssetTask;
  129549. }
  129550. /**
  129551. * Class used to share progress information about assets loading
  129552. */
  129553. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129554. /**
  129555. * Defines the number of remaining tasks to process
  129556. */
  129557. remainingCount: number;
  129558. /**
  129559. * Defines the total number of tasks
  129560. */
  129561. totalCount: number;
  129562. /**
  129563. * Defines the task that was just processed
  129564. */
  129565. task: AbstractAssetTask;
  129566. /**
  129567. * Creates a AssetsProgressEvent
  129568. * @param remainingCount defines the number of remaining tasks to process
  129569. * @param totalCount defines the total number of tasks
  129570. * @param task defines the task that was just processed
  129571. */
  129572. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129573. }
  129574. /**
  129575. * Define a task used by AssetsManager to load meshes
  129576. */
  129577. export class MeshAssetTask extends AbstractAssetTask {
  129578. /**
  129579. * Defines the name of the task
  129580. */
  129581. name: string;
  129582. /**
  129583. * Defines the list of mesh's names you want to load
  129584. */
  129585. meshesNames: any;
  129586. /**
  129587. * Defines the root url to use as a base to load your meshes and associated resources
  129588. */
  129589. rootUrl: string;
  129590. /**
  129591. * Defines the filename of the scene to load from
  129592. */
  129593. sceneFilename: string;
  129594. /**
  129595. * Gets the list of loaded meshes
  129596. */
  129597. loadedMeshes: Array<AbstractMesh>;
  129598. /**
  129599. * Gets the list of loaded particle systems
  129600. */
  129601. loadedParticleSystems: Array<IParticleSystem>;
  129602. /**
  129603. * Gets the list of loaded skeletons
  129604. */
  129605. loadedSkeletons: Array<Skeleton>;
  129606. /**
  129607. * Gets the list of loaded animation groups
  129608. */
  129609. loadedAnimationGroups: Array<AnimationGroup>;
  129610. /**
  129611. * Callback called when the task is successful
  129612. */
  129613. onSuccess: (task: MeshAssetTask) => void;
  129614. /**
  129615. * Callback called when the task is successful
  129616. */
  129617. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129618. /**
  129619. * Creates a new MeshAssetTask
  129620. * @param name defines the name of the task
  129621. * @param meshesNames defines the list of mesh's names you want to load
  129622. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129623. * @param sceneFilename defines the filename of the scene to load from
  129624. */
  129625. constructor(
  129626. /**
  129627. * Defines the name of the task
  129628. */
  129629. name: string,
  129630. /**
  129631. * Defines the list of mesh's names you want to load
  129632. */
  129633. meshesNames: any,
  129634. /**
  129635. * Defines the root url to use as a base to load your meshes and associated resources
  129636. */
  129637. rootUrl: string,
  129638. /**
  129639. * Defines the filename of the scene to load from
  129640. */
  129641. sceneFilename: string);
  129642. /**
  129643. * Execute the current task
  129644. * @param scene defines the scene where you want your assets to be loaded
  129645. * @param onSuccess is a callback called when the task is successfully executed
  129646. * @param onError is a callback called if an error occurs
  129647. */
  129648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129649. }
  129650. /**
  129651. * Define a task used by AssetsManager to load text content
  129652. */
  129653. export class TextFileAssetTask extends AbstractAssetTask {
  129654. /**
  129655. * Defines the name of the task
  129656. */
  129657. name: string;
  129658. /**
  129659. * Defines the location of the file to load
  129660. */
  129661. url: string;
  129662. /**
  129663. * Gets the loaded text string
  129664. */
  129665. text: string;
  129666. /**
  129667. * Callback called when the task is successful
  129668. */
  129669. onSuccess: (task: TextFileAssetTask) => void;
  129670. /**
  129671. * Callback called when the task is successful
  129672. */
  129673. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129674. /**
  129675. * Creates a new TextFileAssetTask object
  129676. * @param name defines the name of the task
  129677. * @param url defines the location of the file to load
  129678. */
  129679. constructor(
  129680. /**
  129681. * Defines the name of the task
  129682. */
  129683. name: string,
  129684. /**
  129685. * Defines the location of the file to load
  129686. */
  129687. url: string);
  129688. /**
  129689. * Execute the current task
  129690. * @param scene defines the scene where you want your assets to be loaded
  129691. * @param onSuccess is a callback called when the task is successfully executed
  129692. * @param onError is a callback called if an error occurs
  129693. */
  129694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129695. }
  129696. /**
  129697. * Define a task used by AssetsManager to load binary data
  129698. */
  129699. export class BinaryFileAssetTask extends AbstractAssetTask {
  129700. /**
  129701. * Defines the name of the task
  129702. */
  129703. name: string;
  129704. /**
  129705. * Defines the location of the file to load
  129706. */
  129707. url: string;
  129708. /**
  129709. * Gets the lodaded data (as an array buffer)
  129710. */
  129711. data: ArrayBuffer;
  129712. /**
  129713. * Callback called when the task is successful
  129714. */
  129715. onSuccess: (task: BinaryFileAssetTask) => void;
  129716. /**
  129717. * Callback called when the task is successful
  129718. */
  129719. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129720. /**
  129721. * Creates a new BinaryFileAssetTask object
  129722. * @param name defines the name of the new task
  129723. * @param url defines the location of the file to load
  129724. */
  129725. constructor(
  129726. /**
  129727. * Defines the name of the task
  129728. */
  129729. name: string,
  129730. /**
  129731. * Defines the location of the file to load
  129732. */
  129733. url: string);
  129734. /**
  129735. * Execute the current task
  129736. * @param scene defines the scene where you want your assets to be loaded
  129737. * @param onSuccess is a callback called when the task is successfully executed
  129738. * @param onError is a callback called if an error occurs
  129739. */
  129740. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129741. }
  129742. /**
  129743. * Define a task used by AssetsManager to load images
  129744. */
  129745. export class ImageAssetTask extends AbstractAssetTask {
  129746. /**
  129747. * Defines the name of the task
  129748. */
  129749. name: string;
  129750. /**
  129751. * Defines the location of the image to load
  129752. */
  129753. url: string;
  129754. /**
  129755. * Gets the loaded images
  129756. */
  129757. image: HTMLImageElement;
  129758. /**
  129759. * Callback called when the task is successful
  129760. */
  129761. onSuccess: (task: ImageAssetTask) => void;
  129762. /**
  129763. * Callback called when the task is successful
  129764. */
  129765. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129766. /**
  129767. * Creates a new ImageAssetTask
  129768. * @param name defines the name of the task
  129769. * @param url defines the location of the image to load
  129770. */
  129771. constructor(
  129772. /**
  129773. * Defines the name of the task
  129774. */
  129775. name: string,
  129776. /**
  129777. * Defines the location of the image to load
  129778. */
  129779. url: string);
  129780. /**
  129781. * Execute the current task
  129782. * @param scene defines the scene where you want your assets to be loaded
  129783. * @param onSuccess is a callback called when the task is successfully executed
  129784. * @param onError is a callback called if an error occurs
  129785. */
  129786. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129787. }
  129788. /**
  129789. * Defines the interface used by texture loading tasks
  129790. */
  129791. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129792. /**
  129793. * Gets the loaded texture
  129794. */
  129795. texture: TEX;
  129796. }
  129797. /**
  129798. * Define a task used by AssetsManager to load 2D textures
  129799. */
  129800. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129801. /**
  129802. * Defines the name of the task
  129803. */
  129804. name: string;
  129805. /**
  129806. * Defines the location of the file to load
  129807. */
  129808. url: string;
  129809. /**
  129810. * Defines if mipmap should not be generated (default is false)
  129811. */
  129812. noMipmap?: boolean | undefined;
  129813. /**
  129814. * Defines if texture must be inverted on Y axis (default is false)
  129815. */
  129816. invertY?: boolean | undefined;
  129817. /**
  129818. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129819. */
  129820. samplingMode: number;
  129821. /**
  129822. * Gets the loaded texture
  129823. */
  129824. texture: Texture;
  129825. /**
  129826. * Callback called when the task is successful
  129827. */
  129828. onSuccess: (task: TextureAssetTask) => void;
  129829. /**
  129830. * Callback called when the task is successful
  129831. */
  129832. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  129833. /**
  129834. * Creates a new TextureAssetTask object
  129835. * @param name defines the name of the task
  129836. * @param url defines the location of the file to load
  129837. * @param noMipmap defines if mipmap should not be generated (default is false)
  129838. * @param invertY defines if texture must be inverted on Y axis (default is false)
  129839. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129840. */
  129841. constructor(
  129842. /**
  129843. * Defines the name of the task
  129844. */
  129845. name: string,
  129846. /**
  129847. * Defines the location of the file to load
  129848. */
  129849. url: string,
  129850. /**
  129851. * Defines if mipmap should not be generated (default is false)
  129852. */
  129853. noMipmap?: boolean | undefined,
  129854. /**
  129855. * Defines if texture must be inverted on Y axis (default is false)
  129856. */
  129857. invertY?: boolean | undefined,
  129858. /**
  129859. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129860. */
  129861. samplingMode?: number);
  129862. /**
  129863. * Execute the current task
  129864. * @param scene defines the scene where you want your assets to be loaded
  129865. * @param onSuccess is a callback called when the task is successfully executed
  129866. * @param onError is a callback called if an error occurs
  129867. */
  129868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129869. }
  129870. /**
  129871. * Define a task used by AssetsManager to load cube textures
  129872. */
  129873. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  129874. /**
  129875. * Defines the name of the task
  129876. */
  129877. name: string;
  129878. /**
  129879. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129880. */
  129881. url: string;
  129882. /**
  129883. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129884. */
  129885. extensions?: string[] | undefined;
  129886. /**
  129887. * Defines if mipmaps should not be generated (default is false)
  129888. */
  129889. noMipmap?: boolean | undefined;
  129890. /**
  129891. * Defines the explicit list of files (undefined by default)
  129892. */
  129893. files?: string[] | undefined;
  129894. /**
  129895. * Gets the loaded texture
  129896. */
  129897. texture: CubeTexture;
  129898. /**
  129899. * Callback called when the task is successful
  129900. */
  129901. onSuccess: (task: CubeTextureAssetTask) => void;
  129902. /**
  129903. * Callback called when the task is successful
  129904. */
  129905. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  129906. /**
  129907. * Creates a new CubeTextureAssetTask
  129908. * @param name defines the name of the task
  129909. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129910. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129911. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129912. * @param files defines the explicit list of files (undefined by default)
  129913. */
  129914. constructor(
  129915. /**
  129916. * Defines the name of the task
  129917. */
  129918. name: string,
  129919. /**
  129920. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129921. */
  129922. url: string,
  129923. /**
  129924. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129925. */
  129926. extensions?: string[] | undefined,
  129927. /**
  129928. * Defines if mipmaps should not be generated (default is false)
  129929. */
  129930. noMipmap?: boolean | undefined,
  129931. /**
  129932. * Defines the explicit list of files (undefined by default)
  129933. */
  129934. files?: string[] | undefined);
  129935. /**
  129936. * Execute the current task
  129937. * @param scene defines the scene where you want your assets to be loaded
  129938. * @param onSuccess is a callback called when the task is successfully executed
  129939. * @param onError is a callback called if an error occurs
  129940. */
  129941. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129942. }
  129943. /**
  129944. * Define a task used by AssetsManager to load HDR cube textures
  129945. */
  129946. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  129947. /**
  129948. * Defines the name of the task
  129949. */
  129950. name: string;
  129951. /**
  129952. * Defines the location of the file to load
  129953. */
  129954. url: string;
  129955. /**
  129956. * Defines the desired size (the more it increases the longer the generation will be)
  129957. */
  129958. size: number;
  129959. /**
  129960. * Defines if mipmaps should not be generated (default is false)
  129961. */
  129962. noMipmap: boolean;
  129963. /**
  129964. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129965. */
  129966. generateHarmonics: boolean;
  129967. /**
  129968. * 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)
  129969. */
  129970. gammaSpace: boolean;
  129971. /**
  129972. * Internal Use Only
  129973. */
  129974. reserved: boolean;
  129975. /**
  129976. * Gets the loaded texture
  129977. */
  129978. texture: HDRCubeTexture;
  129979. /**
  129980. * Callback called when the task is successful
  129981. */
  129982. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  129983. /**
  129984. * Callback called when the task is successful
  129985. */
  129986. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  129987. /**
  129988. * Creates a new HDRCubeTextureAssetTask object
  129989. * @param name defines the name of the task
  129990. * @param url defines the location of the file to load
  129991. * @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.
  129992. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129993. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129994. * @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)
  129995. * @param reserved Internal use only
  129996. */
  129997. constructor(
  129998. /**
  129999. * Defines the name of the task
  130000. */
  130001. name: string,
  130002. /**
  130003. * Defines the location of the file to load
  130004. */
  130005. url: string,
  130006. /**
  130007. * Defines the desired size (the more it increases the longer the generation will be)
  130008. */
  130009. size: number,
  130010. /**
  130011. * Defines if mipmaps should not be generated (default is false)
  130012. */
  130013. noMipmap?: boolean,
  130014. /**
  130015. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130016. */
  130017. generateHarmonics?: boolean,
  130018. /**
  130019. * 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)
  130020. */
  130021. gammaSpace?: boolean,
  130022. /**
  130023. * Internal Use Only
  130024. */
  130025. reserved?: boolean);
  130026. /**
  130027. * Execute the current task
  130028. * @param scene defines the scene where you want your assets to be loaded
  130029. * @param onSuccess is a callback called when the task is successfully executed
  130030. * @param onError is a callback called if an error occurs
  130031. */
  130032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130033. }
  130034. /**
  130035. * Define a task used by AssetsManager to load Equirectangular cube textures
  130036. */
  130037. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130038. /**
  130039. * Defines the name of the task
  130040. */
  130041. name: string;
  130042. /**
  130043. * Defines the location of the file to load
  130044. */
  130045. url: string;
  130046. /**
  130047. * Defines the desired size (the more it increases the longer the generation will be)
  130048. */
  130049. size: number;
  130050. /**
  130051. * Defines if mipmaps should not be generated (default is false)
  130052. */
  130053. noMipmap: boolean;
  130054. /**
  130055. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130056. * but the standard material would require them in Gamma space) (default is true)
  130057. */
  130058. gammaSpace: boolean;
  130059. /**
  130060. * Gets the loaded texture
  130061. */
  130062. texture: EquiRectangularCubeTexture;
  130063. /**
  130064. * Callback called when the task is successful
  130065. */
  130066. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130067. /**
  130068. * Callback called when the task is successful
  130069. */
  130070. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130071. /**
  130072. * Creates a new EquiRectangularCubeTextureAssetTask object
  130073. * @param name defines the name of the task
  130074. * @param url defines the location of the file to load
  130075. * @param size defines the desired size (the more it increases the longer the generation will be)
  130076. * If the size is omitted this implies you are using a preprocessed cubemap.
  130077. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130078. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130079. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130080. * (default is true)
  130081. */
  130082. constructor(
  130083. /**
  130084. * Defines the name of the task
  130085. */
  130086. name: string,
  130087. /**
  130088. * Defines the location of the file to load
  130089. */
  130090. url: string,
  130091. /**
  130092. * Defines the desired size (the more it increases the longer the generation will be)
  130093. */
  130094. size: number,
  130095. /**
  130096. * Defines if mipmaps should not be generated (default is false)
  130097. */
  130098. noMipmap?: boolean,
  130099. /**
  130100. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130101. * but the standard material would require them in Gamma space) (default is true)
  130102. */
  130103. gammaSpace?: boolean);
  130104. /**
  130105. * Execute the current task
  130106. * @param scene defines the scene where you want your assets to be loaded
  130107. * @param onSuccess is a callback called when the task is successfully executed
  130108. * @param onError is a callback called if an error occurs
  130109. */
  130110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130111. }
  130112. /**
  130113. * This class can be used to easily import assets into a scene
  130114. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130115. */
  130116. export class AssetsManager {
  130117. private _scene;
  130118. private _isLoading;
  130119. protected _tasks: AbstractAssetTask[];
  130120. protected _waitingTasksCount: number;
  130121. protected _totalTasksCount: number;
  130122. /**
  130123. * Callback called when all tasks are processed
  130124. */
  130125. onFinish: (tasks: AbstractAssetTask[]) => void;
  130126. /**
  130127. * Callback called when a task is successful
  130128. */
  130129. onTaskSuccess: (task: AbstractAssetTask) => void;
  130130. /**
  130131. * Callback called when a task had an error
  130132. */
  130133. onTaskError: (task: AbstractAssetTask) => void;
  130134. /**
  130135. * Callback called when a task is done (whatever the result is)
  130136. */
  130137. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130138. /**
  130139. * Observable called when all tasks are processed
  130140. */
  130141. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130142. /**
  130143. * Observable called when a task had an error
  130144. */
  130145. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130146. /**
  130147. * Observable called when all tasks were executed
  130148. */
  130149. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130150. /**
  130151. * Observable called when a task is done (whatever the result is)
  130152. */
  130153. onProgressObservable: Observable<IAssetsProgressEvent>;
  130154. /**
  130155. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130157. */
  130158. useDefaultLoadingScreen: boolean;
  130159. /**
  130160. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130161. * when all assets have been downloaded.
  130162. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130163. */
  130164. autoHideLoadingUI: boolean;
  130165. /**
  130166. * Creates a new AssetsManager
  130167. * @param scene defines the scene to work on
  130168. */
  130169. constructor(scene: Scene);
  130170. /**
  130171. * Add a MeshAssetTask to the list of active tasks
  130172. * @param taskName defines the name of the new task
  130173. * @param meshesNames defines the name of meshes to load
  130174. * @param rootUrl defines the root url to use to locate files
  130175. * @param sceneFilename defines the filename of the scene file
  130176. * @returns a new MeshAssetTask object
  130177. */
  130178. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130179. /**
  130180. * Add a TextFileAssetTask to the list of active tasks
  130181. * @param taskName defines the name of the new task
  130182. * @param url defines the url of the file to load
  130183. * @returns a new TextFileAssetTask object
  130184. */
  130185. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130186. /**
  130187. * Add a BinaryFileAssetTask to the list of active tasks
  130188. * @param taskName defines the name of the new task
  130189. * @param url defines the url of the file to load
  130190. * @returns a new BinaryFileAssetTask object
  130191. */
  130192. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130193. /**
  130194. * Add a ImageAssetTask to the list of active tasks
  130195. * @param taskName defines the name of the new task
  130196. * @param url defines the url of the file to load
  130197. * @returns a new ImageAssetTask object
  130198. */
  130199. addImageTask(taskName: string, url: string): ImageAssetTask;
  130200. /**
  130201. * Add a TextureAssetTask to the list of active tasks
  130202. * @param taskName defines the name of the new task
  130203. * @param url defines the url of the file to load
  130204. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130205. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130206. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130207. * @returns a new TextureAssetTask object
  130208. */
  130209. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130210. /**
  130211. * Add a CubeTextureAssetTask to the list of active tasks
  130212. * @param taskName defines the name of the new task
  130213. * @param url defines the url of the file to load
  130214. * @param extensions defines the extension to use to load the cube map (can be null)
  130215. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130216. * @param files defines the list of files to load (can be null)
  130217. * @returns a new CubeTextureAssetTask object
  130218. */
  130219. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130220. /**
  130221. *
  130222. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130223. * @param taskName defines the name of the new task
  130224. * @param url defines the url of the file to load
  130225. * @param size defines the size you want for the cubemap (can be null)
  130226. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130227. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130228. * @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)
  130229. * @param reserved Internal use only
  130230. * @returns a new HDRCubeTextureAssetTask object
  130231. */
  130232. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130233. /**
  130234. *
  130235. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130236. * @param taskName defines the name of the new task
  130237. * @param url defines the url of the file to load
  130238. * @param size defines the size you want for the cubemap (can be null)
  130239. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130240. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130241. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130242. * @returns a new EquiRectangularCubeTextureAssetTask object
  130243. */
  130244. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130245. /**
  130246. * Remove a task from the assets manager.
  130247. * @param task the task to remove
  130248. */
  130249. removeTask(task: AbstractAssetTask): void;
  130250. private _decreaseWaitingTasksCount;
  130251. private _runTask;
  130252. /**
  130253. * Reset the AssetsManager and remove all tasks
  130254. * @return the current instance of the AssetsManager
  130255. */
  130256. reset(): AssetsManager;
  130257. /**
  130258. * Start the loading process
  130259. * @return the current instance of the AssetsManager
  130260. */
  130261. load(): AssetsManager;
  130262. /**
  130263. * Start the loading process as an async operation
  130264. * @return a promise returning the list of failed tasks
  130265. */
  130266. loadAsync(): Promise<void>;
  130267. }
  130268. }
  130269. declare module BABYLON {
  130270. /**
  130271. * Wrapper class for promise with external resolve and reject.
  130272. */
  130273. export class Deferred<T> {
  130274. /**
  130275. * The promise associated with this deferred object.
  130276. */
  130277. readonly promise: Promise<T>;
  130278. private _resolve;
  130279. private _reject;
  130280. /**
  130281. * The resolve method of the promise associated with this deferred object.
  130282. */
  130283. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130284. /**
  130285. * The reject method of the promise associated with this deferred object.
  130286. */
  130287. readonly reject: (reason?: any) => void;
  130288. /**
  130289. * Constructor for this deferred object.
  130290. */
  130291. constructor();
  130292. }
  130293. }
  130294. declare module BABYLON {
  130295. /**
  130296. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130297. */
  130298. export class MeshExploder {
  130299. private _centerMesh;
  130300. private _meshes;
  130301. private _meshesOrigins;
  130302. private _toCenterVectors;
  130303. private _scaledDirection;
  130304. private _newPosition;
  130305. private _centerPosition;
  130306. /**
  130307. * Explodes meshes from a center mesh.
  130308. * @param meshes The meshes to explode.
  130309. * @param centerMesh The mesh to be center of explosion.
  130310. */
  130311. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130312. private _setCenterMesh;
  130313. /**
  130314. * Get class name
  130315. * @returns "MeshExploder"
  130316. */
  130317. getClassName(): string;
  130318. /**
  130319. * "Exploded meshes"
  130320. * @returns Array of meshes with the centerMesh at index 0.
  130321. */
  130322. getMeshes(): Array<Mesh>;
  130323. /**
  130324. * Explodes meshes giving a specific direction
  130325. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130326. */
  130327. explode(direction?: number): void;
  130328. }
  130329. }
  130330. declare module BABYLON {
  130331. /**
  130332. * Class used to help managing file picking and drag'n'drop
  130333. */
  130334. export class FilesInput {
  130335. /**
  130336. * List of files ready to be loaded
  130337. */
  130338. static readonly FilesToLoad: {
  130339. [key: string]: File;
  130340. };
  130341. /**
  130342. * Callback called when a file is processed
  130343. */
  130344. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130345. private _engine;
  130346. private _currentScene;
  130347. private _sceneLoadedCallback;
  130348. private _progressCallback;
  130349. private _additionalRenderLoopLogicCallback;
  130350. private _textureLoadingCallback;
  130351. private _startingProcessingFilesCallback;
  130352. private _onReloadCallback;
  130353. private _errorCallback;
  130354. private _elementToMonitor;
  130355. private _sceneFileToLoad;
  130356. private _filesToLoad;
  130357. /**
  130358. * Creates a new FilesInput
  130359. * @param engine defines the rendering engine
  130360. * @param scene defines the hosting scene
  130361. * @param sceneLoadedCallback callback called when scene is loaded
  130362. * @param progressCallback callback called to track progress
  130363. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130364. * @param textureLoadingCallback callback called when a texture is loading
  130365. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130366. * @param onReloadCallback callback called when a reload is requested
  130367. * @param errorCallback callback call if an error occurs
  130368. */
  130369. 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);
  130370. private _dragEnterHandler;
  130371. private _dragOverHandler;
  130372. private _dropHandler;
  130373. /**
  130374. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130375. * @param elementToMonitor defines the DOM element to track
  130376. */
  130377. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130378. /**
  130379. * Release all associated resources
  130380. */
  130381. dispose(): void;
  130382. private renderFunction;
  130383. private drag;
  130384. private drop;
  130385. private _traverseFolder;
  130386. private _processFiles;
  130387. /**
  130388. * Load files from a drop event
  130389. * @param event defines the drop event to use as source
  130390. */
  130391. loadFiles(event: any): void;
  130392. private _processReload;
  130393. /**
  130394. * Reload the current scene from the loaded files
  130395. */
  130396. reload(): void;
  130397. }
  130398. }
  130399. declare module BABYLON {
  130400. /**
  130401. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130403. */
  130404. export class SceneOptimization {
  130405. /**
  130406. * Defines the priority of this optimization (0 by default which means first in the list)
  130407. */
  130408. priority: number;
  130409. /**
  130410. * Gets a string describing the action executed by the current optimization
  130411. * @returns description string
  130412. */
  130413. getDescription(): string;
  130414. /**
  130415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130416. * @param scene defines the current scene where to apply this optimization
  130417. * @param optimizer defines the current optimizer
  130418. * @returns true if everything that can be done was applied
  130419. */
  130420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130421. /**
  130422. * Creates the SceneOptimization object
  130423. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130424. * @param desc defines the description associated with the optimization
  130425. */
  130426. constructor(
  130427. /**
  130428. * Defines the priority of this optimization (0 by default which means first in the list)
  130429. */
  130430. priority?: number);
  130431. }
  130432. /**
  130433. * Defines an optimization used to reduce the size of render target textures
  130434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130435. */
  130436. export class TextureOptimization extends SceneOptimization {
  130437. /**
  130438. * Defines the priority of this optimization (0 by default which means first in the list)
  130439. */
  130440. priority: number;
  130441. /**
  130442. * 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
  130443. */
  130444. maximumSize: number;
  130445. /**
  130446. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130447. */
  130448. step: number;
  130449. /**
  130450. * Gets a string describing the action executed by the current optimization
  130451. * @returns description string
  130452. */
  130453. getDescription(): string;
  130454. /**
  130455. * Creates the TextureOptimization object
  130456. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130457. * @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
  130458. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130459. */
  130460. constructor(
  130461. /**
  130462. * Defines the priority of this optimization (0 by default which means first in the list)
  130463. */
  130464. priority?: number,
  130465. /**
  130466. * 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
  130467. */
  130468. maximumSize?: number,
  130469. /**
  130470. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130471. */
  130472. step?: number);
  130473. /**
  130474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130475. * @param scene defines the current scene where to apply this optimization
  130476. * @param optimizer defines the current optimizer
  130477. * @returns true if everything that can be done was applied
  130478. */
  130479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130480. }
  130481. /**
  130482. * Defines an optimization used to increase or decrease the rendering resolution
  130483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130484. */
  130485. export class HardwareScalingOptimization extends SceneOptimization {
  130486. /**
  130487. * Defines the priority of this optimization (0 by default which means first in the list)
  130488. */
  130489. priority: number;
  130490. /**
  130491. * Defines the maximum scale to use (2 by default)
  130492. */
  130493. maximumScale: number;
  130494. /**
  130495. * Defines the step to use between two passes (0.5 by default)
  130496. */
  130497. step: number;
  130498. private _currentScale;
  130499. private _directionOffset;
  130500. /**
  130501. * Gets a string describing the action executed by the current optimization
  130502. * @return description string
  130503. */
  130504. getDescription(): string;
  130505. /**
  130506. * Creates the HardwareScalingOptimization object
  130507. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130508. * @param maximumScale defines the maximum scale to use (2 by default)
  130509. * @param step defines the step to use between two passes (0.5 by default)
  130510. */
  130511. constructor(
  130512. /**
  130513. * Defines the priority of this optimization (0 by default which means first in the list)
  130514. */
  130515. priority?: number,
  130516. /**
  130517. * Defines the maximum scale to use (2 by default)
  130518. */
  130519. maximumScale?: number,
  130520. /**
  130521. * Defines the step to use between two passes (0.5 by default)
  130522. */
  130523. step?: number);
  130524. /**
  130525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130526. * @param scene defines the current scene where to apply this optimization
  130527. * @param optimizer defines the current optimizer
  130528. * @returns true if everything that can be done was applied
  130529. */
  130530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130531. }
  130532. /**
  130533. * Defines an optimization used to remove shadows
  130534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130535. */
  130536. export class ShadowsOptimization extends SceneOptimization {
  130537. /**
  130538. * Gets a string describing the action executed by the current optimization
  130539. * @return description string
  130540. */
  130541. getDescription(): string;
  130542. /**
  130543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130544. * @param scene defines the current scene where to apply this optimization
  130545. * @param optimizer defines the current optimizer
  130546. * @returns true if everything that can be done was applied
  130547. */
  130548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130549. }
  130550. /**
  130551. * Defines an optimization used to turn post-processes off
  130552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130553. */
  130554. export class PostProcessesOptimization extends SceneOptimization {
  130555. /**
  130556. * Gets a string describing the action executed by the current optimization
  130557. * @return description string
  130558. */
  130559. getDescription(): string;
  130560. /**
  130561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130562. * @param scene defines the current scene where to apply this optimization
  130563. * @param optimizer defines the current optimizer
  130564. * @returns true if everything that can be done was applied
  130565. */
  130566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130567. }
  130568. /**
  130569. * Defines an optimization used to turn lens flares off
  130570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130571. */
  130572. export class LensFlaresOptimization extends SceneOptimization {
  130573. /**
  130574. * Gets a string describing the action executed by the current optimization
  130575. * @return description string
  130576. */
  130577. getDescription(): string;
  130578. /**
  130579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130580. * @param scene defines the current scene where to apply this optimization
  130581. * @param optimizer defines the current optimizer
  130582. * @returns true if everything that can be done was applied
  130583. */
  130584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130585. }
  130586. /**
  130587. * Defines an optimization based on user defined callback.
  130588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130589. */
  130590. export class CustomOptimization extends SceneOptimization {
  130591. /**
  130592. * Callback called to apply the custom optimization.
  130593. */
  130594. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130595. /**
  130596. * Callback called to get custom description
  130597. */
  130598. onGetDescription: () => string;
  130599. /**
  130600. * Gets a string describing the action executed by the current optimization
  130601. * @returns description string
  130602. */
  130603. getDescription(): string;
  130604. /**
  130605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130606. * @param scene defines the current scene where to apply this optimization
  130607. * @param optimizer defines the current optimizer
  130608. * @returns true if everything that can be done was applied
  130609. */
  130610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130611. }
  130612. /**
  130613. * Defines an optimization used to turn particles off
  130614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130615. */
  130616. export class ParticlesOptimization extends SceneOptimization {
  130617. /**
  130618. * Gets a string describing the action executed by the current optimization
  130619. * @return description string
  130620. */
  130621. getDescription(): string;
  130622. /**
  130623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130624. * @param scene defines the current scene where to apply this optimization
  130625. * @param optimizer defines the current optimizer
  130626. * @returns true if everything that can be done was applied
  130627. */
  130628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130629. }
  130630. /**
  130631. * Defines an optimization used to turn render targets off
  130632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130633. */
  130634. export class RenderTargetsOptimization extends SceneOptimization {
  130635. /**
  130636. * Gets a string describing the action executed by the current optimization
  130637. * @return description string
  130638. */
  130639. getDescription(): string;
  130640. /**
  130641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130642. * @param scene defines the current scene where to apply this optimization
  130643. * @param optimizer defines the current optimizer
  130644. * @returns true if everything that can be done was applied
  130645. */
  130646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130647. }
  130648. /**
  130649. * Defines an optimization used to merge meshes with compatible materials
  130650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130651. */
  130652. export class MergeMeshesOptimization extends SceneOptimization {
  130653. private static _UpdateSelectionTree;
  130654. /**
  130655. * Gets or sets a boolean which defines if optimization octree has to be updated
  130656. */
  130657. /**
  130658. * Gets or sets a boolean which defines if optimization octree has to be updated
  130659. */
  130660. static UpdateSelectionTree: boolean;
  130661. /**
  130662. * Gets a string describing the action executed by the current optimization
  130663. * @return description string
  130664. */
  130665. getDescription(): string;
  130666. private _canBeMerged;
  130667. /**
  130668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130669. * @param scene defines the current scene where to apply this optimization
  130670. * @param optimizer defines the current optimizer
  130671. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130672. * @returns true if everything that can be done was applied
  130673. */
  130674. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130675. }
  130676. /**
  130677. * Defines a list of options used by SceneOptimizer
  130678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130679. */
  130680. export class SceneOptimizerOptions {
  130681. /**
  130682. * Defines the target frame rate to reach (60 by default)
  130683. */
  130684. targetFrameRate: number;
  130685. /**
  130686. * Defines the interval between two checkes (2000ms by default)
  130687. */
  130688. trackerDuration: number;
  130689. /**
  130690. * Gets the list of optimizations to apply
  130691. */
  130692. optimizations: SceneOptimization[];
  130693. /**
  130694. * Creates a new list of options used by SceneOptimizer
  130695. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130696. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130697. */
  130698. constructor(
  130699. /**
  130700. * Defines the target frame rate to reach (60 by default)
  130701. */
  130702. targetFrameRate?: number,
  130703. /**
  130704. * Defines the interval between two checkes (2000ms by default)
  130705. */
  130706. trackerDuration?: number);
  130707. /**
  130708. * Add a new optimization
  130709. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130710. * @returns the current SceneOptimizerOptions
  130711. */
  130712. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130713. /**
  130714. * Add a new custom optimization
  130715. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130716. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130718. * @returns the current SceneOptimizerOptions
  130719. */
  130720. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130721. /**
  130722. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130723. * @param targetFrameRate defines the target frame rate (60 by default)
  130724. * @returns a SceneOptimizerOptions object
  130725. */
  130726. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130727. /**
  130728. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130729. * @param targetFrameRate defines the target frame rate (60 by default)
  130730. * @returns a SceneOptimizerOptions object
  130731. */
  130732. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130733. /**
  130734. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130735. * @param targetFrameRate defines the target frame rate (60 by default)
  130736. * @returns a SceneOptimizerOptions object
  130737. */
  130738. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130739. }
  130740. /**
  130741. * Class used to run optimizations in order to reach a target frame rate
  130742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130743. */
  130744. export class SceneOptimizer implements IDisposable {
  130745. private _isRunning;
  130746. private _options;
  130747. private _scene;
  130748. private _currentPriorityLevel;
  130749. private _targetFrameRate;
  130750. private _trackerDuration;
  130751. private _currentFrameRate;
  130752. private _sceneDisposeObserver;
  130753. private _improvementMode;
  130754. /**
  130755. * Defines an observable called when the optimizer reaches the target frame rate
  130756. */
  130757. onSuccessObservable: Observable<SceneOptimizer>;
  130758. /**
  130759. * Defines an observable called when the optimizer enables an optimization
  130760. */
  130761. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130762. /**
  130763. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130764. */
  130765. onFailureObservable: Observable<SceneOptimizer>;
  130766. /**
  130767. * Gets a boolean indicating if the optimizer is in improvement mode
  130768. */
  130769. readonly isInImprovementMode: boolean;
  130770. /**
  130771. * Gets the current priority level (0 at start)
  130772. */
  130773. readonly currentPriorityLevel: number;
  130774. /**
  130775. * Gets the current frame rate checked by the SceneOptimizer
  130776. */
  130777. readonly currentFrameRate: number;
  130778. /**
  130779. * Gets or sets the current target frame rate (60 by default)
  130780. */
  130781. /**
  130782. * Gets or sets the current target frame rate (60 by default)
  130783. */
  130784. targetFrameRate: number;
  130785. /**
  130786. * Gets or sets the current interval between two checks (every 2000ms by default)
  130787. */
  130788. /**
  130789. * Gets or sets the current interval between two checks (every 2000ms by default)
  130790. */
  130791. trackerDuration: number;
  130792. /**
  130793. * Gets the list of active optimizations
  130794. */
  130795. readonly optimizations: SceneOptimization[];
  130796. /**
  130797. * Creates a new SceneOptimizer
  130798. * @param scene defines the scene to work on
  130799. * @param options defines the options to use with the SceneOptimizer
  130800. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130801. * @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)
  130802. */
  130803. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130804. /**
  130805. * Stops the current optimizer
  130806. */
  130807. stop(): void;
  130808. /**
  130809. * Reset the optimizer to initial step (current priority level = 0)
  130810. */
  130811. reset(): void;
  130812. /**
  130813. * Start the optimizer. By default it will try to reach a specific framerate
  130814. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130815. */
  130816. start(): void;
  130817. private _checkCurrentState;
  130818. /**
  130819. * Release all resources
  130820. */
  130821. dispose(): void;
  130822. /**
  130823. * Helper function to create a SceneOptimizer with one single line of code
  130824. * @param scene defines the scene to work on
  130825. * @param options defines the options to use with the SceneOptimizer
  130826. * @param onSuccess defines a callback to call on success
  130827. * @param onFailure defines a callback to call on failure
  130828. * @returns the new SceneOptimizer object
  130829. */
  130830. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  130831. }
  130832. }
  130833. declare module BABYLON {
  130834. /**
  130835. * Class used to serialize a scene into a string
  130836. */
  130837. export class SceneSerializer {
  130838. /**
  130839. * Clear cache used by a previous serialization
  130840. */
  130841. static ClearCache(): void;
  130842. /**
  130843. * Serialize a scene into a JSON compatible object
  130844. * @param scene defines the scene to serialize
  130845. * @returns a JSON compatible object
  130846. */
  130847. static Serialize(scene: Scene): any;
  130848. /**
  130849. * Serialize a mesh into a JSON compatible object
  130850. * @param toSerialize defines the mesh to serialize
  130851. * @param withParents defines if parents must be serialized as well
  130852. * @param withChildren defines if children must be serialized as well
  130853. * @returns a JSON compatible object
  130854. */
  130855. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  130856. }
  130857. }
  130858. declare module BABYLON {
  130859. /**
  130860. * Class used to host texture specific utilities
  130861. */
  130862. export class TextureTools {
  130863. /**
  130864. * Uses the GPU to create a copy texture rescaled at a given size
  130865. * @param texture Texture to copy from
  130866. * @param width defines the desired width
  130867. * @param height defines the desired height
  130868. * @param useBilinearMode defines if bilinear mode has to be used
  130869. * @return the generated texture
  130870. */
  130871. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  130872. }
  130873. }
  130874. declare module BABYLON {
  130875. /**
  130876. * This represents the different options available for the video capture.
  130877. */
  130878. export interface VideoRecorderOptions {
  130879. /** Defines the mime type of the video. */
  130880. mimeType: string;
  130881. /** Defines the FPS the video should be recorded at. */
  130882. fps: number;
  130883. /** Defines the chunk size for the recording data. */
  130884. recordChunckSize: number;
  130885. /** The audio tracks to attach to the recording. */
  130886. audioTracks?: MediaStreamTrack[];
  130887. }
  130888. /**
  130889. * This can help with recording videos from BabylonJS.
  130890. * This is based on the available WebRTC functionalities of the browser.
  130891. *
  130892. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  130893. */
  130894. export class VideoRecorder {
  130895. private static readonly _defaultOptions;
  130896. /**
  130897. * Returns whether or not the VideoRecorder is available in your browser.
  130898. * @param engine Defines the Babylon Engine.
  130899. * @returns true if supported otherwise false.
  130900. */
  130901. static IsSupported(engine: Engine): boolean;
  130902. private readonly _options;
  130903. private _canvas;
  130904. private _mediaRecorder;
  130905. private _recordedChunks;
  130906. private _fileName;
  130907. private _resolve;
  130908. private _reject;
  130909. /**
  130910. * True when a recording is already in progress.
  130911. */
  130912. readonly isRecording: boolean;
  130913. /**
  130914. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  130915. * @param engine Defines the BabylonJS Engine you wish to record.
  130916. * @param options Defines options that can be used to customize the capture.
  130917. */
  130918. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  130919. /**
  130920. * Stops the current recording before the default capture timeout passed in the startRecording function.
  130921. */
  130922. stopRecording(): void;
  130923. /**
  130924. * Starts recording the canvas for a max duration specified in parameters.
  130925. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  130926. * If null no automatic download will start and you can rely on the promise to get the data back.
  130927. * @param maxDuration Defines the maximum recording time in seconds.
  130928. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  130929. * @return A promise callback at the end of the recording with the video data in Blob.
  130930. */
  130931. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  130932. /**
  130933. * Releases internal resources used during the recording.
  130934. */
  130935. dispose(): void;
  130936. private _handleDataAvailable;
  130937. private _handleError;
  130938. private _handleStop;
  130939. }
  130940. }
  130941. declare module BABYLON {
  130942. /**
  130943. * Class containing a set of static utilities functions for screenshots
  130944. */
  130945. export class ScreenshotTools {
  130946. /**
  130947. * Captures a screenshot of the current rendering
  130948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130949. * @param engine defines the rendering engine
  130950. * @param camera defines the source camera
  130951. * @param size This parameter can be set to a single number or to an object with the
  130952. * following (optional) properties: precision, width, height. If a single number is passed,
  130953. * it will be used for both width and height. If an object is passed, the screenshot size
  130954. * will be derived from the parameters. The precision property is a multiplier allowing
  130955. * rendering at a higher or lower resolution
  130956. * @param successCallback defines the callback receives a single parameter which contains the
  130957. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130958. * src parameter of an <img> to display it
  130959. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130960. * Check your browser for supported MIME types
  130961. */
  130962. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  130963. /**
  130964. * Captures a screenshot of the current rendering
  130965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130966. * @param engine defines the rendering engine
  130967. * @param camera defines the source camera
  130968. * @param size This parameter can be set to a single number or to an object with the
  130969. * following (optional) properties: precision, width, height. If a single number is passed,
  130970. * it will be used for both width and height. If an object is passed, the screenshot size
  130971. * will be derived from the parameters. The precision property is a multiplier allowing
  130972. * rendering at a higher or lower resolution
  130973. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130974. * Check your browser for supported MIME types
  130975. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  130976. * to the src parameter of an <img> to display it
  130977. */
  130978. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  130979. /**
  130980. * Generates an image screenshot from the specified camera.
  130981. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130982. * @param engine The engine to use for rendering
  130983. * @param camera The camera to use for rendering
  130984. * @param size This parameter can be set to a single number or to an object with the
  130985. * following (optional) properties: precision, width, height. If a single number is passed,
  130986. * it will be used for both width and height. If an object is passed, the screenshot size
  130987. * will be derived from the parameters. The precision property is a multiplier allowing
  130988. * rendering at a higher or lower resolution
  130989. * @param successCallback The callback receives a single parameter which contains the
  130990. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130991. * src parameter of an <img> to display it
  130992. * @param mimeType The MIME type of the screenshot image (default: image/png).
  130993. * Check your browser for supported MIME types
  130994. * @param samples Texture samples (default: 1)
  130995. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  130996. * @param fileName A name for for the downloaded file.
  130997. */
  130998. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  130999. /**
  131000. * Generates an image screenshot from the specified camera.
  131001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131002. * @param engine The engine to use for rendering
  131003. * @param camera The camera to use for rendering
  131004. * @param size This parameter can be set to a single number or to an object with the
  131005. * following (optional) properties: precision, width, height. If a single number is passed,
  131006. * it will be used for both width and height. If an object is passed, the screenshot size
  131007. * will be derived from the parameters. The precision property is a multiplier allowing
  131008. * rendering at a higher or lower resolution
  131009. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131010. * Check your browser for supported MIME types
  131011. * @param samples Texture samples (default: 1)
  131012. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131013. * @param fileName A name for for the downloaded file.
  131014. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131015. * to the src parameter of an <img> to display it
  131016. */
  131017. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131018. /**
  131019. * Gets height and width for screenshot size
  131020. * @private
  131021. */
  131022. private static _getScreenshotSize;
  131023. }
  131024. }
  131025. declare module BABYLON {
  131026. /**
  131027. * A cursor which tracks a point on a path
  131028. */
  131029. export class PathCursor {
  131030. private path;
  131031. /**
  131032. * Stores path cursor callbacks for when an onchange event is triggered
  131033. */
  131034. private _onchange;
  131035. /**
  131036. * The value of the path cursor
  131037. */
  131038. value: number;
  131039. /**
  131040. * The animation array of the path cursor
  131041. */
  131042. animations: Animation[];
  131043. /**
  131044. * Initializes the path cursor
  131045. * @param path The path to track
  131046. */
  131047. constructor(path: Path2);
  131048. /**
  131049. * Gets the cursor point on the path
  131050. * @returns A point on the path cursor at the cursor location
  131051. */
  131052. getPoint(): Vector3;
  131053. /**
  131054. * Moves the cursor ahead by the step amount
  131055. * @param step The amount to move the cursor forward
  131056. * @returns This path cursor
  131057. */
  131058. moveAhead(step?: number): PathCursor;
  131059. /**
  131060. * Moves the cursor behind by the step amount
  131061. * @param step The amount to move the cursor back
  131062. * @returns This path cursor
  131063. */
  131064. moveBack(step?: number): PathCursor;
  131065. /**
  131066. * Moves the cursor by the step amount
  131067. * If the step amount is greater than one, an exception is thrown
  131068. * @param step The amount to move the cursor
  131069. * @returns This path cursor
  131070. */
  131071. move(step: number): PathCursor;
  131072. /**
  131073. * Ensures that the value is limited between zero and one
  131074. * @returns This path cursor
  131075. */
  131076. private ensureLimits;
  131077. /**
  131078. * Runs onchange callbacks on change (used by the animation engine)
  131079. * @returns This path cursor
  131080. */
  131081. private raiseOnChange;
  131082. /**
  131083. * Executes a function on change
  131084. * @param f A path cursor onchange callback
  131085. * @returns This path cursor
  131086. */
  131087. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131088. }
  131089. }
  131090. declare module BABYLON {
  131091. /** @hidden */
  131092. export var blurPixelShader: {
  131093. name: string;
  131094. shader: string;
  131095. };
  131096. }
  131097. declare module BABYLON {
  131098. /** @hidden */
  131099. export var pointCloudVertexDeclaration: {
  131100. name: string;
  131101. shader: string;
  131102. };
  131103. }
  131104. // Mixins
  131105. interface Window {
  131106. mozIndexedDB: IDBFactory;
  131107. webkitIndexedDB: IDBFactory;
  131108. msIndexedDB: IDBFactory;
  131109. webkitURL: typeof URL;
  131110. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131111. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131112. WebGLRenderingContext: WebGLRenderingContext;
  131113. MSGesture: MSGesture;
  131114. CANNON: any;
  131115. AudioContext: AudioContext;
  131116. webkitAudioContext: AudioContext;
  131117. PointerEvent: any;
  131118. Math: Math;
  131119. Uint8Array: Uint8ArrayConstructor;
  131120. Float32Array: Float32ArrayConstructor;
  131121. mozURL: typeof URL;
  131122. msURL: typeof URL;
  131123. VRFrameData: any; // WebVR, from specs 1.1
  131124. DracoDecoderModule: any;
  131125. setImmediate(handler: (...args: any[]) => void): number;
  131126. }
  131127. interface HTMLCanvasElement {
  131128. requestPointerLock(): void;
  131129. msRequestPointerLock?(): void;
  131130. mozRequestPointerLock?(): void;
  131131. webkitRequestPointerLock?(): void;
  131132. /** Track wether a record is in progress */
  131133. isRecording: boolean;
  131134. /** Capture Stream method defined by some browsers */
  131135. captureStream(fps?: number): MediaStream;
  131136. }
  131137. interface CanvasRenderingContext2D {
  131138. msImageSmoothingEnabled: boolean;
  131139. }
  131140. interface MouseEvent {
  131141. mozMovementX: number;
  131142. mozMovementY: number;
  131143. webkitMovementX: number;
  131144. webkitMovementY: number;
  131145. msMovementX: number;
  131146. msMovementY: number;
  131147. }
  131148. interface Navigator {
  131149. mozGetVRDevices: (any: any) => any;
  131150. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131151. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131152. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131153. webkitGetGamepads(): Gamepad[];
  131154. msGetGamepads(): Gamepad[];
  131155. webkitGamepads(): Gamepad[];
  131156. }
  131157. interface HTMLVideoElement {
  131158. mozSrcObject: any;
  131159. }
  131160. interface Math {
  131161. fround(x: number): number;
  131162. imul(a: number, b: number): number;
  131163. }
  131164. interface WebGLRenderingContext {
  131165. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131166. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131167. vertexAttribDivisor(index: number, divisor: number): void;
  131168. createVertexArray(): any;
  131169. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131170. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131171. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131172. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131173. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131174. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131175. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131176. // Queries
  131177. createQuery(): WebGLQuery;
  131178. deleteQuery(query: WebGLQuery): void;
  131179. beginQuery(target: number, query: WebGLQuery): void;
  131180. endQuery(target: number): void;
  131181. getQueryParameter(query: WebGLQuery, pname: number): any;
  131182. getQuery(target: number, pname: number): any;
  131183. MAX_SAMPLES: number;
  131184. RGBA8: number;
  131185. READ_FRAMEBUFFER: number;
  131186. DRAW_FRAMEBUFFER: number;
  131187. UNIFORM_BUFFER: number;
  131188. HALF_FLOAT_OES: number;
  131189. RGBA16F: number;
  131190. RGBA32F: number;
  131191. R32F: number;
  131192. RG32F: number;
  131193. RGB32F: number;
  131194. R16F: number;
  131195. RG16F: number;
  131196. RGB16F: number;
  131197. RED: number;
  131198. RG: number;
  131199. R8: number;
  131200. RG8: number;
  131201. UNSIGNED_INT_24_8: number;
  131202. DEPTH24_STENCIL8: number;
  131203. MIN: number;
  131204. MAX: number;
  131205. /* Multiple Render Targets */
  131206. drawBuffers(buffers: number[]): void;
  131207. readBuffer(src: number): void;
  131208. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131209. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131210. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131211. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131212. // Occlusion Query
  131213. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131214. ANY_SAMPLES_PASSED: number;
  131215. QUERY_RESULT_AVAILABLE: number;
  131216. QUERY_RESULT: number;
  131217. }
  131218. interface WebGLProgram {
  131219. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131220. }
  131221. interface EXT_disjoint_timer_query {
  131222. QUERY_COUNTER_BITS_EXT: number;
  131223. TIME_ELAPSED_EXT: number;
  131224. TIMESTAMP_EXT: number;
  131225. GPU_DISJOINT_EXT: number;
  131226. QUERY_RESULT_EXT: number;
  131227. QUERY_RESULT_AVAILABLE_EXT: number;
  131228. queryCounterEXT(query: WebGLQuery, target: number): void;
  131229. createQueryEXT(): WebGLQuery;
  131230. beginQueryEXT(target: number, query: WebGLQuery): void;
  131231. endQueryEXT(target: number): void;
  131232. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131233. deleteQueryEXT(query: WebGLQuery): void;
  131234. }
  131235. interface WebGLUniformLocation {
  131236. _currentState: any;
  131237. }
  131238. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131239. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131240. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131241. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131242. interface WebGLRenderingContext {
  131243. readonly RASTERIZER_DISCARD: number;
  131244. readonly DEPTH_COMPONENT24: number;
  131245. readonly TEXTURE_3D: number;
  131246. readonly TEXTURE_2D_ARRAY: number;
  131247. readonly TEXTURE_COMPARE_FUNC: number;
  131248. readonly TEXTURE_COMPARE_MODE: number;
  131249. readonly COMPARE_REF_TO_TEXTURE: number;
  131250. readonly TEXTURE_WRAP_R: number;
  131251. readonly HALF_FLOAT: number;
  131252. readonly RGB8: number;
  131253. readonly RED_INTEGER: number;
  131254. readonly RG_INTEGER: number;
  131255. readonly RGB_INTEGER: number;
  131256. readonly RGBA_INTEGER: number;
  131257. readonly R8_SNORM: number;
  131258. readonly RG8_SNORM: number;
  131259. readonly RGB8_SNORM: number;
  131260. readonly RGBA8_SNORM: number;
  131261. readonly R8I: number;
  131262. readonly RG8I: number;
  131263. readonly RGB8I: number;
  131264. readonly RGBA8I: number;
  131265. readonly R8UI: number;
  131266. readonly RG8UI: number;
  131267. readonly RGB8UI: number;
  131268. readonly RGBA8UI: number;
  131269. readonly R16I: number;
  131270. readonly RG16I: number;
  131271. readonly RGB16I: number;
  131272. readonly RGBA16I: number;
  131273. readonly R16UI: number;
  131274. readonly RG16UI: number;
  131275. readonly RGB16UI: number;
  131276. readonly RGBA16UI: number;
  131277. readonly R32I: number;
  131278. readonly RG32I: number;
  131279. readonly RGB32I: number;
  131280. readonly RGBA32I: number;
  131281. readonly R32UI: number;
  131282. readonly RG32UI: number;
  131283. readonly RGB32UI: number;
  131284. readonly RGBA32UI: number;
  131285. readonly RGB10_A2UI: number;
  131286. readonly R11F_G11F_B10F: number;
  131287. readonly RGB9_E5: number;
  131288. readonly RGB10_A2: number;
  131289. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131290. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131291. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131292. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131293. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131294. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131295. 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;
  131296. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131297. readonly TRANSFORM_FEEDBACK: number;
  131298. readonly INTERLEAVED_ATTRIBS: number;
  131299. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131300. createTransformFeedback(): WebGLTransformFeedback;
  131301. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131302. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131303. beginTransformFeedback(primitiveMode: number): void;
  131304. endTransformFeedback(): void;
  131305. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131306. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131307. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131308. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131309. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131310. }
  131311. interface ImageBitmap {
  131312. readonly width: number;
  131313. readonly height: number;
  131314. close(): void;
  131315. }
  131316. interface WebGLQuery extends WebGLObject {
  131317. }
  131318. declare var WebGLQuery: {
  131319. prototype: WebGLQuery;
  131320. new(): WebGLQuery;
  131321. };
  131322. interface WebGLSampler extends WebGLObject {
  131323. }
  131324. declare var WebGLSampler: {
  131325. prototype: WebGLSampler;
  131326. new(): WebGLSampler;
  131327. };
  131328. interface WebGLSync extends WebGLObject {
  131329. }
  131330. declare var WebGLSync: {
  131331. prototype: WebGLSync;
  131332. new(): WebGLSync;
  131333. };
  131334. interface WebGLTransformFeedback extends WebGLObject {
  131335. }
  131336. declare var WebGLTransformFeedback: {
  131337. prototype: WebGLTransformFeedback;
  131338. new(): WebGLTransformFeedback;
  131339. };
  131340. interface WebGLVertexArrayObject extends WebGLObject {
  131341. }
  131342. declare var WebGLVertexArrayObject: {
  131343. prototype: WebGLVertexArrayObject;
  131344. new(): WebGLVertexArrayObject;
  131345. };
  131346. // Type definitions for WebVR API
  131347. // Project: https://w3c.github.io/webvr/
  131348. // Definitions by: six a <https://github.com/lostfictions>
  131349. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131350. interface VRDisplay extends EventTarget {
  131351. /**
  131352. * Dictionary of capabilities describing the VRDisplay.
  131353. */
  131354. readonly capabilities: VRDisplayCapabilities;
  131355. /**
  131356. * z-depth defining the far plane of the eye view frustum
  131357. * enables mapping of values in the render target depth
  131358. * attachment to scene coordinates. Initially set to 10000.0.
  131359. */
  131360. depthFar: number;
  131361. /**
  131362. * z-depth defining the near plane of the eye view frustum
  131363. * enables mapping of values in the render target depth
  131364. * attachment to scene coordinates. Initially set to 0.01.
  131365. */
  131366. depthNear: number;
  131367. /**
  131368. * An identifier for this distinct VRDisplay. Used as an
  131369. * association point in the Gamepad API.
  131370. */
  131371. readonly displayId: number;
  131372. /**
  131373. * A display name, a user-readable name identifying it.
  131374. */
  131375. readonly displayName: string;
  131376. readonly isConnected: boolean;
  131377. readonly isPresenting: boolean;
  131378. /**
  131379. * If this VRDisplay supports room-scale experiences, the optional
  131380. * stage attribute contains details on the room-scale parameters.
  131381. */
  131382. readonly stageParameters: VRStageParameters | null;
  131383. /**
  131384. * Passing the value returned by `requestAnimationFrame` to
  131385. * `cancelAnimationFrame` will unregister the callback.
  131386. * @param handle Define the hanle of the request to cancel
  131387. */
  131388. cancelAnimationFrame(handle: number): void;
  131389. /**
  131390. * Stops presenting to the VRDisplay.
  131391. * @returns a promise to know when it stopped
  131392. */
  131393. exitPresent(): Promise<void>;
  131394. /**
  131395. * Return the current VREyeParameters for the given eye.
  131396. * @param whichEye Define the eye we want the parameter for
  131397. * @returns the eye parameters
  131398. */
  131399. getEyeParameters(whichEye: string): VREyeParameters;
  131400. /**
  131401. * Populates the passed VRFrameData with the information required to render
  131402. * the current frame.
  131403. * @param frameData Define the data structure to populate
  131404. * @returns true if ok otherwise false
  131405. */
  131406. getFrameData(frameData: VRFrameData): boolean;
  131407. /**
  131408. * Get the layers currently being presented.
  131409. * @returns the list of VR layers
  131410. */
  131411. getLayers(): VRLayer[];
  131412. /**
  131413. * Return a VRPose containing the future predicted pose of the VRDisplay
  131414. * when the current frame will be presented. The value returned will not
  131415. * change until JavaScript has returned control to the browser.
  131416. *
  131417. * The VRPose will contain the position, orientation, velocity,
  131418. * and acceleration of each of these properties.
  131419. * @returns the pose object
  131420. */
  131421. getPose(): VRPose;
  131422. /**
  131423. * Return the current instantaneous pose of the VRDisplay, with no
  131424. * prediction applied.
  131425. * @returns the current instantaneous pose
  131426. */
  131427. getImmediatePose(): VRPose;
  131428. /**
  131429. * The callback passed to `requestAnimationFrame` will be called
  131430. * any time a new frame should be rendered. When the VRDisplay is
  131431. * presenting the callback will be called at the native refresh
  131432. * rate of the HMD. When not presenting this function acts
  131433. * identically to how window.requestAnimationFrame acts. Content should
  131434. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131435. * asynchronously from other displays and at differing refresh rates.
  131436. * @param callback Define the eaction to run next frame
  131437. * @returns the request handle it
  131438. */
  131439. requestAnimationFrame(callback: FrameRequestCallback): number;
  131440. /**
  131441. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131442. * Repeat calls while already presenting will update the VRLayers being displayed.
  131443. * @param layers Define the list of layer to present
  131444. * @returns a promise to know when the request has been fulfilled
  131445. */
  131446. requestPresent(layers: VRLayer[]): Promise<void>;
  131447. /**
  131448. * Reset the pose for this display, treating its current position and
  131449. * orientation as the "origin/zero" values. VRPose.position,
  131450. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131451. * updated when calling resetPose(). This should be called in only
  131452. * sitting-space experiences.
  131453. */
  131454. resetPose(): void;
  131455. /**
  131456. * The VRLayer provided to the VRDisplay will be captured and presented
  131457. * in the HMD. Calling this function has the same effect on the source
  131458. * canvas as any other operation that uses its source image, and canvases
  131459. * created without preserveDrawingBuffer set to true will be cleared.
  131460. * @param pose Define the pose to submit
  131461. */
  131462. submitFrame(pose?: VRPose): void;
  131463. }
  131464. declare var VRDisplay: {
  131465. prototype: VRDisplay;
  131466. new(): VRDisplay;
  131467. };
  131468. interface VRLayer {
  131469. leftBounds?: number[] | Float32Array | null;
  131470. rightBounds?: number[] | Float32Array | null;
  131471. source?: HTMLCanvasElement | null;
  131472. }
  131473. interface VRDisplayCapabilities {
  131474. readonly canPresent: boolean;
  131475. readonly hasExternalDisplay: boolean;
  131476. readonly hasOrientation: boolean;
  131477. readonly hasPosition: boolean;
  131478. readonly maxLayers: number;
  131479. }
  131480. interface VREyeParameters {
  131481. /** @deprecated */
  131482. readonly fieldOfView: VRFieldOfView;
  131483. readonly offset: Float32Array;
  131484. readonly renderHeight: number;
  131485. readonly renderWidth: number;
  131486. }
  131487. interface VRFieldOfView {
  131488. readonly downDegrees: number;
  131489. readonly leftDegrees: number;
  131490. readonly rightDegrees: number;
  131491. readonly upDegrees: number;
  131492. }
  131493. interface VRFrameData {
  131494. readonly leftProjectionMatrix: Float32Array;
  131495. readonly leftViewMatrix: Float32Array;
  131496. readonly pose: VRPose;
  131497. readonly rightProjectionMatrix: Float32Array;
  131498. readonly rightViewMatrix: Float32Array;
  131499. readonly timestamp: number;
  131500. }
  131501. interface VRPose {
  131502. readonly angularAcceleration: Float32Array | null;
  131503. readonly angularVelocity: Float32Array | null;
  131504. readonly linearAcceleration: Float32Array | null;
  131505. readonly linearVelocity: Float32Array | null;
  131506. readonly orientation: Float32Array | null;
  131507. readonly position: Float32Array | null;
  131508. readonly timestamp: number;
  131509. }
  131510. interface VRStageParameters {
  131511. sittingToStandingTransform?: Float32Array;
  131512. sizeX?: number;
  131513. sizeY?: number;
  131514. }
  131515. interface Navigator {
  131516. getVRDisplays(): Promise<VRDisplay[]>;
  131517. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131518. }
  131519. interface Window {
  131520. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131521. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131522. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131523. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131524. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131525. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131526. }
  131527. interface Gamepad {
  131528. readonly displayId: number;
  131529. }
  131530. type XRSessionMode =
  131531. | "inline"
  131532. | "immersive-vr"
  131533. | "immersive-ar";
  131534. type XRReferenceSpaceType =
  131535. | "viewer"
  131536. | "local"
  131537. | "local-floor"
  131538. | "bounded-floor"
  131539. | "unbounded";
  131540. type XREnvironmentBlendMode =
  131541. | "opaque"
  131542. | "additive"
  131543. | "alpha-blend";
  131544. type XRVisibilityState =
  131545. | "visible"
  131546. | "visible-blurred"
  131547. | "hidden";
  131548. type XRHandedness =
  131549. | "none"
  131550. | "left"
  131551. | "right";
  131552. type XRTargetRayMode =
  131553. | "gaze"
  131554. | "tracked-pointer"
  131555. | "screen";
  131556. type XREye =
  131557. | "none"
  131558. | "left"
  131559. | "right";
  131560. interface XRSpace extends EventTarget {
  131561. }
  131562. interface XRRenderState {
  131563. depthNear?: number;
  131564. depthFar?: number;
  131565. inlineVerticalFieldOfView?: number;
  131566. baseLayer?: XRWebGLLayer;
  131567. }
  131568. interface XRInputSource {
  131569. handedness: XRHandedness;
  131570. targetRayMode: XRTargetRayMode;
  131571. targetRaySpace: XRSpace;
  131572. gripSpace: XRSpace | undefined;
  131573. gamepad: Gamepad | undefined;
  131574. profiles: Array<string>;
  131575. }
  131576. interface XRSession {
  131577. addEventListener: Function;
  131578. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131579. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131580. requestAnimationFrame: Function;
  131581. end(): Promise<void>;
  131582. renderState: XRRenderState;
  131583. inputSources: Array<XRInputSource>;
  131584. }
  131585. interface XRReferenceSpace extends XRSpace {
  131586. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131587. onreset: any;
  131588. }
  131589. interface XRFrame {
  131590. session: XRSession;
  131591. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131592. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131593. }
  131594. interface XRViewerPose extends XRPose {
  131595. views: Array<XRView>;
  131596. }
  131597. interface XRPose {
  131598. transform: XRRigidTransform;
  131599. emulatedPosition: boolean;
  131600. }
  131601. declare var XRWebGLLayer: {
  131602. prototype: XRWebGLLayer;
  131603. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131604. };
  131605. interface XRWebGLLayer {
  131606. framebuffer: WebGLFramebuffer;
  131607. framebufferWidth: number;
  131608. framebufferHeight: number;
  131609. getViewport: Function;
  131610. }
  131611. interface XRRigidTransform {
  131612. position: DOMPointReadOnly;
  131613. orientation: DOMPointReadOnly;
  131614. matrix: Float32Array;
  131615. inverse: XRRigidTransform;
  131616. }
  131617. interface XRView {
  131618. eye: XREye;
  131619. projectionMatrix: Float32Array;
  131620. transform: XRRigidTransform;
  131621. }
  131622. interface XRInputSourceChangeEvent {
  131623. session: XRSession;
  131624. removed: Array<XRInputSource>;
  131625. added: Array<XRInputSource>;
  131626. }